腾讯云 CentOS 6.8 使用静默模式安装 Oracle 11gR2

记录如何在 OEL6 系统中使用静默安装模式安装11G Release 2 (11.2) 的折腾情况。
OTN上提供了 11.2.0.1 版本或 metalink 上提供了 11.2.0.4 版本的安装软件。 在此安装中,我将介绍11.2.0.4的安装,但对于先前版本11.2.0.X,应该没有什么不同。

接下来将会进行软件,监听,建库的静默安装。

参考资料:

https://blog.csdn.net/u011391839/article/details/76566316
https://dbaora.com/install-oracle-in-silent-mode-11g-release-2-11-2/
https://www.cnblogs.com/jyzhao/p/3891769.html
https://cloud.tencent.com/developer/article/1431642
https://blog.csdn.net/okhymok/article/details/78093493
https://cloud.tencent.com/developer/article/1533151

1 环境配置及软件准备

1.1 涉及工具及环境

  • 本地环境windows10+ssh远程连接工具xShell、xFtp
  • 腾讯云服务器 CentOS6.8 64位系统
  • 安装包文件 p13390677_112040_Linux-x86-64_1of7.zip、p13390677_112040_Linux-x86-64_2of7.zip

1.2 操作系统配置和检查

  • 最小内存1G,推荐2G或2G以上
  • 1GB跟2GB物理内存之间的,设定swap大小为物理内存的1.5倍;2GB跟16GB物理内存之间的,设置swap大小与物理内存相等;16GB物理内存以上的,设置swap大小为16GB
  • 硬盘要求空间至少5-6GB

服务器配置检查操作记录

[root@VM_0_12_centos /]# cat /etc/issue                          # 系统版本查询
CentOS release 6.8 (Final)
Kernel \r on an \m

[root@VM_0_12_centos /]# uname -r                            # 内核版本查询
2.6.32-642.6.2.el6.x86_64
[root@VM_0_12_centos /]# grep MemTotal /proc/meminfo             # 内存大小查询
MemTotal:        3922640 kB
[root@VM_0_12_centos /]# grep SwapTotal /proc/meminfo            # 交换区大小
SwapTotal:       0 kB
[root@VM_0_12_centos /]# grep "model name" /proc/cpuinfo         # CPU信息查询
model name  : Intel(R) Xeon(R) CPU E5-26xx v4
[root@VM_0_12_centos /]# hostname                                # 主机名
VM_0_12_centos
[root@VM_0_12_centos /]# df -h                                   # 磁盘大小
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        50G  5.2G   42G  12% /

注意:新买的腾讯云主机没有提供Swap分区,理由是由于主机经常因为内存使用率过高,频繁使用Swap,导致磁盘IO过高,服务器整体性能反而下降。下文有介绍可以使用Swap文件的方式添加Swap分区。

2 准备工作

2.1 开启 swap 分区

安装到后面才发现,以下是启动流程。

  1. 查看内存和当前分区情况,下图可以看出swap分区显示为 0

    [root@VM_0_12_centos ~]# free -m
                 total       used       free     shared    buffers     cached
    Mem:          3830        215       3615          0          8         90
    -/+ buffers/cache:        116       3714
    Swap:            0          0          0
  2. 新建一个目录用于交换分区的文件,比如我的目录/swap/swap, 创建一个4G的文件

    [root@VM_0_12_centos ~]# cd /
    [root@VM_0_12_centos /]# ls
    bin  boot  data  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  selinux  srv  sys  tmp  usr  var
    [root@VM_0_12_centos /]# mkdir swap
    [root@VM_0_12_centos /]# dd if=/dev/zero of=/swap/swap bs=4096 count=1048576
    1048576+0 records in
    1048576+0 records out
    4294967296 bytes (4.3 GB) copied, 35.3833 s, 121 MB/s
  3. 把这个文件设置为交换分区文件。

    [root@VM_0_12_centos /]# mkswap /swap/swap
    mkswap: /swap/swap: warning: don't erase bootbits sectors
            on whole disk. Use -f to force.
    Setting up swapspace version 1, size = 4194300 KiB
    no label, UUID=c0ffed76-dc34-448c-91b1-dd32848e6915
  4. 修改文件权限为600。

    [root@VM_0_12_centos /]# chmod 600 /swap/swap
  5. 启用交换分区文件。

    [root@VM_0_12_centos /]# swapon /swap/swap
  6. 设置开机自启动

    [root@VM_0_12_centos /]# cat /etc/fstab
    /dev/vda1            /                    ext3       noatime,acl,user_xattr 1 1
    proc                 /proc                proc       defaults              0 0
    sysfs                /sys                 sysfs      noauto                0 0
    debugfs              /sys/kernel/debug    debugfs    noauto                0 0
    devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
    [root@VM_0_12_centos /]# vi /etc/fstab
    [root@VM_0_12_centos /]# cat /etc/fstab
    /dev/vda1            /                    ext3       noatime,acl,user_xattr 1 1
    proc                 /proc                proc       defaults              0 0
    sysfs                /sys                 sysfs      noauto                0 0
    debugfs              /sys/kernel/debug    debugfs    noauto                0 0
    devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
    /swap/swap swap swap defaults 0 0
    [root@VM_0_12_centos /]# 

