Oracle 19c(19.3) 单机数据库静默安装
一、环境介绍
操作系统:CentOS 7.4
数据库版本:Oracle database 19.3
主机名:oradb31
IP地址:192.168.1.31
安装目录:/opt/oracle/product/19.3/db_1
数据库名称:orcl
字符集:AL32UTF8
二、环境准备
2.1:关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
2.2:禁用NetworkManager服务
systemctl stop NetworkManager
systemctl disable NetworkManager
2.3:禁用SELINUX
[root@adg19c ~]# setenforce 0
setenforce: SELinux is disabled
cat /etc/selinux/config
SELINUX=disabled
2.4:配置HOSTS解析
cat /etc/hosts
192.168.1.31 oradb31
2.5:修改主机名
cat /etc/sysconfig/network
[root@adg19c ~]# sed -i 's#^NETWORKING_IPV6=.*$#NETWORKING_IPV6=no#' /etc/sysconfig/network
2.6:配置NOZEROCONFIG
cat >> /etc/sysconfig/network
NOZEROCONF=yes
2.7:创建组和用户
# 创建dba和onstall两个用户组
groupadd -g 501 dba
groupadd -g 502 oinstall
groupadd -g 503 backupdba
groupadd -g 504 dgdba
groupadd -g 505 kmdba
groupadd -g 506 racdba
# 创建oracle用户
useradd -u 503 -g oinstall -G dba,backupdba,dgdba,kmdba,racdba oracle
# 配置oracle用户密码
passwd oracle
2.8:创建安装目录并赋权
# 创建目录
mkdir -p /opt/oraInventory
mkdir -p /opt/oracle/product/19.3/db_1
# 赋权
chown -R oracle:oinstall /opt
chmod -R 775 /opt/oraInventory
2.9:配置用户环境变量
cat /home/oracle/.bash_profile
export TMP=/tmp
export ORACLE_HOSTNAME=oradb31
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/19.3/db_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=/bin:/usr/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=AMERICAN_AMERICA AL32UTF16
umask 022
[root@adg19c ~]# source /home/oracle/.bash_profile
2.10:配置系统环境变量
cat /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
source /etc/profile
2.11. 修改系统内核参数
[root@adg19c ~]# cat >> /etc/sysctl.conf <<EOF
kernel.shmall = 4294967296
kernel.sem = 5130 65280 510 256
kernel.shmmni = 4096
kernel.shmmax = 549755813888 #support max TotalMemory 512GB
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 1048576
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.file-max = 6815744
fs.aio-max-nr = 1048576
vm.swappiness = 10
vm.dirty_background_ratio = 20
vm.dirty_ratio = 80
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.tcp_wmem = 262144
net.ipv4.tcp_rmem = 4194304
EOF
[root@adg19c ~]# /sbin/sysctl -p
kernel.shmall = 4294967296
kernel.sem = 5130 65280 510 256
kernel.shmmni = 4096
kernel.shmmax = 549755813888 #support max TotalMemory 512GB
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 1048576
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.file-max = 6815744
fs.aio-max-nr = 1048576
vm.swappiness = 10
vm.dirty_background_ratio = 20
vm.dirty_ratio = 80
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.tcp_wmem = 262144
net.ipv4.tcp_rmem = 4194304
2.12. 配置LIMITS限制参数
cat >> /etc/security/limits.conf <<EOF
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft memlock 3145728
oracle hard memlock 3145728
2.13. 配置PAM验证
vi /etc/pam.d/login
session required /lib64/security/pam_limits.so
2.14:安装依赖包:
yum install -y bc binutils compat-libcap1 compat-libstdc++ elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc libstdc++ libstdc++-devel libxcb make net-tools nfs-utils python python-configshell python-rtslib python-six targetcli smartmontools sysstat unzip vim
2.15:安装compat-libstdc++:
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
2.16:检查已安装依赖包
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' bc binutils compat-libcap1 compat-libstdc++ elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc libstdc++ libstdc++-devel libxcb make net-tools nfs-utils python python-configshell python-rtslib python-six targetcli smartmontools sysstat unzip vim
三、安装软件
3.1:解压数据库软件
su - oracle
unzip -q LINUX.X64_193000_db_home.zip -d $ORACLE_HOME
du -sh $ORACLE_HOME
6.5G /opt/oracle/product/19.3/dbhome_1
3.2:开始安装数据库 软件
# 编写相应文件
[oracle@adg19c ~]$ cat /home/oracle/19c_db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/oracle/oraInventory
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/19.3/dbhome_1
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=oper
oracle.install.db.OSBACKUPDBA_GROUP=backupdba
oracle.install.db.OSDGDBA_GROUP=dgdba
oracle.install.db.OSKMDBA_GROUP=kmdba
oracle.install.db.OSRACDBA_GROUP=racdba
oracle.install.db.rootconfig.executeRootScript=true
oracle.install.db.rootconfig.configMethod=ROOT
# 运行安装命令
[oracle@adg19c ~]$ $ORACLE_HOME/runInstaller -silent -force -noconfig -ignorePrereq -responseFile /home/oracle/19c_db_install.rsp
Launching Oracle Database Setup Wizard...
[FATAL] [INS-35954] The installer has detected that the Oracle home location provided in the response file is not correct.
CAUSE: The Database Oracle home is the location from where the installer is executed. It has been detected that the value set in the response file is different (/opt/oracle/product/19.3/dbhome_1). Value expected is: /opt/oracle/product/19.3/db_1
ACTION: It is not required to specify ORACLE_HOME in the response file for Database installation. Alternatively, set it to the location of the installer (/opt/oracle/product/19.3/db_1).
Moved the install session logs to:
/opt/oracle/oraInventory/logs/InstallActions2021-10-30_07-23-54PM
四、 创建监听
# 编写监听配置文件
[oracle@adg19c ~]$ cat 19c_netca.rsp
[GENERAL]
RESPONSEFILE_VERSION="19.3"
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@adg19c ~]$ netca /silent /responsefile /home/oracle/19c_netca.rsp
五、创建数据库
# 编写数据库创建相应文件(原博客这里配置项不准确,
我在此步骤停滞了很长时间(报错:dbca -slient [FATAL] java.lang.NullPointerException),
配置项可参考::cat $ORACLE_HOME/assistants/dbca/dbca.rsp)
[oracle@adg19c ~]$ cat 19c_dbca.rsp
responseFileVersion=/home/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0
templateName=General_Purpose.dbc
gdbName=orcl
sid=orcl
createAsContainerDatabase=FALSE (true则会安装pdb新特性,false则不安装)
sysPassword=woo
systemPassword=woo
datafileDestination=/opt/oracle/oradata
recoveryAreaDestination=/opt/oracle/flash_recovery_area
storageType=FS
characterSet=AL32UTF8
nationalCharacterSet=AL16UTF16
sampleSchema=true
totalMemory=2048
databaseType=OLTP
emConfiguration=NONE
# 静默创建数据库
dbca -silent -createDatabase -responseFile /home/oracle/19c_dbca.rsp
#############################################################################
Oracle 19c 单实例 19.3.0 升级到19.11.0
1:查看当前DB环境
cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
uname -r
3.10.0-693.el7.x86_64
lsnrctl status
2:从MOS下载19.6 的RU 补丁
19.11 的DB补丁是:p32545013_190000_Linux-x86-64.zip, 可以直接从MOS上下载。解压之后查阅readme文档。
3:开始安装RU补丁
3.1 检查OPatch工具版本
要安装19c的RU,OPatch 工具的版本必须大于 12.2.0.1.23。 在Oracle 19.3的版本中,OPatch版本是12.2.0.1.17的。 所以需要单独的更新OPatch。
[oracle@oradb31 ~]$ /opt/oracle/product/19.3/db_1/OPatch/opatch version
OPatch Version: 12.2.0.1.17
OPatch succeeded.
3.2查看OPatch是否冲突
[oracle@oradb31 soft]$ unzip p32545013_190000_Linux-x86-64.zip
[oracle@oradb31 soft]$ cd 32545013/
[oracle@oradb31 32545013]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.2.0.1.17
Copyright (c) 2021, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /opt/oracle/product/19.3/db_1
Central Inventory : /opt/oracle/oraInventory
from : /opt/oracle/product/19.3/db_1/oraInst.loc
OPatch version : 12.2.0.1.17
OUI version : 12.2.0.7.0
Log file location : /opt/oracle/product/19.3/db_1/cfgtoollogs/opatch/opatch2021-10-30_23-59-23PM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
3.3 应用patch
这里有几点注意事项:
1.如果是物理DG,那么主备库都需要安装Patch,可以先在备库安装,再安装主库,操作步骤可以参考:Document 278641.1。
2.对于RAC 环境,可以使用OPatch rolling 方式来安装,这样没有停机时间,具体操作可以参考:Document 244241.1。
3.对于单实例,必须关闭待升级ORACLE HOME关联的所有实例和监听,并且包括退出所有的sqlplus窗口。
1:关闭监听
[oracle@oradb31 32545013]$ lsnrctl stop
2:关闭数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
[oracle@oradb31 32545013]$ pwd
/soft/32545013
[oracle@oradb31 32545013]$ $ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.17
Copyright (c) 2021, Oracle Corporation. All rights reserved.
Oracle Home : /opt/oracle/product/19.3/db_1
Central Inventory : /opt/oracle/oraInventory
from : /opt/oracle/product/19.3/db_1/oraInst.loc
OPatch version : 12.2.0.1.17
OUI version : 12.2.0.7.0
Log file location : /opt/oracle/product/19.3/db_1/cfgtoollogs/opatch/opatch2021-10-31_00-12-57AM_1.log
Verifying environment and performing prerequisite checks...
Prerequisite check "CheckMinimumOPatchVersion" failed.
The details are:
The OPatch being used has version 12.2.0.1.17 while the following patch(es) require higher versions:
Patch 32545013 requires OPatch version 12.2.0.1.23.
Please download latest OPatch from My Oracle Support.
UtilSession failed: Prerequisite check "CheckMinimumOPatchVersion" failed.
Log file location: /opt/oracle/product/19.3/db_1/cfgtoollogs/opatch/opatch2021-10-31_00-12-57AM_1.log
OPatch failed with error code 73
如果报错,需要安装psmisc
yum install -y psmisc
去下载opatch,并升级:
https://updates.oracle.com/download/6880880.html
https://www.jianshu.com/p/69279268b068
[oracle@oradb31 32545013]$ $ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.27
Copyright (c) 2021, Oracle Corporation. All rights reserved.
Oracle Home : /opt/oracle/product/19.3/db_1
Central Inventory : /opt/oracle/oraInventory
from : /opt/oracle/product/19.3/db_1/oraInst.loc
OPatch version : 12.2.0.1.27
OUI version : 12.2.0.7.0
Log file location : /opt/oracle/product/19.3/db_1/cfgtoollogs/opatch/opatch2021-10-31_00-35-23AM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 32545013
Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/opt/oracle/product/19.3/db_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '32545013' to OH '/opt/oracle/product/19.3/db_1'
ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.rdbms.tg4db2, 19.0.0.0.0 ] , [ oracle.tfa, 19.0.0.0.0 ] , [ oracle.options.olap.api, 19.0.0.0.0 ] , [ oracle.ons.cclient, 19.0.0.0.0 ] , [ oracle.options.olap, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.oid.client, 19.0.0.0.0 ] , [ oracle.ons.eons.bwcompat, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.xdk.companion, 19.0.0.0.0 ] , [ oracle.jdk, 1.8.0.191.0 ] not present in the Oracle Home or a higher version is found.
Patching component oracle.rdbms.rsf, 19.0.0.0.0...
Patching component oracle.rdbms.util, 19.0.0.0.0...
Patching component oracle.rdbms, 19.0.0.0.0...
...
Patching component oracle.precomp.lang, 19.0.0.0.0...
Patching component oracle.jdk, 1.8.0.201.0...
Patch 32545013 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [32545013].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /opt/oracle/product/19.3/db_1/cfgtoollogs/opatch/opatch2021-10-31_00-35-23AM_1.log
OPatch succeeded.
3.4 加载变化的SQL到数据库
安装补丁之后,还需要将有变化的SQL加载到数据库中,这里可以直接运行Datapatch工具将这些修改的SQL重新加载到数据库中,如果是RAC环境,只需要在一个节点执行就可以了。
根据readme的说明,操作步骤如下:
1:启动数据库
[oracle@oradb31 32545013]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Oct 31 00:52:33 2021
Version 19.11.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1728050768 bytes
Fixed Size 9135696 bytes
Variable Size 402653184 bytes
Database Buffers 1308622848 bytes
Redo Buffers 7639040 bytes
Database mounted.
Database opened.
exit
[oracle@oradb31 ~]$ /opt/oracle/product/19.3/db_1/OPatch/datapatch -verbos
SQL Patching tool version 19.11.0.0.0 Production on Sun Oct 31 01:02:27 2021
Copyright (c) 2012, 2021, Oracle. All rights reserved.
Log file for this invocation: /opt/oracle/cfgtoollogs/sqlpatch/sqlpatch_32849_2021_10_31_01_02_27/sqlpatch_invocation.log
Connecting to database...OK
Gathering database info...done
Note: Datapatch will only apply or rollback SQL fixes for PDBs
that are in an open state, no patches will be applied to closed PDBs.
Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
(Doc ID 1585822.1)
Bootstrapping registry and package to current versions...done
Determining current state...done
Current state of interim SQL patches:
No interim patches found
Current state of release update SQL patches:
Binary registry:
19.11.0.0.0 Release_Update 210413004009: Installed
PDB CDB$ROOT:
Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 30-OCT-21 08.20.24.613193 PM
PDB PDB$SEED:
Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 30-OCT-21 08.37.34.192471 PM
Adding patches to installation queue and performing prereq checks...done
Installation queue:
For the following PDBs: CDB$ROOT PDB$SEED
No interim patches need to be rolled back
Patch 32545013 (Database Release Update : 19.11.0.0.210420 (32545013)):
Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.11.0.0.0 Release_Update 210413004009
No interim patches need to be applied
Installing patches...
Patch installation complete. Total patches installed: 2
Validating logfiles...done
Patch 32545013 apply (pdb CDB$ROOT): SUCCESS
logfile: /opt/oracle/cfgtoollogs/sqlpatch/32545013/24175065/32545013_apply_ORCL_CDBROOT_2021Oct31_01_04_56.log (no errors)
Patch 32545013 apply (pdb PDB$SEED): SUCCESS
logfile: /opt/oracle/cfgtoollogs/sqlpatch/32545013/24175065/32545013_apply_ORCL_PDBSEED_2021Oct31_02_15_57.log (no errors)
SQL Patching tool complete on Sun Oct 31 02:56:09 2021
七、 检查监听注册状态lsnrctl status
八、编译失效对象
@$ORACLE_HOME/rdbms/admin/utlrp.sql