Silently install oracle19c database

Article directory

  • Preface
  • 1. Configure the operating system environment
    • 0.Environment variable settings
    • 1. Turn off the firewall
    • 2. Close Selinux
    • 3. Mount the optical drive
    • 4. Configure local yum file
    • 5. Install dependency packages
    • 6. Configure host
    • 7. Create users and groups
    • 8.Create the installation directory
    • 9. Configure avahi-deamon
    • 10. Turn off transparent huge pages and numa
    • 11. Configure the system parameter file (the parameters here are configured according to 8G memory)
    • 12. Configure system resource limits
    • 13.Configure pam.d
    • 14.Configure /dev/shm
    • 15. Configure user environment variables
      • 15.1. Configure root user
      • 15.2. Configure oracle user
    • 17. Restart
    • 18.Verification
  • 2. Configure response file
    • 1. First you need to grant permissions to the /soft directory
    • 2. Connect oracle user
    • 3. Create a response file
  • 3. Silently install database software
  • 4. Install monitoring
  • 5. Silent installation example
  • 6. Log in to the database
  • Summarize

Foreword

Some environments do not allow graphical installation of the Oracle database. In this case, you can install it through silent installation. This article is about the process of silently installing the 19c database. If there are any improvements or errors that need to be made during the process, please help point them out.

The environment configuration is as follows:

IP address Host name Instance name oracle version Operating system Version
192.168.40.16 test16 testdb 19c oraclelinux 7.6

1. Configure operating system environment

Note: The installation file is placed in the /soft directory

[root@test16:/root]# ls /soft
compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
LINUX.X64_193000_db_home.zip

0. Environment variable setting

#Set the ORACLE_HOME directory
ORACLE_HOME=/u01/app/oracle/product/19.3.0/db
#Set the ORACLE_BASE directory
ORACLE_BASE=/u01/app/oracle
#Set oraInventory directory
oraInventory_HOME=/u01/app/oraInventory
#Set the data file storage directory
DATA_HOME=/oradata
#Set archive storage directory
ARCH_HOME=/oradata/archivelog
#Set instance name
ORACLE_SID=testdb
#Set instance character set
INSTANCE_CHARACTERSET=AL32UTF8
#Set the actual national character set
INSTANCE_NCHARACTERSET=AL16UTF16
#Set whether CDB mode (TRUE/FALSE)
ISCDB=FALSE

1. Turn off the firewall

systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld

2. Close Selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat /etc/selinux/config

3. Mount the optical drive

mount /dev/sr0 /mnt

4. Configure local yum file

mkdir /etc/yum.repos.d/bak -p

mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak

cat<<EOF>/etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
EOF
#renew
yum repolist all

5. Install dependency packages

yum install -y bc \
binutils \
compat-libcap1 \
compat-libstdc + + -33 \
gcc \
gcc-c + + \
elfutils-libelf \
elfutils-libelf-devel \
glibc \
glibc-devel \
ksh \
libaio\
libaio-devel \
libgcc \
libstdc + + \
libstdc++-devel\
libxcb \
libX11 \
libXau \
libXi \
libXtst \
libXrender \
libXrender-devel\
make \
net-tools\
nfs-utils \
smartmontools \
sysstat \
e2fsprogs \
e2fsprogs-libs \
fontconfig-devel \
expect \
unzip \
openssh-clients \
readline* \
psmisc --skip-broken

#Note: RHEL 7 requires manual installation of compat-libstdc++ dependency packages:

rpm -ivh /soft/compat-libstdc + + -33-3.2.3-72.el7.x86_64.rpm

6. Configure host

cat <<EOF >>/etc/hosts
${<!-- -->HOST_IP} ${<!-- -->HOSTNAME}
EOF
cat /etc/hosts

7. Create users and groups

#Create oinstall dba oper group
/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper
/usr/sbin/groupadd -g 54324 backupdba
/usr/sbin/groupadd -g 54325 dgdba
/usr/sbin/groupadd -g 54326 kmdba
/usr/sbin/groupadd -g 54330 racdba
#Create oracle user
/usr/sbin/useradd -u 54321 -g oinstall -G dba,backupdba,dgdba,kmdba,racdba,oper oracle
# Change the oracle user password to oracle
echo oracle | passwd --stdin oracle
# Check oracle user
id oracle

