Centos7静默安装Oracle12C
Centos系统
#该系统为KVM中的虚拟机,宿主机为ubuntu18.04LTS
[eric@oracle ~]$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
修改主机名和hosts文件
[eric@oracle ~]$ su root #root用户修改
Password:
[root@oracle eric]# cd
[root@oracle ~]# cat /etc/hostsname
oracle #vim 编辑,只保留Oracle
#修改host文文件 oracle+主机ip
[root@oracle ~]# cat /etc/hosts
oracle 192.168.122.13
关闭防火墙
[root@oracle ~]# systemctl stop firewalld
关闭selinux
#ftp 需要关闭selinux
[root@oracle ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g'/etc/selinux/config
[root@oracle ~]# getenforce
Disabled
ftp安装及文件传输参考:
[]: https://blog.csdn.net/EricLeiy/article/details/78779812 “宿主机通过FTP 向KVM虚拟机传文件”
安装依赖
[root@oracle ~]#yum -y install binutils compat-libstdc++ compat-libstdc++-33 elfutils-libelf-devel gcc gcc-c++ glibc-devel glibc-headers ksh libaio-devel libstdc++-devel make sysstat unixODBC-devel binutils-* compat-libstdc++* elfutils-libelf* glibc* gcc-* libaio* libgcc* libstdc++* make* sysstat* unixODBC* wget unzip
[root@oracle ~]# yum -y install java-1.8.0-openjdk*
为oracle创建用户
#创建安装用户组oinstall
[root@oracle ~]# groupadd oinstall
#创建dba用户组
[root@oracle ~]# groupadd dba
#创建oracle用户并添加组权限
[root@oracle ~]# useradd -g oinstall -G dba oracle
#设置密码
[root@oracle ~]# passwd oracle
Changing password for user oracle.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
#查看
[root@oracle ~]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
创建安装目录
$ORACLE_BASE
[root@oracle ~]# mkdir -p /opt/oracle
$ORACLE_HOME
[root@oracle ~]# mkdir -p /opt/oracle/12c
#数据存放目录
[root@oracle ~]# mkdir /opt/oracle/oradata
#清单目录:该目录不能放在oracle_base目录下,不然后期静默安装数据库时,读取db_install.rsp文件报错
[root@oracle ~]# mkdir /opt/inventory
#数据恢复目录
[root@oracle ~]# mkdir /opt/oracle/flash_recovery_area
#赋权限
[root@oracle ~]# chown -R oracle:oinstall /opt/oracle
[root@oracle ~]# chmod -R 775 /opt/oracle
[root@oracle ~]# chmod -R 775 /opt/inventory
调整系统参数
[root@oracle ~]# vim /etc/sysctl.conf
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
#重启生效
[root@oracle ~]# sysctl -p
修改用户限制文件(后来补充,没有修改也可以,如果失败,可以再调整)
#不调整也OK了,但是后来重新安装时,没有这一步报错了
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
设置环境变量
[root@oracle opt]# vim /etc/profile --在文件末尾添加
# Oracle environment set
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
#使文件生效,执行
[root@oracle opt]# source /etc/profile
使用oracle用户,配置oracle环境变量
[root@oracle opt]# su oracle
[oracle@oracle opt]$ cd
[oracle@oracle ~]$ vim .bash_profile
#在文件尾部添加
#For oracle user environment set
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/12c
export ORACLE_HOME_LISTNER=$ORACLE_HOME
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
使配置文件生效
[oracle@oracle ~]$ source .bash_profile
下载oralce12c,上传至/opt/oracle/目录
[oracle@oracle ~]$ cd /opt/oracle/
[oracle@oracle oracle]$ ftp
ftp> open 192.168.122.1
Connected to 192.168.122.1 (192.168.122.1).
220 (vsFTPd 3.0.3)
Name (192.168.122.1:oracle): Eric
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> get /home/eric/share/linuxx64_12201_database.zip ./linuxx64_12201_database.zip
#解压
[oracle@oracle oracle]$ unzip linuxx64_12201_database.zip
解压后,查看三个配置文件:数据库安装文件 db_install.rsp,建立数据库实例dbca.rsp,监听配置安装文件netca.rsp
[oracle@oracle oracle]$ cd database/response/
[oracle@oracle response]$ ll
total 84
-rwxrwxr-x 1 oracle oinstall 25609 Nov 20 06:01 dbca.rsp
-rw-rw-r-- 1 oracle oinstall 23085 Nov 19 21:34 db_install.rsp
-rw-r--r-- 1 oracle oinstall 22924 Nov 19 06:09 db_install.rsp.bak
-rwxrwxr-x 1 oracle oinstall 6209 Jun 20 2016 netca.rsp
[oracle@oracle response]$
修改数据库安装文件db_install.rsp,为静默安装做准备,下面是必须填写的
[oracle@oracle response]$ vim db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0 #默认
oracle.install.option=INSTALL_DB_SWONLY #安装类型
UNIX_GROUP_NAME=oinstall #安装组
INVENTORY_LOCATION=/opt/inventory #清单目录
ORACLE_HOME=/opt/oracle/12c/ #ORACLE_HOME
ORACLE_BASE=/opt/oracle #ORACLE_BASE
oracle.install.db.InstallEdition=EE #oracle版本
oracle.install.db.OSDBA_GROUP=dba #dba用户组
oracle.install.db.OSOPER_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
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryLimit=81920 #自动管理内存的最小内存(M)
oracle.install.db.config.starterdb.password.ALL=oracle #设定所有数据库用户使用同一个密码
DECLINE_SECURITY_UPDATES=true #设置安全更新
安装,执行下面命令
[oracle@oracle ~]$ cd /opt/oracle/database/
[oracle@oracle database]$ ./runInstaller -silent -responseFile /opt/oracle/database/response/db_install.rsp -ignorePrereq
[oracle@oracle response]$ The installation of Oracle Database 12c was successful.
Please check '/opt/inventory/logs/silentInstall2018-11-19_09-53-55PM.log' for more details.
As a root user, execute the following script(s):
1. /opt/inventory/orainstRoot.sh
2. /opt/oracle/12c/root.sh
#切换到root用户执行上面的脚本
查看监听文件,启动监听
[oracle@oracle response]$ vim netca.rsp
[GENERAL]
RESPONSEFILE_VERSION="12.2"
CREATE_TYPE="CUSTOM"
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@oracle response]$ netca /silent /responseFile netca.rsp
#检查 有三个配置文件生成 listener.ora sqlnet.ora tnsnames.ora
[oracle@oracle ~]$ ls /opt/oracle/12c/network/admin/
listener.ora samples shrept.lst sqlnet.ora tnsnames.ora
#检查1521端口是否启动
oracle@oracle ~]$ netstat -tulnp |grep 1521
tcp6 0 0 :::1521 :::* LISTEN 1616/tnslsnr
添加数据库实例,修改daca.rsp文件
[oracle@oracle ~]$ cd /opt/oracle/database/response/
[oracle@oracle response]$ ls
dbca.rsp db_install.rsp db_install.rsp.bak netca.rsp
[oracle@oracle response]$ vim dbca.rsp
#下面这些是必须填写的
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0 #默认
gdbName=orcl #数据库名
sid=orcl #数据库实例名
templateName=General_Purpose.dbc #这个不太明白
sysPassword=oracle #sys密码
systemPassword=oracle #system密码
emExpressPort=5500 #好像默认的,可以参考
datafileDestination=/opt/oracle/oradata #清单目录
recoveryAreaDestination=/opt/oracle/flash_recovery_area #数据恢复目录
characterSet=AL32UTF8 #字符集,最后配置对了,不然后面更改很麻烦
执行安装数据库实例
[oracle@oracle ~]$ cd /opt/oracle/12c/bin/
[oracle@oracle response]$ dbca -silent -createdatabase -responseFile /opt/oracle/database/response/dbca.rsp
[WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
Copying database files
1% complete
2% complete
18% complete
33% complete
Creating and starting Oracle instance
35% complete
40% complete
44% complete
49% complete
50% complete
53% complete
55% complete
Completing Database Creation
56% complete
57% complete
58% complete
62% complete
65% complete
66% complete
Executing Post Configuration Actions
100% complete
Look at the log file "/opt/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
[oracle@oracle response]$
[oracle@oracle respo
检查
#实例状态
[oracle@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Wed Nov 21 07:01:02 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SYS@orcl>
#实例进程,监听状态
[oracle@oracle ~]$ ps -ef |grep ora_ |grep -v grep
oracle 1784 1 0 Nov20 ? 00:00:04 ora_pmon_orcl
oracle 1786 1 0 Nov20 ? 00:00:01 ora_clmn_orcl
oracle 1788 1 0 Nov20 ? 00:00:14 ora_psp0_orcl
...
关于启动的问题
若使用dbstart报错如下,则修改文件dbstart
[oracle@oracle ~]$ dbstart
ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
Usage: /opt/oracle/12c/bin/dbstart ORACLE_HOME
#修改dbstart文件
[oracle@oracle ~]$ cd $ORACLE_HOME/bin
[oracle@oracle bin]$ vim dbstart
将文件中的ORACLE_HOME_LISTNER=$1
调整为 ORACLE_HOME_LISTNER=$ORACLE_HOME