Author Photo

Being a Linux Enthusiast and a Fan of Open Source Software, I created Ahmer’s SysAdmin Recipes blog to share my experiences with other System Administrators. The curiosity doesn’t let me stop; therefore, I am constantly trying to learn new software tools and techniques. Whereas I also have the passion and the patience to teach the others.

I am always ready to accept new challenges and wish to explore the areas, that I haven’t worked on. Please give me your feedback and help me improve this blog.

Friday, 22 March 2019

Install Oracle Database 18c on CentOS 7

Install Oracle Database 18c on CentOS 7Oracle 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 Warhousing / 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 Database 18c on CentOS 7 on-premises 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 18c: From Novice to Professional to have a third party perspective about Oracle Database 18c.

 

System Specification:

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

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

 

Configure Local DNS Resolver in CentOS 7:

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.example.com using ssh as root user and execute following command.

[root@oracle-01 ~]# cat >> /etc/hosts << EOF > 192.168.116.148 oracle-01.example.com oracle-01 > EOF

Verify name resolution by using ping command.

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

 

Disable Transparent Hugepages in CentOS 7:

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.

[root@oracle-01 ~]# 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.

[root@oracle-01 ~]# 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.

[root@oracle-01 ~]# 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.

[root@oracle-01 ~]# systemctl reboot

After reboot, check status of Transparent HugePages again.

[root@oracle-01 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never]

Transparent Hugepages has been disabled.

 

Install Oracle Database 18c Prerequisite Packages on CentOS 7:

Install prerequisite software packages using yum command.

[root@oracle-01 ~]# 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++ ... Installed: bc.x86_64 0:1.06.95-13.el7 compat-libcap1.x86_64 0:1.10-7.el7 compat-libstdc++-33.x86_64 0:3.2.3-72.el7 glibc-devel.x86_64 0:2.17-260.el7_6.3 ksh.x86_64 0:20120801-139.el7 libX11.x86_64 0:1.6.5-2.el7 libXau.x86_64 0:1.0.8-2.1.el7 libXi.x86_64 0:1.7.9-1.el7 libXrender.x86_64 0:0.9.10-1.el7 libXrender-devel.x86_64 0:0.9.10-1.el7 libXtst.x86_64 0:1.2.3-1.el7 libaio-devel.x86_64 0:0.3.109-13.el7 libstdc++-devel.x86_64 0:4.8.5-36.el7 libxcb.x86_64 0:1.13-1.el7 smartmontools.x86_64 1:6.5-1.el7 sysstat.x86_64 0:10.1.5-17.el7 Dependency Installed: glibc-headers.x86_64 0:2.17-260.el7_6.3 kernel-headers.x86_64 0:3.10.0-957.5.1.el7 libX11-common.noarch 0:1.6.5-2.el7 libX11-devel.x86_64 0:1.6.5-2.el7 libXau-devel.x86_64 0:1.0.8-2.1.el7 libXext.x86_64 0:1.3.3-3.el7 libxcb-devel.x86_64 0:1.13-1.el7 lm_sensors-libs.x86_64 0:3.4.0-6.20160601gitf9185e5.el7 mailx.x86_64 0:12.5-19.el7 xorg-x11-proto-devel.noarch 0:2018.4-1.el7 Updated: glibc.x86_64 0:2.17-260.el7_6.3 Dependency Updated: glibc-common.x86_64 0:2.17-260.el7_6.3 Complete!

 

Create Oracle Database 18c User and Groups:

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

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

 

Set Security Limits for Oracle User in CentOS 7:

Execute follwing command to set security limits for oracle user.

[root@oracle-01 ~]# 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 in CentOS 7:

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

[root@oracle-01 ~]# 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 [root@oracle-01 ~]# sysctl -p

 

Adjust SELinux Mode in CentOS 7:

Set SELinux to Permissive mode.

[root@oracle-01 ~]# sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/sysconfig/selinux [root@oracle-01 ~]# setenforce permissive

 

Open Service Ports in CentOS 7 Firewall:

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

[root@oracle-01 ~]# firewall-cmd --permanent --add-port=1521/tcp success [root@oracle-01 ~]# firewall-cmd --reload success

 

Create Directories for Oracle Database 18c:

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

[root@oracle-01 ~]# mkdir -p /u01/app/oracle/product/18.3.0/dbhome_1 [root@oracle-01 ~]# mkdir -p /u02/oradata [root@oracle-01 ~]# chown -R oracle:oinstall /u01 /u02 [root@oracle-01 ~]# chmod -R 775 /u01 /u02

 

Set Environment Variables in CentOS 7:

Use following commands to set environment variables for oracle user.

[root@oracle-01 ~]# su - oracle [oracle@oracle-01 ~]$ cat >> ~/.bash_profile << EOF > # Oracle Settings > export TMP=/tmp > export TMPDIR=\$TMP > > export ORACLE_HOSTNAME=oracle-01.example.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

 

Installing Oracle Database 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.

[root@oracle-01 ~]# su - oracle [oracle@oracle-01 ~]# unzip LINUX.X64_180000_db_home.zip -d $ORACLE_HOME

Start Oracle Database 18c installation in Silent mode.

