Od
Databases Azure

Oracle Database Client 19c on OEL 8 on Azure User Guide

| Product: Oracle Database Client 19c on OEL 8 on Azure

Videos

Overview: Oracle Database Client 19c on OEL 8 on Azure: overview
Launch and log in: Oracle Database Client 19c on OEL 8 on Azure: launch and log in
Deep Dive: Oracle Database Client 19c on OEL 8 on Azure: deep dive

Overview

This guide covers deploying cloudimg's Oracle Database Client 19c on OEL 8 image on Microsoft Azure. Oracle Database Client 19c is the set of tools and libraries an application or a DBA uses to reach a remote Oracle database: SQL*Plus, Oracle Net (tnsping, tnsnames.ora), SQL*Loader, Data Pump (expdp, impdp) and the OCI and JDBC client libraries. It does not include a database server: the VM connects out to an Oracle database you already run.

What's included in this VM image:

  • Oracle Database Client 19c, version 19.3.0.0.0 (Administrator install), in /u01/app/oracle/product/19.3.0/client_1
  • A dedicated oracle OS user, with an environment script at /home/oracle/setEnv.sh
  • SQL*Plus, tnsping, sqlldr, expdp, impdp and the rest of the Oracle Net client utilities
  • A starter tnsnames.ora (an example entry, commented out) and sqlnet.ora (TNSNAMES and EZCONNECT naming)
  • A system wide hook, /etc/profile.d/oracle-client.sh, so every Linux user on the VM finds the client tools on login
  • The Oracle software on its own 20 GB Azure data disk, mounted at /u01
  • Oracle Linux 8.10 with the Unbreakable Enterprise Kernel, SELinux enforcing
  • Azure Linux Agent (waagent) and cloud-init for provisioning
  • cloudimg's support team on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours

Platform: Microsoft Azure (Gen1 and Gen2 Hyper-V) Login user: the administrator username you choose when you deploy (azureuser in the examples below) Oracle Home: /u01/app/oracle/product/19.3.0/client_1 TNS Admin: /u01/app/oracle/product/19.3.0/client_1/network/admin

Prerequisites

Before deploying this image, make sure you have:

  1. An active Microsoft Azure subscription
  2. Access to the Azure Portal or the Azure CLI
  3. An SSH key pair for Linux VM access
  4. The hostname, port and service name of the Oracle database you want to connect to
  5. Network connectivity from the new VM to that database (usually TCP 1521 outbound)

Recommended VM size: Standard_B2s (2 vCPU, 4 GB RAM) or larger. The Oracle Client is a set of tools and libraries rather than a running service, so its needs are modest.

Step 1: Deploy the Virtual Machine

Option A: Azure Portal

  1. In the Azure Portal, open Marketplace and search for "Oracle Database Client 19c on OEL 8 cloudimg"
  2. Select the image and click Create
  3. Configure the basics:
  4. Subscription: your Azure subscription
  5. Resource group: create a new one or select an existing one
  6. Virtual machine name: a name for your VM
  7. Region: your preferred Azure region
  8. Size: Standard_B2s recommended
  9. Under Administrator account, select SSH public key and enter your key
  10. Under Inbound port rules, allow SSH (port 22), and restrict it to your trusted IP address once the VM is created
  11. Keep the image's data disk on the Disks tab: it holds the Oracle software at /u01
  12. Click Review + create, then Create

Option B: Azure CLI

First check the image's Marketplace terms are accepted (you accept them once per subscription, with az vm image terms accept), then create the VM from the Marketplace image, with your SSH key. Replace <your-vm-size> with the size you chose (see Prerequisites):

az vm image terms show --urn cloudimg1647283583153:prod-yrgn7dh342eog:prod-yrgn7dh342eog-gen2:latest --query accepted
az vm image terms accept --urn cloudimg1647283583153:prod-yrgn7dh342eog:prod-yrgn7dh342eog-gen2:latest

az vm create \
  --resource-group my-resource-group \
  --name my-oracle-client-19c-vm \
  --image cloudimg1647283583153:prod-yrgn7dh342eog:prod-yrgn7dh342eog-gen2:latest \
  --size <your-vm-size> \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_rsa.pub \
  --public-ip-sku Standard

The prod-yrgn7dh342eog-gen2 plan is the Gen2 image. For a Gen1 VM, use the plan prod-yrgn7dh342eog in both commands.

