Installing and Creating an Oracle Database 19c on Linux 7.8

Oracle database is one the widely used RDMBS system. In this tutorial, you will install and create an Oracle database 19c on Linux 7 on a virtual machine. It will be a CDB database, without Oracle Restart services.

In high level, you will perform the following:

  • Change the Settings of the Appliance srv1
  • Make the machine IP address static
  • Configure Putty to connect to srv1
  • Set up the environment variables for the OS account oracle
  • Change the kernel parameter values to the recommended values
  • Install more packages
  • Install Oracle database software and create the sample database

Required Resources

  • A machine with a free 8GB in its memory. This means the RAM memory in your PC should be at least 12GB.
  • At least 30GB free disk space.
  • Good Internet Connection

Edit the /etc/hosts file and add the hostname and the IP address to it.

# vi /etc/hosts

192.168.1.127 srv1.localdomain srv1

Database Specifications

The tutorial aims at creating a database with the following high level specifications:

SID  oradb

Home 

/u01/app/oracle/product/19.0.0/db_1
Release  19c
Version  19.3
CDB/non-CDB  CDB
OS  Linux 7.8
Hostname  srv1
Storage Option  file system

Required Software and Packages

Oracle Database 19c installation files for Linux x86-64. This can be downloaded from Oracle site.

Note: download the zip file, not the rpm file.

Putty: which is a utility that provides a command line prompt to connect to a Linux server from Windows.

Setting up Environment Variables for the Software Owner Account

In the following steps, you will configure the OS variables for the software owner account (oracle).

In the Putty session, make sure the current user is root then add oracle account to vboxsf group.
The vboxsf group was created by VirtualBox Guest Additions and it allows its members to access the shared folder (staging folder) in the hosting machine. In a production real life machine, you may not need to implement this step.

# usermod -a -G vboxsf oracle

Switch the current user to oracle and make a backup copy of its bash profile file:

# su - oracle

# mv ~/.bash_profile ~/.bash_profile_bkp

Open the .bash_profile file with the vi editor

vi ~/.bash_profile

Add the following to it.

# .bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_SID=oradb; export ORACLE_SID
ORACLE_HOME=$ORACLE_BASE/product/19.0.0/db_1; export ORACLE_HOME
NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
PATH=$PATH:$HOME/.local/bin:$HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/local/bin
PATH=.:${PATH}:$ORACLE_HOME/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
export TEMP=/tmp
export TMPDIR=/tmp
umask 022

As root, run the following code to create the groups and directories required by Oracle software.

# su –
# groupadd oinstall
# usermod -g oinstall oracle
# mkdir -p /u01/app/oracle/product/19.0.0/db_1
# mkdir -p /u01/app/oraInventory
# chown -R oracle:oinstall /u01/app/oracle
# chown -R oracle:oinstall /u01/app/oraInventory

Changing Kernel Parameter Values

In the following step, you will change the kernel parameter values to the values recommended by Oracle.
Make sure the current user is root
Create the following file then add the code that follows to it.

# vi /etc/sysctl.d/97-oracle-database-sysctl.conf

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
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

Change the current values of the kernel parameters:

# /sbin/sysctl --system

Next Reboot srv1

# shutdown -r now

Install More Packages

In the following steps, you will install further packages in srv1 that are required by Oracle database software.

Open Putty and login to srv1 as root
Run the following code to install further packages required by Oracle software.

# yum install ksh
# yum install libaio-devel.x86_64

Installing Oracle Database Software and Creating the Database

In the following steps, you will install Oracle database software in srv1 and create the database.
Copy the Oracle database software installation file to the staging folder.

At the time of this writing, the installation file name downloaded from Oracle site is LINUX.X64_193000_db_home.zip

In the Putty session, change the current user to oracle then extract the installation file into the Oracle database software home directory

# su - oracle
# unzip /media/sf_staging/LINUX.X64_193000_db_home.zip -d $ORACLE_HOME >/dev/null

In the linux  machine login as oracle user and open a terminal window, change the current directory to the Oracle database home directory and run the gridSetup.sh script.

# cd $ORACLE_HOME
# ./runInstaller

Next respond to the Installer windows as follows:

Window  Action
Configuration Option 

Select the following option:

“Create and Configure a single instance database.”

System Class 

Select the following option: “Server Class”

Database Edition

Select the following option:
“Enterprise Edition”
Installation Location  Keep the default values
Create Inventory  oraInventory Group Name: oracle
Configuration Type  Select the following option:
General Purpose
Database Identifiers

Global Database Name: oradb.localdomain
Oracle SID: oradb
Pluggable Database Name: pdb1
Configuration Options Do not mark the AMM checkbox
Memory: 5120 MB
Character set: Use Unicode (AL32UTF8)
Sample Schemas: (optional) Mark the checkbox “Install sample schema in the database”
Database Storage Make sure “File System” option is selected
Management Options Make sure the checkbox is not marked.
Recovery Option

Mark the checkbox Enable Recovery

Make sure “File system” option is selected

Schema Password  Set passwords for the accounts
Operating System Groups  Select the “oinstall” group for all the options, except the OSOPER keep it blank.
Root Script Execution  Mark the checkbox “Automatically run configuration scripts” and enter the root password
Prerequisite Checks  All the Prerequisite Checks should pass.
Summary  Click on Install button
Install Product  When the installation reaches to nearly 12%, if will display a confirmation message. Click on Yes button.
Finish  click on Close button

After the installation and database creation are finished, verify the database is up and running by logging to it as sysdba

# sqlplus / as sysdba

Check if a connection entry to oradb is added to the tnsnames.ora file. The tnsnames.ora file was created.

# cat $TNS_ADMIN/tnsnames.ora

In the VirtualBox window of srv1, start the Firefox browser and open the EM Express using the following URL. Accept the warning displayed by the browser. Enter the sys username, its password, leave the container name blank then click on Login button.

https://srv1:5500/em

Note: You may consider creating and deploying a script that automatically starts up the database when the machine is rebooted. The steps to perform this task are as follows

Open Putty and login as root to srv1. Edit the oratab file

# vi /etc/oratab

Change the last field for the database line to Y

oradb:/u01/app/oracle/product/19.0.0/db_1:Y

4. Create the file /etc/init.d/dbora and add the following code in it:

vi /etc/init.d/dbora
#! /bin/sh
# description: Oracle auto start-stop script.
ORA_HOME=/u01/app/oracle/product/19.0.0/db_1
ORA_OWNER=oracle
case "$1" in
'start')
# Start the Oracle databases:
# Remove "&" if you don't want startup as a background process.
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" &
touch /var/lock/subsys/dbora
;;
'stop')
# Stop the Oracle databases:
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" &
rm -f /var/lock/subsys/dbora
;;
esac

Change the group of the dbora file to oinstall, and set its permissions to 750.

# chgrp oinstall /etc/init.d/dbora
# chmod 750 /etc/init.d/dbora

6. Create symbolic links to the dbora script in the appropriate run-level script directories

ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora

Restart srv1 and wait for a few minutes to allow the database to automatically start up. Login as oracle to srv1 and verify that the database has automatically started.

# ps -ef | grep pmon
# sqlplus / as sysdba

Conclusion

Hence we successfully installed and configured an Oracle Database 19c on Linux 7.8. If you got any query please do write comment.

Read More : How to Setup Master-Slave Replication in MySQL 8 on Ubuntu 20.04

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.

Recommended Reading..

Leave a Comment