Search code examples
oracleapacheperlcgidbd

Error querying Oracle database from CGI Perl script


I have a CGI Perl script that will run a select statement from a Oracle Database to get records. This scripts runs on Apache with cgi-bin linked. It was running fine.

Due to failover we moved the hard disk to the backup server with similar setups. When we run the script however, the following error is shown:

install_driver(Oracle) failed: Can't load '/u02/system/perl/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file: No such file or directory at /u02/system/perl/usr/lib64/perl5/DynaLoader.pm line 200.

I had checked my ORACLE_HOME and LD_LIBRARY_PATH variables and they both pointing to the correct oracle client. Also try locate libclntsh.so.11.1 and managed to find the file in the correct directory, with permission granted.

Also added a oracle.conf file that has the path to oracle lib directory in /etc/ld.so.conf.d

All these and still it's showing the same error. Am running out of ideas....

Any pointers or suggestion are appreciated. Thank you.


Solution

  • You've covered the basics already which is good: make sure the libraries exist, make sure your program has read/execute permissions, and setting environment variables for ORACLE_HOME and LD_LIBRARY_PATH.

    You many need to check the dependencies recursively.

    ldd /u02/system/perl/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so
    

    should show you any dependencies of the .so that can't be loaded. DBD::Oracle is also version sensitive to the Oracle client. If the version or location of the Oracle client has changed (or when all else fails), you may need to recompile DBD::Oracle.