2.2 修改主机名

[root@VM_0_12_centos /]# cat /etc/sysconfig/network 
# Created by cloud-init on instance boot automatically, do not edit.
#
NETWORKING=yes
HOSTNAME=VM_0_12_centos
[root@VM_0_12_centos /]# vim /etc/sysconfig/network # 编辑network文件修改hostname行(重启生效)
[root@VM_0_12_centos /]# cat /etc/sysconfig/network # 检查修改
# Created by cloud-init on instance boot automatically, do not edit.
#
NETWORKING=yes
HOSTNAME=node1
[root@VM_0_12_centos /]# 
[root@VM_0_12_centos /]# hostname node1     # 设置当前的hostname(立即生效)
[root@VM_0_12_centos /]# cat /etc/hosts
127.0.0.1 VM_0_12_centos VM_0_12_centos
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

::1 VM_0_12_centos VM_0_12_centos
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

# 基于安全考虑,填写的 IP 地址是修改过的,替换成自己服务器的共有IP即可。
[root@VM_0_12_centos /]# vim /etc/hosts     # 编辑hosts文件,给123.207.156.32添加hostname
[root@VM_0_12_centos /]# cat /etc/hosts
127.0.0.1 node1
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

::1 VM_0_12_centos VM_0_12_centos
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
123.207.156.32 node1
[root@VM_0_12_centos /]# reboot             # 重启

Broadcast message from root@node1
    (/dev/pts/0) at 16:08 ...

The system is going down for reboot NOW!
[root@VM_0_12_centos /]# Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(腾讯云上海机) at 16:08:27.
# 重启后再次检查
[root@node1 ~]# cat /etc/hosts
127.0.0.1 node1
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

::1 VM_0_12_centos VM_0_12_centos
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
123.207.156.32 node1
[root@node1 ~]# cat /etc/sysconfig/network
# Created by cloud-init on instance boot automatically, do not edit.
#
NETWORKING=yes
HOSTNAME=node1

2.3 关闭 Secure Linux

腾讯云服务器本身已经关闭该选项

[root@node1 ~]# more /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#   enforcing - SELinux security policy is enforced.
#   permissive - SELinux prints warnings instead of enforcing.
#   disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#   targeted - Only targeted network daemons are protected.
#   strict - Full SELinux protection.
SELINUXTYPE=targeted

如果没有关闭,可以使用以下操作进行关闭

vim /etc/selinux/config  设置SELINUX=disabled
[root@node1 ~]# setenforce 0        #关闭selinux

扩展(可忽略),也可以设置为

SELINUX=permissive

但如果是彻底关闭了,那就需要先vi /etc/selinux/config 修改SELINUX=1,重启后才能通过 setenforce 命令来调整状态。

2.4 关闭防火墙(Disable firewall)

service iptables stop
chkconfig iptables off

2.5 添加组

--用于数据库管理的组
--groups id与12C安装相同
--这里有些组目前不需要,但可以以后使用
--稍后也用于安装grid

[root@node1 ~]# groupadd -g 54321 oinstall
[root@node1 ~]# groupadd -g 54322 dba
[root@node1 ~]# groupadd -g 54323 oper
[root@node1 ~]# groupadd -g 54327 asmdba
[root@node1 ~]# groupadd -g 54328 asmoper
[root@node1 ~]# groupadd -g 54329 asmadmin

2.6 添加 Oracle 用户

[root@node1 ~]# useradd -u 54321 -g oinstall -G dba,oper,asmadmin oracle
[root@node1 ~]# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54329(asmadmin)
[root@node1 ~]# passwd oracle       # 设置 oracle 用户密码
Changing password for user oracle.
New password: 
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@node1 ~]# 

2.7 在/etc/security/limits.conf为用户oracle设置限制

