Install Oracle on a Linux VM

Peter Goldthorp, Dito February 2023

Oracle provides templates to automate the creation of a Single Instance, Oracle Restart (Single Instance/HA) or Oracle Real Application Clusters (RAC) configurations in OLVM environments. These are used in combination with a CLI utility called DeployCluster.

Watch an Oracle video for an overview of the steps to provision Oracle Database VMs using DeployCluster then:

Create a VM template in OLVM

  1. Download the latest VM database template from Oracle. The template is delivered as 2 zip files that need to be concatenated together to form a single .ova file. A readme in the download describes the process for doing this. Follow the readme instructions and stage the .ova file on the (CRD host) jump server.
  2. .ova files must be accessible from a KVM Host. To avoid using expensive storage to stage files for upload, export an NFS share from the jump host and mount it on one of the BMS servers.
  3. Import the .ova file as a template

Download and setup the DeployCluster utility

  1. Download the DeployCluster tool from the VM database template page . Look for a link titled “For OLVM: DeployCluster Tool for Oracle KVM/OLVM V4 Download” near the bottom of the page.

  2. Copy the file to the jump server and unzip it.

  3. Edit the deploycluster.ini to specify connection details for the OLVM Engine. Tip: create a separate logs directory and set DEPLOYCLUSTER_AUTOLOG_DIR=logs/ to save log files into a separate folder.

  4. Issue a deploycluster command to test the connection. Example:

     ./deploycluster -L
     Oracle DB/RAC Deploycluster (v4.0.4) for Oracle Linux Virtualization Manager - (c) 2021 Oracle Corporation
     Started on Fri Nov 11 18:05:51 UTC 2022 by user peter_goldthorp
     Using: ./deploycluster -L
     [LIST MODE]
    
     INFO: Reading defaults from deploycluster.ini
     INFO: Connecting to OLVM host olvm32.c.dito-oracle-migration-dev.internal (Cluster: Default DataCenter: Default) processing request...
    
     ---------------------------------------------------------------------------------------------------------
     Vm name: dockertest (dockertest.localdomain)                     [69eabc74-15c1-41a2-bbbc-fcabf37abcf4]
     Status: up   Memory: 1.00G [1073741824]   Vcpus: 1 (1:1:1)
     Description:
     Comment:
     Nics:
     - nic1 [56:6f:4b:6e:00:09] (ovirtmgmt)
         - 10.2.0.116
         - fe80::7368:f5c3:7a23:48be
     Disks:
     - dockertest_Disk1 (5.00G/50.00G, image)                     [a872f80e-6472-411c-98e8-c901ca26ae5a]
     ---------------------------------------------------------------------------------------------------------
    
     INFO: Listing completed in 1.435s
     INFO: Logfile at: 'deploycluster31.log'
    
    
  5. Verify the VM template has been loaded:

     ./deploycluster -LT
     Oracle DB/RAC Deploycluster (v4.0.4) for Oracle Linux Virtualization Manager - (c) 2021 Oracle Corporation
     Started on Fri Nov 11 18:34:24 UTC 2022 by user peter_goldthorp
     Using: ./deploycluster -LT
     [LIST MODE]
    
     INFO: Reading defaults from deploycluster.ini
     INFO: Connecting to OLVM host olvm32.c.dito-oracle-migration-dev.internal (Cluster: Default DataCenter: Default) processing request...
    
     ------------------------------------------------------------------------------------------------------
     Template: Blank Ver: 0                                        [00000000-0000-0000-0000-000000000000]
     Status: ok   Memory: 1.00G [1073741824]   Vcpus: 1 (1:1:1)
     Description: Blank template
     Comment:
     Nics:
     Disks:
     ------------------------------------------------------------------------------------------------------
     Template: OLVM-OL8U5-19140DBRAC-KVM Ver: 1                    [e56088a0-7843-49b5-8c0e-183cb1809e3f]
     Status: ok   Memory: 4.00G [4294967296]   Vcpus: 2 (2:1:1)
     Description: OL8.5-19.14 Oracle Database Templates For OLVM
     Comment: admin
     Nics:
     - nic1 [mac not assigned] (ovirtmgmt)
     - nic2 [mac not assigned] (ovirtmgmt)
     Disks:
     - Disk_OL8U5_x86_64-olvm-b113 (2.75G/37.00G, image)          [7015a019-5325-47a1-88bb-0ee2bcb2a9e5]
     - OL8U5Oracle19140DBRAC_x86_64 (26.25G/60.00G, image)        [13043c1b-4628-41d8-8d81-62c938d9cbec]
     ------------------------------------------------------------------------------------------------------
    
     INFO: Listing completed in 511ms
     INFO: Logfile at: 'deploycluster32.log'
    

Create a Single Instance or Oracle RAC database

Follow the steps described in the Oracle technical paper titled Using Deploycluster Tool with OLVM

Create a Single Instance HA database with ASM disks

