[Centos7] oracle11.2.0.1 的静默安装

站在巨人的肩膀上

part.1安装环境及版本

安装环境:Centos7
安装版本:11.2.0.1(而后会升级至11.2.0.4)

part.2.安装步骤

2.1 安装依赖包

# yum install -y binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel \
compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh \
libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel \
libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686

2.2 创建oinstall和dba组

# groupadd oinstall
# groupadd dba

2.3 创建oracle用户并设置密码

# useradd -g oinstall -G dba oracle
# passwd oracle

2.4 验证是否创建成功

# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)

2.5 配置内核参数

# vim /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 = 1048576

添加后生效

# /sbin/sysctl -p

2.6 修改用户权限

# vim /etc/security/limits.conf

在末尾添加:

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

2.7 修改profile文件

在/etc/pam.d/login 文件中,使用文本编辑器或vi命令增加或修改以下内容

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

在/etc/profile 文件中,使用文本编辑器或vi命令增加或修改以下内容

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

使之生效

# source /etc/profile

2.8 创建安装目录

mkdir -p /u01/app
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app

2.9 配置环境变量

# su - oracle
# vim ~/.bash_profile

添加如下变量

export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
export ORACLE_PID=ora11g
#export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin

export LANG="zh_CN.UTF-8"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'

2.10 解压oracle软件

在/usr/local/src文件夹下解压

# unzip linux.x64_11gR2_database_1of2.zip
# unzip linux.x64_11gR2_database_2of2.zip

2.11 复制响应文件模板

# su - oracle
# mkdir etc
# cp  /usr/local/src/database/response/* /home/oracle/etc/

2.12 修改db_install.rsp 文件

# vim /home/oracle/etc/db_install.rsp

修改如下条目

oracle.install.option=INSTALL_DB_SWONLY     // 安装类型
ORACLE_HOSTNAME=localhost        // 主机名称(hostname查询)
UNIX_GROUP_NAME=oinstall     // 安装组
INVENTORY_LOCATION=/u01/app/oraInventory   //INVENTORY目录(不填就是默认值)
SELECTED_LANGUAGES=en,zh_CN,zh_TW // 选择语言:
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1    //oracle_home
ORACLE_BASE=/u01/app/oracle     //oracle_base
oracle.install.db.InstallEdition=EE     // oracle版本
oracle.install.db.isCustomInstall=false   //自定义安装,否,使用默认组件
oracle.install.db.DBA_GROUP=dba /  / dba用户组
oracle.install.db.OPER_GROUP=oinstall // oper用户组
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //数据库类型
oracle.install.db.config.starterdb.globalDBName=orcl //globalDBName
oracle.install.db.config.starterdb.SID=orcl      //SID
oracle.install.db.config.starterdb.memoryLimit=81920 //自动管理内存的内存(M)
oracle.install.db.config.starterdb.password.ALL=oracle //设定所有数据库用户使用同一个密码
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false         //(手动写了false)
DECLINE_SECURITY_UPDATES=true   //设置安全更新(貌似是有bug,这个一定要选true,否则会无限提醒邮件地址有问题,终止安装。PS:不管地址对不对)

2.13 静默安装

# su - oracle
# cd /usr/local/src/database
# ./runInstaller -silent -responseFile /home/oracle/etc/db_install.rsp

若出现如下信息,就是安装成功

------------------------------------------------------------------------
The following configuration scripts need to be executed as the "root" user. 
#!/bin/sh 
#Root scripts to run

/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window 
2. Log in as "root" 
3. Run the scripts 
4. Return to this window and hit "Enter" key to continue

Successfully Setup Software.

-----------------------------------------------------------------------------

2.14 使用root用户执行脚本

su - root
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/db_1/root.sh

2.15 修改建库应答文件参数,并建库

vim /home/oracle/etc/dbca/rsp

修改如下信息条目


[oracle@docker ~]$ vi /home/oracle/etc/dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
CHARACTERSET = "AL32UTF8"
# su - oracle
dbca -silent -responseFile /home/oracle/etc/dbca.rsp

2.16 创建/启动监听(oracle用户)

# cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
# vim listener.ora

添加如下信息

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      )
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = orcl)
    )
  ) 

启动监听

# lsnrctl start

2.17 测试连接

# sqlplus / as sysdba
SQL> startup

2.18 开机启动项添加

#vim /etc/rc.local

su - oracle << EOF
export ORACLE_SID=dbsrv
lsnrctl start
sqlplus / as sysdba
startup
quit
EOF

你可能感兴趣的:([Centos7] oracle11.2.0.1 的静默安装)