Saturday, August 8, 2026

Install Oracle Database 21C and Create a Database on Oracle Linux 7


 This guide provides a practical, step-by-step procedure for installing Oracle Database 21c and creating a database on an Oracle Linux 7 x86_64 server.

The example uses the following directory structure:

/u01/app/oracle       Oracle software and database files
/u02                  Oracle installation software

Step 0: Prerequisites

Before installing Oracle Database 21c, verify that the server meets the required prerequisites.

Server Requirements

ComponentRequirement
Operating SystemOracle Linux 7.x x86_64
Memory4 GB minimum; more recommended for production
Swap15 GB or more
Disk100 GB or more
Oracle SoftwareOracle Database 19c for Linux x86_64

Check the server:

cat /etc/os-release
uname -r
free -h
df -h

Install Oracle Preinstallation Package

The Oracle preinstallation RPM automatically installs many required packages and configures the operating system for Oracle Database.

sudo yum install -y oracle-database-preinstall-21c

The package can configure:

  • Required OS packages
  • Oracle user and groups
  • Kernel parameters
  • Resource limits
  • Other Oracle installation prerequisites

Verify the Oracle user:

id oracle

Example:

uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba)

Step 1: Create Oracle User and Groups

If the preinstallation RPM was not used, create the Oracle groups and user manually.

sudo groupadd oinstall
sudo groupadd dba
sudo useradd -g oinstall -G dba oracle
sudo passwd oracle

The groups are used as follows:

  • oinstall — Oracle software installation owner group
  • dba — Database administrator group

Verify:

id oracle

Step 2: Prepare Oracle Directories

Create the Oracle software and database directories.

sudo mkdir -p /u01/app/oracle
sudo mkdir -p /u01/app/oracle/oradata
sudo mkdir -p

Set ownership and permissions:

sudo chown -R oracle:oinstall /u01
sudo chmod -R 775 /u01

Create a directory for the Oracle installation ZIP file:

sudo mkdir -p /u02
sudo chmod -R 775 /u02
sudo chown -R oracle:oinstall /u02

Directory Structure

/u01/app/oracle
├── product
│   └── 21c
│       └── dbhome_1
└── oradata

/u02
└── Oracle installation ZIP file

Step 3: Configure Oracle Environment Variables

Switch to the Oracle user:

su - oracle

Edit the Oracle user's profile:

vi ~/.bash_profile

Add the following:

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/21c/dbhome_1
export ORACLE_SID=PRODDB

export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

Apply the changes:

source ~/.bash_profile

Verify:

echo $ORACLE_BASE
echo $ORACLE_HOME
echo $ORACLE_SID

Expected:

/u01/app/oracle
/u01/app/oracle/product/21c/dbhome_1
PRODDB

Step 4: Download Oracle Database 19c

Download the Oracle Database 21c Linux x86_64 software from the Oracle Software Downloads website.

Copy the ZIP file to:

/u02

For example:

cd /u02
ls -lrt
chown oracle:oinstall V839960-01.zip

I forgot to create bellow directories create as bellow:---------

mkdir -p /u01/app/oracle/product/21c/dbhome_1
chown oracle:oinstall
/u01/app/oracle/product/21c/dbhome_1
This is where you will install the Oracle Database 21c software.mkdir -p /u01/app/oraInventory
chown oracle:oinstall /u01/app/oraInventory
chmod 770 /u01/app/oraInventoryThis is Oracle's central inventory directorymkdir -p  /u01/app/oracle/FRA 
chown oracle:oinstall
/u01/app/oracle/FRA
FRA is used by Oracle for recovery-related files. 

Extract the Oracle software directly into the Oracle Home directory:


unzip /u02/V1011496-01.zip -d "$ORACLE_HOME"

Verify:

ls -l $ORACLE_HOME



Step 5: Install Oracle Database Software

Oracle 21c Silent Install


Start the run installer in silent mode to begin the installation

cd $ORACLE_HOME/ ls -lrt you will see runInstaller

./runInstaller -ignorePrereqFailure -silent -waitForCompletion \
oracle.install.option=INSTALL_DB_SWONLY \
ORACLE_HOSTNAME=${HOSTNAME} \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oraInventory \
SELECTED_LANGUAGES=en,en_GB \
ORACLE_HOME=${ORACLE_HOME} \
ORACLE_BASE=${ORACLE_BASE} \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSOPER_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true \
oracle.installer.autoupdates.option=SKIP_UPDATES

Once installation is completed, run the root scripts and you can move to DBCA create database.
Step 08 : Create Database using DBCA silent mode


dbca -silent -createDatabase \

-templateName General_Purpose.dbc \

-gdbName prod \

-sid prod \

-createAsContainerDatabase true \

-numberOfPDBs 1 \

-pdbName prodpdb \

-emConfiguration NONE \

-datafileDestination /u01/app/oradata \

-storageType FS \

-characterSet AL32UTF8 \

-totalMemory 1500 \

-recoveryAreaDestination /u01/app/oracle/FRA


Enter SYS user password:  EnterCDB#123

Enter SYSTEM user password:  EnterCDB#123

keep both same


Verify

[oracle@prm ~]$ cat /etc/oratab | grep -i prod
ps -ef | grep pmon
su - oracle
. oraenv
prod
sqlplus / as sysdba

