Listener.ora、tnsnames.ora这两个文件常常因为格式问题而不好用,我平时都是配置好了留个备份,以后都是拷贝过去改改就好了!嘿嘿~~~
因为平时使用Linux的时候较多,所以有时还会遇到sqlnet.ora这个文件有问题,直接给它删了就好了~~
有时在Windows下装的Oracle的listener服务就启动不了,遇到这种情况,直接去Oracle的bin目录下面找到lsnrctl.exe那个文件,直接给它运行,弹出来的窗口不要关闭,就可以了。
Oracle Server端Listener.ora文件(一个instance):
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1521)) //主机名或IP及端口设置
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = database1) // database1为数据库instance名
(ORACLE_HOME = /opt/oracle/product/10.1.0) //oracle安装目录,根据安装情况更改
(PROGRAM = extproc)
)
)
Oracle Server端Listener.ora文件(两个instance):
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1521))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = database1) // database1为数据库instance1名
(ORACLE_HOME = /opt/oracle/product/10.1.0)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = database2) // database2为数据库instance2名
(ORACLE_HOME = /opt/oracle/product/10.1.0)
(PROGRAM = extproc)
)
)
Oracle Server端监听器启动、停止、查看状态命令:
$ lsnrctl start
$ lsnrctl stop
$ lsnrctl status
Oracle Client端Tnsnames.ora文件:
ORALOCAL = //别名oralocal
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = database1) //database1为SID名
)
)
Oracle Client端检查监听器连接状态用命令:
$ tnsping 别名
例如:用oracle用户执行命令 $ tnsping oralocal