I recently had to work on a project that was pulling data from an Oracle database. While there are many tutorials on installing the relevant drivers, I needed a simple setup that would work across multiple programming languages. Here are the instructions for installing the latest Oracle drivers on Ubuntu 18.04 and above:
- Download the Oracle 18 "Basic" zip file along with the SDK zip file. Note that you would need to register with Oracle first to be able to download.
Unzip the files to somewhere accessible:
sudo mkdir -p /opt/oracle cd /opt/oracle sudo mv ~/Downloads/instantclient-basic-linux.x64-22.214.171.124.0dbru.zip . sudo mv ~/Downloads/instantclient-sdk-linux.x64-126.96.36.199.0dbru.zip . sudo unzip instantclient-basic-linux.x64-188.8.131.52.0dbru.zip sudo unzip instantclient-sdk-linux.x64-184.108.40.206dbru.zip
Note that the last command will unzip the sdk under the
Install random dependency (note that on some systems it is libaio1):
sudo apt install libaio
Permanently add Instant Client to the runtime link path:
sudo sh -c "echo /opt/oracle/instantclient_18_3 > /etc/ld.so.conf.d/oracle-instantclient.conf" sudo ldconfig
For maximum compatibility you should co-locate the Oracle configuration files such as
sqlnet.ora, etc., with the instant client. Create the following directory and put them in there:
mkdir -p /opt/oracle/instantclient_18_3/network/admin
The above should be enough to allow you to install the relevant drivers for your programming language environment and get coding. Finally, note that Version 18 and 12.2 client libraries can connect to Oracle Database 11.2 or greater. Version 12.1 client libraries can connect to Oracle Database 10.2 or greater. Version 11.2 client libraries can connect to Oracle Database 9.2 or greater.
Maximum credit for this tutorial goes to the python cx_oracle module installation documentation!