Oracle 11gR2 RAC Listener - 多端口多监听


Oracle单实例库,可以配置多个监听服务,同时监听同一个service,具体的步骤可以参考之前的文章。

Oracle RAC想使用多端口,多监听服务,来同时监听同一个service,也可以。

官方文档:http://docs.oracle.com/cd/B28359_01/network.111/b28317/listener.htm

例子-1

Oracle 11gR2 RAC安装完毕之后,默认会在grid用户下创建4个监听服务,包括1个普通监听服务,3个scan监听服务。

可以到oracle账户下创建一个另监听服务器listener_prod端口1531,来监听prod服务。

1,创建配置listener.ora文件(oraprod用户,节点1,节点2)

节点1
LISTENER_PROD =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = q1ebsdb01-vip.imc.com)(PORT = 1531)(IP = FIRST)))
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = q1ebsdb01)(PORT = 1531)(IP = FIRST)))
    )
  )

SID_LIST_LISTENER_PROD =
  (SID_LIST =
    (SID_DESC = (ORACLE_HOME = /prod/oracle/product/11.2.0/db_1)(SID_NAME = prod1))
  )
节点2
LISTENER_prod =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = q1ebsdb02-vip.imc.com)(PORT = 1531)(IP = FIRST)))
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = q1ebsdb02)(PORT = 1531)(IP = FIRST)))
    )
  )

SID_LIST_LISTENER_prod =
  (SID_LIST =
    (SID_DESC = (ORACLE_HOME = /prod/oracle/product/11.2.0/db_1)(SID_NAME = prod2))
  )
2,创建配置tnsnames.ora文件(oraprod用户,节点1,节点2)

节点1
grid_LOCAL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = q1ebsdb01-vip.imc.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prod)
    )
  )

prod_LOCAL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = q1ebsdb01-vip.imc.com)(PORT = 1531))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prod)
    )
  )

节点2
grid_LOCAL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = q1ebsdb02-vip.imc.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prod)
    )
  )

prod_LOCAL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = q1ebsdb02-vip.imc.com)(PORT = 1531))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prod)
    )
  )

3,检查oraprod的TNS_ADMIN环境变量,默认系统会到$ORACLE_HOME/network/admin下寻找listener.ora和tnsnames.ora的配置。

设置oraprod的环境变量TNS_ADMIN='/prod/oracle/product/11.2.0/network/admin/PROD_p1ebsdb',监听的配置文件都放在该目录下,否则会导致出错

TNS-01101:Could not find service name,参考网友http://jvardhan.blogspot.com/2012/02/tnsadmin-effects.html

4,修改local_listener

SQL> show parameter listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
listener_networks                    string
local_listener                       string      (DESCRIPTION=(ADDRESS_LIST=(AD
                                                 DRESS=(PROTOCOL=TCP)(HOST=10.2
                                                 53.52.40)(PORT=1521))))
remote_listener                      string      q1ebsdb-scan:1521

SQL> show parameter listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
listener_networks                    string
local_listener                       string      (DESCRIPTION=(ADDRESS_LIST=(AD
                                                 DRESS=(PROTOCOL=TCP)(HOST=10.2
                                                 53.52.41)(PORT=1521))))
recovery_parallelism                 integer     0
remote_listener                      string      q1ebsdb-scan:1521

RAC中同一个service_name默认被一个listener监听,也能同时被2个不同的listener所监听。
tnsnames.ora文件只需要有一个即可,但listner.ora为2个,oragrid和oraprod的监听都使用该文件。
SQL> show parameter listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
listener_networks                    string
local_listener                       string      (DESCRIPTION=(ADDRESS_LIST=(AD
                                                 DRESS=(PROTOCOL=TCP)(HOST=10.2
                                                 53.52.40)(PORT=1521)))), (DESC
                                                 RIPTION=(ADDRESS_LIST=(ADDRESS
                                                 =(PROTOCOL=TCP)(HOST=10.253.52
                                                 .40)(PORT=1531))))
remote_listener                      string      q1ebsdb-scan:1521

SQL> !hostname
q1ebsdb01.imc.com

SQL> alter system set local_listener='grid_LOCAL','prod_LOCAL' scope=memory sid='prod1';

System altered.

SQL> alter system set local_listener='grid_LOCAL','prod_LOCAL' scope=memory sid='prod2';

System altered.

SQL> show parameter lis

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
listener_networks                    string
local_listener                       string      grid_LOCAL, prod_LOCAL
recovery_parallelism                 integer     0
remote_listener                      string      q1ebsdb-scan:1521

SQL> alter system set local_listener='grid_LOCAL','prod_LOCAL' sid='prod1';

System altered.

SQL> alter system set local_listener='grid_LOCAL','prod_LOCAL' sid='prod2';

System altered.

注意不能同时一起更新该参数文件,因为配置文件的具体内容不相同。
SQL> alter system set local_listener='grid_LOCAL','prod_LOCAL';
alter system set local_listener='grid_LOCAL','prod_LOCAL'
*
ERROR at line 1:
ORA-32008: error while processing parameter update at instance prod1
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'grid_LOCAL'
ORA-00132: syntax error or unresolved network

5,注册新建的listener服务到CRS,oraprod用户执行

srvctl add listener -l LISTENER_PROD  -o /prod/oracle/product/11.2.0 -p 1531

srvctl setenv listener -lLISTENER_PROD  -T TNS_ADMIN='/prod/oracle/product/11.2.0/network/admin/PROD_p1ebsdb'

6,验证一下

lsnrctl status LISTENER

lsnrctl status LISTENER_PROD

你可能感兴趣的:(Oracle,Administration,Oracle,11G,RAC,Oracle,Network)