I am receiving random errors every so often when connecting/running Oracle SQL Commands. This works 99% of the day, but randomly for around 10 minutes we will get a load of the errors, and the SQL Queries all fail.
Sorry for all the below code, just trying to assist
Error is:
PHP Warning: oci_connect() [<a href='function.oci-connect'>function.oci-connect</a>]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that LD_LIBRARY_PATH includes the directory with Oracle Instant Client libraries in /var/www/db.php on line 59, referer: https://www.abc.com/abc.php
Oracle Instant Client:
root@server:/opt/oracle/instantclient# pwd
/opt/oracle/instantclient
root@server:/opt/oracle/instantclient# ls -l
total 99940
-rw-r--r-- 1 root root 238 2009-07-03 14:40 BASIC_README
-r--r--r-- 1 root root 1609607 2009-07-03 14:40 classes12.jar
-rwxr-xr-x 1 root root 67766 2009-07-03 14:40 genezi
lrwxrwxrwx 1 root root 17 2009-07-03 14:41 libclntsh.so -> libclntsh.so.10.1
-rwxr-xr-x 1 root root 19076649 2009-07-03 14:40 libclntsh.so.10.1
-r-xr-xr-x 1 root root 5656445 2009-07-03 14:40 libnnz10.so
lrwxrwxrwx 1 root root 15 2009-07-03 14:41 libocci.so -> libocci.so.10.1
-rwxr-xr-x 1 root root 1398244 2009-07-03 14:40 libocci.so.10.1
-rwxr-xr-x 1 root root 72698427 2009-07-03 14:40 libociei.so
-r-xr-xr-x 1 root root 120443 2009-07-03 14:40 libocijdbc10.so
-r--r--r-- 1 root root 1555682 2009-07-03 14:40 ojdbc14.jar
drwxrwxr-x 4 root root 4096 2008-02-17 08:58 sdk
Other useful info:
root@server:/# cat /etc/apache2/envvars
# envvars - default environment variables for apache2ctl
# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2.pid
export LD_LIBRARY_PATH=/opt/oracle/instantclient
Inside the script, We debug any errors, and email a report when these are encountered to try and debug the issue a bit further. I am doing the following:
if(isset($ocierr) && $ocierr!="")
$mb.="Oracle OCI Error: ".$ocierr."
";
$mb.="Oracle Error Message: ".print_r($errmsg,true)."
";
$mb.="Debugging:
LD_LIBRARY_PATH: ".var_export(getenv('LD_LIBRARY_PATH'),true);
which returns:
Oracle Error Message:
Cannot contact to Oracle
Debugging:
LD_LIBRARY_PATH: '/opt/oracle/instantclient'