centos 6.5_x64上静默模式安装oracle 11.2.0.1

时间:2021-08-07 08:43:55

centos 6.5_x64上静默模式安装oracle 11.2.0.1

 

1. 检查软件包依赖,Oracle官方要求redhat enterprise linux 6 以上需要安装以下包:

binutils-2.20.51.0.2-5.11.el6 (x86_64)
compat-libcap1-1.10-1 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (x86_64)
compat-libstdc++-33-3.2.3-69.el6.i686
gcc-4.4.4-13.el6 (x86_64)
gcc-c++-4.4.4-13.el6 (x86_64)
glibc-2.12-1.7.el6 (i686)
glibc-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6.i686
ksh
libgcc-4.4.4-13.el6 (i686)
libgcc-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6.i686
libstdc++-devel-4.4.4-13.el6 (x86_64)
libstdc++-devel-4.4.4-13.el6.i686
libaio-0.3.107-10.el6 (x86_64)
libaio-0.3.107-10.el6.i686
libaio-devel-0.3.107-10.el6 (x86_64)
libaio-devel-0.3.107-10.el6.i686
make-3.81-19.el6
sysstat-9.0.4-11.el6 (x86_64)

 

执行:

yum -install binutils compat-libcap1 compat-libstdc++-33-* gcc gcc-c++ glibc-* glibc-devel-* ksh libgcc-* libstdc++-* libstdc++-devel-* libaio-* libaio-devel-* make sysstat

 

2. 配置内核参数、设置资源,创建相关用户、用户组并配置oracle用户环境

cp /etc/sysctl.conf{,.bak}

cat >> /etc/sysctl.conf <<EOF

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 = 1048576

EOF

 

sysctl -p

 

cp /etc/pam.d/login{,.bak}

cat >>  /etc/pam.d/login <<EOF

session    required     /lib64/security/pam_selinux.so open

EOF

 

cp /etc/security/limits.conf{,.bak}

cat >> /etc//security/limits.conf <<EOF

oracle   soft   nofile    131072
oracle   hard   nofile    131072
oracle   soft   nproc    131072
oracle   hard   nproc    131072
oracle   soft   core    unlimited
oracle   hard   core    unlimited
oracle   soft   memlock    50000000
oracle   hard   memlock    50000000

EOF

 

groupadd -g 501 oinstall

groupadd -g 502 dba

groupadd -g 503 asm

groupadd -g 504 oper

useradd -g oinstall -G dba, asm, oper -u 501 oracle

 

cat >> /home/oracle/.bash_profile <<EOF

export ORACLE_BASE=/u01/app
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib:/lib64:/usr/lib64
export PATH=\$ORACLE_HOME/bin:\$PATH

EOF

 

vim /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

 

 

mkdir /u01/app

chown -R oracle.oinstall /u01

passwd oracle

 

su - oracle

mkdir -p  $ORACLE_HOME

tar xvf  linux.x64_11gR2_database_1of2.zip

tar xvf linux.x64_11gR2_database_2of2.zip

rm -rf linux.x64_11gR2_database_*

cd database

cp response/install_db.rsp  ~/oracle_install_swonly.rsp

cp response/netca.rsp ~/netca.rsp

cp response/dbca.rsp  ~/dbca.rsp

 

vim ~/oracle_install_swonly.rsp

vim ~/netca.rsp

vim ~/dbca.rsp

 

## 仅安装oracle软件

./runInstaller -silent -noconfig -responseFile /home/oracle/oracle_install_swonly.rsp

 查看安装日志,等待安装完成后,执行

/u01/app/oraInventory/orainstRoot.sh

/u01/app/oracle/product/11.2.0.1/db_1/root.sh

 

## 使用静默模式创建监听

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

 

监听程序配置完成,尚需要配置TNS服务,在$ORACLE_HOME/network/admin目录下新建tnsnames.ora文件,输入以下内容:

ORCL =
(DESCRIPTION =
 (ADDRESS_LIST =
   (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.201.13)(PORT = 1521))
  )
  (CONNECT_DATA =
  (SERVICE_NAME =orcl)
  )
)

## 使用静默模式建库

dbca -silent -responseFile /home/oracle/dbca.rsp

 

创建过程,输出如下:

[oracle@node3 ~]$ dbca -silent -responseFile /home/oracle/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
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/cfgtoollogs/dbca/orcl/orcl.log" for further details.

 

# dbca.rsp中createDatabase部分参数

[oracle@node3 ~]$ cat dbca.rsp | grep -v "^#" | grep -v "^$"
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
CHARACTERSET = "AL32UTF8"
NATIONALCHARACTERSET= "AL16UTF16"
MEMORYPERCENTAGE = "30"
TOTALMEMORY = "800"

 ## 使用dbca静默方式删除建立的数据库,修改dbca.rsp中的OPERATION_TYPE = "deleteDatabase"

dbca -silent -deleteDatabase -responseFile /home/oracle/dbca.rsp

 

 

## 让oracle 实例、监听服务开机自启动

[oracle@node3 ~]$ vim +80  /u01/app/product/11.2.0/db_1/bin/dbstart

 ORACLE_HOME_LISTNER=$1

改为

ORACLE_HOME_LISTNER=$ORACLE_HOME

 

[oracle@node3 ~]$ vim /etc/oratab

orcl:/u01/app/product/11.2.0/db_1:N

改为

orcl:/u01/app/product/11.2.0/db_1:Y

 

[oracle@node3 ~]$ echo "su - oracle -c \"/u01/app/product/11.2.0/db_1/bin/dbstart\"" >> /etc/rc.local