Installing Oracle Database 19c on CentOS 9 for development or testing can be a complex process. Many users encounter errors during installation, and I have also faced challenges. However, by following a systematic approach, as outlined in this guide, you can successfully install Oracle Database 19c on CentOS 9.
Below is a step-by-step guide, including the installation of necessary packages, configuration of environment variables, and setting up systemd for managing the Oracle service.
Step 1: Install Pre-Installation RPM Package
First, install the Oracle Database pre-installation RPM package, which prepares your system by installing necessary packages and setting up kernel parameters.
sudo dnf -y install https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el8.x86_64.rpm
Step 2: Install Oracle Database 19c
Download and Configure Repository:
Download the public YUM repository for Oracle Linux 7 and disable it by default:
sudo curl https://public-yum.oracle.com/public-yum-ol7.repo -o /etc/yum.repos.d/public-yum-ol7.repo
sudo sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/public-yum-ol7.repo
Import the GPG Key and Install Pre-Installation Package:
sudo rpm --import http://yum.oracle.com/RPM-GPG-KEY-oracle-ol7
sudo yum --enablerepo=ol7_latest -y install oracle-database-preinstall-19c
Copy and Install Oracle Database RPM:
sudo cp /opt/oracle-database-ee-19c-1.0-1.x86_64.rpm .
sudo rpm -Uvh oracle-database-ee-19c-1.0-1.x86_64.rpm
Step 3: Configure Oracle Database
Edit Configuration File:
Open the Oracle Database configuration file to set listener ports and data locations:
sudo vi /etc/sysconfig/oracledb_ORCLCDB-19c.conf
Example configuration:
LISTENER_PORT=1521
ORACLE_DATA_LOCATION=/opt/oracle/oradata
EM_EXPRESS_PORT=5500
Run Oracle Database Configuration:
sudo /etc/init.d/oracledb_ORCLCDB-19c configure
Step 4: Set Up User Environment
Update User Profile:
Switch to Oracle User:
su - oracle
Edit your .bash_profile to include the Oracle environment variables:
vi ~/.bash_profile
Example content:
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/bin
export PATH
Apply Profile Changes:
source ~/.bash_profile
Access Oracle SQL Plus:
sqlplus / as sysdba
exit
Edit Oracle Configuration Files:
Edit /etc/oratab:
sudo vi /etc/oratab
Example entry:
ORCLCDB:/opt/oracle/product/19c/dbhome_1:Y
Create /etc/sysconfig/ORCLCDB.oracledb:
sudo vi /etc/sysconfig/ORCLCDB.oracledb
Example content:
ORACLE_BASE=/opt/oracle/oradata
ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
ORACLE_SID=ORCLCDB
Create Systemd Service File:
sudo vi /usr/lib/systemd/system/ORCLCDB@oracledb.service
[Unit]
Description=Oracle Database service
After=network.target lsnrctl.service
[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/ORCLCDB.oracledb
ExecStart=/opt/oracle/product/19c/dbhome_1/bin/dbstart $ORACLE_HOME
ExecStop=/opt/oracle/product/19c/dbhome_1/bin/dbshut $ORACLE_HOME
User=oracle
[Install]
WantedBy=multi-user.target
Reload and Enable the Service:
sudo systemctl daemon-reload
sudo systemctl enable ORCLCDB@lsnrctl ORCLCDB@oracledb
Reference: Server World