The Oracle paper does not explain how to create a HA single instance. The following is a worked example:

  1. Create a netconfig.ini file vi netconfig-demo.ini

     # Sample Single Instance or Single Instance/HA (Oracle Restart)
     NODE1=oracle-demo
     NODE1IP=10.2.0.92
    
     # Common data
     PUBADAP=eth0
     PUBMASK=255.255.255.0
     PUBGW=10.2.0.254
     DOMAINNAME=localdomain  # May be blank
     DNSIP=""  # Starting from 2013 Templates allows multi value
    
     # Single Instance (description in params.ini)
     CLONE_SINGLEINSTANCE_HA=yes  # Setup Single Instance/HA (Oracle Restart)
    
  2. Pre-create disk for ASM usage. This example creates 5, 20G disks on the ssd-lun-5651 storage domain.

     ./deploycluster --createdisk namefmt=oracle-demo-disk%02d,count=5,size=20g,storagedomain=ssd-lun-5651
    
  3. Clone the template loaded earlier. Note: the example assumes only one template matches the OLVM* wildcard.

     ./deploycluster -C OLVM* --cloneattach oracle-demo-disk* --clonetype thin -N netconfig-demo.ini
    
  4. Start the VM and install Oracle

     ./deploycluster  -N netconfig-demo.ini
    
  5. Monitor installation progress (using the IP address specified in the netconfig.ini file)

     ssh -i ~/.ssh/id_rsa cloud-user@10.2.0.92 "tail -f /u01/racovm/buildsingle.log"
    

Post Install

The template creates a database called ORCL with a single container called ORCLPDB. The ASM instance is called +ASM and has a single disk group called +OCRVFDG.

ASM Administration

  1. Connect to ASM instance

    • asmcmd:

        ORACLE_HOME=/u01/app/19c/grid
        ORACLE_SID=+ASM
      
        asmcmd
        ASMCMD> lsdg
        State    Type    Rebal  Sector  Logical_Sector  Block       AU  Total_MB     Voting_files  Name
        MOUNTED  EXTERN  N         512             512   4096  4194304    102380                N  OCRVFDG/
        ASMCMD> exit
      
    • SQL*Plus:

        ORACLE_HOME=/u01/app/19c/grid
        ORACLE_SID=+ASM
      
        sqlplus / as sysasm
      
        SQL*Plus: Release 19.0.0.0.0 - Production on Fri Nov 11 20:40:47 2022
        Version 19.14.0.0.0
      
        Copyright (c) 1982, 2021, Oracle.  All rights reserved.
      
      
        Connected to:
        Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
        Version 19.14.0.0.0
      
        SQL> select * from V$ASM_CLIENT;
      
        GROUP_NUMBER INSTANCE_NAME
        ------------ ----------------------------------------------------------------
        DB_NAME  CLUSTER_NAME			 STATUS
        -------- ------------------------------- ------------
        SOFTWARE_VERSION
        ------------------------------------------------------------
        COMPATIBLE_VERSION						 CON_ID
        ------------------------------------------------------------ ----------
            1 +ASM
        +ASM	 ASM				 CONNECTED
        19.0.0.0.0
        19.0.0.0.0							      0
      
            1 ORCL
        ORCL	 ASM				 CONNECTED
        19.0.0.0.0
        19.0.0.0.0							      0
      
      
  2. ASM Documentation

Database Administration

  1. Connect to Oracle instance

     ORACLE_SID=ORCL
     ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1
    
     sqlplus / as sysdba
    
     alter session set container=orclpdb
    
  2. Create tablespaces (example)

     create BIGFILE tablespace PR_PROPERTY_DATA2 datafile '+OCRVFDG' SIZE 11G AUTOEXTEND ON;
     create BIGFILE tablespace PR_CORP_DATA2 datafile '+OCRVFDG' SIZE 3G AUTOEXTEND ON;
     create BIGFILE tablespace MLS_DATA2 datafile '+OCRVFDG' SIZE 1G AUTOEXTEND ON;
     create BIGFILE tablespace RNT_DATA2 datafile '+OCRVFDG' SIZE 3G AUTOEXTEND ON;
     create tablespace MGT_DATA2 datafile '+OCRVFDG' SIZE 500M AUTOEXTEND ON;
     create tablespace SPATIAL_INDEX2 datafile '+OCRVFDG' SIZE 1G AUTOEXTEND ON;
     create tablespace SPATIAL_WORK2 datafile '+OCRVFDG' SIZE 1G AUTOEXTEND ON;
    
  3. Use Oracle Data Pump to upgrade and import a schema (RNTMGR2 in the example) from an 11.2.0.4 (or later) database

    • Find the DATA_PUMP_DIR location

        sqlplus / as sysdba
      
        alter session set container=orclpdb
        select * from dba_directories where directory_name='DATA_PUMP_DIR';
      
    • Stage the expdp file in the DATA_PUMP_DIR location identified in the previous step

    • Run impdp

        impdp system@oracle-asm2.localdomain:1521/orclpdb \
        directory=DATA_PUMP_DIR \
        dumpfile=vis22datapump_rntmgr2.dmp \
        schemas=RNTMGR2 exclude=statistics \
        transform=lob_storage:securefile
      
    • Compute database statistics

        sqlplus system@oracle-asm2.localdomain:1521/orclpdb
        exec dbms_utility.analyze_schema('RNTMGR2', 'COMPUTE')
      

