How to Set Up Oracle on Linux

Galaxy Glossary

How do I set up Oracle Database 21c on Linux?

Install and configure Oracle Database on a Linux server, create a starter database, and enable SQL access.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

What does setting up Oracle on Linux involve?

Installation requires system preparation, software deployment, database creation, listener configuration, and service enablement. Oracle supplies RPM and GUI installers to automate most steps.

What are the prerequisites for Oracle on Linux?

Use a supported distribution (OL 8/9, RHEL 8/9, CentOS 8-stream), 8 GB RAM, 30 GB free disk, swap = RAM, and hostname resolving to a static IP. Disable SELinux or set it to permissive.

Install OS packages in one line

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

The preinstall RPM creates oracle groups, users, kernel parameters, ulimits, and required libraries.

How do I install the Oracle software?

RPM-based silent install

# Download from OTN, then
sudo yum localinstall -y oracle-database-ee-21c-1.0-1.x86_64.rpm

RPM places binaries under /opt/oracle/product/21c/dbhome_1 and installs the oracledb service unit.

Configure the database in one command

sudo /etc/init.d/oracledb_ORCLCDB-21c configure

This script sets the CDB name ORCLCDB, listener port 1521, creates a PDB ORCLPDB1, and outputs the generated SYS user password.

How can I connect and verify?

sudo su - oracle
sqlplus sys@ORCLPDB1 as sysdba
SQL> SELECT open_mode FROM v$database;

The query should return READ WRITE, confirming the PDB is open and ready.

How do I create an e-commerce sample schema?

CREATE USER shop IDENTIFIED BY "Sh0pPwd" QUOTA UNLIMITED ON users;
GRANT connect, resource TO shop;

ALTER SESSION SET current_schema = shop;

CREATE TABLE customers (
id NUMBER PRIMARY KEY,
name VARCHAR2(100),
email VARCHAR2(255),
created_at DATE DEFAULT SYSDATE
);

CREATE TABLE products (
id NUMBER PRIMARY KEY,
name VARCHAR2(100),
price NUMBER(10,2),
stock NUMBER
);

CREATE TABLE orders (
id NUMBER PRIMARY KEY,
customer_id NUMBER REFERENCES customers(id),
order_date DATE DEFAULT SYSDATE,
total_amount NUMBER(10,2)
);

CREATE TABLE orderitems (
id NUMBER PRIMARY KEY,
order_id NUMBER REFERENCES orders(id),
product_id NUMBER REFERENCES products(id),
quantity NUMBER
);

These tables mirror a typical online store and help confirm DML functionality after installation.

Best practices after installation

Create a separate ASM or LVM volume for datafiles, enable flashback, schedule RMAN backups, and patch quarterly with opatchauto.

Common mistakes to avoid

Skipping the preinstall RPM causes missing libraries; running the configure script twice corrupts ORACLE_HOME. Always verify logs in /opt/oracle/diag.

Why How to Set Up Oracle on Linux is important

How to Set Up Oracle on Linux Example Usage


-- Total order amount per customer this month
SELECT c.name,
       SUM(o.total_amount) AS monthly_total
FROM   customers c
JOIN   orders o ON o.customer_id = c.id
WHERE  o.order_date >= TRUNC(SYSDATE,'MM')
GROUP  BY c.name
ORDER  BY monthly_total DESC;

How to Set Up Oracle on Linux Syntax


# 1. Prepare the OS (CentOS/RHEL example)
sudo yum update -y
sudo yum install -y oracle-database-preinstall-21c

# 2. Deploy software (RPM method)
sudo yum localinstall -y oracle-database-ee-21c-1.0-1.x86_64.rpm

# 3. Configure starter database
sudo /etc/init.d/oracledb_ORCLCDB-21c configure \
  --dbname ORCLCDB \
  --sid ORCLCDB \
  --characterSet AL32UTF8 \
  --pdbName ORCLPDB1 \
  --listenerPort 1521

# 4. Enable auto-start
sudo systemctl enable oracledb_ORCLCDB-21c.service

# 5. Sample connection & DML
echo "INSERT INTO customers VALUES (1,'Alice','alice@example.com',SYSDATE);" | sqlplus shop/Sh0pPwd@ORCLPDB1

Common Mistakes

Frequently Asked Questions (FAQs)

Can I install Oracle on Ubuntu?

Oracle only certifies its database on selected Red Hat compatible distributions. For Ubuntu use Oracle XE in a container or run Oracle inside a supported VM.

Is the RPM method production-ready?

Yes. The RPM places files under /opt/oracle, registers a systemd service, and supports patching with OPatch. For advanced options, use the GUI installer instead.

How do I apply future patches?

Download the quarterly RU patch from MOS, unzip it, and run opatchauto apply as root. Reboot the server if requested to relink binaries.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.