在文件最后添加以下参数

oracle               soft     nproc    2047
oracle               hard     nproc    16384
oracle               soft     nofile   1024
oracle               hard     nofile   65536
oracle               soft     stack    10240

2.8 将内核参数添加到 /etc/sysctl.conf

# 复制粘贴到文件最后
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912 
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586

2.9 修改/etc/pam.d/login 文件

修改/etc/pam.d/login 文件,添加以下内容到文件中。

session required /lib/security/pam_limits.so
session required pam_limits.so

2.10 修改 /etc/profile 文件

修改 /etc/profile 文件,添加以下内容到文件中

if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
        ulimit -p 16384
        ulimit -n 65536
    else
        ulimit -u 16384 -n 65536
    fi
fi

操作过程

[root@node1 ~]# more /etc/profile           # 修改前
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}


if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`id -u`
        UID=`id -ru`
    fi
    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
    pathmunge /sbin after
fi

HOSTNAME=`/bin/hostname 2>/dev/null`
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 002
else
    umask 022
fi

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null 2>&1
        fi
    fi
done

unset i
unset -f pathmunge

[root@node1 ~]# vim /etc/profile        
[root@node1 ~]# more /etc/profile           #修改后
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}

if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
        ulimit -p 16384
        ulimit -n 65536
    else
        ulimit -u 16384 -n 65536
    fi
fi

if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`id -u`
        UID=`id -ru`
    fi
    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
    pathmunge /sbin after
fi

HOSTNAME=`/bin/hostname 2>/dev/null`
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 002
else
    umask 022
fi

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null 2>&1
        fi
    fi
done

unset i
unset -f pathmunge

2.11 安装依赖包

使用以下语句检查哪些软件包已安装,哪些缺失

rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\n' binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
ksh \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
sysstat \
unixODBC \
unixODBC-devel

目前服务器上所需安装包安装情况

[root@node1 ~]# rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\n' binutils \
> compat-libstdc++-33 \
> elfutils-libelf \
> elfutils-libelf-devel \
> gcc \
> gcc-c++ \
> glibc \
> glibc-common \
> glibc-devel \
> glibc-headers \
> ksh \
> libaio \
> libaio-devel \
> libgcc \
> libstdc++ \
> libstdc++-devel \
> make \
> sysstat \
> unixODBC \
> unixODBC-devel
binutils-2.20.51.0.2-5.44.el6(x86_64)
compat-libstdc++-33-3.2.3-69.el6(x86_64)
compat-libstdc++-33-3.2.3-69.el6(i686)
elfutils-libelf-0.164-2.el6(x86_64)
package elfutils-libelf-devel is not installed
package gcc is not installed
package gcc-c++ is not installed
glibc-2.12-1.192.el6(x86_64)
glibc-2.12-1.192.el6(i686)
glibc-common-2.12-1.192.el6(x86_64)
glibc-devel-2.12-1.192.el6(x86_64)
glibc-headers-2.12-1.192.el6(x86_64)
package ksh is not installed
libaio-0.3.107-10.el6(x86_64)
package libaio-devel is not installed
libgcc-4.4.7-17.el6(x86_64)
libgcc-4.4.7-17.el6(i686)
libstdc++-4.4.7-17.el6(x86_64)
libstdc++-4.4.7-17.el6(i686)
package libstdc++-devel is not installed
make-3.81-23.el6(x86_64)
package sysstat is not installed
package unixODBC is not installed
package unixODBC-devel is not installed
[root@node1 ~]# 

对于没有安装的表,使用 yum install 命令来安装,举个例子

yum install unixODBC unixODBC-devel sysstat

这里我选择一个一个缺失包来执行,执行以下缺失包,执行需要输入y确认

yum install elfutils-libelf-devel
yum install gcc-c++
yum install ksh
yum install libaio-devel
yum install sysstat
yum install unixODBC
yum install unixODBC-devel

再次检查所需软件包均已安装

