EM 无法使用的解决:首先我们知道 EM 只支持动态注册的监听。哪怕是有动态注册信息就可以。
在考试 11gOCM 的时候,有一道题是要配置两个监听,一个名字是 listener 另一个是 lsnr2, 还需要配置 EM,首先我先配置了 listener 这个监听,具体配置如下:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = edbjr2p1.example.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
很显然这个是动态监听,正好这时候我用这个监听配置了 EM。
EM 配置完成之后,我继续配置 lsnr2 , 具体配置如下:
LSNR2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = edbjr2p1.example.com)(PORT = 1526))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1526))
)
)
要求要 lsnr2 也能动态注册到数据库信息,这时候我们发现这个监听的端口非默认端口。然而 oracle 默认动态是注册到 1521 端口上的,所有这时候 lsnr2 是不能动态注册到数据库信息的,如下:
[oracle@edbjr2p1 admin]$ lsnrctl status lsnr2
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 05-JUL-2016 23:34:29
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edbjr2p1.example.com)(PORT=1526)))
STATUS of the LISTENER
------------------------
Alias lsnr2
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 05-JUL-2016 23:34:06
Uptime 0 days 0 hr. 0 min. 22 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/edbjr2p1/lsnr2/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edbjr2p1.example.com)(PORT=1526)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526)))
The listener supports no services
The command completed successfully
可以通过 local_listener 这个参数来修改 oracle 默认动态注册的端口,使 lsnr2 可以动态注册到信息。
1. 然后 修改数据库参数
sqlplus / as sysdba
SQL> alter system set local_listener='lSNR2';
SQL> alter system register; ### 动态监听如果先于数据库启动,那就不必要执行这个命令。
2. 再次查看监听状态,发现动态注册到了信息
[oracle@edbjr2p1 admin]$ lsnrctl status lsnr2
。。。。。。。
Services Summary...Service "PROD1.us.oracle.com" has 1 instance(s).Instance "PROD1", status READY, has 1 handler(s) for this service...Service "PROD1XDB.us.oracle.com" has 1 instance(s).Instance "PROD1", status READY, has 1 handler(s) for this service...The command completed successfully
这样我觉得 OK 了,可是等到后面使用 EM 的时候,我发现报错,说 database is down,
可是我检查发现数据库正常, 然后查看监听 listener 的状态:发现原本动态注册的信息已经没有了。如下:
[oracle@edbjr2p1 admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 05-JUL-2016 23:34:29
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edbjr2p1.example.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias listener
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 05-JUL-2016 23:34:06
Uptime 0 days 0 hr. 0 min. 22 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/edbjr2p1/lsnr2/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edbjr2p1.example.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526)))
The listener supports no services
The command completed successfully
可以推测出可能是这里的原因导致报错 :database is down
那么是什么原因导致的呢?
原来 当你设置 local_listener=lsnr2 后,数据库信息就会动态的注册到 1526 端口,他就不会动态的注册到 1521,所以 listener 这个监听注册不到信息,导致 EM 链接不到数据库,报错 database is down。
解决办法:只需要修改参数 local_listener='listener','lsnr2'; 即可,这样 oracle 会动态注册到两个端口上。
然后发现 EM 可以使用了。
2.关于 oracle 监听动态和静态的分析
oracle 静态监听如下:
[oracle@edbjr2p1 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = edbjr2p1.example.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=PROD1)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=PROD1))
(SID_DESC=
(SID_NAME=plsextproc)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM=extproc)))
尽管是静态监听,但是他也会有动态注册信息,如下 ready 代表动态,unknown 代表静态。如果你刚才用这样的话已经配置好的 EM 是可以使用这个监听的,可不要认为静态监听也可以了,真正的原因是虽然是静态监听配置,但是 oracle 会默认动态的注册到 1521 这个端口上,所以既有动态又有静态的注册信息(前提是没有修改 local_listener 这个参数)
[oracle@edbjr2p1 admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 05-JUL-2016 23:45:04
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edbjr2p1.example.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 05-JUL-2016 23:43:44
Uptime 0 days 0 hr. 1 min. 20 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/edbjr2p1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edbjr2p1.example.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "PROD1" has 1 instance(s).
Instance "PROD1", status UNKNOWN, has 1 handler(s) for this service...
Service "PROD1.us.oracle.com" has 1 instance(s).
Instance "PROD1", status READY, has 1 handler(s) for this service...
Service "PROD1XDB.us.oracle.com" has 1 instance(s).
Instance "PROD1", status READY, has 1 handler(s) for this service...
Service "plsextproc" has 1 instance(s).
Instance "plsextproc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
如果你配置 EM 使用的监听没有动态注册信息,那么当你使用 EM 的时候就会报错,具体如下:
小结:EM 管理器,配置和使用只支持动态注册的监听,如果你刚开始是用动态注册的监听配置好了 EM,你又把动态的监听改成了静态的,这时候你没有修改 local_listener 这个参数,正常情况还是可以使用 EM 的,因为这时候你的监听既有静态注册信息又有动态注册信息,EM 使用的是动态信息,说白了就是保证有动态注册的信息即可。