Skip to content

Instantly share code, notes, and snippets.

@AstralJaeger
Last active November 26, 2021 13:32
Show Gist options
  • Save AstralJaeger/c285ce6300c64d94cec09bb9031cea69 to your computer and use it in GitHub Desktop.
Save AstralJaeger/c285ce6300c64d94cec09bb9031cea69 to your computer and use it in GitHub Desktop.
A short guide how to connect to Oracle 19c on OCI. Works on free instances!

Connecting to Oracle 19c ADB on OCI

Ubuntu

Step 1

Run updates and install upgrades:

sudo apt update && sudo apt upgrade

Step 2

Install unzip utility and libaio for sqlplus:

sudo apt install unzip -y
sudo apt-get install libaio1 libaio-dev -y

Step 3

Create folder in /opt:

sudo mkdir /opt/oracle

Step 4

Download instantclient and instantclient_sqlplus, please make sure to download the correct version from this website. The easiest solution is to copy the download link and download it using (please replace xx.x with the desired version, at the time of writing the newest version is 21.4):

wget -O instantclient_xx_x.zip https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-basic-linux.x64-xx.x.0.0.0dbru.zip
wget -O instantclient_sqlplus_xx_x.zip https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sqlplus-linux.x64-xx.x.0.0.0dbru.zip

Step 5

Unzip the downloaded zip files into the previously created folder in /opt/oracle:

sudo unzip instantclient_xx_X.zip -d /opt/oracle
sudo unzip instantclient_sqlplus_xx_x.zip -d /opt/oracle/

Step 6

In the next step we need to add the folder /opt/oracle to the PATH and LD_LIBRARY_PATH environment variables.

This would be the ideal point to create a new user account for your application to run under using the command useradd username, add it to the sudo group using usermod -aG sudo username.

This can by done by adding these lines at the end of your .profile file using these commands:

su - username
nano ~/.profile

Make sure to replace xx_x with your actual version number like 21_4

export PATH="$PATH:/opt/oracle/instantclient_xx_x"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/oracle/instantclient_xx_x"

After adding it to the .profile file execute:

source ~/.profile

Step 7

Download the wallet archive file from your database and move it into this folder: /opt/oracle/instantclient_xx_x/network/admin and unzip it there.

Step 8

Now you should be able to connect to your database by using the sqlplus utility. You can copy the connection string in your database.

sqlplus username@password/connectionstring

Step 9

Finally you can uninstall unzip if you don't desire to keep it.

sudo apt remove unzip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment