How to Install Oracle Database 18c XE on CentOS 7.6

I am currently building a home server using CentOS 7.6. I install this OS on my AMD Phenom desktop. I am planning to use this server for my Oracle Database as well as Virtualization host. So in this port, I am going to share how to install Oracle Database 18c XE on CentOS 7.6.

I was thinking that installing Oracle in Linux is super hard. But in fact, even I cannot say that it is super easy, I still can do this. With some efforts and patience, I was able to run Oracle Database 18c on my CentOS Linux. If you are interested, here are the steps.

Prerequisites

Before I install the Oracle Database, I do the following tasks:

  1. Update CentOS >> yum update command
  2. Create new “oracle” user >> useradd oracle command. I also create new password for my oracle user.
  3. Change or set the hostname. Edit the /etc/hosts file. I change my hostname to: server.griyaku.lan

Here is my /etc/hosts file looks like. Make sure you enter the hostname in a correct format.

Steps to Install Oracle Database 18c XE on CentOS 7.6

Here are the general steps of Installing Oracle Database 18c XE on CentOS 7.6.

  1. Download the installation files
  2. Install Oracle pre-install file
  3. Install and Configure Oracle Database
  4. Edit PATH
  5. Test the Connection
  6. Configure Database
  7. Configure Oracle Enterprise manager

Step 1. Download the Oracle Database 18c XE installation files

Use the link below to download the oracle pre-install file and also the Oracle database 18c XE installation file. Save the file to your download directory.

There are two files you will need to download.


You should now have the following files:

  • oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
  • oracle-database-xe-18c-1.0-1.x86_64.rpm

Step 2. Install Oracle Pre-Install file

su -
cd /home/oracle/Downloads
yum localinstall oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm

Step 3. Install and Configure Oracle Database

Now, install the Oracle Database package with this command as root

yum localinstall oracle-database-xe-18c-1.0-1.x86_64.rpm

This install process will take some times. In my case, it takes up to 15 minutes. Once installed, you will see the following

Configure Oracle Database Installation

This is an important step. Make sure it completes successfully and no error. Run this command as root user. During this process, you will need to create a password that will be used for SYS, SYSTEM and PDBADMIN accounts.

su -
/etc/init.d/oracle-xe-18c configure

The configuration process will take up to 30 minutes in my case. So, be patient.

Edit tnsnames.ora

We are going to edit the tnsnames.ora file. We need to add our pluggable database information to this file.

nano /opt/oracle/product/18c/dbhomeXE/network/admin/tnsnames.ora

Add these lines to the end of the file

XEPDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = server.griyaku.lan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XEPDB1) )
)

Change the value server.griyaku.lan with your hostname/domain name. Or, you can also put the IP address of your server running Oracle.

Step 4. Modify PATH

Now, let’s modify the PATH. We need to edit the file ~/.bash_profile.

su -
nano /home/oracle/.bash_profile

Add the following line

export ORACLE_BASE=/opt/oracle/ 
export LD_LIBRARY_PATH=/opt/oracle/product/18c/dbhomeXE/lib
export ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE
export PATH=$ORACLE_BASE/product/18c/dbhomeXE/bin:$PATH
export PATH=/usr/bin:$PATH
export ORACLE_SID=XE

Next, execute this command using oracle account

source ~/.bash_profile

Step 5. Test the Connection using SQLPlus

You can try to connect to the new Oracle database using sqlplus

sqlplus sys as sysdba
[oracle@server admin]$ sqlplus sys as sysdba 
SQL*Plus: Release 18.0.0.0.0 - Production on Wed Jan 23 06:23:04 2019 Version 18.4.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Enter password:

Step 6. Configure Database

Now we need to configure the database so it starts automatically during the system boot. To do this, login as root and execute this command

su -
systemctl daemon-reload
systemctl enable oracle-xe-18c

OK, so now Oracle database will be started on system boot. We can also start and stop the database manually using Oracle command

SQL> Startup   >> Startup the database
SQL> Shutdown immediate >>Shutdown the database

Step 7. Configure Oracle Enterprise Manager

We can access the Oracle Enterprise Manager using address:

https://server.griyaku.lan:5500/em

But, by default, Oracle EM only accessible from the localhost. We need to configure the Oracle EM so it accessible from remote client. Login to Oracle using sqlplus

sqlplus sys as sysdba
EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
exit;

At first, I can open the EM from the CentOS machine. But, I cannot open it from other computer. So, I need to configure the firewalld to allow https and port 5500 used by Oracle EM. Here is the commands

su -
firewall-cmd --zone=public --permanent --add-port=5500/tcp
firewall-cmd --zone=public --add-service=https --permanent
firewall-cmd --reload

Final Words

It’s a great feeling that I have successfully installed the Oracle Database 18c XE on my CentOS 7. It took about 2 hours to get everything run smoothly. The database configure process take a long time. So, that’s it. I hope you enjoy this article.

Source:

Admin

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.