How to Install Oracle Database 12c on RHEL/CentOS 7

Oracle database is one of the most widely used relational database management systems (RDBMS) in enterprise environments. Developed, maintained, and supported by Oracle Corporation, this RDBMS is often installed on top of a flavor of Enterprise Linux (RHEL, CentOS, or Scientific Linux). This makes for a very robust operating system – database choice.

In this article, we will explain how to install Oracle 12c Release 2 on a RHEL/CentOS 7 GUI server.

Attention: RHEL/CentOS 6 users can follow this guide to Install Oracle Database 12c on RHEL/CentOS 6.x

Let’s begin.

Prerequisites:

After installing Oracle 12c, the configuration will be performed through a graphical interface. That is the reason why we need a CentOS 7 server with the X Window System software group installed.

Read Also: Install GUI (Gnome) on RHEL/CentOS 7 Server

Additionally, please note that an Oracle account is required to download the Oracle Database 12c installation file (3.2 GB). Don’t worry about this, though, as you can create an account for free.

Finally, make sure your server has at least 2 GB of RAM and 30 GB of available disk space. These hardware requirements are safe for a testing environment such as ours, but will need to increase if you consider using Oracle in production.

Preparing for Oracle 12c Installation

1. To begin, make sure that all the packages currently installed on your RHEL/CentOS 7 system are updated to their latest versions.

# yum update -y

2. Next, installed all the required dependencies for the RDBMS, along with the zip and unzip packages.

# yum install -y binutils.x86_64 compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686 glibc.x86_64 glibc-devel.i686 glibc-devel.x86_64 ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libXi.i686 libXi.x86_64 libXtst.i686 libXtst.x86_64 make.x86_64 sysstat.x86_64 zip unzip

3. Create the user account and groups for Oracle.

# groupadd oinstall
# groupadd dba
# useradd -g oinstall -G dba oracle

Finally, set a password for the newly created oracle account.

# passwd oracle

4. Add the following kernel parameters to /etc/sysctl.conf file.

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

and apply them:

# sysctl -p
# sysctl -a

5. Set the limits for oracle in /etc/security/limits.conf file.

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

6. Create a directory named /stage and extract the zipped installation file.

# unzip linuxx64_12201_database.zip -d /stage/

Before proceeding, create other directories that will be used during the actual installation, and assign the necessary permissions.

# mkdir /u01
# mkdir /u02
# chown -R oracle:oinstall /u01
# chown -R oracle:oinstall /u02
# chmod -R 775 /u01
# chmod -R 775 /u02
# chmod g+s /u01
# chmod g+s /u02

We are now ready to run the installation script.

7. Open a GUI session in the RHEL/CentOS 7 server and launch the installation script.

/stage/database/runInstaller 

and follow the steps presented by the installer.

Installing Oracle 12c on CentOS 7

8. Enter the email address associated with your Oracle account (optional).

Oracle Account Email Address
Oracle Account Email Address

9. Choose Create and configure a database.

Configure a Oracle Database
Configure a Oracle Database

10. Select Desktop class since we are setting up a minimal configuration and a starter database.

Oracle Desktop Class Installation
Oracle Desktop Class Installation

11. Select the following options for basic configuration.

  • Oracle base: /u01/app/oracle
  • Software location: /u01/app/oracle/product/12.2.0/dbhome_1
  • Database file location: /u01
  • OSDBA group: dba
  • Global database name: your choice. We chose tecmint here.
  • Take note of the password, as you will be using it when you first connect to the database.
  • Uncheck Create as Container database.
Oracle 12c Basic Configuration
Oracle 12c Basic Configuration

12. Leave the default Inventory Directory as /u01/app/oraInventory.

Oracle 12c Inventory Directory
Oracle 12c Inventory Directory

13. Verify that the installation pre-checks are completed without errors.

Oracle 12c Installation Settings
Oracle 12c Installation Settings

The installer will not let you past this point if any errors are found.

14. Wait until the Oracle 12c installation completes.

Oracle 12c Installation Progress
Oracle 12c Installation Progress

It is possible that at some point during the installation you will be asked to run a couple of scripts to set up further permissions or correct issues. This is illustrated here:

Oracle 12c Configuration Scripts
Oracle 12c Configuration Scripts

And here:

# cd /u01/app/oraInventory
# ./orainstRoot.sh
# cd /u01/app/oracle/product/12.2.0/dbhome_1
# ./root.sh
Execute Oracle 12c Configuration Scripts
Execute Oracle 12c Configuration Scripts

15. After that, you will need to return to the previous screen in the GUI session and click OK so that the installation can continue.

When it is finished, you will be presented with the following message indicating the URL of the Oracle Enterprise Manager:

