Install Oracle 19c on Red Hat 8 and apply the 19.13 patch
Checklist to install Oracle Database 19c on RHEL 8: OS prerequisites, installation, 19.13 patching and post-installation settings.
Checklist for installing Oracle Database 19c (single instance) on Red Hat Enterprise Linux 8, then patching it to 19.13 and applying common post-installation settings. Paths, SID and host names below are generic examples.
Operating system preparation
Sudo for the DBA group
su -
echo -e "dba\tALL=(ALL)\tNOPASSWD: ALL" > /etc/sudoers.d/020_sudo_dba
cat /etc/sudoers.d/020_sudo_dba
Remove the GUI, keep a minimal X11 stack
sudo dnf groupinstall -y "Minimal Install"
sudo dnf groupremove -y "Server with GUI"
sudo dnf groupinstall -y "Server"
# minimal graphic stack (see Red Hat solution 3887371)
sudo subscription-manager repos --enable=codeready-builder-for-rhel-8-x86_64-rpms
sudo yum install xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-apps -y
X11 forwarding in /etc/ssh/sshd_config:
AllowTcpForwarding yes
X11UseLocalhost yes
X11DisplayOffset 10
X11Forwarding yes
On the client side, enable forwarding in /etc/ssh/ssh_config:
sudo sed -i -E 's/#\s+ForwardX11 no/ForwardX11 yes/' /etc/ssh/ssh_config
Useful tools
sudo yum install sysstat
sudo systemctl enable sysstat
sudo systemctl start sysstat
sudo dnf install gvim
Groups and oracle user
Check which standard groups already exist:
getent group | grep oinstall # 54321
getent group | grep dba # 54322
getent group | grep oper # 54323
getent group | grep dgdba
getent group | grep kmdba
getent group | grep backupdba
Create the missing ones, then the user:
groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
groupadd -g 65539 dgdba
groupadd -g 65540 kmdba
groupadd -g 65538 backupdba
useradd -u 54321 -g oinstall -G dba,oper,backupdba,dgdba,kmdba oracle
Required packages
yum install -y bc binutils elfutils-libelf elfutils-libelf-devel fontconfig-devel
yum install -y glibc glibc-devel ksh libaio libaio-devel
yum install -y libXrender libXrender-devel libX11 libXau libXi libXtst
yum install -y libgcc librdmacm-devel libstdc++ libstdc++-devel libxcb
yum install -y make smartmontools sysstat net-tools
dnf install -y gcc
compat-libcap1, compat-libstdc++-33 and libdtrace-ctf-devel do not exist on RHEL 8 and can be skipped.
If the installer fails with libnsl.so.1: cannot open shared object file, install the libnsl packages:
dnf install -y libnsl libnsl.i686 libnsl2 libnsl2.i686
Kernel parameters
/etc/sysctl.d/99-oracle.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.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
net.ipv4.ip_local_port_range = 9000 65500
Apply it (or reboot):
/sbin/sysctl -p
sysctl --system
Shell limits
/etc/security/limits.d/99-oracle-limits.conf:
# shell limits for user oracle 19c
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 soft memlock 134217728
oracle hard memlock 134217728
Optional: disable transparent hugepages
If the server crashes (see My Oracle Support Doc ID 1557478.1), add transparent_hugepage=never to the kernel command line in /etc/default/grub:
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off transparent_hugepage=never"
Firewall and SELinux
systemctl stop firewalld
systemctl disable firewalld
/etc/selinux/config:
SELINUX=permissive
Directories
ORACLE_BASE is /u01/app/oracle and ORACLE_HOME is /u01/app/oracle/product/19c/dbhome_1.
mkdir -p /u01/app/oracle/product/19c/dbhome_1
mkdir -p /u01/app/oraInventory
mkdir -p /u02/oradata /u02/temp
mkdir -p /u03/oracle/flash_recovery_area
chown -R oracle:oinstall /u01 /u02 /u03
chmod -R 775 /u01 /u02 /u03
/etc/hosts
Add the server's own name:
192.0.2.10 dbhost01.example.com dbhost01
Environment of the oracle user
mkdir /home/oracle/scripts/
cat > /home/oracle/scripts/setEnv.sh <<EOF
# Oracle Settings
export TMP=/tmp
export TMPDIR=\$TMP
export ORACLE_HOSTNAME=dbhost01.example.com
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/19c/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=orcl
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
Start and stop scripts:
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
Installation
Unzip the installer into ORACLE_HOME, then run runInstaller as the oracle user:
unzip /u02/temp/LINUX.X64_193000_db_home.zip -d /u01/app/oracle/product/19c/dbhome_1
cd /u01/app/oracle/product/19c/dbhome_1
./runInstaller
On RHEL 8 the installer does not recognise the distribution. Make it assume Oracle Linux 8 in cvu_config:
sed -i 's/#CV_ASSUME_DISTID=OEL5/CV_ASSUME_DISTID=OEL8/' /u01/app/oracle/product/19c/dbhome_1/cv/admin/cvu_config
After the installation, check that the alert log shows no error.
Patching to 19.13
Update OPatch
Back up the current OPatch, then replace it with the latest version (patch 6880880):
DATE=$(date '+%Y%m%d%H%M%S')
cd $ORACLE_HOME
tar -zcvf OPatch-${DATE}.tgz $ORACLE_HOME/OPatch
mv *.tgz /u02/temp/
tar -tvf /u02/temp/OPatch-${DATE}.tgz
cp /u02/temp/p6880880_190000_Linux-x86-64.zip $ORACLE_HOME
cd $ORACLE_HOME
rm -rf OPatch/
unzip p6880880_190000_Linux-x86-64.zip
Check the version and the current inventory:
export PATH=$PATH:$ORACLE_HOME/OPatch
$ORACLE_HOME/OPatch/opatch lsinventory
Prepare and check the patch
Copy the patch zip (here p33182768_190000_Linux-x86-64.zip) to /u02/temp and unzip it:
cd /u02/temp
unzip p33182768_190000_Linux-x86-64.zip
Check for conflicts, then check the free space for all sub-patches:
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u02/temp/33182768/33192793
cat > /tmp/patch_list_dbhome.txt <<EOF
/u02/temp/33182768/33192793
/u02/temp/33182768/33208123
EOF
$ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /tmp/patch_list_dbhome.txt
Apply
Stop the database and listener, then:
cd /u02/temp/33182768/33192793
opatch apply
Post-patch steps:
sqlplus /nolog
connect / as sysdba
startup
quit
cd $ORACLE_HOME/OPatch
./datapatch -verbose
Post-installation settings
Save the configuration
column TODAY new_value datestr;
SELECT TO_CHAR (SYSDATE, 'YYYYMMDDHH24MISS') "TODAY" FROM DUAL;
define myv = &DATESTR._spfile.ora
define myv
create pfile='/u03/oracle/flash_recovery_area/&myv' from spfile;
Multiplex control files
Look at the current layout:
select name from v$controlfile;
set linesize 400
column NAME_COL_PLUS_SHOW_PARAM format A40
column TYPE format A20
column VALUE_COL_PLUS_SHOW_PARAM format A100
show parameter control_files;
Initial layout:
/u02/oradata/orcl/control01.ctl
/u03/oracle/flash_recovery_area/orcl/control02.ctl
Target layout, spreading the copies on three file systems:
/u01/app/oracle/admin/orcl/control01.ctl
/u02/oradata/orcl/control02.ctl
/u03/oracle/flash_recovery_area/orcl/control03.ctl
alter system set control_files='/u01/app/oracle/admin/orcl/control01.ctl',
'/u02/oradata/orcl/control02.ctl',
'/u03/oracle/flash_recovery_area/orcl/control03.ctl'
scope=spfile;
With the database stopped, move the files, then restart it:
mv /u02/oradata/orcl/control01.ctl /u01/app/oracle/admin/orcl/control01.ctl
cp /u01/app/oracle/admin/orcl/control01.ctl /u02/oradata/orcl/control02.ctl
mv /u03/oracle/flash_recovery_area/orcl/control02.ctl /u03/oracle/flash_recovery_area/orcl/control03.ctl
Move the archived logs out of the recovery area
show parameter log_archive_dest_1;
show parameter db_recovery
alter system set log_archive_dest_1 = 'LOCATION=/u03/oracle/archivelog/orcl';
alter system set db_recovery_file_dest = '';
show parameter log_archive_dest_1
alter system set LOG_ARCHIVE_FORMAT = "log%t_%s_%r.arc" scope=spfile;
Oracle Managed Files (OMF)
show parameter db_create_file_dest
show parameter db_create_online_log_dest
alter system set db_create_file_dest = '/u02/oradata/ORCL/datafile' scope=both;
alter system set db_create_online_log_dest_1 = '/u02/oradata/ORCL/onlinelog' scope=both;
ADR purge policy (adrci)
show homes
set home diag/rdbms/orcl/orcl
show control
set control (SHORTP_POLICY=14)
set control (LONGP_POLICY=21)
purge
show control
show base
set base "/u01/app/oracle"
Manual purge of trace and alert files older than a given age in minutes (168 hours = 10080 minutes):
purge -age 10080 -type TRACE
purge -age 10080 -type ALERT
Script applying a policy to every ADR home (policies are expressed in hours):
#!/bin/sh
for ADRHOME in `adrci exec="show home"`
do
if [ $ADRHOME = "ADR" -o $ADRHOME = "Homes:" ]
then
continue;
fi
echo $ADRHOME
adrci <<EOF
set home $ADRHOME
set control (SHORTP_POLICY = 168)
set control (LONGP_POLICY = 168)
purge
exit
EOF
done
HugePages and swappiness
Find the GID of the dba group (getent group | grep dba), then in /etc/sysctl.conf:
# huge pages
vm.nr_hugepages=1003
vm.hugetlb_shm_group=54322
vm.swappiness = 0
Reboot, then check:
grep Huge /proc/meminfo
Adjust vm.nr_hugepages to your SGA size.
Start the database at boot with systemd
Unit file, for example /etc/systemd/system/oracle-db.service (adapted from a Martin Bach article on using systemd to start an Oracle single-instance database):
[Unit]
Description=a service to start databases and listener automatically
After=syslog.target network.target
[Service]
LimitNOFILE=1024:65536
LimitNPROC=2047:16384
LimitSTACK=10485760:33554432
LimitMEMLOCK=infinity
Type=forking
User=oracle
Group=oinstall
ExecStart=/u01/app/oracle/product/19c/dbhome_1/bin/dbstart /u01/app/oracle/product/19c/dbhome_1
ExecStop=/u01/app/oracle/product/19c/dbhome_1/bin/dbshut /u01/app/oracle/product/19c/dbhome_1
RemainAfterExit=True
Restart=no
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable oracle-db
sudo systemctl start oracle-db
sudo systemctl status oracle-db
Monitoring user
Minimal grants for a read-only monitoring account (here a generic monitor_usr; replace the password):
CREATE USER monitor_usr IDENTIFIED BY "<PASSWORD>" DEFAULT TABLESPACE "USERS" TEMPORARY TABLESPACE "TEMP";
GRANT CREATE SESSION TO monitor_usr;
GRANT SELECT_CATALOG_ROLE TO monitor_usr;
GRANT CONNECT TO monitor_usr;
GRANT SELECT ANY DICTIONARY TO monitor_usr;
GRANT SELECT ON V_$SYSSTAT TO monitor_usr;
GRANT SELECT ON V_$INSTANCE TO monitor_usr;
GRANT SELECT ON V_$LOG TO monitor_usr;
GRANT SELECT ON SYS.DBA_DATA_FILES TO monitor_usr;
GRANT SELECT ON SYS.DBA_FREE_SPACE TO monitor_usr;
GRANT SELECT ANY TABLE TO monitor_usr;
ALTER USER monitor_usr DEFAULT ROLE "SELECT_CATALOG_ROLE","CONNECT";
To change the password later: ALTER USER monitor_usr IDENTIFIED BY "<PASSWORD>";
Other settings
Asynchronous and direct I/O on file systems:
ALTER SYSTEM SET FILESYSTEMIO_OPTIONS=SETALL SCOPE=SPFILE;
Check or disable Secure Boot validation:
sudo mokutil --sb-state
sudo mokutil --disable-validation
Mail from scripts: sendmail is deprecated on RHEL 8, use postfix and mailx.
sudo yum install postfix -y
sudo yum install mailx -y
sudo mkfifo /var/spool/postfix/public/pickup
sudo systemctl restart postfix
Reference values
Memory parameters observed on the small instance used for this setup:
pga_aggregate_limit 2G
pga_aggregate_target 250M
sga_max_size 1504M
sga_target 1504M
Adding redo log members to groups 1 to 3 (group 2 drops and re-creates a member):
ALTER DATABASE ADD LOGFILE MEMBER '/u02/oradata/orcl/redo01.log' TO GROUP 1;
ALTER DATABASE DROP LOGFILE MEMBER '/u02/oradata/orcl/redo02.log';
ALTER DATABASE ADD LOGFILE MEMBER '/u02/oradata/orcl/redo02.log' TO GROUP 2;
ALTER DATABASE ADD LOGFILE MEMBER '/u02/oradata/orcl/redo03.log' TO GROUP 3;
Notes
- Based on public guides, among them infolipi, dbaora and a Dmitry Romanoff article.
- Always verify the patch numbers and OPatch version against the current Oracle Release Update for your target.