Oracle Install standalone noncontainer 19c on Redhat 7 in silent mode

記錄透過 silent mode 安裝 oracle database

1. PreCheck environment and unzip Database Software

a. Install dependencies rpm by root

# yum install bc bind-utils compat-libcap1 glibc-devel ksh libaio-devel libstdc++-devel nfs-utils smartmontools unzip xorg-x11-xauth xorg-x11-utils compat-libstdc++-33 net-tools psmisc sysstat vim -y

Note: compat-libstdc++-33 is not available on RHEL 7 from yum

Download link: https://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm

b. Install oracle preinstall by root

-- Install oracle 19c preinstall
# yum install oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

-- Or Install from oracle yum server
# curl -o oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
# yum -y localinstall oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

c. Check hostname is mapping ipaddress

# cat /etc/hosts

11.11.11.11 hostname

d. Check selinux is disable

# vim /etc/selinux/config
SELINUX=permissive

# setenforce 0

e. Check firewall is disable

# systemctl status firewalld.service
# systemctl stop firewalld.service
# systemctl disable firewalld.service

f. create oracle account and change password

# useradd -u 54321 -g oinstall -G oper,backupdba,kmdba,dgdba,racdba oracle
# passwd oracle

g. set Oracle Environment by root

# vim /home/oracle/.bash_profile
export ORACLE_SID=orcl1
export ORACLE_UNQNAME=orcl
export ORACLE_HOSTNAME=`hostname`
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin

h. create software directory by root

# mkdir /u01
# chown oracle.oinstall /u01

i. unzip Oracle Database Source by oracle

$ mkdir -p $ORACLE_HOME
$ unzip LINUX.X64_193000_db_home.zip -d $ORACLE_HOME

 

2. Install Oracle Software in silent mode

a. copy db_install.rsp to oracle home and edit db_install.rsp config

$ cp $ORACLE_HOME/install/response/db_install.rsp ~/db_install.rsp
$ vim ~/db_install.rsp

oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/19.0.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=oinstall
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

b. run Installer using db_install.rsp in silent mode

$ cd $ORACLE_HOME
$ ./runInstaller -silent -responseFile /home/oracle/db_install.rsp

c. execute root.sh by root when runInstaller is finish

# sh /u01/app/oraInventory/orainstRoot.sh

Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.

# sh /u01/app/oracle/product/19.0.0/db_1/root.sh

Check /u01/app/oracle/product/19.0.0/db_1/install/root_yum-svr1_2021-03-04_15-13-36-597262925.log for the output of root script

d. check root.sh log

# tail /u01/app/oracle/product/19.0.0/db_1/install/root_yum-svr1_2021-03-04_15-13-36-597262925.log

   ORACLE_HOME=  /u01/app/oracle/product/19.0.0/db_1
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...

Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Oracle Trace File Analyzer (TFA) is available at : /u01/app/oracle/product/19.0.0/db_1/bin/tfactl

 

3. Install Oracle Listener in silent mode

a. find netca.rsp

$ find $ORACLE_HOME -name 'netca.rsp'

/u01/app/oracle/product/19.0.0/db_1/assistants/netca/netca.rsp

b. run netca using netca.rsp in silent mode

$ netca -silent -responseFile /u01/app/oracle/product/19.0.0/db_1/assistants/netca/netca.rsp

c. start listener by oracle and check status

$ lsnrctl start
$ lsnrctl status

 

4. Install Oracle Database in silent mode

a. create database directory

$ mkdir -p /u01/app/oradata

b. run dbca on silent mode (可以調整 totalMemory 的大小,會自動切割適合的 sga + pga 大小)

$ dbca -silent -createDatabase \
>  -templateName General_Purpose.dbc \
>  -gdbname orcl -sid orcl1 -responseFile NO_VALUE \
>  -characterSet AL32UTF8 \
>  -sysPassword oracle \
>  -systemPassword oracle \
>  -createAsContainerDatabase false \
>  -numberOfPDBs 0 \
>  -databaseType MULTIPURPOSE \
>  -memoryMgmtType auto_sga \
>  -totalMemory 2048 \
>  -storageType FS \
>  -datafileDestination "/u01/app/oradata/" \
>  -useOMF true \
>  -redoLogFileSize 100 \
>  -emConfiguration NONE \
>  -ignorePreReqs

c. Check status

$ ps aux | grep pmon
$ lsnrctl status
$ sqlplus / as sysdba
SQL> select open_mode from v$database;

 

5. enable archive log mode and add oracle database on systemd service

a. enable archive log mode

--create archivelog destation
$ mkdir -p /u01/app/oradata/archivelog

--edit archivelog parameter destation
$ sqlplus / as sysdba
SQL> show parameter log_archive_dest_1;
SQL> alter system set log_archive_dest_1='LOCATION=/u01/app/oradata/archivelog' scope=both;

--enable archivelog
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;
SQL> alter system switch logfile;

b. create dbora script by oracle

$ mkdir /home/oracle/scirpt
$ vim /home/oracle/script/dbora
#! /bin/sh
#
# chkconfig: 2345 80 05
# description: start and stop Oracle Database Enterprise Edition on Oracle Linux 5 and 6
#

# In /etc/oratab, change the autostart field from N to Y for any
# databases that you want autostarted.
#
# Note: Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
ORACLE_HOME=/u01/app/oracle/product/19.0.0/db_1

