一、环境
操作系统: CentOs7.6_64
安装源: Oracle Database 19.3.0.0.0 for Linux x86-64.zip
主机名: server
IP地址: 192.168.10.131
二、过程
参考:https://oracle-base.com/articles/19c/oracle-db-19c-installation-on-oracle-linux-7
2.1 准备阶段
1.关闭防火墙
[root@server ~]# systemctl stop firewalld.service
[root@server ~]# systemctl disable firewalld.service
[root@server ~]# systemctl status firewalld.service
2.关闭selinux
[root@server ~]# setenforce 0 #临时设置SELinux 成为permissive模式, 1为enforcing模式
#[root@server ~]# setenforce Permissive #或者
[root@server ~]# sed -i "s/^SELINUX=.*/SELINUX=Permissive/" /etc/selinux/config #重启生效
3.修改hosts文件
[root@server ~]# cat >> /etc/hosts <<'EOF'
#add for oracle
192.168.10.131 server
EOF
4.修改内核参数文件,添加内容
# Add the following lines to the "/etc/sysctl.conf" file, or in a file called "/etc/sysctl.d/98-oracle.conf".
[root@server ~]# cat >>/etc/sysctl.conf <<'EOF'
# add for oracle by me
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
EOF
[root@server ~]# /sbin/sysctl -p #重启生效
5.修改vi /etc/security/limits.conf
#linux资源限制配置文件是/etc/security/limits.conf;限制用户进程的数量对于linux系统的稳定性非常重要。limits.conf文件限制着用户可以使用的最大文件数,最大线程,最大内存等资源使用量。
#oracle base写的/etc/security/limits.d/oracle-database-preinstall-19c.conf,操作系统为oracle linux。
[root@server ~]# cat >>/etc/security/limits.conf <<'EOF'
#add for oracle by me
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 134217728
oracle soft memlock 134217728
EOF
6.安装必要的包
[root@server ~]# yum install -y bc binutils compat-libcap1 compat-libstdc++-33 dtrace-utils elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh
yum install -y libaio libaio-devel libdtrace-ctf-devel libXrender libXrender-devel libX11 libXau libXi libXtst libgcc librdmacm-devel libstdc++ libstdc++-devel
yum install -y libxcb make net-tools nfs-utils python python-configshell python-rtslib python-six targetcli smartmontools sysstat
yum install gcc-c++*
#yum install -y dtrace-modules
#yum install -y dtrace-modules-headers
#yum install -y dtrace-modules-provider-headers
# Added by me.
yum install -y unixODBC
7.创建用户和组
[root@server ~]# groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
#groupadd -g 54324 backupdba
#groupadd -g 54325 dgdba
#groupadd -g 54326 kmdba
#groupadd -g 54327 asmdba
#groupadd -g 54328 asmoper
#groupadd -g 54329 asmadmin
#groupadd -g 54330 racdba
useradd -u 54321 -g oinstall -G dba,oper oracle
[root@server ~]# passwd oracle #修改oracle密码
8.创建安装目录
[root@server ~]# mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1
mkdir -p /u02/oradata
chown -R oracle:oinstall /u01 /u02
chmod -R 775 /u01 /u02 #u01放软件 u02放数据文件
9.创建设置oracle 环境变量脚本
[root@server ~]# mkdir /home/oracle/scripts
[root@server ~]# cat > /home/oracle/scripts/setEnv.sh <<EOF
# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=server
export ORACLE_UNQNAME=cdb1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=cdb1
export PDB_NAME=pdb1
export DATA_DIR=/u02/oradata
export PATH=/usr/sbin:/usr/local/bin:$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
EOF
[root@server ~]# chmod +x /home/oracle/scripts/setEnv.sh
[root@server ~]# echo ". /home/oracle/scripts/setEnv.sh" >> /home/oracle/.bash_profile
10.将安装源解压至ORACLE_HOME
[root@server ~]# unzip /root/Oracle Database 19.3.0.0.0 for Linux x86-64.zip -d /u01/app/oracle/product/19.0.0/dbhome_1
[root@server ~]# chown -R oracle:oinstall /u01 /u02 #在root用户解压,需要修改文件权限
[root@server ~]# chmod -R 775 /u01 /u02 #u01放软件 u02放数据文件
2.2 安装数据库软件
1.启动安装
[root@server ~]# su - oracle
[oracle@server ~]$ cd $ORACLE_HOME
# 图形化安装
[oracle@server dbhome_1]$ ./runInstaller
# 静默安装
[oracle@server dbhome_1]$ ./runInstaller -ignorePrereq -waitforcompletion -silent
-responseFile ${ORACLE_HOME}/install/response/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=${ORACLE_HOSTNAME}
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=${ORA_INVENTORY}
SELECTED_LANGUAGES=en,en_GB
ORACLE_HOME=${ORACLE_HOME}
ORACLE_BASE=${ORACLE_BASE}
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_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
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
##########################################################################################################
[oracle@server dbhome_1]$ ./runInstaller -ignorePrereq -waitforcompletion -silent
> -responseFile ${ORACLE_HOME}/install/response/db_install.rsp
> oracle.install.option=INSTALL_DB_SWONLY
> ORACLE_HOSTNAME=${ORACLE_HOSTNAME}
> UNIX_GROUP_NAME=oinstall
> INVENTORY_LOCATION=${ORA_INVENTORY}
> SELECTED_LANGUAGES=en,en_GB
> ORACLE_HOME=${ORACLE_HOME}
> ORACLE_BASE=${ORACLE_BASE}
> oracle.install.db.InstallEdition=EE
> oracle.install.db.OSDBA_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
> SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
> DECLINE_SECURITY_UPDATES=true
Launching Oracle Database Setup Wizard...
[WARNING] [INS-32047] The location (/u01/app/oraInventory) specified for the central inventory is not empty.
ACTION: It is recommended to provide an empty location for the inventory.
[WARNING] [INS-13014] Target environment does not meet some optional requirements.
CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2020-03-27_04-49-31PM.log
ACTION: Identify the list of failed prerequisite checks from the log: installActions2020-03-27_04-49-31PM.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/19.0.0/dbhome_1/install/response/db_2020-03-27_04-49-31PM.rsp
You can find the log of this install session at:
/tmp/InstallActions2020-03-27_04-49-31PM/installActions2020-03-27_04-49-31PM.log
As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/19.0.0/dbhome_1/root.sh
Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:
[server]
Execute /u01/app/oracle/product/19.0.0/dbhome_1/root.sh on the following nodes:
[server]
Successfully Setup Software with warning(s).
Moved the install session logs to:
/u01/app/oraInventory/logs/InstallActions2020-03-27_04-49-31PM
#root用户执行脚本
[oracle@server dbhome_1]$ /u01/app/oraInventory/orainstRoot.sh
[oracle@server dbhome_1]$ /u01/app/oracle/product/19.0.0/dbhome_1/root.sh
2.3 安装数据库实例
# 启动监听
[oracle@server dbhome_1]$ lsnrctl start
# 图形安装
dbca
# 静默安装.
#拓展阅读 https://oracle-base.com/articles/misc/database-configuration-assistant-dbca-silent-mode
dbca -silent -createDatabase
-templateName General_Purpose.dbc
-gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -responseFile NO_VALUE
-characterSet AL32UTF8
-sysPassword Ora123456
-systemPassword Ora123456
-createAsContainerDatabase true
-numberOfPDBs 1
-pdbName ${PDB_NAME}
-pdbAdminPassword Ora123456
-databaseType MULTIPURPOSE
-automaticMemoryManagement false
-totalMemory 2000
-storageType FS
-datafileDestination "${DATA_DIR}"
-redoLogFileSize 50
-emConfiguration NONE
-ignorePreReqs
############################################################################################
[oracle@server dbhome_1]$ dbca -silent -createDatabase
> -templateName General_Purpose.dbc
> -gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -responseFile NO_VALUE
> -characterSet AL32UTF8
> -sysPassword Ora123456
> -systemPassword Ora123456
> -createAsContainerDatabase true
> -numberOfPDBs 1
> -pdbName ${PDB_NAME}
> -pdbAdminPassword Ora123456
> -databaseType MULTIPURPOSE
> -automaticMemoryManagement false
> -totalMemory 2000
> -storageType FS
> -datafileDestination "${DATA_DIR}"
> -redoLogFileSize 50
> -emConfiguration NONE
> -ignorePreReqs
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/cdb1.
Database Information:
Global Database Name:cdb1
System Identifier(SID):cdb1
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log" for further details.
2.4 创建数据库启动、停止脚本
参考:https://oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux
#修改/etc/oratab
#将cdb1:/u01/app/oracle/product/19.0.0/dbhome_1:N这一行最后的N改成Y
[oracle@server dbhome_1]$ sed -i 's/:N/:Y/' /etc/oratab
#创建启动脚本 start_all.sh
[oracle@server dbhome_1]$ cat > /home/oracle/scripts/start_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES
dbstart $ORACLE_HOME
EOF
#创建关闭脚本 stop_all.sh
[oracle@server dbhome_1]$ cat > /home/oracle/scripts/stop_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES
dbshut $ORACLE_HOME
EOF
[oracle@server dbhome_1]$ chown -R oracle:oinstall /home/oracle/scripts
[oracle@server dbhome_1]$ chmod u+x /home/oracle/scripts/*.sh
2.5配置数据库自启动 #使用OL7 systemcl
参考: https://oracle-base.com/articles/linux/linux-services-systemd#creating-linux-services
#注意:在root用户执行
#[root@server ~]$ cat > /lib/systemd/system/dbora.service <<EOF # oracle base
[root@server ~]$ cat > /etc/systemd/system/dbora.service <<EOF # modify by me
[Unit]
Description=The Oracle Database Service
After=syslog.target network.target
[Service]
# systemd ignores PAM limits, so set any necessary limits in the service.
# Not really a bug, but a feature.
# https://bugzilla.redhat.com/show_bug.cgi?id=754285
LimitMEMLOCK=infinity
LimitNOFILE=65535
#Type=simple
# idle: similar to simple, the actual execution of the service binary is delayed
# until all jobs are finished, which avoids mixing the status output with shell output of services.
RemainAfterExit=yes
User=oracle
Group=oinstall
Restart=no
ExecStart=/bin/bash -c '/home/oracle/scripts/start_all.sh'
ExecStop=/bin/bash -c '/home/oracle/scripts/stop_all.sh'
[Install]
WantedBy=multi-user.target
EOF
#
[root@server ~]# systemctl daemon-reload
[root@server ~]# systemctl start dbora.service
[root@server ~]# systemctl enable dbora.service
[root@server ~]# systemctl status dbora.service
[root@server ~]# reboot #重启验证是否能够自动启动
三、19c基本管理
...