Centos7.5静默安装Oracle18c
环境:
CentOS7.5、Oracle18c(LINUX.X64_180000_db_home.zip)
1. 安装必要的依赖包
[root@bogon ~]# yum install bc binutils compat-libcap compat-libstdc glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libgcc libstdc++ libstdc++-devel libxcb make smartmontools sysstat
2.修改系统参数,添加以下参数
[root@bogon ~]# vi /etc/sysctl.conf kernel.shmmax = 68719476736 kernel.shmall = 106029312 kernel.shmmni = 4096 kernel.sem =250 32000 100 128 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1262144 net.ipv4.ip_local_port_range =9000 65500 fs.file-max=7065536 fs.aio-max-nr=1048576
3. 修改/etc/security/limits.conf
[root@bogon ~]# vi /etc/security/limits.conf oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 oracle hard stack 10240
4. 关闭防火墙 关闭selinux
[root@bogon ~]# systemctl stop firewalld [root@bogon ~]# setenforce 0
5. 配置网络
[root@bogon ~]# vim /etc/hosts 192.168.110.37(本机IP) Oracle
6. 测试网络
[root@bogon ~]# ping Oracle PING Oracle (192.168.110.37) 56(84) bytes of data. 64 bytes from Oracle (192.168.110.37): icmp_seq=1 ttl=64 time=0.061 ms 64 bytes from Oracle (192.168.110.37): icmp_seq=2 ttl=64 time=0.045 ms 64 bytes from Oracle (192.168.110.37): icmp_seq=3 ttl=64 time=0.055 ms 64 bytes from Oracle (192.168.110.37): icmp_seq=4 ttl=64 time=0.054 ms 64 bytes from Oracle (192.168.110.37): icmp_seq=5 ttl=64 time=0.070 ms
7. 创建所需操作系统用户组和用户
[root@bogon ~]# groupadd oinstall [root@bogon ~]# groupadd dba [root@bogon ~]# groupadd oper [root@bogon ~]# useradd -g oinstall -G dba,oper oracle [root@bogon ~]# 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.
8. 创建Oracle安装目录
[root@bogon ~]# mkdir -p /u01/app/oracle/product/18.3/db_1
9. 解压Oracle安装文件
[root@bogon ~]# unzip LINUX.X64_180000_db_home.zip -d /u01/app/oracle/product/18.3/db_1
10. 安装目录权限
[root@bogon ~]# chown -R oracle:oinstall /u01
11. 配置Oracle安装响应文件
[root@bogon ~]# vim /u01/app/oracle/product/18.3/db_1/install/response/db_install.rsp 根据下面的参数一个个配置,其它的参数可以先不用配置 oracle.install.option=INSTALL_DB_SWONLY UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oracle/oraInventory ORACLE_HOME=/u01/app/oracle/product/18.3/db_1 ORACLE_BASE=/u01/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.OSDBA_GROUP=dba oracle.install.db.OSOPER_GROUP=dba 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=cdb1 oracle.install.db.config.starterdb.SID=cdb1 oracle.install.db.config.starterdb.characterSet=AL32UTF8 oracle.install.db.config.starterdb.password.ALL=[全局密码]
12. 修改环境变量
[root@bogon ~]# vi /etc/profile export TMP=/tmp #日志存放位置 export TMPDIR=$TMP export ORACLE_HOSTNAME=Oracle #主机名 export ORACLE_UNQNAME=cdb1 #库名称 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/18.3/db_1 export ORACLE_SID=cdb1 #库名称 export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
13. 使环境变量生效
[root@bogon ~]# source /etc/profile
14. 创建Oracle数据目录
[root@bogon ~]# mkdir -p /u01/app/oracle/oradata [root@bogon ~]# mkdir -p /u01/app/oracle/oradata_back [root@bogon ~]# chmod -R 775 /u01/app
[root@bogon ~]# chown -R oracle:oinstall /u01
15. 开始安装
[oracle@bogon ~]$ su oracle [oracle@bogon ~]$ echo $ORACLE_HOME /u01/app/oracle/product/18.3/db_1 [oracle@bogon ~]$ echo $ORACLE_SID cdb1 [oracle@bogon ~]$ cd $ORACLE_HOME [oracle@Oracle db_1]$ ./runInstaller -force -silent -responseFile ./install/response/db_install.rsp Launching Oracle Database Setup Wizard... [WARNING] [INS-32055] The Central Inventory is located in the Oracle base. ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory. [WARNING] [INS-13014] Target environment does not meet some optional requirements. CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2018-09-10_06-22-35PM.log ACTION: Identify the list of failed prerequisite checks from the log: installActions2018-09-10_06-22-35PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually. The response file for this session can be found at: /u01/app/oracle/product/18.3/db_1/install/response/db_2018-09-10_06-22-35PM.rsp You can find the log of this install session at: /tmp/InstallActions2018-09-10_06-22-35PM/installActions2018-09-10_06-22-35PM.log As a root user, execute the following script(s): 1. /u01/app/oracle/oraInventory/orainstRoot.sh 2. /u01/app/oracle/product/18.3/db_1/root.sh Execute /u01/app/oracle/oraInventory/orainstRoot.sh on the following nodes: [Oracle] Execute /u01/app/oracle/product/18.3/db_1/root.sh on the following nodes: [Oracle] Successfully Setup Software with warning(s). Moved the install session logs to: /u01/app/oracle/oraInventory/logs/InstallActions2018-09-10_06-22-35PM
16. 执行安装后的文件
[oracle@Oracle db_1]$ exit exit [root@Oracle ~]# /u01/app/oracle/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oracle/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /u01/app/oracle/oraInventory to oinstall. The execution of the script is complete. [root@Oracle ~]# /u01/app/oracle/product/18.3/db_1/root.sh Check /u01/app/oracle/product/18.3/db_1/install/root_Oracle_2018-09-10_18-31-03-524717373.log for the output of root script
17. 配置静默监听
[oracle@Oracle ~]$ netca -silent -responsefile /u01/app/oracle/product/18.3/db_1/assistants/netca/netca.rsp Parsing command line arguments: Parameter "silent" = true Parameter "responsefile" = /u01/app/oracle/product/18.3/db_1/assistants/netca/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/18.3/db_1/bin/lsnrctl start LISTENER Listener Control complete. Listener started successfully. Listener configuration complete. Oracle Net Services configuration successful. The exit code is 0
18. 开启监听
[oracle@Oracle ~]$ lsnrctl start LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 10-SEP-2018 18:34:53 Copyright (c) 1991, 2018, Oracle. All rights reserved. TNS-01106: Listener using listener name LISTENER has already been started
19. 查看监听状态
[oracle@Oracle ~]$ lsnrctl status LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 10-SEP-2018 18:35:20 Copyright (c) 1991, 2018, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Oracle)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 18.0.0.0.0 - Production Start Date 10-SEP-2018 18:33:58 Uptime 0 days 0 hr. 1 min. 21 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/18.3/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/Oracle/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) The listener supports no services The command completed successfully
20. 静默建立数据库
[oracle@Oracle ~]$ vim /u01/app/oracle/product/18.3/db_1/assistants/dbca/dbca.rsp gdbName=cdb1 sid=cdb1 createAsContainerDatabase=true numberOfPDBs=1 pdbName=cdb1pdb templateName=/u01/app/oracle/product/18.3/db_1/assistants/dbca/templates/General_Purpose.dbc datafileJarLocation={ORACLE_HOME}/assistants/dbca/templates/ datafileDestination={ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/ recoveryAreaDestination={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME} characterSet=AL32UTF8 listeners=LISTENER initParams=undo_tablespace=UNDOTBS1,memory_target=796MB,processes=300,db_recovery_file_dest_size=11000MB,nls_language=AMERICAN,dispatchers=(PROTOCOL=TCP) (SERVICE=cdb1XDB),db_recovery_file_dest={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME},db_block_size=8192BYTES,diagnostic_dest={ORACLE_BASE},audit_file_dest={ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump,nls_territory=AMERICA,local_listener=LISTENER_CDB1,compatible=18.3.0,control_files=("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl","{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/control02.ctl"),db_name=cdb1,audit_trail=db,remote_login_passwordfile=EXCLUSIVE,open_cursors=300 memoryPercentage=40 totalMemory=529
21. 修改配置文件
[root@bogon ~] vi /u01/app/oracle/product/18.3/db_1/network/admin/sqlnet.ora SQLNET.ALLOWED_LOGON_VERSION=8
22. 安装数据库实例
[oracle@localhost ~]$ dbca -silent -createDatabase -responseFile /u01/app/oracle/product/18.3/db_1/assistants/dbca/dbca.rsp -sampleSchema false -J-Doracle.assistants.dbca.validate.ConfigurationParams=false 输入 SYS 用户口令: 输入 SYSTEM 用户口令: 输入 PDBADMIN 用户口令: [WARNING] [DBT-06208] 输入的 'SYS(S)' 口令未遵从 Oracle 建议的标准。 原因: a. Oracle 建议, 输入的口令长度不应少于 8 个字符, 至少包含 1 个大写字符, 1 个小写字符和 1 个数字 [0-9]。 b. 输入的口令是一个关键字, Oracle 建议不要将其用作口令 操作: 指定强口令。如果需要, 请参阅 Oracle 文档以了解相关指南。 [WARNING] [DBT-06208] 输入的 'SYSTEM' 口令未遵从 Oracle 建议的标准。 原因: a. Oracle 建议, 输入的口令长度不应少于 8 个字符, 至少包含 1 个大写字符, 1 个小写字符和 1 个数字 [0-9]。 b. 输入的口令是一个关键字, Oracle 建议不要将其用作口令 操作: 指定强口令。如果需要, 请参阅 Oracle 文档以了解相关指南。 [WARNING] [DBT-06208] 输入的 'PDBADMIN' 口令未遵从 Oracle 建议的标准。 原因: a. Oracle 建议, 输入的口令长度不应少于 8 个字符, 至少包含 1 个大写字符, 1 个小写字符和 1 个数字 [0-9]。 b. 输入的口令是一个关键字, Oracle 建议不要将其用作口令 操作: 指定强口令。如果需要, 请参阅 Oracle 文档以了解相关指南。 准备执行数据库操作 已完成 8% 复制数据库文件 已完成 31% 正在创建并启动 Oracle 实例 已完成 32% 已完成 36% 已完成 40% 已完成 43% 已完成 46% 正在进行数据库创建 已完成 51% 已完成 53% 已完成 54% 正在创建插接式数据库 已完成 58% 已完成 77% 执行配置后操作 已完成 100% 数据库创建完成。有关详细信息, 请查看以下位置的日志文件: /u01/app/oracle/cfgtoollogs/dbca/cdb1。 数据库信息: 全局数据库名:cdb1 系统标识符 (SID):cdb1 有关详细信息, 请参阅日志文件 "/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log"。
23. 安装完成之后system还无法登录,需要解锁system并且重新修改system用户密码就可以远程链接了
[oracle@Oracle ~]$ sqlplus / as sysdba SQL*Plus: Release 18.0.0.0.0 - Production on Tue Sep 11 08:48:49 2018 Version 18.3.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Connected to: Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production Version 18.3.0.0.0 SQL> connect system/oracle (oracle是创建的时候指定的) Connected. SQL> alter user system account unlock; User altered. SQL> alter user system identified by manager; User altered. SQL> exit Disconnected from Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
24. 设置开机自启动oracle和监听器
su - oracle vim /u01/app/oracle/product/18.3/db_1/bin/dbstart 将ORACLE_HOME_LISTNER=$1,修改为ORACLE_HOME_LISTNER=$ORACLE_HOME vim /u01/app/oracle/product/18.3/db_1/bin/dbshut 将ORACLE_HOME_LISTNER=$1,修改为ORACLE_HOME_LISTNER=$ORACLE_HOME vim /etc/oratab cdb1: /u01/app/oracle/product/18.3/db_1:Y exit sudo vim /etc/rc.local su - oracle -c 'dbstart' su - oracle -c 'lsnrctl start' sudo chmod +x /etc/rc.local
参考文章: https://blog.csdn.net/Alisebeast/article/details/81538457