Install Oracle from media

  1. Download an Oracle Enterprise Linux ISO file from https://yum.oracle.com/oracle-linux-isos.html
  2. Load the ISO file into OLVM
  3. Use the image to provision a VM
  4. SSH into the newly provisioned VM from the jump host using the -Y flag. This will provide the X11 support which the Oracle Installer requires
  5. Run dnf update to install latest OS patches

  6. Download the database rpm’s and install:

     sudo dnf -y install oracle-database-preinstall-19c-1.0-2.el8.x86_64.rpm
     sudo dnf -y install oracle-database-ee-19c-1.0-1.x86_64.rpm
    

Post Install

Create database

Use /etc/init.d/oracledb_ORCLCDB-19c configure to create container database called ‘ORCLCDB with a single PDB ORCLPDB1`

su - root

/etc/init.d/oracledb_ORCLCDB-19c configure

less /opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log

firewall-cmd --get-active-zones
firewall-cmd --zone=public --add-port=1521/tcp --permanent
firewall-cmd --reload

exit

Setup Oracle Environment

Edit the .bash_profile file in /home/oracle/

vi .bash_profile

export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export ORACLE_SID=ORCLCDB
export PDB_NAME=ORCLPDB1
export ORAENV_ASK=NO
. /opt/oracle/product/19c/dbhome_1/bin/oraenv

Install rlwrap

Download the latest rpm from https://yum.oracle.com/repo/OracleLinux/OL8/developer/EPEL/x86_64/index.html, install using dnf and create aliases. Example:

wget https://yum.oracle.com/repo/OracleLinux/OL8/developer/EPEL/x86_64/getPackage/rlwrap-0.45.2-1.el8.x86_64.rpm
sudo dnf localinstall rlwrap-0.45.2-1.el8.x86_64.rpm
echo "alias sqlplus='rlwrap sqlplus'" >> /home/oracle/.bash_profile
echo "alias rman='rlwrap rman'" >> /home/oracle/.bash_profile

Database setup

Set system password, switch to archivelog mode.

sqlplus / as sysdba

alter user system identified by &system_password;
alter user sys identified by &sys_password;

shutdown immediate
startup mount
alter database archivelog;
alter database open;

archive log list

select name, open_mode from v$pdbs;
alter pluggable database orclpdb1 open;

Native network encryption

  1. Check encryption status

     sqlplus / as sysdba
    
     SQL> select network_service_banner
         from  v$session_connect_info
         where sid in (select distinct sid from v$mystat);
    
     NETWORK_SERVICE_BANNER
     --------------------------------------------------------------------------------
     Oracle Bequeath NT Protocol Adapter for Linux: Version 21.0.0.0.0 - Production
     Authentication service for Linux: Version 21.0.1.0.0 - Production
     Encryption service for Linux: Version 21.0.1.0.0 - Production
     Crypto-checksumming service for Linux: Version 21.0.1.0.0 - Production
    

    This example shows native network encryption is available but has not been enabled

  2. Edit sqlnet.ora in $ORACLE_HOME/network/admin append:

     SQLNET.ENCRYPTION_SERVER = REQUIRED
     SQLNET.ENCRYPTION_TYPES_SERVER = (AES256)
     SQLNET.CRYPTO_CHECKSUM_SERVER = REQUIRED
     SQLNET.CRYPTO_CHECKSUM_TYPES_SERVER = (SHA512)
    
  3. Restart the TNS Listener

     lsnrctl stop
     lsnrctl start
    
  4. Restest

     SQL> select network_service_banner
         from  v$session_connect_info
         where sid in (select distinct sid from v$mystat);
    
     NETWORK_SERVICE_BANNER
     --------------------------------------------------------------------------------
     Oracle Bequeath NT Protocol Adapter for Linux: Version 21.0.0.0.0 - Production
     Authentication service for Linux: Version 21.0.1.0.0 - Production
     Encryption service for Linux: Version 21.0.1.0.0 - Production
     AES256 Encryption service adapter for Linux: Version 21.0.1.0.0 - Production
     Crypto-checksumming service for Linux: Version 21.0.1.0.0 - Production
     SHA512 Crypto-checksumming service adapter for Linux: Version 21.0.1.0.0 - Production
    

    The AES256 Encryption service adapter and SHA512 Crypto-checksumming service adapter entries indicate native network encryption has been enabled

Patch the database

Download and apply the latest Critical Patch Updates

Copyright © Dito LLC, 2023