首页 > 数据库 > Oracle > oracle之监听的方方面面
2.oracle的链接方式
[oracle@localhost admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-MAY-2015 06:13:07
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.237.129)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 14-MAY-2015 04:34:23
Uptime 0 days 1 hr. 38 min. 44 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/network/admin/listener.ora
Listener Log File /u01/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.237.129)(PORT=1522)))
Services Summary...
Service "orcl.LILE" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "wilson.LILE" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
上面的service名字是service_names.db_domain,db_unique_name.db_domain,其中service_name可以配置多个值,用‘,’隔开就行了。其实在在tnsname.ora中配置的时候,service_name是这里的service name,并不是instance_name或者单纯的service_name,只是平时我们db_domain都没有设置,db_unique_name,service_names都等于instance_name,这个很容易引起误解。
动态监听最明显的地方就是它的状态时ready的,当数据库是nomount状态时,它的状态时blocked状态,这个时候远程连接时不允许的。但是我们下面要看的静态监听在数据库是nomount状态时,我们是可以通过远程连接上的。
3.2 静态监听
静态监听一定是通过listener.ora这个文件来配置的,它的配置如下:
LISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=sale-server)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=sales.us.example.com)
(ORACLE_HOME=/oracle11g)
(SID_NAME=sales))
(SID_DESC=
(SID_NAME=plsextproc)
(ORACLE_HOME=/oracle11g)
(PROGRAM=extproc)))
监听名称为LISTTENER1,和SID_LIST_LISTENER1中的LISTENER1是对应的,它们应该相等,静态监听改名service的名字是通过SID_DESC中的GLOBAL_DBNAME来实现的,同样的道理,在tnsname.ora中service_name也是对应监听中的service,即global_name。其中(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)),(SID_DESC=
(SID_NAME=plsextproc)
(ORACLE_HOME=/oracle11g)
(PROGRAM=extproc))是配置外部监听的,当数据库需要调用外部函数的时候,就需要用到外部监听。我们通过lsnrclt status查看静态监听的状态:
[oracle@localhost admin]$ lsnrctl status LISTENER1
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-MAY-2015 06:29:16
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER1
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 14-MAY-2015 06:28:53
Uptime 0 days 0 hr. 0 min. 23 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/network/admin/listener.ora
Listener Log File /u01/diag/tnslsnr/localhost/listener1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.237.129)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
可以发现,静态监听的状态unknown的。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30557618/viewspace-1833717/ ,如需转载,请注明出处,否则将追究法律责任。