Oracle RAC下添加静态注册监听器listener

yanhui00 2012-09-14

通过设置不同的listener,可以在一台服务器多实例c环境下实现业务的隔离,方便业务起停和管理。添加的方法除了netca外,比较简单的方式是使用srvctl命令,具体用法如下

[grid@dtydb5 ~]$ srvctl add listener -h

Adds a listener configuration to the Oracle Clusterware.

Usage: srvctl add listener [-l <lsnr_name>] [-s] [-p "[TCP:]<port>[, ...][/IPC:<key>][/NMP:<pipe_name>][/TCPS:<s_port>] [/SDP:<port>]"] [-o <oracle_home>] [-k <net_num>]
    -l <lsnr_name>           Listener name (default name is LISTENER)
    -o <oracle_home>         ORACLE_HOME path (default value is CRS_HOME)
    -k <net_num>             network number (default number is 1)
    -s                       Skip the checking of ports
    -p "[TCP:]<port>[, ...][/IPC:<key>][/NMP:<pipe_name>][/TCPS:<s_port>] [/SDP:<port>]"       Comma separated tcp ports or listener endpoints
    -h                       Print usage

具体过程如下,数据库是oracle 11gr2版本


1,开始添加 ,使用grid用户 

[grid@dtydb5 admin]$ srvctl add listener -l listener_epm -p 1522 -o $ORACLE_HOME

2,启动
srvctl start listener -l listener_epm


启动后相关文件才发生变化
[grid@dtydb5 admin]$ cat listener.ora
LISTENER_EPM=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_EPM))))            # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))            # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))))                # line added by Agent
#LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))           # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON                # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_EPM=ON          # line added by Agent
[grid@dtydb5 admin]$
[grid@dtydb5 admin]$
[grid@dtydb5 admin]$
[grid@dtydb5 admin]$ cat endpoints_listener.ora
LISTENER_EPM_DTYDB5=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dtydb5-vip)(PORT=1522))(ADDRESS=(PROTOCOL=TCP)(HOST=10.4.124.235)(PORT=1522)(IP=FIRST))))                # line added by Agent
LISTENER_DTYDB5=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dtydb5-vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=10.4.124.235)(PORT=1521)(IP=FIRST))))            # line added by Agent

3,查看资源的状态online
ora.LISTENER_EPM.lsnr
               ONLINE  ONLINE       dtydb3                                      
               ONLINE  ONLINE       dtydb4                                      
               ONLINE  ONLINE       dtydb5

[grid@dtydb5 admin]$ lsnrctl status listener_epm

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 13-SEP-2012 10:16:48

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_EPM)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_EPM
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                13-SEP-2012 10:14:17
Uptime                    0 days 0 hr. 2 min. 32 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /oracle/11.2.0/grid/network/admin/listener.ora
Listener Log File         /oracle/11.2.0/grid/log/diag/tnslsnr/dtydb5/listener_epm/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_EPM)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.4.124.235)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.4.124.245)(PORT=1522)))
The listener supports no services
The command completed successfully

4,vi listener.ora 添加以下信息,主要要修改三个节点的信息(后来证实,本步骤可以省略,可能因为静态监听信息已在endpoints_listener.ora文件中了)

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
     (GLOBAL_DBNAME = epmdb)
     (ORACLE_HOME = /oracle/app/oracle/product/11.2.0/db_1)
     (SID_NAME = epmdb3)
    )
   )

5, 重启listener
[grid@dtydb5 admin]$ srvctl stop listener -l listener_epm
[grid@dtydb5 admin]$ srvctl start listener -l listener_epm


这时服务还是没有注册上来
[grid@dtydb5 admin]$ lsnrctl status listener_epm

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 13-SEP-2012 10:27:15

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_EPM)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_EPM
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                13-SEP-2012 10:26:35
Uptime                    0 days 0 hr. 0 min. 40 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /oracle/11.2.0/grid/network/admin/listener.ora
Listener Log File         /oracle/11.2.0/grid/log/diag/tnslsnr/dtydb5/listener_epm/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_EPM)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.4.124.235)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.4.124.245)(PORT=1522)))
The listener supports no services
The command completed successfully

6,什么原因?应该是local_listener设置问题,还需要修改该参数

sys@EPMDB3(dtydb5)> show parameter local

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      (DESCRIPTION=(ADDRESS_LIST=(AD
                                                 DRESS=(PROTOCOL=TCP)(HOST=10.4
                                                 .124.245)(PORT=1521))))

sys@EPMDB3(dtydb5)> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.4.124.245)(PORT=1522))))' scope=both sid='*';

系统已更改。
 alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.4.124.243)(PORT=1522))))' scope=both sid='epmdb1';
  alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.4.124.244)(PORT=1522))))' scope=both sid='epmdb2';
   alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.4.124.245)(PORT=1522))))' scope=both sid='epmdb3';

 

7,已成功注册
[grid@dtydb5 admin]$ lsnrctl status  LISTENER_EPM

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 13-SEP-2012 10:40:47

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_EPM)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_EPM
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                13-SEP-2012 10:26:35
Uptime                    0 days 0 hr. 14 min. 12 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /oracle/11.2.0/grid/network/admin/listener.ora
Listener Log File         /oracle/11.2.0/grid/log/diag/tnslsnr/dtydb5/listener_epm/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_EPM)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.4.124.235)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.4.124.245)(PORT=1522)))
Services Summary...
Service "epmdb" has 1 instance(s).
  Instance "epmdb3", status READY, has 1 handler(s) for this service...
The command completed successfully

相关推荐