[root@node1 ~]# rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\n' binutils \
> compat-libstdc++-33 \
> elfutils-libelf \
> elfutils-libelf-devel \
> gcc \
> gcc-c++ \
> glibc \
> glibc-common \
> glibc-devel \
> glibc-headers \
> ksh \
> libaio \
> libaio-devel \
> libgcc \
> libstdc++ \
> libstdc++-devel \
> make \
> sysstat \
> unixODBC \
> unixODBC-devel
binutils-2.20.51.0.2-5.44.el6(x86_64)
compat-libstdc++-33-3.2.3-69.el6(x86_64)
compat-libstdc++-33-3.2.3-69.el6(i686)
elfutils-libelf-0.164-2.el6(x86_64)
elfutils-libelf-devel-0.164-2.el6(x86_64)
gcc-4.4.7-23.el6(x86_64)
gcc-c++-4.4.7-23.el6(x86_64)
glibc-2.12-1.192.el6(x86_64)
glibc-2.12-1.192.el6(i686)
glibc-common-2.12-1.192.el6(x86_64)
glibc-devel-2.12-1.192.el6(x86_64)
glibc-headers-2.12-1.192.el6(x86_64)
ksh-20120801-38.el6_10(x86_64)
libaio-0.3.107-10.el6(x86_64)
libaio-devel-0.3.107-10.el6(x86_64)
libgcc-4.4.7-23.el6(x86_64)
libgcc-4.4.7-23.el6(i686)
libstdc++-4.4.7-23.el6(x86_64)
libstdc++-4.4.7-23.el6(i686)
libstdc++-devel-4.4.7-23.el6(x86_64)
make-3.81-23.el6(x86_64)
sysstat-9.0.4-33.el6_9.1(x86_64)
unixODBC-2.2.14-14.el6(x86_64)
unixODBC-devel-2.2.14-14.el6(x86_64)
[root@node1 ~]# 

2.12 创建目录结构

创建 $ORACLE_BASE 目录并赋予oracle目录权限

[root@node1 ~]# mkdir -p /u01/app/oracle
[root@node1 ~]# chown -R oracle:oinstall /u01/app

2.13 上传软件包

通过 xFTP 将2个压缩文件传入到/home/oracle 目录下

2.14 Oacle用户环境变量配置

进入 oracle 用户,并且编辑 /home/oracle/.bash_profile 文件,插入以下内容:

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export NLS_LANG="american_america.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH

操作脚本

[root@node1 ~]# su - oracle
[oracle@node1 ~]$ pwd
/home/oracle
[oracle@node1 ~]$ pwd
/home/oracle
[oracle@node1 ~]$ exit
logout
[root@node1 ~]# clear
[root@node1 ~]# su - oracle
[oracle@node1 ~]$ pwd
/home/oracle
[oracle@node1 ~]$ ll -a
total 2489664
drwx------  2 oracle oinstall       4096 Mar 19 18:04 .
drwxr-xr-x. 3 root   root           4096 Mar 19 16:39 ..
-rw-------  1 oracle oinstall         65 Mar 19 18:05 .bash_history
-rw-r--r--  1 oracle oinstall         18 May 11  2016 .bash_logout
-rw-r--r--  1 oracle oinstall        176 May 11  2016 .bash_profile
-rw-r--r--  1 oracle oinstall        124 May 11  2016 .bashrc
-rw-r--r--  1 root   root     1395582860 Mar 19 16:52 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r--  1 root   root     1151304589 Mar 19 16:51 p13390677_112040_Linux-x86-64_2of7.zip
[oracle@node1 ~]$ cat .bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
[oracle@node1 ~]$ vim .bash_profile 
[oracle@node1 ~]$ cat .bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export NLS_LANG="american_america.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin

2.15 Oracle用户解压oracle软件安装包

su - oracle
cd /home/oracle
--unzip software 11.2.0.4
unizp p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip

解压完成后会在当前文件夹生成 database 目录。

3 静默安装过程

3.1 初步处理响应文件

3.1.1 备份响应文件

[oracle@node1 database]$ cd /home/oracle/database/response/
[oracle@node1 response]$ mkdir rspbak
[oracle@node1 response]$ cp *.rsp ./rspbak/
[oracle@node1 response]$ ll
total 84
-rwxr-xr-x 1 oracle oinstall 44533 Aug 27  2013 dbca.rsp
-rw-r--r-- 1 oracle oinstall 25116 Aug 27  2013 db_install.rsp
-rwxr-xr-x 1 oracle oinstall  5871 Aug 27  2013 netca.rsp
drwxr-xr-x 2 oracle oinstall  4096 Mar 19 18:17 rspbak
[oracle@node1 response]$ 

