最近小白总是能够遇到一些数据库监听问题,导致工具PLSQL连不上去,现在总结一把。
1. 数据库监听的配置文件: listener.ora 和 tnsnames.ora
listener.ora: 主要负责服务器端的监听配置
tnsnames.ora: 主要负责客户端的监听配置
listen.ora文件的内容如下:
# listener.ora Network Configuration File: /home/oracle/app/product/11/db/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER_ORA = (注:LISTENER_ORA 为监听名字)
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 12.1.4.5)(PORT = 1521))
)
)
SID_LIST_LISTENER_ORA = (注:LISTENER_ORA 为监听名字)
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = wsj)
(ORACLE_HOME = /home/oracle/app/product/11/db)
(SID_NAME = wsj)
)
)
tnsnames.ora的文件内容如下:
# tnsnames.ora Network Configuration File: /home/oracle/app/product/11/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
WSJ = (注: WSJ 为实例名)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 12.1.4.5)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = wsj)
)
)
2. 一个监听的有无取决于listen.ora和tnsnames.ora中有没有那个监听相关的配置,与此同理,重建一个监听也只需要在listen.ora和tnsnames.ora中添加如上的配置即可,切忌PORT=1521中的1521端口不能被其他进程给占用