SQL> select name,open_mode,cdb from v$database;

NAME      OPEN_MODE            CDB
--------- -------------------- ---
prod   READ WRITE           NO <------ NON-CDB

SQL> show con_name

CON_NAME
------------------------------
prod
SQL> archive log list

lets enable archiving.
shutdown immediate; startup mount;
alter database archivelog;
alter database open; archive log list;
alter system set db_recovery_file_dest_size=20G scope=both; alter system set db_recovery_file_dest='/u01/app/oracle/FRA' scope=both;

Step 7: Post-Installation Validation

force service registration:

tells the Oracle instance to immediately register its database services with the listener.

alter system register;
lsnrctl start
if you see
The listener supports no services
do this
show pdbs;
alter pluggable database PRODPDB open;
alter pluggable database PRODPDB save state;
alter system register;
lsnrctl start
lsnrctl status

Start the Database

Connect as SYSDBA:

sqlplus / as sysdba

Start the database:

STARTUP;

Check the database:

SELECT name, open_mode FROM v$database;

show pdbs

ALTER PLUGGABLE DATABASE PRODPDB OPEN;

if you want PRODPDB to automatically open after a database restart:

ALTER PLUGGABLE DATABASE PRODPDB SAVE STATE;

Exit:

EXIT;

Check the Listener

Run:

lsnrctl status

If the listener is not running:

force service registration:

tells the Oracle instance to immediately register its database services with the listener.

alter system register;
lsnrctl start

Verify again:

lsnrctl status

The default Oracle listener port is:

1521

Step 8: Test Database Connectivity

Test a local connection:

lest connect to pluggable database:

 sqlplus system@//prod.entopdba.com:1521/prodpdb

Enter the password when prompted.


For production environments, prompting for the password is preferable to placing it directly in shell history or scripts.


Unlock the HR Schema

The HR sample schema is commonly used for Oracle training and laboratory exercises.

Step 1: Connect as SYSDBA

sqlplus / as sysdba

Step 2: Check the HR Account

SELECT username, account_status
FROM dba_users
WHERE username = 'HR';

Example:

USERNAME   ACCOUNT_STATUS
---------  -------------
HR         LOCKED

That's expected. Oracle Database 21c does not automatically create the classic HR sample schema when you create a database with DBCA.

Download the official sample schemas

As oracle:

cd /u01/app/oracle
wget -O db-sample-schemas.zip https://github.com/oracle/db-sample-schemas/archive/refs/heads/main.zip
unzip -q db-sample-schemas.zip

The official Oracle sample-schema repository contains the HR installation scripts.

Check:

find /u01/app/oracle -name hr_install.sql -o -name hr_main.sql

You should see something like:

/u01/app/oracle/db-sample-schemas-main/human_resources/hr_install.sql

2. Make sure PRODPDB is open

sqlplus / as sysdba
show pdbs;

alter pluggable database PRODPDB open;

alter pluggable database PRODPDB save state;

Then explicitly switch into the PDB:

alter session set container=PRODPDB;

show con_name;

You want:

CON_NAME
------------------------------
PRODPDB

3. Install HR

I recommend using the 21c hr_install.sql script from the current Oracle sample-schema repository. Oracle's 21c documentation specifically describes hr_install.sql as the HR installation script, and it creates the HR user, objects, and sample data.

Exit SQL*Plus:

exit

Then:

cd /u01/app/oracle/db-sample-schemas-main/human_resources

Start SQL*Plus against PRODPDB, not the CDB root:

sqlplus system@//prod.entopdba.com:1521/prodpdb

Enter your SYSTEM password.

Then:

@hr_install.sql

It will ask for the HR password and tablespace. Use:

HR password: <choose a password>
Default tablespace: USERS

Lets connect to HR Schema,

sqlplus hr@//prod.entopdba.com:1521/prodpdb

Final Verification Checklist

Before considering the installation complete, verify:

✓ Oracle Linux configured
✓ Required packages installed
✓ oracle user created
✓ oinstall and dba groups configured
✓ /u01 and /u02 created
✓ ORACLE_BASE configured
✓ ORACLE_HOME configured
✓ Oracle 21c software installed
✓ Root scripts completed
✓ Database created with DBCA
✓ Listener running on port 1521
✓ Database OPEN
✓ Client connection tested
✓ HR schema tested (optional)

Installation Flow

Linux Server
     ↓
OS Prerequisites
     ↓
Oracle Preinstall RPM
     ↓
Oracle User & Groups
     ↓
/u01 and /u02
     ↓
Environment Variables
     ↓
Oracle 21c Software
     ↓
Listener
     ↓
DBCA
     ↓
PRODDB Database
     ↓
Validation & Testing

Conclusion: Following these steps provides a basic Oracle Database 21c installation suitable for a lab, development environment, or as a starting point for a production deployment. Production systems should additionally be configured for backup/recovery, monitoring, security, patching, storage performance, and high availability according to the organization's requirements.

No comments:

Post a Comment

Please do not enter any spam link in the comments

Install Oracle Database 21C and Create a Database on Oracle Linux 7

 This guide provides a practical, step-by-step procedure for installing Oracle Database 21c and creating a database on an Oracle Linux 7 x8...