远程客户端连接数据库时提示TNS-12541: TNS: 无监听程序

在windows环境下监听程序和本地服务文件配置如下

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
  )

ocp =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ocp)
    )
  )

当在远程机器上使用tnsping ocp是会报TNS-12541: TNS: 无监听程序

D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora

已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 10.138.135.114)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ocp)))
TNS-12541: TNS: 无监听程序
原因在于当host=localhost或127.0.0.1时在远程客户端使用tnsping ocp时会解释成
ip加服务名比如:10.138.135.114:1521/ocp但当在监听程序中配置为localhost或
127.0.0.1时当远程连接时解释服务名时就不能映射到真正的ip所以远程连接时就会报
TNS-12541: TNS: 无监听程序 所以配置监听程序和本地服务文件时host这个参数最好使用真实的ip或机器名

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.135.114)(PORT = 1521))
    )
  )

ocp =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.135.114)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ocp)
    )
  )
  

发表评论

电子邮件地址不会被公开。