日期:2014-05-17  浏览次数:21157 次

客户端如何配置监听?
我想在客户端里用SQLPLUS,服务器的监听正常,就是客户端的监听无法监听到实例,
服务器的监听配置:
SQL code

# listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
       (SID_DESC =
         (GLOBAL_DBNAME = YONGDB.yongyy.com)
         (SID_NAME = YONGDB)
       )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST =yongyy.com)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /yongyy/u01/app/oracle

#------------------------------------------
tnsnames.ora

YONGDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yongyy.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = YONGDB.yongyy.com)
    )
  )

#-------------------------------
# sqlnet.ora
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

ADR_BASE = /yongyy/u01/app/oracle


-----------------------------------------------------
客户端的配置:
[color=#FF0000]listener.ora[/color]

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.24.128)(PORT = 1521))    --本来是 YONGYY-PC :是客户端的主机名
    )
  )

ADR_BASE_LISTENER = D:\Oracle

YONGDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.24.128)(PORT = 1521))  -- 服务器的IP
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = YONGDB)
    )
  )

[color=#FF0000]sqlnet.ora[/color]
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

[color=#FF0000]tnsnames[/color]
YONGDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.24.128)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = YONGDB)
    )
  )





相关参数:
------服务器参数---------------------
ORACLE_SID=YONGDB
全局SID : YONGDB.yongyy.com
192.168.24.128 yongyy.com yongyy # Added by NetworkManager
127.0.0.1 localhost.localdomain localhost
::1 yongyy.com yongyy localhost6.localdomain6 localhost6

说明:
防火墙神马的关了;sqldeveloper可以轻松连接,因为sqldeveloper太占内存了,所以换其他的

报错信息:
-------客户端-----------
使用命令:
>lsnrctl stop 或者 lsnrctl start 或者 lsnrctl status 都报下面的错误
正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=yongyy.com)(PORT=1521)))
TNS-01189: 监听程序无法验证用户

>tnsping yongyy.com
已使用的参数文件:
D:\Oracle\product\11.2.0\client_1\network\admin\sqlnet.ora
已使用 EZCONNECT 适配器来解析别名
尝试连接 (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOS
=192.168.24.128)(PORT=1521)))
OK (20 毫秒)

--------------------------------------------
>sqlplus yong/yong@yongyy.com:1521
ERROR:
ORA-12504: TNS: 监听程序在 CONNECT_DATA 中未获得 SERVICE_NAME

在服务器上:
如果我把: listener.ora
HOST=yongyy.com 改成 192.168.24.128 或者 localhost
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.24.128)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused

$ping yongyy.com
64 bytes from yongyy.com (192.168.24.128): icmp_seq=1 ttl=64 time=0.371 ms


为什么客户端的监听无法监听到服务器的实例?




------解决方案--------------------
#------------------------------------------
tnsnames.ora

YONGDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yongyy.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = YONGDB.yongyy.com)
)
)

#-------------------------------
这个应该在客户端配置 HOST改为你服务器的IP
------解决方案--------------------
将tnsname.ora中的host改成ip地址,SERVER写到是服务器的实例名,使用netmgr可以手动创建一个