Oracle Database delivers market-leading performance, scalability, reliability, and security on-premises and in the cloud. Oracle Database 19c is the latest long-term support version. It has an ultra-high level of version stability and a long support and error fix support cycle, providing a highly stable platform for your applications.

Install info

  • OS:Oracle Linux 7/8
  • Core:2
  • Memory:8GB
  • Swap:16GB
  • Disk:100GB

System environment preparation

# Install oracle-database-preinstall-19c package and update
yum install epel* -y
yum update -y
yum groupinstall "Development Tools" -y
yum install oracle-database-preinstall-19c -y

# Disable firewall and selinux
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/sysconfig/selinux

# Create an Oracle database installation directory
# dbhome_1 serves as the $ORACLE_HOME path and is assigned to the oracle account
mkdir -p /data/u01/app/oracle/product/19.0.0/dbhome_1
chown -R oracle:oinstall /data/u01 && chmod -R 775 /data/u01

# Increment environment variable

# Backup .bash_profile file
mv /home/oracle/.bash_profile /home/oracle/bash_profile-$(date '+%Y%m%d%H%M%S')

cat >/home/oracle/.bash_profile <<EOF
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

# Fake Oracle Linux 8
export CV_ASSUME_DISTID=OEL8.8

# Oracle Settings
export ORACLE_HOSTNAME=oracle-db-19c.test.com
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=test
export PATH=.:\$PATH:\$HOME/bin:\$ORACLE_HOME/bin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib
EOF

chown oracle:oinstall /home/oracle/.bash_profile

What is worth noting here is the oracle-database-preinstall-19c software package, which will automatically help you prepare the system environment required by Oracle without the need for manual operation by the user.

Download software

Installing Database Software

# Decompress the installation package
su -c "unzip LINUX.X64_193000_db_home.zip" oracle

# Silent installation because no graphics are installed
su -c "./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,zh_CN \
ORACLE_HOME=${ORACLE_HOME} \
ORACLE_BASE=${ORACLE_BASE} \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=backupdba \
oracle.install.db.OSDGDBA_GROUP=dgdba \
oracle.install.db.OSKMDBA_GROUP=kmdba \
oracle.install.db.OSRACDBA_GROUP=racdba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true" oracle

# Root run script
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/19.0.0/dbhome_1/root.sh

Database Creation

# Create oracle data folder
mkdir -p /u01/oradata
chown oracle:oinstall /u01/oradata

# Set oracle database envionment variables
export ORACLE_SID=test
export SYS_PASSWORD="Test-1234"
export DATA_DIR=/u01/oradata

# Silent mode
su -c "dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword ${SYS_PASSWORD} \
-systemPassword ${SYS_PASSWORD} \
-createAsContainerDatabase false \
-databaseType MULTIPURPOSE \
-memoryMgmtType auto_sga \
-totalMemory 2048 \
-storageType FS \
-datafileDestination "${DATA_DIR}" \
-redoLogFileSize 600 \
-emConfiguration NONE \
-ignorePreReqs" oracle

# Start listener
su - oracle -c "lsnrctl start"

Post Installation

# Edit the "/etc/oratab" file setting the restart flag for each instance to 'Y'
sed -i 's/:N$/:Y/' /etc/oratab

# Reset system password
su - oracle -c "sqlplus / as sysdba <<EOF
alter user system identified by \"Test-1234\";
alter system set db_domain='test.com' scope=spfile;
exit;
EOF"

# Set up auto-start at boot
file_path="/etc/init.d/dbora"
cat << EOF > "$file_path"
#! /bin/sh -x
#
# 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.
#
# Create this file as /etc/init.d/dbora and execute:
#  chmod 750 /etc/init.d/dbora
#  chkconfig --add dbora
#  chkconfig dbora on

# Note: Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
# ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
# OMS_HOME=/u01/app/oracle/middleware
#
# 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
'start')
        echo -n $"Starting Oracle: "
        su \$ORACLE -c "\$ORACLE_HOME/bin/dbstart \$ORACLE_HOME"
        # sleep 5
        # su \$ORACLE -c "\$ORACLE_HOME/bin/lsnrctl start"
        # sleep 5
        # su \$ORACLE -c "\$OMS_HOME/bin/emctl start oms"

        ;;
'stop')
        echo -n $"Shutting down Oracle: "
        su \$ORACLE -c "\$ORACLE_HOME/bin/dbshut \$ORACLE_HOME"
        ;;
'restart')
        echo -n $"Shutting down Oracle: "
        su \$ORACLE -c "\$ORACLE_HOME/bin/dbshut \$ORACLE_HOME"
        sleep 5
        echo -n $"Starting Oracle: "
        su \$ORACLE -c "\$ORACLE_HOME/bin/dbstart \$ORACLE_HOME"
        ;;
*)
        echo "usage: \$0 {start|stop|restart}"
        exit
        ;;
esac

exit 0
EOF

chmod 750 /etc/init.d/dbora
chkconfig --add dbora
chkconfig dbora on
chkconfig --list |grep dbora