How to install Oracle 18c on CentOS 7

Share on Social Media

In this guide, you will learn, how to install Oracle 18c on CentOS 7 or other Redhat based Linux OS. #centlinux #linux #oracle

What is Oracle 18c ? :

Oracle Database 18c is latest version of Oracle Relational Database Management System or RDBMS, is a multi-model database. Oracle Database is commonly used in Online Transaction Processing / OLTP and Data Warehousing / DW environments. Oracle Database 18c is also available on Public and Private Clouds, Exadata and On-premises systems.

In this article, we will install Oracle 18c on CentOS 7 on-premises database server in Silent mode.

There are many good reading material is available, specially from Oracle Certification Professional / OCP preparation guides. However, we also recommend reading Beginning Oracle SQL: For Oracle Database 12c (PAID LINK) by Apress to have a third party perspective about Oracle Database 18c.

System Specification:

We have provisioned a CentOS 7 minimal installed virtual machine with following specifications:

  • CPU – 3.4 Ghz (2 Cores)
  • Memory – 2 GB
  • Storage – 60 GB
  • Hostname – oracle-01.centlinux.com
  • IP Address – 192.168.116.148 /24
  • Operating System – CentOS 7.6

Configure Local DNS Resolver:

To configure name resolution, we can either use a central DNS server or we can use local DNS resolver. To keep it simple, we are using local DNS resolver for our server.

Connect to oracle-01.centlinux.com using ssh as root user and execute following command.

# cat >> /etc/hosts << EOF
> 192.168.116.148 oracle-01.centlinux.com oracle-01
> EOF

Verify name resolution by using ping command.

# ping oracle-01.centlinux.com
PING oracle-01.centlinux.com (192.168.116.148) 56(84) bytes of data.
64 bytes from oracle-01.centlinux.com (192.168.116.148): icmp_seq=1 ttl=64 time=0.053 ms
64 bytes from oracle-01.centlinux.com (192.168.116.148): icmp_seq=2 ttl=64 time=0.068 ms

Disable Transparent Hugepages:

Transparent Hugepages can cause memory allocation delays during runtime. Therefore, to avoid performance issues, Oracle recommends to disable Transparent Hugepages before starting installation. Oracle recommends that we instead use Standard Hugepages for enhanced performance.

Verify that Transparent Hugepages are enabled on our CentOS 7 server.

# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

The [always] flag shows that the Transparent Hugepages are in used by our CentOS 7 server.

To disable Transparent Hugepages we have to edit GRUB configuration.

# vi /etc/default/grub

Look for GRUB_CMDLINE_LINUX and add transparent_hugepage=never at the end. After editing this directive should be looks like as follows.

GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet transparent_hugepage=never"

Generate /etc/grub.cfg file using modified configurations.

# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-07fcd178406f4b3ca09084082364afba
Found initrd image: /boot/initramfs-0-rescue-07fcd178406f4b3ca09084082364afba.img
done

Reboot the machine to verify configurations.

# systemctl reboot

After reboot, check status of Transparent HugePages again.

# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

Transparent Hugepages has been disabled.

Install Oracle 18c Prerequisites:

Install prerequisite software packages using yum command.

# yum install -y bc binutils compat-libcap1 compat-libstdc++-33 glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender-devel libXrender libgcc libstdc++ libstdc++-devel libxcb make smartmontools sysstat net-tools nfs-utils gcc-c++

Create User and Groups for Oracle 18c:

Create OS users and groups as required by Oracle Database 18c.

# groupadd -g 1501 oinstall
# groupadd -g 1502 dba
# groupadd -g 1503 oper
# groupadd -g 1504 backupdba
# groupadd -g 1505 dgdba
# groupadd -g 1506 kmdba
# groupadd -g 1507 racdba
# useradd -u 1501 -g oinstall -G dba,oper,backupdba,dgdba,kmdba,racdba oracle
# echo "oracle" | passwd oracle --stdin
Changing password for user oracle.
passwd: all authentication tokens updated successfully.

Set Security Limits for Oracle User:

Execute following command to set security limits for oracle user.

# cat >> /etc/security/limits.d/30-oracle.conf << EOF
> oracle   soft   nofile    1024
> oracle   hard   nofile    65536
> oracle   soft   nproc    16384
> oracle   hard   nproc    16384
> oracle   soft   stack    10240
> oracle   hard   stack    32768
> oracle   hard   memlock    134217728
> oracle   soft   memlock    134217728
> EOF

Adjust Kernel Parameters:

Set following Kernel parameters as required by Oracle Database 18c.