Important: the Oracle Client makes outbound connections to your databases, on port 1521 by default. You do not need to open port 1521 inbound on this VM. Check that your Network Security Group and route tables let the VM reach your database's listener.

Step 2: Connect via SSH

Once it's running, read off its public IP address:

az vm show --resource-group my-resource-group --name my-oracle-client-19c-vm --show-details --query publicIps -o tsv

Then connect with SSH:

ssh azureuser@<public-ip>

Important: wait for the VM to reach the running state before connecting. An early attempt can be refused while cloud-init finishes provisioning.

Step 3: Switch to the Oracle User and Set the Environment

The Oracle Client software belongs to the dedicated oracle OS user. Switch to it and source the environment script:

sudo su - oracle
cd $HOME
. ./setEnv.sh

setEnv.sh sets the Oracle environment that SQL*Plus and the other tools need:

export ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/19.3.0/client_1 TNS_ADMIN=/u01/app/oracle/product/19.3.0/client_1/network/admin NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export PATH=/u01/app/oracle/product/19.3.0/client_1/bin:$PATH LD_LIBRARY_PATH=/u01/app/oracle/product/19.3.0/client_1/lib:${LD_LIBRARY_PATH:-}

/etc/profile.d/oracle-client.sh sets the same variables for every Linux user at login, so azureuser can run sqlplus too.

Check the client is ready:

sqlplus -V
which sqlplus tnsping sqlldr expdp impdp

Expected output:

SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

/u01/app/oracle/product/19.3.0/client_1/bin/sqlplus
/u01/app/oracle/product/19.3.0/client_1/bin/tnsping
/u01/app/oracle/product/19.3.0/client_1/bin/sqlldr
/u01/app/oracle/product/19.3.0/client_1/bin/expdp
/u01/app/oracle/product/19.3.0/client_1/bin/impdp

Step 4: Configure tnsnames.ora

Before connecting to a remote database, add an entry for it to tnsnames.ora. As the oracle user, run the following, replacing the placeholder values with your database's details:

cat >> "$ORACLE_HOME/network/admin/tnsnames.ora" << 'TNS'
MY_DATABASE =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = YOUR_DB_HOSTNAME)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = YOUR_SERVICE_NAME)
    )
  )
TNS

Replace:

  • YOUR_DB_HOSTNAME with the IP address or DNS name of your Oracle database server
  • 1521 with your listener's port, if it is different
  • YOUR_SERVICE_NAME with the service name of the database

Check that Oracle Net resolves the alias:

tnsping MY_DATABASE

Expected output (the common part):

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on <date>

Copyright (c) 1997, 2019, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/19.3.0/client_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = YOUR_DB_HOSTNAME)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = YOUR_SERVICE_NAME)))

followed by one of:

  • OK (n msec): the host resolves and the remote listener answers. This is what you want to see.
  • TNS-12545: Connect failed because target host or object does not exist: the host is still the placeholder, or does not resolve. Oracle Net itself is working; put in a real database host you can reach.
  • TNS-12541: TNS:no listener: the host resolves, but nothing listens on that port. Check that the database listener is up and reachable from this VM.

Step 5: Connect to a Remote Database with SQL*Plus

With the environment sourced and the alias in place, connect with a database user and password of your own:

sqlplus your_user@MY_DATABASE

SQL*Plus prompts for the password and does not echo it, so it never lands in your shell history. You can also connect with EZCONNECT, without editing tnsnames.ora:

sqlplus your_user@//your-db-host:1521/your-service-name

Expected output, once you have typed the password at its prompt:

SQL*Plus: Release 19.0.0.0.0 - Production on <date>
Version 19.3.0.0.0

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

Connected to:
Oracle Database ...

SQL>

Type EXIT to leave SQL*Plus. If nothing listens at the address, SQL*Plus reports ORA-12541: TNS:no listener instead (see Troubleshooting).

Server Components

Component Version Install Path
Oracle Database Client 19c (Administrator) 19.3.0.0.0 /u01/app/oracle/product/19.3.0/client_1
Oracle Linux 8.10 /

Filesystem Layout