https://localhost:5500/em

Oracle 12c Finishing Touches

16. To allow connections from outside the server, you will need to open the following ports:

1521/TCP
5500/TCP
5520/TCP
3938/TCP

As follows:

# firewall-cmd --zone=public --add-port=1521/tcp --add-port=5500/tcp --add-port=5520/tcp --add-port=3938/tcp --permanent
# firewall-cmd --reload

17. Next, login as oracle using the password that was chosen previously and add the following lines to .bash_profilefile.

TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=tecmint; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

18. Finally, replace localhost with 0.0.0.0 on.

# vi $ORACLE_HOME/network/admin/listener.ora
Set Oracle 12c Listener
Set Oracle 12c Listener

19. The last step consists in reloading .bash_profile to apply the new settings.

# source .bash_profile

20. And then login to the database using the system account and the password chosen in Step 11 of the previous section.

# sqlplus [email protected]

Optionally, let’s create a table inside the tecmint database where we will insert some sample records as follows.

SQL> CREATE TABLE NamesTBL
(id   NUMBER GENERATED AS IDENTITY,
name VARCHAR2(20));

Please note that IDENTITY columns were first introduced in Oracle 12c.

SQL> INSERT INTO NamesTBL (name) VALUES ('Gabriel');
SQL> INSERT INTO NamesTBL (name) VALUES ('Admin');
SQL> SELECT * FROM NamesTBL;
Create Table in Oracle 12c Database
Create Table in Oracle 12c Database

Enabling Oracle to Start on System Boot

21. To enable the database service to start automatically on boot, add the following lines to /etc/systemd/system/oracle-rdbms.service file.

# /etc/systemd/system/oracle-rdbms.service
# Invoking Oracle scripts to start/shutdown Instances defined in /etc/oratab
# and starts Listener

[Unit]
Description=Oracle Database(s) and Listener
Requires=network.target

[Service]
Type=forking
Restart=no
ExecStart=/u01/app/oracle/product/12.2.0/dbhome_1/bin/dbstart /u01/app/oracle/product/12.2.0/dbhome_1
ExecStop=/u01/app/oracle/product/12.2.0/dbhome_1/bin/dbshut /u01/app/oracle/product/12.2.0/dbhome_1
User=oracle

[Install]
WantedBy=multi-user.target

22. Finally, we need to indicate that the tecmint database should be brought up during boot in /etc/oratab (Y: Yes).

Enable Oracle 12c Database on Boot
Enable Oracle 12c Database on Boot
Summary

In this article, we have explained how to install Oracle 12c on RHEL/CentOS 7, how to create and configure a database, and how to create tables and insert rows of data.

Additionally, it is important to note that the database server should be up and running when the system boots, and our default database should be available at that point.

If you have any questions or comments about this article, feel free to drop us a line using the form below.

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

27 thoughts on “How to Install Oracle Database 12c on RHEL/CentOS 7”

  1. Hi,

    Thanks for those steps, May I have your help what can cause oracle not to start after a system restart?

    I noticed first that listener.ora point to /u02/ when it was working, after system restart listener.ora point to /u01/ … /listener.ora.

    do we to change the path of the database ( as we install a database on directory /u02?

    Thanks

    Reply
  2. I installed Oracle 12c under centos 7.7 in VMWare machine as told by you. Still while connecting to sqlplus and I get the following error.

    nter user-name: system
    Enter password: 
    ERROR:
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux-x86_64 Error: 2: No such file or directory
    Additional information: 3701
    Additional information: -267818573
    Process ID: 0
    Session ID: 0 Serial number: 0
    

    and also when I checked.

    # lsnrctl start
    

    LSNRCTL for Linux: Version 12.2.0.1.0 – Production on 15-APR-2020 18:52:46

    Copyright (c) 1991, 2016, Oracle. All rights reserved.

    TNS-01106: Listener using listener name LISTENER has already been started

    basically it seems oracle is not staring.

    Reply
  3. Hi, thanks for this good and valuable tutorial.

    I’m getting this message when I try to connect :ORA-12514: TNS:listener does not currently know of service requested in connect.

    Can you tell me please what I’m missing?
    Thanks

    Reply
  4. The steps are detailed and easy to implement. Appreciate your help!

    Having trouble with Step 18 :

    [[email protected] ~]$ cat $ORACLE_HOME/network/admin/listener.ora
    cat: /network/admin/listener.ora: No such file or directory
    
    Reply
  5. Hi, thanks for the tutorial. I think that you have to execute:

    systemctl daemon-reload
    systemctl enable oracle-rdbms
    

    after the /etc/systemd/system/oracle-rdbms.service creation.

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.