无法解析 ORA-12154:TNS:无法解析指定的连接标识符



我无法解决仅从Web浏览器获得的此错误。我正在尝试使用 PHP 中的PDO_ODBC连接到远程 Oracle DB。我认为一切都配置得很好,因为当我尝试使用 sqlplus 或 isql 连接时,一切都很好!当我尝试从 Web 浏览器连接时,首先它提供了成功的连接,但只需简单地刷新页面,我就会在对象中出现错误。

这是我的全部环境:

odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /var/www/html/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
/etc/odbc.ini
[esecns_test]
Driver = OracleODBC-11g
DSN = OracleODBC-11g
ServerName = ESECNS_TEST
UserID = ****
Password = ****
/etc/odbcinst.it
[OracleODBC-11g]
Description     = Oracle ODBC driver for Oracle 11g
Driver          = /usr/lib/oracle/12.2/client64/lib/libsqora.so.12.1
Setup           =
FileUsage       = 1
CPTimeout       = 5
CPReuse         = 5
Driver Logging  = 7
[ODBC]
Trace = Yes
TraceFile = /tmp/odbc.log
ForceTrace = Yes
Pooling = No
DEBUG = 1 Example driver definitions
# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description     = ODBC for PostgreSQL
Driver          = /usr/lib/psqlodbcw.so
Setup           = /usr/lib/libodbcpsqlS.so
Driver64        = /usr/lib64/psqlodbcw.so
Setup64         = /usr/lib64/libodbcpsqlS.so
FileUsage       = 1

# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description     = ODBC for MySQL
Driver          = /usr/lib/libmyodbc5.so
Setup           = /usr/lib/libodbcmyS.so
Driver64        = /usr/lib64/libmyodbc5.so
Setup64         = /usr/lib64/libodbcmyS.so
FileUsage       = 1

/etc/oracle/tnsnames.ora
ESECNS_TEST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.213.24)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = xxxxxx.xxxxxx.it)
    )
  )

-bash-4.2$ ldd  libsqora.so.12.1
        linux-vdso.so.1 =>  (0x00007ffeed87c000)
        libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007f5cc7a19000)
        libm.so.6 => /usr/lib64/libm.so.6 (0x00007f5cc7716000)
        libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007f5cc74fa000)
        libnsl.so.1 => /usr/lib64/libnsl.so.1 (0x00007f5cc72e1000)
        librt.so.1 => /usr/lib64/librt.so.1 (0x00007f5cc70d8000)
        libaio.so.1 => /usr/lib64/libaio.so.1 (0x00007f5cc6ed6000)
        libresolv.so.2 => /usr/lib64/libresolv.so.2 (0x00007f5cc6cbc000)
        libclntsh.so.12.1 => /usr/lib/oracle/12.2/client64/lib/libclntsh.so.12.1 (0x00007f5cc3216000)
        libclntshcore.so.12.1 => /usr/lib/oracle/12.2/client64/lib/libclntshcore.so.12.1 (0x00007f5cc2c48000)
        libodbcinst.so.2 => /usr/lib64/libodbcinst.so.2 (0x00007f5cc2a36000)
        libc.so.6 => /usr/lib64/libc.so.6 (0x00007f5cc2674000)
        libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007f5cc245e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f5cc7ee1000)
        libmql1.so => /usr/lib/oracle/12.2/client64/lib/libmql1.so (0x00007f5cc21e7000)
        libipc1.so => /usr/lib/oracle/12.2/client64/lib/libipc1.so (0x00007f5cc1db3000)
        libnnz12.so => /usr/lib/oracle/12.2/client64/lib/libnnz12.so (0x00007f5cc166a000)
        libons.so => /usr/lib/oracle/12.2/client64/lib/libons.so (0x00007f5cc141c000)
        libltdl.so.7 => /usr/lib64/libltdl.so.7 (0x00007f5cc1211000)

-bash-4.2$ printenv
XDG_SESSION_ID=381
HOSTNAME=cmapps-test
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=xx.xxx.xxx.xx 61528 22
SSH_TTY=/dev/pts/2
USER=cmapps
TWO_TASK=//xxx.xxx.xxx.xxx:1521/listener
LD_LIBRARY_PATH=/usr/lib64:/usr/lib/oracle/12.2/client64/lib
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
TNS_ADMIN=/etc/oracle
MAIL=/var/spool/mail/cmapps
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
PWD=/usr/lib/oracle/12.2/client64/lib
LANG=en_US.UTF-8
HISTCONTROL=ignoredups
SHLVL=1
HOME=/var/www/html
LOGNAME=cmapps
SSH_CONNECTION=xx.xxx.xxx.xx 61528 192.168.180.18 22
LESSOPEN=||/usr/bin/lesspipe.sh %s
XDG_RUNTIME_DIR=/run/user/1000
ORACLE_HOME=/usr/lib/oracle/12.2/client64
_=/usr/bin/printenv
OLDPWD=/var/www/html        

isql -v ESECNS_TEST
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

sqlplus64 *****/******@ESECNS_TEST
SQL*Plus: Release 12.2.0.1.0 Production on Mon May 8 15:18:26 2017
Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connesso a:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>

连接正常

刷新页面后出现连接错误

正如我所看到的,你只运行 64 位的 Oracle 驱动程序,而 PHP(Apache(需要安装 32 位。

http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html

相关内容

  • 没有找到相关文章

最新更新