# cat >> /etc/sysctl.d/98-oracle.conf << EOF
> fs.file-max = 6815744
> kernel.sem = 250 32000 100 128
> kernel.shmmni = 4096
> kernel.shmall = 1073741824
> kernel.shmmax = 4398046511104
> kernel.panic_on_oops = 1
> net.core.rmem_default = 262144
> net.core.rmem_max = 4194304
> net.core.wmem_default = 262144
> net.core.wmem_max = 1048576
> net.ipv4.conf.all.rp_filter = 2
> net.ipv4.conf.default.rp_filter = 2
> fs.aio-max-nr = 1048576
> net.ipv4.ip_local_port_range = 9000 65500
> EOF
# sysctl -p

Adjust SELinux Mode:

Set SELinux to Permissive mode.

# sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/sysconfig/selinux
# setenforce permissive

Configure Linux Firewall:

Allow Oracle SQL* Net Listener port 1521/tcp in Linux Firewall.

# firewall-cmd --permanent --add-port=1521/tcp
success
# firewall-cmd --reload
success

Create Directories for Oracle 18c Database:

We are using following two directories, One for the RDBMS software and other for the Oracle Databases.

# mkdir -p /u01/app/oracle/product/18.3.0/dbhome_1
# mkdir -p /u02/oradata
# chown -R oracle:oinstall /u01 /u02
# chmod -R 775 /u01 /u02

Set Environment Variables in CentOS 7:

Use following commands to set environment variables for oracle user.

# su - oracle
$ cat >> ~/.bash_profile << EOF
> # Oracle Settings
> export TMP=/tmp
> export TMPDIR=$TMP
>
> export ORACLE_HOSTNAME=oracle-01.centlinux.com
> export ORACLE_UNQNAME=cdb1
> export ORACLE_BASE=/u01/app/oracle
> export ORACLE_HOME=$ORACLE_BASE/product/18.3.0/dbhome_1
> export ORA_INVENTORY=/u01/app/oraInventory
> export ORACLE_SID=cdb1
> export PDB_NAME=pdb1
> export DATA_DIR=/u02/oradata
>
> 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
> EOF

Install Oracle 18c on CentOS 7 in Silent Mode:

We have downloaded Oracle Database 18c (18.3) for Linux from Oracle website and transferred the zip file to our CentOS 7 virtual machine using WinSCP.

Switch to oracle user and unzip downloaded zip file.

# su - oracle
# unzip LINUX.X64_180000_db_home.zip -d $ORACLE_HOME

Start Oracle Database 18c installation in Silent mode.

$ cd $ORACLE_HOME
$ ./runInstaller -ignorePrereq -waitforcompletion -silent 
> oracle.install.option=INSTALL_DB_SWONLY 
> ORACLE_HOSTNAME=${ORACLE_HOSTNAME} 
> UNIX_GROUP_NAME=oinstall 
> INVENTORY_LOCATION=${ORA_INVENTORY} 
> ORACLE_HOME=${ORACLE_HOME} 
> ORACLE_BASE=${ORACLE_BASE} 
> oracle.install.db.InstallEdition=EE 
> oracle.install.db.OSDBA_GROUP=dba 
> oracle.install.db.OSBACKUPDBA_GROUP=backupdba 
> oracle.install.db.OSDGDBA_GROUP=dgdba 
> oracle.install.db.OSKMDBA_GROUP=kmdba 
> oracle.install.db.OSRACDBA_GROUP=racdba 
> SECURITY_UPDATES_VIA_MYORACLESUPPORT=false 
> DECLINE_SECURITY_UPDATES=true
Launching Oracle Database Setup Wizard...

[WARNING] [INS-13014] Target environment does not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2019-03-20_10-26-13PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: installActions2019-03-20_10-26-13PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
The response file for this session can be found at:
 /u01/app/oracle/product/18.3.0/dbhome_1/install/response/db_2019-03-20_10-26-13PM.rsp

You can find the log of this install session at:
 /tmp/InstallActions2019-03-20_10-26-13PM/installActions2019-03-20_10-26-13PM.log

As a root user, execute the following script(s):
        1. /u01/app/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/18.3.0/dbhome_1/root.sh

Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:
[oracle-01]

Execute /u01/app/oracle/product/18.3.0/dbhome_1/root.sh on the following nodes: 
[oracle-01]

Successfully Setup Software with warning(s). Moved the install session logs to:  /u01/app/oraInventory/logs/InstallActions2019-03-20_10-26-13PM 

Oracle Universal Installer is giving warning because we are installing on a system with 2 GB RAM, whereas Oracle recommends at least 8 GB RAM for Oracle Database 18c installation. Therefore, you can safely ignore this warning.

Oracle Database 18c has been installed. Now connect as root user and execute the post-installation scripts.

# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
# /u01/app/oracle/product/18.3.0/dbhome_1/root.sh
Check /u01/app/oracle/product/18.3.0/dbhome_1/install/root_oracle-01.centlinux.com_2019-03-20_22-42-29-680074976.log for the output of root script

Create Oracle Multitenant Database in Silent Mode:

Manually start default Oracle Listener.

$ lsnrctl start

LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 20-MAR-2019 22:47:53

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

Starting /u01/app/oracle/product/18.3.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/oracle-01/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle-01.centlinux.com)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Start Date                20-MAR-2019 22:47:53
Uptime                    0 days 0 hr. 0 min. 1 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/oracle-01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle-01.centlinux.com)(PORT=1521)))
The listener supports no services
The command completed successfully

Create an Oracle Multitenant Database in Silent mode as follows.

$ dbca -silent -createDatabase 
> -templateName General_Purpose.dbc 
> -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID} 
> -responseFile NO_VALUE 
> -characterSet AL32UTF8 
> -sysPassword 123 
> -systemPassword 123 
> -createAsContainerDatabase true 
> -numberOfPDBs 1 
> -pdbName ${PDB_NAME} 
> -pdbAdminPassword 123 
> -databaseType MULTIPURPOSE 
> -automaticMemoryManagement false 
> -totalMemory 800 
> -storageType FS 
> -datafileDestination "${DATA_DIR}" 
> -redoLogFileSize 50 
> -emConfiguration NONE 
> -ignorePreReqs
[WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards.
   CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
   ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards.
   CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
   ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'PDBADMIN' password entered does not conform to the Oracle recommended standards.
   CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
   ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/cdb1.
Database Information:
Global Database Name:cdb1
System Identifier(SID):cdb1
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log" for further details.

We have set a simple password, therefore dbca is giving us warnings.

Connect as root and execute following command to enable auto restart of CDB1 database.

# sed -i 's/:N$/:Y/g' /etc/oratab

Connect to CDB1 using sqlplus and enable Oracle Managed Files (OMF).

$ sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Wed Mar 20 23:56:25 2019
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0

SQL> ALTER SYSTEM SET DB_CREATE_FILE_DEST='/u02/oradata' SCOPE=BOTH;

System altered.

Alter PDB1 so it will be open automatically at the time of database startup of CDB1 Database.

SQL> ALTER PLUGGABLE DATABASE PDB1 SAVE STATE;

Pluggable database altered.

Setup AutoStart of Oracle 18c Database and Listener:

To AutoStart Oracle 18c Database and Listener we must create a systemd service as follows:

# vi /usr/lib/systemd/system/dbora.service

And add following directives therein.

[Unit]
Description=Oracle Database Service
After=network.target
 
[Service]
Type=forking
ExecStart=/u01/app/oracle/product/18.3.0/dbhome_1/bin/dbstart /u01/app/oracle/product/18.3.0/dbhome_1
ExecStop=/u01/app/oracle/product/18.3.0/dbhome_1/bin/dbshut /u01/app/oracle/product/18.3.0/dbhome_1
User=oracle
TimeoutSec=300s
 
[Install]
WantedBy=multi-user.target

Start and enable dbora.service.

# systemctl daemon-reload
# systemctl enable dbora.service
Created symlink from /etc/systemd/system/multi-user.target.wants/dbora.service to /usr/lib/systemd/system/dbora.service.
# systemctl start dbora.service
# systemctl status dbora.service
â dbora.service - Oracle Database Service
   Loaded: loaded (/usr/lib/systemd/system/dbora.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-03-21 09:13:28 PKT; 1min 31s ago
  Process: 12004 ExecStart=/u01/app/oracle/product/18.3.0/dbhome_1/bin/dbstart /u01/app/oracle/product/18.3.0/dbhome_1 (code=exited, status=0/SUCCESS)
 Main PID: 10315 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/dbora.service
           ââ12017 /u01/app/oracle/product/18.3.0/dbhome_1/bin/tnslsnr LISTEN...
           ââ12505 ora_mz04_cdb1
           ââ12507 ora_q005_cdb1
           ââ12513 ora_mz03_cdb1
           ââ12553 ora_qm03_cdb1

Mar 21 09:12:55 oracle-01.centlinux.com systemd[1]: Starting Oracle Database Se...
Mar 21 09:12:55 oracle-01.centlinux.com dbstart[12004]: Processing Database ins...
Mar 21 09:13:28 oracle-01.centlinux.com systemd[1]: Started Oracle Database Ser...
Hint: Some lines were ellipsized, use -l to show in full.

We have successfully install Oracle 18c on CentOS 7 server.

Conclusion – Install Oracle 18c on CentOS 7:

In this guide, you have learned, how to install Oracle 18c on CentOS 7 or other Redhat based Linux OS.