8. Create the installation directory

mkdir -p ${<!-- -->ORACLE_HOME}
mkdir -p ${<!-- -->oraInventory_HOME}
mkdir -p ${<!-- -->DATA_HOME}
mkdir -p ${<!-- -->ARCH_HOME}
chown -R oracle:oinstall ${<!-- -->DATA_HOME}
chown -R oracle:oinstall ${<!-- -->ARCH_HOME}
chown -R oracle:oinstall ${<!-- -->oraInventory_HOME}
chown -R oracle:oinstall ${<!-- -->ORACLE_BASE}
chmod -R 775 ${<!-- -->oraInventory_HOME}
chmod -R 775 ${<!-- -->ORACLE_BASE}

9. Configure avahi-deamon

systemctl stop avahi-daemon.socket
systemctl stop avahi-daemon.service
systemctl disable avahi-daemon.service
systemctl disable avahi-daemon.socket

#CloseNOZEROCONF
cat <<EOF >>/etc/sysconfig/network
NOZEROCONF=yes
EOF
cat /etc/sysconfig/network

10. Close transparent large pages and numa

sed -i 's/quiet/quiet transparent_hugepage=never numa=off/' /etc/default/grub

grub2-mkconfig -o /boot/grub2/grub.cfg

11. Configure the system parameter file (the parameters here are configured according to 8G memory)

DAYTIME=$(date + %Y%m%d)
mv /etc/sysctl.conf /etc/sysctl.conf.${<!-- -->DAYTIME}
memTotal=$(grep MemTotal /proc/meminfo | awk '{print $2}')
totalMemory=$((memTotal / 2048))
shmall=$((memTotal / 4))
if [ $shmall -lt 2097152 ]; then
  shmall=2097152
fi
shmmax=$((memTotal * 1024 - 1))
if [ "$shmmax" -lt 4294967295 ]; then
  shmmax=4294967295
fi
cat <<EOF >/etc/sysctl.conf
##shmmal's Calculation formula: physical memory 8G: (8*1024*1024*1024)/4096=2097152
##shmmax's Calculation formula: physical memory 8G: (8/2)*1024*1024*1024 -1=4294967295
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = $shmall
kernel.shmmax = $shmmax
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
EOF
##Make it effective
sysctl -p

12. Configure system resource limits

cat <<EOF >>/etc/security/limits.conf
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
oracle hard memlock 134217728
oracle soft memlock 134217728
EOF

13.Configure pam.d

cat <<EOF >>/etc/pam.d/login
session required pam_limits.so
session required /lib64/security/pam_limits.so
EOF

14.Configure /dev/shm

cp /etc/fstab /tmp/fstab
memTotal=$(grep MemTotal /proc/meminfo | awk '{print $2}')
shmTotal=$(df -k /dev/shm | awk '{print $2}' | head -n 2 | tail -n 1)
if [ "$(grep -E -c "/dev/shm" /etc/fstab)" -eq 0 ]; then
    cat <<EOF >>/etc/fstab
tmpfs /dev/shm tmpfs size=${<!-- -->memTotal}k 0 0
EOF
    mount -o remount /dev/shm
else
  if [ "$shmTotal" -lt "$memTotal" ]; then
    shmTotal=$memTotal
    line=$(grep -n "/dev/shm" /etc/fstab | awk -F ":" '{print $1}')
    sed -i "${line} d" /etc/fstab
    cat <<EOF >>/etc/fstab
tmpfs /dev/shm tmpfs size=${<!-- -->memTotal}k 0 0
EOF
    fi
    mount -o remount /dev/shm
fi

15. Configure user environment variables

15.1. Configure root user

cat <<EOF >>/root/.bash_profile
alias so='su - oracle'
export PS1="[\`whoami\`@\`hostname\`:"'\$PWD]# '
EOF

15.2. Configure oracle user

