0

I have this connection string on an older server which works fine and connects to a remote oracle server.

On this new server I installed oracle instant client simple and devel and php pecl oci8. Below is the screenshot of the oci8.

Here is the code I use to connect

$db = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" . $ORACLE_HOST . ")(PORT=" . $ORACLE_PORT . ")))(CONNECT_DATA=(SID=" . $ORACLE_DB . ")))";
$this->dbh = oci_connect($ORACLE_USER, $ORACLE_PASS, $db);

But when I try to connect to oracle I get this error

oci_connect(): Error while trying to retrieve text for error ORA-28547

If I type a random hostname I get ORA-12154 error which makes sense If I type a random SID I get ORA-12514 error which makes sense If I type a random port I get ORA-12545 error which makes sense If I nc the server and port I get this result

Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 10.10.40.21:1521.
Ncat: 0 bytes sent, 0 bytes received in 0.02 seconds.

System I use is Centos 7 64bit, php 5.6

Anyone has any idea why this might happen?

enter image description here

Ergec
  • 608
  • 1
  • 9
  • 25

3 Answers3

1

It seems even though phpinfo can detect oracle client version 18.5 but it fails to get ORACLE_HOME directory

If you only set

SetEnv ORACLE_HOME "/usr/lib/oracle/18.5/client64/lib"

in client's virtual host config file

/etc/httpd/conf/sites-available/client.vhost

This adds ORACLE_HOME to PHP Variables only which has NO EFFECT fixing the problem

Instead

You need to add

env[ORACLE_HOME] = /usr/lib/oracle/18.5/client64/lib

in client's php-fpm config file

/etc/php-fpm.d/client.conf

This adds ORACLE_HOME under both PHP Variables and Environment which fixes the problem.

enter image description here

Ergec
  • 608
  • 1
  • 9
  • 25
0

Is your sqlnet.ora set up for easy connect? (Located in $ORACLE_HOME//network/admin) Check out Oracle Net Services documentation on setting it up; you should have a line there similar to:

NAMES.DIRECTORY_PATH=(ezconnect, tnsnames)

Also see this troubleshooting guide.

Mark Stewart
  • 103
  • 8
0

You've got two problems:

  • Oracle can't get the correct translation for error ORA-28547. This is probably because of a incorrect installation/configuration. Is your echo $ORACLE_HOME set?
  • But the real problem is the error ORA-28547 which is "connection to server failed", probably Oracle Net admin error".
ckujau
  • 642
  • 4
  • 13
Jan
  • 101
  • 1