Oracle 19c on Oracle Linux 7

Preface

Oracle Linux (OL, formerly known as Oracle Enterprise Linux) is a Linux distribution packaged and freely distributed by Oracle. It is compiled from Red Hat Enterprise Linux (RHEL) source code, replacing Red Hat branding with Oracle's. Users can freely download Oracle Linux through Oracle's E-delivery service (Oracle Software Delivery Cloud) or from a variety of mirror sites, and can deploy and distribute it without cost.

Oracle Database 19c is the long term support release of the Oracle Database 12c and 18c family of products, offering customers Premier and Extended Support through to March 2023 and March 2026 respectively. This tutorial installs the Enterprise Edition, but the Standard Edition 2 will work too.

In this tutorial linux and oracle are installed in a virtual machine under VMware Workstation 15 Player. Oracle VM VirtualBox should also work, probably with small modifications.

Installation

Download Linux ISO

Download Oracle Linux from https://edelivery.oracle.com

  • Sign In with your oracle credentials
  • Search for “Oracle Linux”
  • Add “DLP: Oracle Linux 7.7.0.0.0 (Oracle Linux)” to cart
  • Checkout and select “x86 64 bit” asl platform
  • Accept license terms
  • Download “V983339-01.iso Oracle Linux Release 7 Update 7 for x86 (64 bit), 4.4 GB

Create Virtual Machine

Start VMware Workstation 15 Player

  • Create a New Virtual Machine
  • Installer Disc image file (iso): V983339-01.iso
  • Virtual machine name: vmora19
  • Location: E:\VM\vmora19
  • Maximum disk size (GB): 120
  • Store virtual disk as a single file
  • Customize Hardware
    • Memory: 3 GB
    • Processors: 2
    • Network Adapter: Bridged
  • Power on this virtual machine after creation

Install Linux

Show all config steps

At this point interrupt the graphical setup. Before proceeding, apply the oracle 19c preinstall package which will create the user “oracle” we want to use in the GUI.

Update and DB Preinstall

Open a ssh terminal to “vmora19” and login as root with the password defined before.

Update the software:

yum -y update

Run Oracle 19c preinstall:

yum install -y oracle-database-preinstall-19c

Set a password for user “oracle” so we can login:

passwd oracle

Optional: Assign a fixed IP in Swisscom Router

Reboot:

reboot

Finish graphical setup

Setup SSH key auth for root

Create ~/.ssh and key

ssh-keygen -t rsa -b 4096
    <enter>
    <enter>
    <enter>

Load my personal key in PuTTYgen, and copy public key to the clipboard

Add my personal key to authorized keys:

nano ~/.ssh/authorized_keys
<paste>

Turn of password auth for ssh:

nano /etc/ssh/sshd_config
...
PasswordAuthentication no
...

Restart ssh:

service sshd restart

Leave SSH terminal yet open in case.

Create and test PuTTY session for root:

  • Session
    • Host Name: vmora19
    • Port: 22 / SSH
  • Connection
    • Data
      • Auto-login username: root
    • SSH
      • Auth
        • Private key file: (location of my ppk)
  • Session
    • Saved sessions: vmora19 - root
    • Save

Test if autologin successful

Create logo at http://www.network-science.de/ascii/

  • Text: vmora19
  • Font: slant
  • Reflection: no
  • Adjustment: center
  • Stretch: no
  • Width: 80
  • do it!

Copy logo to clipboard, and paste to motd

nano /etc/motd
<paste>

Install rlwrap for cursor keys in sqlplus

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum -y install rlwrap

Make SELinux permissive

nano /etc/selinux/config
...
SELINUX=permissive
setenforce Permissive

Disable firewall

systemctl stop firewalld
systemctl disable firewalld

Create oracle folders

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

Enable SSH Login for User oracle

Similar as for root

su oracle
ssh-keygen -t rsa -b 4096
    <enter>
    <enter>
    <enter>
nano ~/.ssh/authorized_keys
<paste my personal public key>

Create PuTTY Session

  • Load session “vmora19 - root”
  • Change auto-login username: oracle
  • Save session as “vmora19 - oracle”

Test if working

exit
reboot

Get Oracle Database 19c Software

Download Database 19c software for linux:

Use Filezilla to connect as oracle with SFTP/SSH, then upload LINUX.X64_193000_db_home.zip to /home/oracle

Preparations as user oracle

Create scripts

Make scripts executable:

