如何在 Oracle Restart环境中,在指定的网卡上增配第二套listener

**最近接触到了一个 Restart 环境配置第二套 listener 的案例,共享给大家,希望有所帮助。如有不足,还望指正。

背景:
客户想在Oracle Restart环境中配置两个listener,分别对eth0和eth1的网卡所对应的IP地址进行监听。

大致步骤:
编辑listener.ora 配置两个listener(HOST部分分别指定两个网卡对应的IP地址)
通过 srvctl add listener 及 srvctl start listener 命令来添加和启动 listener resource
通过 crsctl stat res -t 命令查看 listener resource 的最新情况
lsnrctl status 来分别查看两个listener的监听情况(是否分别对两个网卡上指定的IP进行监听)

执行例子:
-bash-4.2$ cat $ORACLE_HOME/network/admin/listener.ora
listener.ora Network Configuration File: /refresh/app/oracle/product/12.1.0/grid/network/admin/listener.ora
Generated by Oracle configuration tools.

LISTENER =
(DESCRIPTION_LIST =

(DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 10.30.203.165)(PORT = 1521))
  (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)

)

LISTENER2 =
(DESCRIPTION_LIST =

(DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.10)(PORT = 1741))
  (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1741))
)

)

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
VALID_NODE_CHECKING_REGISTRATION_LISTENER=SUBNET # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER2=ON # line added by Agent
VALID_NODE_CHECKING_REGISTRATION_LISTENER2=SUBNET # line added by Agent
-bash-4.2$
-bash-4.2$ srvctl add listener -listener LISTENER2 -s -endpoints TCP:1741
-bash-4.2$
-bash-4.2$ srvctl start listener -listener LISTENER2
-bash-4.2$

-bash-4.2$ crsctl stat res -t

Name Target State Server State details

Local Resources

ora.DATA.dg

           ONLINE  ONLINE       o1asm                  STABLE

ora.LISTENER.lsnr

           ONLINE  ONLINE       olasm                  STABLE

ora.LISTENER2.lsnr★★

           ONLINE  ONLINE       olasm                  STABLE★★<<新增的第二套listener资源

ora.asm

           ONLINE  ONLINE       olasm                  Started,STABLE

...
-bash-4.2$
-bash-4.2$ lsnrctl

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 25-MAR-2021 09:06:31

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

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> status LISTENER
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.30.203.165)(PORT=1521)))

STATUS of the LISTENER

Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 25-MAR-2021 09:05:01
Uptime 0 days 0 hr. 1 min. 35 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /refresh/app/oracle/product/12.1.0/grid/network/admin/listener.ora
Listener Log File /refresh/app/oracle/diag/tnslsnr/olasm/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.30.203.165)(PORT=1521))) ★<<对第二个网卡的IP进行监听
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost)(PORT=5500))(Security=(my_wallet_directory=/refresh/app/oracle/product/12.1.0/ASMdbA/admin/ASMdbA/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "ASMdbA.us.oracle.com" has 1 instance(s).
Instance "ASMdbA", status READY, has 1 handler(s) for this service...
Service "ASMdbAXDB.us.oracle.com" has 1 instance(s).
Instance "ASMdbA", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>
LSNRCTL> status LISTENER2
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.10)(PORT=1741)))

STATUS of the LISTENER

Alias LISTENER2
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 25-MAR-2021 09:00:42
Uptime 0 days 0 hr. 6 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /refresh/app/oracle/product/12.1.0/grid/network/admin/listener.ora
Listener Log File /refresh/app/oracle/diag/tnslsnr/olasm/listener2/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.10.10)(PORT=1741))) ★<<对第二个网卡的IP进行监听
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1741)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1741)))
Services Summary...
Service "ASMdbA.us.oracle.com" has 1 instance(s).
Instance "ASMdbA", status READY, has 1 handler(s) for this service...
Service "ASMdbAXDB.us.oracle.com" has 1 instance(s).
Instance "ASMdbA", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>

接下来简单查看一下停掉新增的 listener 时,资源和监听状态变化:
-bash-4.2$ /refresh/app/oracle/product/12.1.0/grid/bin/srvctl stop listener -listener LISTENER2
-bash-4.2$

-bash-4.2$ /refresh/app/oracle/product/12.1.0/grid/bin/crsctl stat res -t

Name Target State Server State details

Local Resources

ora.DATA.dg

           ONLINE  ONLINE       olasm                  STABLE

ora.LISTENER.lsnr

           ONLINE  ONLINE       olasm                  STABLE

ora.LISTENER2.lsnr

           OFFLINE OFFLINE      olasm                  STABLE

...
-bash-4.2$ /refresh/app/oracle/product/12.1.0/grid/bin/lsnrctl status LISTENER2

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 25-MAR-2021 09:15:28

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.10)(PORT=1741)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1741)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 2: No such file or directory
-bash-4.2$

你可能感兴趣的:(如何在 Oracle Restart环境中,在指定的网卡上增配第二套listener)