[oracle@oracle-01 ~]$ cd $ORACLE_HOME [oracle@oracle-01 dbhome_1]$ ./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.

[root@oracle-01 ~]# /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. [root@oracle-01 ~]# /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.example.com_2019-03-20_22-42-29-680074976.log for the output of root script

 

Create Oracle 18c Multitenant Database in Silent Mode:

Manually start default Oracle Listener.

[oracle@oracle-01 ~]$ 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.example.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.example.com)(PORT=1521))) The listener supports no services The command completed successfully

Create an Oracle 18c Multitenant Database in Silent mode as follows.

[oracle@oracle-01 ~]$ 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.

[root@oracle-01 ~]# sed -i 's/:N$/:Y/g' /etc/oratab

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

[oracle@oracle-01 ~]$ 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.

 

Autostart Oracle 18c Database and Listener in CentOS 7:

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

[root@oracle-01 ~]# 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.

[root@oracle-01 ~]# systemctl daemon-reload [root@oracle-01 ~]# systemctl enable dbora.service Created symlink from /etc/systemd/system/multi-user.target.wants/dbora.service to /usr/lib/systemd/system/dbora.service. [root@oracle-01 ~]# systemctl start dbora.service [root@oracle-01 ~]# 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... ââ12128 ora_pmon_cdb1 ââ12130 ora_clmn_cdb1 ââ12132 ora_psp0_cdb1 ââ12134 ora_vktm_cdb1 ââ12138 ora_gen0_cdb1 ââ12142 ora_mman_cdb1 ââ12144 ora_gen1_cdb1 ââ12147 ora_diag_cdb1 ââ12149 ora_ofsd_cdb1 ââ12153 ora_dbrm_cdb1 ââ12155 ora_vkrm_cdb1 ââ12157 ora_svcb_cdb1 ââ12159 ora_pman_cdb1 ââ12161 ora_dia0_cdb1 ââ12163 ora_dbw0_cdb1 ââ12165 ora_lgwr_cdb1 ââ12167 ora_ckpt_cdb1 ââ12169 ora_smon_cdb1 ââ12171 ora_smco_cdb1 ââ12173 ora_w000_cdb1 ââ12176 ora_reco_cdb1 ââ12178 ora_w001_cdb1 ââ12180 ora_lreg_cdb1 ââ12182 ora_pxmn_cdb1 ââ12186 ora_mmon_cdb1 ââ12188 ora_mmnl_cdb1 ââ12190 ora_d000_cdb1 ââ12192 ora_s000_cdb1 ââ12194 ora_tmon_cdb1 ââ12197 ora_m000_cdb1 ââ12207 ora_tt00_cdb1 ââ12209 ora_tt01_cdb1 ââ12211 ora_tt02_cdb1 ââ12214 ora_aqpc_cdb1 ââ12217 ora_w002_cdb1 ââ12222 ora_p000_cdb1 ââ12224 ora_p001_cdb1 ââ12228 ora_w003_cdb1 ââ12265 ora_w004_cdb1 ââ12376 ora_cjq0_cdb1 ââ12451 ora_qm02_cdb1 ââ12453 ora_q001_cdb1 ââ12458 ora_q003_cdb1 ââ12461 ora_q004_cdb1 ââ12468 ora_j000_cdb1 ââ12472 ora_j001_cdb1 ââ12490 ora_m001_cdb1 ââ12492 ora_m002_cdb1 ââ12498 ora_mz02_cdb1 ââ12505 ora_mz04_cdb1 ââ12507 ora_q005_cdb1 ââ12513 ora_mz03_cdb1 ââ12553 ora_qm03_cdb1 Mar 21 09:12:55 oracle-01.example.com systemd[1]: Starting Oracle Database Se... Mar 21 09:12:55 oracle-01.example.com dbstart[12004]: Processing Database ins... Mar 21 09:13:28 oracle-01.example.com systemd[1]: Started Oracle Database Ser... Hint: Some lines were ellipsized, use -l to show in full.

We have successfully installed Oracle Database 18c on CentOS 7 server.

Install Oracle Database 18c on CentOS 7


YOU MIGHT ALSO LIKE:

11 comments:

  1. IT IS VERY HELP FULL ARTICALS THANK YOU.

    ReplyDelete
  2. work perfectly on my vmware vm ....ty man

    ReplyDelete
  3. how do you connect to this new oracle db remotely?

    ReplyDelete
  4. Very helpful guide. Thank you! God bless you!

    ReplyDelete
  5. HI
    I am getting the below Error. Please help me.

    [oracle@oracledb ~]$ lsnrctl start
    -bash: lsnrctl: command not found
    [oracle@oracledb ~]$

    ReplyDelete
    Replies
    1. Looks the command path is not included in PATH environment variable. Try Following commands.

      export PATH=/u01/app/oracle/product/18.3.0/dbhome_1/bin/:$PATH
      echo "export PATH=/u01/app/oracle/product/18.3.0/dbhome_1/bin/:$PATH" >> ~/.bash_profile
      lsnrctl start

      Delete
    2. Thanks you very much. It is working fine.

      But i want to manage DB through remotely . Could you tell me which oracle database client is best and also open source

      Thanks
      Ziaul

      Delete
    3. Please use Oracle Database Client.

      Delete