duanpacan2583 2015-02-16 17:55
浏览 64
已采纳

Vagrant Oracle ORA-12541:TNS:/var/www/core/db.class.php中没有听众

I've finished configuring a Vagrant box with oracle 11G.

I've tested the connection using SqlDeveloper from my local MAC machine and all seems fine (ssm_android -> localhost 1521 xe).

What I really need is to connect to this Oracle DB through PHP.

Here's my Vagrant config for the oracle machine (I added some relevant info below):

vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ echo $ORACLE_HOME 
/u01/app/oracle/product/11.2.0/xe

vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ echo $ORACLE_SID  
XE

vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ vi listener.ora 

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
      (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
    )
  )

DEFAULT_SERVICE_LISTENER = (XE)

vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ vi tnsnames.ora

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 16-FEB-2015 13:26:37

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                16-FEB-2015 11:34:27
Uptime                    0 days 1 hr. 52 min. 10 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XE" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully

And here's the error i get in PHP when I try connecting using the following data

user = "ssm_android"
host = "127.0.0.1:1521/XE"
password = "xxxxxxx"
database = "XE"

:

Fatal error: Uncaught exception 'Exception' with message 'Cannot connect to database: ORA-12541: TNS:no listener' in /var/www/core/db.class.php:164 Stack trace: #0 /var/www/core/db.class.php(113): Db->connect('ssm_android', 'NtakmdVSYgsYSNii11...', '127.0.0.1:1521/...') #1 /var/www/index.php(56): Db->__construct() #2 {main} thrown in /var/www/core/db.class.php on line 164

Could be relevant the fact that the machine running the php is another local Vagrant machine mapped to localhost... not sure..

I'd appreciate any insight on this.

Thanks.

  • 写回答

1条回答 默认 最新

  • douye9175 2015-02-19 04:12
    关注

    It seems the whole problem was that both vagrant machines were configured with dynamic ips. Changing vagrant config files to include static ips did the trick.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器