#
# Note: Change the value of ORACLE to the login name of the oracle owner
ORACLE=oracle

PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH

case $1 in
'status')
        echo -n $"Oracle Process: "
        su $ORACLE -c "ps -ef | grep pmon | grep -v grep; ps -ef | grep -i listener | grep -v grep;" &
        ;;
'start')
        echo -n $"Starting Oracle: "
        $ORACLE_HOME/bin/lsnrctl start
        $ORACLE_HOME/bin/dbstart $ORACLE_HOME &
        ;;
'stop')
        echo -n $"Shutting down Oracle: "
        $ORACLE_HOME/bin/dbshut $ORACLE_HOME &
        $ORACLE_HOME/bin/lsnrctl stop
        ;;
*)
        echo "usage: $0 {start|stop}"
        echo "$1"
        exit
        ;;
esac

exit

c. create systemd service by root

# vim /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=/home/oracle/script/dbora start
ExecStop=/home/oracle/script/dbora stop

[Install]
WantedBy=multi-user.target

d. system daemon reload by root

# systemctl daemon-reload

e. enable database autostartup by oracle (edit Y from N)

$ vim /etc/oratab
orcl:/u01/app/oracle/product/19.0.0/db_1/:Y

 

6. Clear Oracle Log in Crontab by root

# vim /root/clear_oracle_log.sh
#!/bin/sh

SUORA="su - oracle -c "
SUGRI="su - grid -c "

${SUORA} "cd /u01/app/oracle/diag/rdbms/\$ORACLE_UNQNAME/\$ORACLE_SID/alert ; rm -f log_*.xml"
${SUORA} "cd /u01/app/oracle/diag/rdbms/\$ORACLE_UNQNAME/\$ORACLE_SID/trace ; rm -f *.trc *.trm"
${SUORA} "cd /u01/app/oracle/admin/\${ORACLE_UNQNAME}/adump ; rm -f *.aud"
${SUORA} "cd /u01/app/oracle/diag/tnslsnr/`hostname`/listener/alert ; rm -f log_*.xml"
${SUORA} "cd /u01/app/oracle/diag/tnslsnr/`hostname`/listener/trace ; rm -f listener_*.log"

#${SUGRI} "cd /u01/app/grid/diag/crs/`hostname`/crs/trace ; rm -f osysmond_*.trc osysmond_*.trm ologgerd_*.trc ologgerd_*.trm ohasd_orarootagent_root_*.trc ohasd_orarootagent_root_*.trmohasd_cssdmonitor_root_*.trc ohasd_cssdmonitor_root_*.trm ohasd_oraagent_grid_*.trc ohasd_oraagent_grid_*.trm ocrconfig_*.trc ocrconfig_*.trm ohasd_*.trc ohasd_*.trm evmd_*.trc evmd_*.trm gpnpd_*.trc gpnpd_*.trm gipcd_*.trc gipcd_*.trm crsd_jagent_grid_*.trc crsd_jagent_grid_*.trm crsd_scriptagent_grid_*.trc crsd_scriptagent_grid_*.trm crsctl_*.trc crsctl_*.trm ocrcheck_*.trc ocrcheck_*.trm ocssd_*.trc ocssd_*.trm ocssd_*.trm ocssd_*.trc crsd_*.trc crsd_*.trm olsnodes_*.trc olsnodes_*.trm octssd_*.trc octssd_*.trm"
#${SUGRI} "cd /u01/app/grid/diag/crs/`hostname`/crs/alert ; rm -f log_*.xml"
#${SUGRI} "cd /u01/app/grid/diag/tnslsnr/`hostname`/asmnet1lsnr_asm/alert ; rm -f log_*.xml"
#${SUGRI} "cd /u01/app/grid/diag/tnslsnr/`hostname`/asmnet1lsnr_asm/trace ; rm -f asmnet1lsnr_asm_*.log"
#${SUGRI} "cd /u01/app/grid/diag/tnslsnr/`hostname`/listener/trace ; rm -f listener_*.log"
/u01/app/oracle/diag/tnslsnr/evs-db1/listener/alert/log
#${SUGRI} "cd /u01/app/grid/diag/tnslsnr/`hostname`/listener_scan1/alert ; rm -f log_*.xml"
#${SUGRI} "cd /u01/app/grid/diag/tnslsnr/`hostname`/listener_scan1/trace ; rm -f listener_scan1_*.log"
#${SUGRI} "cd /u01/app/grid/diag/asm/+asm/+ASM1/trace ; rm -f *.trm *.trc"
# crontab -l
0 0 * * * /root/clear_oracle_log.sh > /dev/null 2>&1

 

X. Delete Oracle Database in silent mode

$ dbca -silent -deleteDatabase -sourceDB ${ORACLE_SID} -sysDBAPassword {syspwd}

Enter SYS user password: {input password again}

[WARNING] [DBT-19202] The Database Configuration Assistant will delete the Oracle instances and datafiles for your database. All information in the database will be destroyed.
Prepare for db operation
32% complete
Connecting to database
35% complete
39% complete
42% complete
45% complete
48% complete
52% complete
65% complete
Updating network configuration files
68% complete
Deleting instance and datafiles
84% complete
100% complete
Database deletion completed.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl2/orcl2.log" for further details.