Mount Point Size Description
/ 37 GB Root filesystem (LVM logical volume)
/boot 2 GB Operating system kernel files
/boot/efi 100 MB UEFI boot partition (Gen2)
/var/crash 10 GB Reserved for kernel crash dumps (LVM logical volume)
/u01 20 GB Azure data disk (LUN 0): the Oracle software
/mnt varies Azure temporary resource disk (not kept across stop/deallocate)

Key Oracle directories:

Directory Purpose
/u01/app/oracle Oracle base directory
/u01/app/oracle/product/19.3.0/client_1 Oracle Client home
/u01/app/oracle/product/19.3.0/client_1/bin Client binaries (sqlplus, sqlldr, tnsping, expdp, impdp)
/u01/app/oracle/product/19.3.0/client_1/lib Oracle client libraries (libclntsh.so)
/u01/app/oracle/product/19.3.0/client_1/network/admin Oracle Net configuration (tnsnames.ora, sqlnet.ora)
/u01/app/oraInventory Oracle Universal Installer inventory

Managing the Oracle Client

The Oracle Client is a set of tools and libraries, not a running service: there is nothing to start or stop. Switch to the oracle user and source the environment to use it:

sudo su - oracle
cd $HOME
. ./setEnv.sh

Scripts and Log Files

Script/Log Path Description
setEnv.sh /home/oracle Sets the Oracle environment for sqlplus and the other tools
oracle-client.sh /etc/profile.d System wide environment hook for every logged in user
cloudimg-datadisk /usr/local/sbin First boot: puts /u01 on the VM's data disk (cloudimg-datadisk.service)

On Startup

On a new VM's first boot, cloudimg-datadisk.service formats the VM's data disk, copies the Oracle software onto it, and mounts it at /u01 (an entry in /etc/fstab). On later boots it finds the disk already formatted and leaves it alone. Its messages are in the journal:

sudo journalctl -u cloudimg-datadisk

This image does not update its packages on first boot, and no automatic update job is installed. Apply the latest Oracle Linux updates as soon as the VM is running, and regularly after that:

sudo dnf -y update
sudo reboot

Troubleshooting

Cannot connect via SSH

  1. Check the VM is in the Running state in the Azure Portal
  2. Check that port 22 is allowed in the Network Security Group, from your IP address
  3. Use the administrator username you chose at deployment (azureuser only if you kept the example)
  4. Check that your SSH key matches the one you gave at deployment

sqlplus: command not found

  1. Switch to the oracle user: sudo su - oracle
  2. Source the environment script: . ~/setEnv.sh
  3. Check the software is there: ls /u01/app/oracle/product/19.3.0/client_1/bin/sqlplus
  4. If /u01 is empty, check the data disk is attached and mounted: df -h /u01 and sudo journalctl -u cloudimg-datadisk

ORA-12154: TNS:could not resolve the connect identifier specified

  1. Check that your alias is in tnsnames.ora: cat $ORACLE_HOME/network/admin/tnsnames.ora
  2. Check that TNS_ADMIN points at the network/admin directory: echo $TNS_ADMIN
  3. Check that the alias resolves: tnsping MY_DATABASE
  4. Look for typos in the alias name

ORA-12170: TNS:Connect timeout occurred

  1. Check the database host and port are reachable from the VM: nc -vz YOUR_DB_HOSTNAME 1521
  2. Check that the database side's Network Security Group or firewall allows this VM in
  3. Check route tables, peering or VPN between this VM and the database's network
  4. For a database on premises, check your ExpressRoute or site-to-site VPN

ORA-12541: TNS:no listener

  1. The database listener may be down: check with whoever manages the database
  2. Check the port in your tnsnames.ora entry
  3. Run tnsping MY_DATABASE to see whether the listener answers

Security Recommendations

  • Restrict SSH: allow port 22 only from the addresses that need it
  • Restrict outbound access: allow outbound TCP 1521 only to the database servers this VM needs to reach
  • Protect tnsnames.ora: it names your internal database hosts and services; keep its permissions tight
  • Keep passwords out of scripts: let SQL*Plus prompt for them, or set up an Oracle Wallet
  • Encrypt connections: configure Oracle Net native encryption or TLS between the client and your databases
  • Keep the system updated: apply Oracle Linux updates (sudo dnf -y update) regularly

Support

If you have any issue with this product, contact cloudimg support:

Oracle and Oracle Database are registered trademarks of Oracle Corporation. cloudimg is an independent provider and is not affiliated with or endorsed by Oracle Corporation.