cat <<EOF >>/home/oracle/.bash_profile
umask 022
export TMP=/tmp
export TMPDIR=\$TMP
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export ORACLE_BASE=${<!-- -->ORACLE_BASE}
export ORACLE_HOME=\$ORACLE_BASE/product/19.3.0/db
export ORACLE_HOSTNAME=${<!-- -->HOSTNAME}
export ORACLE_TERM=xterm
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=${<!-- -->ORACLE_SID}
export PATH=/usr/sbin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$PATH
alias sas='sqlplus / as sysdba'
export PS1="[\`whoami\`@\`hostname\`:"'\$PWD]\$ '
export INVENTORY_LOCATION=${<!-- -->oraInventory_HOME}
export ORADATADIR=${<!-- -->DATA_HOME}
export ARCHIVEDIR=${<!-- -->ARCH_HOME}
export CHARACTERSET=${<!-- -->INSTANCE_CHARACTERSET}
export NCHARACTERSET=${<!-- -->INSTANCE_NCHARACTERSET}
export ISCDB=${<!-- -->ISCDB}
EOF

cat /home/oracle/.bash_profile

17. Restart

#Restart the system to make the previous configuration take effect
reboot

18.Verification

cat /etc/selinux/config
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /proc/cmdline
rpm -q bc binutils compat-libcap1 compat-libstdc + + -33 gcc gcc-c + + elfutils-libelf elfutils-libelf-devel glibc glibc-devel ksh libaio libaio-devel libgcc libstdc + + libstdc + + -devel libxcb libX11 libXau libXi libXtst libXrender libXrender-devel make net-tools nfs-utils smartmontools sysstat e2fsprogs e2fsprogs-libs fontconfig-devel expect unzip openssh-clients readline psmisc

2. Configure response file

1. First you need to grant permissions to the /soft directory

chown -R oracle.oinstall /soft

2. Connect oracle user

su-oracle
cd /soft

3. Create response file

cat <<EOF >>/soft/db.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=${<!-- -->INVENTORY_LOCATION}
ORACLE_BASE=${<!-- -->ORACLE_BASE}
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=false
oracle.install.db.rootconfig.configMethod=
EOF

3. Silently install database software

Enter the ORACLE_HOME directory to decompress the installation files and perform silent installation

#Silent installation
cd $ORACLE_HOME
#Extract the installation files
unzip /soft/LINUX.X64_193000_db_home.zip
#Run silent installation
./runInstaller -silent -force -responseFile /soft/db.rsp -ignorePrereq -waitForCompletion

At the end of the installation, two root scripts need to be executed as root.

#After installation, two root scripts need to be executed as root
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/19.3.0/db/root.sh

4. Install monitoring

su-oracle
netca -silent -responsefile $ORACLE_HOME/assistants/netca/netca.rsp
lsnrctl status

5. Silent installation example

#Database memory here takes 50% of physical memory
memTotal=$(grep MemTotal /proc/meminfo | awk '{print $2}')
totalMemory=$((memTotal / 2048))

##Execute the installation command
dbca -silent -createDatabase \
-ignorePrereqFailure \
-templateName General_Purpose.dbc \
-responseFile NO_VALUE \
-gdbName ${<!-- -->ORACLE_SID} \
-sid ${<!-- -->ORACLE_SID} \
-sysPassword oracle \
-systemPassword oracle \
-redoLogFileSize 1024 \
-storageType FS \
-databaseConfigType SINGLE \
-datafileDestination ${<!-- -->ORADATADIR} \
-enableArchive true \
-archiveLogDest ${<!-- -->ARCHIVEDIR} \
-characterset ${<!-- -->CHARACTERSET} \
-nationalCharacterSet ${<!-- -->NCHARACTERSET} \
-emConfiguration NONE \
-automaticMemoryManagement false \
-totalMemory ${<!-- -->totalMemory} \
-databaseType OLTP \
-createAsContainerDatabase ${<!-- -->ISCDB}

6. Log in to the database

sqlplus/as sysdba
SQL> select open_mode from v$database;

OPEN_MODE
-------------------
READ WRITE

Summary

The above is what I will talk about today. This article only briefly introduces the silent installation method of 19c.