chmod u+x ~/scripts/*.sh

Append to .bash_profile:

~/.bash_profile
. /home/oracle/scripts/setEnv.sh
alias sqlplus="rlwrap sqlplus"

Unpack DB software and start installation

Login as oracle in GUI and open a terminal.

Check if settings were applied

cd $ORACLE_HOME
unzip -oq ~/LINUX.X64_193000_db_home.zip
./runInstaller

Install Software with Oracle Database 19c Installer

Set up the software only, database will be created later with DBCA .

Show all config steps

Create Database with DBCA

Login as oracle in GUI and open a terminal.

Start up listener and run DCBA:

lsnrctl start
dbca

Show all config steps

Reboot server

Post-installaton steps

As root

Edit /etc/oratab and set the restart flag 'Y' to have cdb1 started by dbstart:

nano /etc/oratab
...
cdb1:/u01/app/oracle/product/19.3.0/dbhome_1:Y
...

As oracle

Manually start listener and db:

lsnrctl start
 ~/scripts/start_all.sh

Enable Oracle Managed Files (OMF) and make sure the PDB starts when the instance starts.

sqlplus / as sysdba
--
alter system set db_create_file_dest='/u02/oradata';
alter pluggable database pdb1 open;
alter pluggable database pdb1 save state;

Automating Database Startup and Shutdown

This is to be done as root:

Create /etc/init.d/dbora

Set the script privileges to 750

chmod 750 /etc/init.d/dbora

Associate the “dbora” service with the appropriate run levels and set it to auto-start

chkconfig --add dbora

You can stop and start the database as root using the service, which is what will happen on a reboot:

service dbora stop
service dbora start

Enable Enterprise Manager Express

As oracle:

sqlplus / as sysdba
--
exec dbms_xdb_config.sethttpsport(5500);

Test in browser

Administration

Create tablespaces in pdb1

mkdir /u02/oradata/CDB1/PDB1
chmod 750 /u02/oradata/CDB1/PDB1
sqlplus / as sysdba

Create and list tablespaces:

ALTER SESSION SET CONTAINER = pdb1;
CREATE TABLESPACE lu_agrar_dat  DATAFILE '/u02/oradata/CDB1/PDB1/lu_agrar_dat.dbf' SIZE 10M  AUTOEXTEND ON NEXT 10M;
CREATE TABLESPACE lu_agrar_inx  DATAFILE '/u02/oradata/CDB1/PDB1/lu_agrar_inx.dbf' SIZE 10M  AUTOEXTEND ON NEXT 10M;
SELECT TABLESPACE_NAME, STATUS, CONTENTS FROM DBA_TABLESPACES;

TABLESPACE_NAME                STATUS    CONTENTS
------------------------------ --------- ---------------------
SYSTEM                         ONLINE    PERMANENT
SYSAUX                         ONLINE    PERMANENT
UNDOTBS1                       ONLINE    UNDO
TEMP                           ONLINE    TEMPORARY
USERS                          ONLINE    PERMANENT
LU_AGRAR_DAT                   ONLINE    PERMANENT
LU_AGRAR_INX                   ONLINE    PERMANENT
7 rows selected.

Check new tablespaces are available in pdb1 only:

ALTER SESSION SET CONTAINER = CDB$ROOT;
SELECT TABLESPACE_NAME, STATUS, CONTENTS FROM DBA_TABLESPACES;

TABLESPACE_NAME                STATUS    CONTENTS
------------------------------ --------- ---------------------
SYSTEM                         ONLINE    PERMANENT
SYSAUX                         ONLINE    PERMANENT
UNDOTBS1                       ONLINE    UNDO
TEMP                           ONLINE    TEMPORARY
USERS                          ONLINE    PERMANENT

Drop tablespaces in pdb1

sqlplus / as sysdba

List and drop tablespaces

ALTER SESSION SET CONTAINER = pdb1;
SELECT TABLESPACE_NAME, STATUS, CONTENTS FROM DBA_TABLESPACES;
DROP TABLESPACE lu_agrar INCLUDING CONTENTS AND DATAFILES;

Monitor Used Space

Connect

sqlplus / as sysdba

Check used space per tablespace:

select tablespace_name, round(bytes/1024/1024) MB, round(bytes/1024/1024/1024,3) GB from cdb_data_files;

Sample output:

TABLESPACE_NAME                        MB         GB
------------------------------ ---------- ----------
USERS                                   5       .005
UNDOTBS1                               65       .063
SYSTEM                                840        .82
SYSAUX                                580       .566
SYSTEM                                290       .283
SYSAUX                                430        .42
UNDOTBS1                              220       .215
USERS                                   5       .005
LU_AGRAR_DAT                           50       .049
LU_AGRAR_INX                           50       .049

If you just want the summary of user data:

select round(sum(bytes)/1024/1024) MB, round(sum(bytes)/1024/1024/1024,3) GB from cdb_data_files
where tablespace_name not like 'SYS%' and tablespace_name not like 'UNDO%';

Sample output:

        MB         GB
---------- ----------
      2535      2.476

TNSNAMES entry for clients

VMORA19 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = vmora19)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb1)
    )
  )

Comments and Discussion

Enter your comment. Wiki syntax is allowed: