环境:
OS:Centos 7
DB:19.3.0.0 2节点组成的RAC
1.添加监听器
在其中一个节点上操作
su - grid
[grid@rac01 ~]$ srvctl add listener -l mylistener -p 1522
2.查看添加的资源
[grid@rac01 ~]$ crsctl stat resource -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
ONLINE ONLINE rac01 STABLE
ONLINE ONLINE rac02 STABLE
ora.MYLISTENER.lsnr
OFFLINE OFFLINE rac01 STABLE
OFFLINE OFFLINE rac02 STABLE
...
3.启动
[grid@rac01 ~]$srvctl start listener -l mylistener
[grid@rac01 ~]$ crsctl stat resource -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
ONLINE ONLINE rac01 STABLE
ONLINE ONLINE rac02 STABLE
ora.MYLISTENER.lsnr
ONLINE ONLINE rac01 STABLE
ONLINE ONLINE rac02 STABLE
...
4.修改数据库配置
在其中一个节点上操作即可,我这里是在节点1上操作
SQL> show parameters listener
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
forward_listener string
listener_networks string
local_listener string (ADDRESS=(PROTOCOL=TCP)(HOST=
192.168.56.201)(PORT=1521))
remote_listener string rac-scan:1521
alter system set local_listener='(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.201)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.201)(PORT = 1522))))' scope=both sid='slnngk1';
alter system set local_listener='(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.202)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.202)(PORT = 1522))))' scope=both sid='slnngk2';
5.这样的话,数据库服务都会注册到了1521和1522两个端口了
[grid@rac02 admin]$ lsnrctl status mylistener
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 21-MAR-2022 02:58:01
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=MYLISTENER)))
STATUS of the LISTENER
------------------------
Alias MYLISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 21-MAR-2022 02:53:38
Uptime 0 days 0 hr. 4 min. 23 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/grid/grid_home/19.3.0.0/network/admin/listener.ora
Listener Log File /u01/grid/grid_base/diag/tnslsnr/rac02/mylistener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=MYLISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.192)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.202)(PORT=1522)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_OCR" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_REDO" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "service_s1" has 1 instance(s).
Instance "slnngk2", status READY, has 1 handler(s) for this service...
Service "service_s2" has 1 instance(s).
Instance "slnngk2", status READY, has 1 handler(s) for this service...
Service "slnngk" has 1 instance(s).
Instance "slnngk2", status READY, has 1 handler(s) for this service...
Service "slnngkXDB" has 1 instance(s).
Instance "slnngk2", status READY, has 1 handler(s) for this service...
The command completed successfully
[grid@rac02 admin]$ lsnrctl status listener
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 21-MAR-2022 03:35:39
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 20-MAR-2022 20:54:47
Uptime 0 days 6 hr. 40 min. 52 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/grid/grid_home/19.3.0.0/network/admin/listener.ora
Listener Log File /u01/grid/grid_base/diag/tnslsnr/rac02/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.192)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.202)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_OCR" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_REDO" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "service_s1" has 1 instance(s).
Instance "slnngk2", status READY, has 1 handler(s) for this service...
Service "service_s2" has 1 instance(s).
Instance "slnngk2", status READY, has 1 handler(s) for this service...
Service "slnngk" has 1 instance(s).
Instance "slnngk2", status READY, has 1 handler(s) for this service...
Service "slnngkXDB" has 1 instance(s).
Instance "slnngk2", status READY, has 1 handler(s) for this service...
The command completed successfully