So, here is the roadmap to correctly install cx_Oracle:
The first task is installing the Oracle client.
It is important that the client version is 11.2.
In higher versions, the cx_Oracle connector does not work correctly.
1) From the http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html page, download the following executables:
instantclient-basic-linux.x64-11.2.0.4.0.zip
instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
instantclient-sdk-linux.x64-11.2.0.4.0.zip
2) In the /opt/splunk folder, unzip the files
3) Configure oracle env:
vim /etc/profile.d/oracle.sh
#! / bin / bash
LD_LIBRARY_PATH = "/usr/lib/oracle/11.2/client64/lib:${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH
TNS_ADMIN = "/etc/oracle"
export TNS_ADMIN
ORACLE_HOME = "/usr/lib oracle/11.2/client64/lib"
export ORACLE_HOME
4) Environment variables:
source /etc/profile.d/oracle.sh
5) Copy or create the tnsnames.ora:
touch /etc/oracle/tnsnames.ora
6) Create symbolic link to ORACLE_HOME to avoid the "can not locate Oracle include files" error:
mkdir /usr/lib/oracle/11.2/client64/lib/sdk
ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/lib/sdk/include
The next step is to install the cx_Oracle connector.
Download cx_Oracle version 5.1.2 from https://sourceforge.net/projects/cx-oracle/files/5.1.2/cx_Oracle-5.1.2-11g-py26-1.x86_64.rpm/download and install the RPM.
It is possible that when importing the cx_Oracle library, the following error occurs:
Traceback (most recent call last):
import cx_Oracle
ImportError: libclntsh.so.11.1: Can not open shared object file: No such file or directory
To bypass this, create the following symbolic links (the paths to the files may change depending on the environment and where the files were extracted. Run find / -name lib * .so * to find the correct path):
/usr/lib64/libclntsh.so.11.1 → /usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1
/usr/lib64/libnnz11.so → /usr/lib/oracle/11.2/client64/lib/libnnz11.so
/usr/lib64/libocci.so.11.1 → /usr/lib/oracle/11.2/client64/lib/libocci.so.11.1
/usr/lib64/libociei.so → /usr/lib/oracle/11.2/client64/lib/libociei.so
/usr/lib64/libsqlplusic.so → /usr/lib/oracle/11.2/client64/lib/libsqlplusic.so
/usr/lib64/libsqlplus.so → /usr/lib/oracle/11.2/client64/lib/libsqlplus.so
Now the environment is ready. To test, simply execute the commands below:
[splunk @ splunktest-01 ~] $ python
Python 2.6.6 (r266: 84292, Sep 4 2013, 07:46:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>>
If no error are displayed, the environment is correctly set up.
... View more