oci_connect连接失败 [英] oci_connect connection failed

查看:562
本文介绍了oci_connect连接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从本地Zend服务器CE连接到外部ORA DB 11g时遇到严重问题. 启用了OCI8并运行版本1.4.6(由于phpinfo()).

I am having serious problem connecting to external ORA DB 11g from local Zend server CE. OCI8 is enabled and running version 1.4.6 (due to phpinfo()).

我尝试了许多连接选项(下面列出),但返回了相同的错误:

I have tried many connection options (listed below) with the same error returned:

oci_connect(): ORA-28547: connection to server failed, probable Oracle Net admin error

在搜索了整整一天之后,我只能说这个错误意味着PHP能够与服务器通信,但是无法连接到具体的服务/数据库,并且该错误不应来自PHP本身. ..

After googling for whole day I am only able to say that this error means that PHP was able to comunicate with the server but was unable to connect to a concrete service/database and that the error shouldn't come from PHP itself...

我已将环境变量TNS_ADMIN设置为c:\oracle_instantclient_11_2,其中文件tnsnames.ora所在的位置包含以下连接说明:

I have set environment variable TNS_ADMIN to c:\oracle_instantclient_11_2 where the file tnsnames.ora is located containing this connection description:

MYDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = X.X.X.X)(PORT = 1521))
    )
    (CONNECT_DATA = (SID = MYDB)(SERVER = DEDICATED))
  )

使用类似的描述

(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=X.X.X.X)(PORT=1521)))(CONNECT_DATA=(SID=MYDB)(SERVER=DEDICATED)))

我能够使用sqlplus控制台连接到服务器和服务/数据库,因此连接非常正确.我还使用相同的主机,端口和SID通过Sqldeveloper工具连接到服务器.问题是在PHP中连接到服务器时...

I am able to connect to the server and the service/database with sqlplus console, so the connection is very right. I am also using the very same HOST, PORT and SID to connect to the server with Sqldeveloper tool. The problem is when connecting to the server within a PHP...

到目前为止我尝试过什么:

What have I tried so far:

oci_connect("user", "password", "X.X.X.X:1521", "AL32UTF8", 0);
oci_connect("user", "password", "MYDB", "AL32UTF8", 0);
oci_connect("user", "password", "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=X.X.X.X)(PORT=1521)))(CONNECT_DATA=(SID=MYDB)(SERVER=DEDICATED)))", "AL32UTF8", 0);

以上所有这些oci_connect调用均返回上述相同错误.

All of these oci_connect calls above return the same error mentioned.

我还尝试了11g的ezconnect方法,如此处-[//]host_name[:port][/service_name][:server_type][/instance_name]:

I had also tried the ezconnect way for 11g as stated here - [//]host_name[:port][/service_name][:server_type][/instance_name]:

oci_connect("user", "password", "X.X.X.X:1521/MYDB", "AL32UTF8", 0);

但是问题是我不知道service name,只有service ID(SID),因此返回的错误是这样的:

but the problem is I do not know the service name, only the service ID (SID), thus the error returned is this:

oci_connect(): ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

表示没有运行带有提供的服务名称的服务(或者ORA侦听器不知道该服务).

that says there is no service running with the service name provided (or that the ORA listener does not know of such service).

PHP版本:5.3.14
Appache v .: 2.2.22(32位)Zend
Zend服务器CE:5.3.6

PHP version: 5.3.14
Appache v.: 2.2.22 (32bit) Zend
Zend server CE: 5.3.6

OCI8的PHP信息:

PHP info for OCI8:

OCI8 Support                   enabled
Version                        1.4.6
Revision                       $Revision: 313688 $
Active Persistent Connections  0
Active Connections             0
Oracle Instant Client Version  Unknown
Temporary Lob support          enabled
Collections support            enabled

Directive                     Local Value   Master Value
oci8.connection_class         no value      no value
oci8.default_prefetch         100           100
oci8.events                   Off           Off
oci8.max_persistent           -1            -1
oci8.old_oci_close_semantics  Off           Off
oci8.persistent_timeout       -1            -1
oci8.ping_interval            60            60
oci8.privileged_connect       Off           Off
oci8.statement_cache_size     20            20

可能的问题是,尽管TNS_ADMINPATH环境变量中都设置了unknown版本,但Oracle instant client的路径仍然存在.

Maybe the problem is that there is unknown version of Oracle instant client though it's path is set within both the TNS_ADMIN and PATH environment variables...

我的问题是:有人知道我做错了什么吗?我想念什么吗?我昨天用了整整一天的时间在Google上搜索,所以大概(有99%的机会)任何Google链接您想向我提供,我已经看过并尝试过...

My question is: does anybody know of what have I done wrong? Am I missing something? I have googled for a whole day yesterday so probably (with 99% chance) any google links You would like to provide me with I have already seen and tried...

尽管此问题可以视为完全重复的其中的一个-尚未得到答复,即使我发表评论我也遇到连接问题,我想没人会再回到这个老问题. 还请记住,在该类似问题中,还会返回并询问另一个错误.

Though this question could be considered as an exact duplicate of this one - it has not been yet answered and I guess nobody will return back to that old question even if I post a comment I am having the connection problems too. Also keep in mind that in that similar question a different error is returned and asked about.

推荐答案

由于在我移至Linux服务器上开发解决方案时出现了一些错误的配置和3天的损失,因此所有的问题都消失了.

Due to several misconfigurations and 3 days lost while looking for a solution I moved to develop on Linux server and all of the problems are gone.

我发现的东西:

    php_oci8_11g.dll均取决于Oracle Instant Client库
    • 这些库不包含oci_函数(例如oci_connect),仅包含ociX函数(例如ociLogon),这很奇怪...
    • both php_oci8.dll and php_oci8_11g.dll are depending on the Oracle Instant Client libraries
      • these libraries does not contain oci_ functions (like oci_connect), only ociX functions (like ociLogon) which is strange...

      最后,在Linux服务器上,我没有问题可以连接到远程Oracle服务器.在某个地方(浏览了成千上万的PHP-Oracle相关页面时),我发现了一条信息,一个人不应该开发在Windows下连接到Oracle服务器的PHP应用程序",而应该坚持使用UNIX系统...

      So finaly on Linux server I have no problems connecting to remote Oracle server. Somewhere (while surfing over thousands of PHP-Oracle related pages) I have found an information that "one shouldn't develop PHP application connecting to Oracle server under windows" and should stick to UNIX system instead...

      所以任何人都遇到类似或相同的问题-善良且不要浪费您的时间,安装VirtualBox,在其上运行Linux并继续前进!

      So anybody experiencing similar or same problems - be so kind and do not waste Your time, install a VirtualBox, run Linux on it and move forward!

      这篇关于oci_connect连接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