3.1.2 删除响应文件中的注释行(以#开头)

#vi编辑替换或者直接使用sed命令快速替换
[oracle@node1 response]$ sed -i 's/^#.*$//g' *.rsp

3.1.3 删除没有内容的空行(^$)

#vi编辑替换或者直接使用sed命令快速替换
[oracle@node1 response]$ sed -i '/^$/d' *.rsp

3.2 静默安装软件,只安装软件,不建库。

3.2.1 编辑 db_install.rsp 文件

修改前
[oracle@node1 response]$ cat /home/oracle/database/response/db_install.rsp 
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=
ORACLE_HOSTNAME=
UNIX_GROUP_NAME=
INVENTORY_LOCATION=
SELECTED_LANGUAGES=en
ORACLE_HOME=
ORACLE_BASE=
oracle.install.db.InstallEdition=
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=
oracle.install.db.OPER_GROUP=
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=ZHS16GBK
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
修改后
[oracle@node1 response]$ vim /home/oracle/database/response/db_install.rsp 
[oracle@node1 response]$ cat /home/oracle/database/response/db_install.rsp 
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=node1
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
[oracle@node1 response]$ 

3.2.2 静默安装软件,成功效果如下

[oracle@node1 response]$ cd /home/oracle/database/
[oracle@node1 database]$ ./runInstaller -silent -force -noconfig -responseFile /home/oracle/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 37378 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 4095 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-03-19_06-33-36PM. Please wait ...[oracle@node1 database]$ [WARNING] [INS-13014] Target environment do not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. /tmp/OraInstall2020-03-19_06-33-36PM/installActions2020-03-19_06-33-36PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2020-03-19_06-33-36PM/installActions2020-03-19_06-33-36PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2020-03-19_06-33-36PM.log
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2020-03-19_06-33-36PM.log' for more details.

As a root user, execute the following script(s):
    1. /u01/app/oraInventory/orainstRoot.sh
    2. /u01/app/oracle/product/11.2.0/dbhome_1/root.sh


Successfully Setup Software.

成功后需要到 root 用户下 执行上图 示的 2 个脚本,执行效果如下:

[root@node1 ~]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@node1 ~]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
Check /u01/app/oracle/product/11.2.0/dbhome_1/install/root_node1_2020-03-19_18-40-49.log for the output of root script

3.2.3 测试软件安装成功

[root@node1 ~]# su - oracle
[oracle@node1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Mar 19 18:42:30 2020

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> 

3.3 静默安装监听

3.3.1 编辑 netca.rsp 文件

无需更改,直接使用默认参数

[oracle@node1 response]$ more netca.rsp 
[GENERAL]
RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
[oracle@node1 response]$ 

3.3.2 静默创建监听

netca -silent -responseFile /home/oracle/database/response/netca.rsp

忘记保存执行结果了,后续再补上,成功会返回以下结果。

netca -silent -responseFile /home/oracle/database/response/netca.rsp

Parsing command line arguments:
  Parameter "silent" = true
  Parameter "responsefile" = /home/oracle/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
  Running Listener Control: 
    /u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER
  Listener Control complete.
  Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

3.4 静默 dbca 建库

3.4.1 编辑 dbca.rsp 文件。

修改[CREATEDATABASE]模块内容如下

[oracle@node1 response]$ cat dbca.rsp 
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
EMCONFIGURATION = "LOCAL"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
STORAGETYPE=FS
DATAFILEDESTINATION=/u01/app/oracle/oradata
RECOVERYAREADESTINATION=/u01/app/oracle/flash_recovery_area
STORAGETYPE=FS
CHARACTERSET = "ZHS16GBK"
NATIONALCHARACTERSET= "AL16UTF16"
LISTENERS = "LISTENER"
SAMPLESCHEMA=TRUE
DATABASETYPE = "OLTP"
AUTOMATICMEMORYMANAGEMENT = "TRUE"
MEMORYPERCENTAGE = "60"
[createTemplateFromDB]
SOURCEDB = "myhost:1521:orcl"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"
[createCloneTemplate]
SOURCEDB = "orcl"
TEMPLATENAME = "My Clone TEMPLATE"
[DELETEDATABASE]
SOURCEDB = "orcl"
[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = "orcl11.us.oracle.com"
[CONFIGUREDATABASE]
[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
NODELIST=
SYSDBAUSERNAME = "sys"
[DELETEINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
INSTANCENAME = "orcl11g"
SYSDBAUSERNAME = "sys"
[oracle@node1 response]$ 

3.4.2 静默创建数据库

[oracle@node1 response]$ $ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/database/response/dbca.rsp
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.

3.4.3 测试建库成功

[oracle@node1 response]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Mar 19 23:50:07 2020

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from dual;

D
-
X

SQL> 

猜你喜欢

转载自www.cnblogs.com/jowell/p/12527905.html
今日推荐