最新学习Oracle 19c的知识,照着Oracle Base和Oracle doc 文档过了一下安装过程,留个记录。
一、先决条件准备
#设置主机名和host映射
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
ora19cstandone 192.168.137.30
hostnamectl set-hostname ora19cstandone
hostnamectl --static set-hostname ora19cstandone
more /etc/hostname
# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld # 关闭自启动
systemctl status firewalld
# 修改selinux
/usr/sbin/sestatus -v
getenforce
setenforce 0 #临时关闭
vi /etc/sysconfig/selinux
SELINUX=disabled # 设置为disabled
#安装Oracle oracle-database-preinstall-19c
自动安装
yum install -y oracle-database-preinstall-19c
yum update -y
手工安装
yum install -y https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
#配置内核参数
Add the following lines to the "/etc/sysctl.conf" file, or in a file called "/etc/sysctl.d/98-oracle.conf"
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
运行以下命令:
/sbin/sysctl -p
# Or
/sbin/sysctl -p /etc/sysctl.d/98-oracle.conf
#配置打开进程数和文件数等:
Add the following lines to a file called "/etc/security/limits.d/oracle-database-preinstall-19c.conf" file.
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
#安装必要的rpm包
yum install -y bc
yum install -y binutils
yum install -y compat-libcap1
yum install -y compat-libstdc++-33
#yum install -y dtrace-modules
#yum install -y dtrace-modules-headers
#yum install -y dtrace-modules-provider-headers
yum install -y dtrace-utils
yum install -y elfutils-libelf
yum install -y elfutils-libelf-devel
yum install -y fontconfig-devel
yum install -y glibc
yum install -y glibc-devel
yum install -y ksh
yum install -y libaio
yum install -y libaio-devel
yum install -y libdtrace-ctf-devel
yum install -y libXrender
yum install -y libXrender-devel
yum install -y libX11
yum install -y libXau
yum install -y libXi
yum install -y libXtst
yum install -y libgcc
yum install -y librdmacm-devel
yum install -y libstdc++
yum install -y libstdc++-devel
yum install -y libxcb
yum install -y make
yum install -y net-tools # Clusterware
yum install -y nfs-utils # ACFS
yum install -y python # ACFS
yum install -y python-configshell # ACFS
yum install -y python-rtslib # ACFS
yum install -y python-six # ACFS
yum install -y targetcli # ACFS
yum install -y smartmontools
yum install -y sysstat
# Added by me.
yum install -y unixODBC
#建立组和账号及目录
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
passwd oracle
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
设置Oracle脚本目录
mkdir /home/oracle/scripts
cat > /home/oracle/scripts/setEnv.sh <<EOF
# Oracle Settings
export TMP=/tmp
export TMPDIR=\$TMP
export ORACLE_HOSTNAME=ol7-19.localdomain
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
echo ". /home/oracle/scripts/setEnv.sh" >> /home/oracle/.bash_profile
#Oracle 启停脚本
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
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
chown -R oracle:oinstall /home/oracle/scripts
chmod u+x /home/oracle/scripts/*.sh
~/scripts/start_all.sh
~/scripts/stop_all.sh
Create the service file called "/lib/systemd/system/dbora.service".
[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
Thanks to Javier and Mark in the comments for their suggestions about using RemainAfterExit, User and Group in this file.
If you are using NFS storage, you need to define the dependency between Oracle and NFS.
[Unit]
Description=The Oracle Database Service
Requires=rpc-statd.service network.target nfs.service nfs-mountd.service local-fs.target remote-fs.target
After=syslog.target network.target nfs.service nfs-mountd.service local-fs.target rpc-statd.service remote-fs.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.
Type=idle
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
Thanks to Fr3dY in the comments for pointing out the NFS dependency management using Requires and After and the issue with systemd and PAM limits.
Reload systemd so it can see the new service.
# systemctl daemon-reload
Start the service and enable so it is automatically restarted on reboot.
# systemctl start dbora.service
# systemctl enable dbora.service
ln -s '/usr/lib/systemd/system/dbora.service' '/etc/systemd/system/multi-user.target.wants/dbora.service'
# systemctl status dbora.service
dbora.service - The Oracle Database Service
Loaded: loaded (/lib/systemd/system/dbora.service; linked)
Active: active (exited) since Tue 2015-03-24 10:55:28 GMT; 5min ago
Process: 6145 ExecStart=/home/oracle/scripts/start_all.sh (code=exited, status=0/SUCCESS)
Main PID: 6145 (code=exited, status=0/SUCCESS)
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: SQL> ORACLE instance started.
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Total System Global Area 1140850688 bytes
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Fixed Size 2923584 bytes
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Variable Size 419431360 bytes
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Database Buffers 704643072 bytes
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Redo Buffers 13852672 bytes
Mar 24 10:56:31 ol7-121.localdomain startup.sh[6145]: Database mounted.
Mar 24 10:56:33 ol7-121.localdomain startup.sh[6145]: Database opened.
Mar 24 10:56:33 ol7-121.localdomain startup.sh[6145]: SQL> Disconnected from Oracle Database 12c Enterprise Edition Re...ction
Mar 24 10:56:33 ol7-121.localdomain startup.sh[6145]: With the Partitioning, OLAP, Advanced Analytics and Real Applica...tions
Hint: Some lines were ellipsized, use -l to show in full.
二、安装
DISPLAY=<machine-name>:0.0; export DISPLAY
# Unzip software.
cd $ORACLE_HOME
unzip -oq /path/to/software/LINUX.X64_193000_db_home.zip
# Interactive mode.
./runInstaller
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
三、建立数据库
# Start the listener.
lsnrctl start
# Interactive mode.
dbca
#设置自动启动
Post Installation
Edit the "/etc/oratab" file setting the restart flag for each instance to 'Y'.
cdb1:/u01/app/oracle/product/19.0.0/db_1:Y
Enable Oracle Managed Files (OMF) and make sure the PDB starts when the instance starts.
sqlplus / as sysdba <<EOF
alter system set db_create_file_dest='${DATA_DIR}';
alter pluggable database ${PDB_NAME} save state;
exit;
EOF
四、测试验证
[root@ora19cstandone ~]# su - oracle
Last login: Sat May 1 04:54:12 CST 2021 on pts/2
[oracle@ora19cstandone ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat May 1 04:57:56 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> exit
\Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@ora19cstandone ~]$ export ORACLE_SID=cdb
[oracle@ora19cstandone ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat May 1 04:58:22 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
参考文档:
Oracle Base:https://oracle-base.com/articles/19c/oracle-db-19c-installation-on-oracle-linux-7
Oracle doc:https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/installing-seha-on-local-file-system.html#GUID-F81473AF-75A2-421B-B8E2-B3EE1D4D103F