2011/12/04 by Maclean Liu 14 Commentshtml
以前有同窗想要給11gR2的RAC添加LISTENER監聽器,查看了listener.ora並發現問題:node
[oracle@vrh2 ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-DEC-2011 02:51:40 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 02-DEC-2011 05:40:09 Uptime 1 days 21 hr. 11 min. 31 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora Listener Log File /g01/orabase/diag/tnslsnr/vrh2/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.163)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.164)(PORT=1521))) Services Summary... Service "+ASM" has 1 instance(s). Instance "+ASM2", status READY, has 1 handler(s) for this service... Service "VPROD" has 1 instance(s). Instance "VPROD2", status READY, has 1 handler(s) for this service... Service "VPRODXDB" has 1 instance(s). Instance "VPROD2", status READY, has 1 handler(s) for this service... The command completed successfully [oracle@vrh2 ~]$ cat /g01/11.2.0/grid/network/admin/listener.ora 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_LSN_MACLEAN=ON # line added by Agent
以上listener.ora配置文件中的信息是Grid Infrastructure安裝過程當中Agent自行添加的(During the Grid Infrastructure installation, the (default) node VIP listener is always created referencing the public network),比較難以理解的多是LISTENER僅指定了PROTOCOL=IPC的信息, 而沒有指定監聽的地址、端口等信息。數據庫
實際上11.2 GI的LISTENER 監聽器配置默認受到11.2新引入的endpoints_listener.ora配置文件的管理:併發
Listener.ora [grid@netrac1 admin]$ more listener.ora LISTENER_SCAN2=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN2)))) # 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 ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN2=ON # line added by Agent The ENABLE_GLOBAL_DYNAMIC_ENDPOINT_ parameter is set to allow the listener to accept connections for pre-11.2 databases which did not register the dynamic endpoint. Listener status "listener" showing 1 instance registered, ie instance running on the node [grid@netrac1 admin]$ lsnrctl status listener Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 15-FEB-2011 10:57:09 Uptime 0 days 0 hr. 0 min. 46 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora Listener Log File /u01/app/grid/diag/tnslsnr/netrac1/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=12.345.678.111)(PORT=1521))) ** Node IP Address ** (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=12.345.678.888)(PORT=1521))) ** Node VIP Address ** Services Summary... Service "v11gr2" has 1 instance(s). Instance "v11gr21", status READY, has 2 handler(s) for this service... The command completed successfully New file for 11.2 called endpoints_listener.ora, showing the Node IP address and Node VIP address. [grid@netrac1 admin]$ more endpoints_listener.ora LISTENER_NETRAC1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=netrac1-vip)(PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=12.345.678.888)(PORT=1521)(IP=FIRST)))) # line added by Agent Endpoints_listener.ora file is there for backward compatibility with pre-11.2 databases. DBCA needs to know the endpoints location to configure database parameters and tnsnames.ora file. It used to use the listener.ora file, 11.2 RAC listener.ora by default only has IPC entries. "Line added by Agent" is the Oraagent is the process updating the listener.ora and endpoints_listener.ora files. Endpoints_listener.ora showing the Node IP address and Node VIP address [grid@netrac2 admin]$ more endpoints_listener.ora LISTENER_NETRAC2=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=netrac2-vip)(PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=12.345.678.999) (PORT=1521)(IP=FIRST)))) # line added by Agent
我一開始覺得LISTENER默認監聽的地址和端口被寫到了OCR中,後來用ocrdump轉儲註冊信息發現沒有相關記錄。 後來才發現原來11.2 GI中監聽器的地址和端口信息被移到了 endpoints_listener.ora中, 「Line added by Agent」說明是由Oraagent 進程更新的記錄。oracle
注意:使用 endpoints_listener.ora的狀況 下不該使用lsnrctl管理LISTENER,而需使用srvctl或crsctl工具管理,不然lsnrctl將不會識別endpoints_listener.ora中的信息,形成監聽沒有在必要地址、端口上工做。如:app
[grid@vrh1 admin]$ lsnrctl status LSN_MACLEAN LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 10:45:26 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LSN_MACLEAN))) STATUS of the LISTENER ------------------------ Alias LSN_MACLEAN Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 26-NOV-2011 08:33:14 Uptime 1 days 2 hr. 12 min. 11 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora Listener Log File /g01/orabase/diag/tnslsnr/vrh1/lsn_maclean/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LSN_MACLEAN))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.161)(PORT=1588))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.162)(PORT=1588))) Services Summary... Service "VPROD" has 1 instance(s). Instance "VPROD1", status READY, has 1 handler(s) for this service... Service "VPRODXDB" has 1 instance(s). Instance "VPROD1", status READY, has 1 handler(s) for this service... The command completed successfully [grid@vrh1 admin]$ lsnrctl reload LSN_MACLEAN LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 10:45:39 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LSN_MACLEAN))) The command completed successfully [grid@vrh1 admin]$ lsnrctl status LSN_MACLEAN LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 10:45:44 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LSN_MACLEAN))) STATUS of the LISTENER ------------------------ Alias LSN_MACLEAN Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 26-NOV-2011 08:33:14 Uptime 1 days 2 hr. 12 min. 30 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora Listener Log File /g01/orabase/diag/tnslsnr/vrh1/lsn_maclean/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LSN_MACLEAN))) The listener supports no services The command completed successfully [grid@vrh1 admin]$ srvctl stop listener -l LSN_MACLEAN [grid@vrh1 admin]$ srvctl start listener -l LSN_MACLEAN [grid@vrh1 admin]$ lsnrctl status LSN_MACLEAN LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 10:46:26 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LSN_MACLEAN))) STATUS of the LISTENER ------------------------ Alias LSN_MACLEAN Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 27-NOV-2011 10:46:22 Uptime 0 days 0 hr. 0 min. 4 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora Listener Log File /g01/orabase/diag/tnslsnr/vrh1/lsn_maclean/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LSN_MACLEAN))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.161)(PORT=1588))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.162)(PORT=1588))) The listener supports no services The command completed successfully
而在11.2 RAC中listener.ora僅記錄LISTENER的IPC條目。這樣作的目的是方便dbca配置數據庫參數及tnsnames.ora配置文件。tcp
瞭解到以上信息後可能你對當前11.2 RAC中的listener.ora文件中的監聽配置信息再也不感到奇怪。工具
咱們可使用netca圖形化工具或者srvctl 命令行工具添加監聽配置; 若是僅僅是手動在listener.ora中添加記錄的話是沒法被註冊爲Cluster Ready Service的服務的,將不會被CRS管理。this
方法1:spa
使用netca和netmgr圖形化工具,完成添加監聽和靜態註冊的工做。
1) 以Grid Infrastructure GI用戶登陸任意節點,並運行netca啓動圖形界面:
su - grid (grid)$ export DISPLAY=:0 (grid)$ netca
選擇LISTENER Configuration
選擇ADD
填入監聽名字
選擇subnet和availabe protocol ,通常默認便可,除非你有多個public network網段
填入端口號
選擇NO
選擇要啓動的監聽名,即方纔你建立的監聽名
以後選擇FINISH退出netca 界面,啓動netmgr界面,爲監聽加入靜態註冊的信息:
su - grid (grid)$ export DISPLAY=:0 (grid)$ netmgr
點選方纔建立的監聽器,選擇Database Services菜單
填入Global Database Name和本地實例的SID信息,並確認ORACLE HOME Directory(應是Grid Infrastructure的Home目錄)正確後點選Save Network Configuration。
以後使用srvctl 或 crsctl 重啓該監聽便可生效:
[grid@vrh1 admin]$ crsctl status res ora.MACLEAN_LISTENER.lsnr NAME=ora.MACLEAN_LISTENER.lsnr TYPE=ora.listener.type TARGET=ONLINE , ONLINE STATE=ONLINE on vrh1, ONLINE on vrh2 [grid@vrh1 admin]$ crsctl stop res ora.MACLEAN_LISTENER.lsnr CRS-2673: Attempting to stop 'ora.MACLEAN_LISTENER.lsnr' on 'vrh1' CRS-2673: Attempting to stop 'ora.MACLEAN_LISTENER.lsnr' on 'vrh2' CRS-2677: Stop of 'ora.MACLEAN_LISTENER.lsnr' on 'vrh1' succeeded CRS-2677: Stop of 'ora.MACLEAN_LISTENER.lsnr' on 'vrh2' succeeded [grid@vrh1 admin]$ crsctl start res ora.MACLEAN_LISTENER.lsnr CRS-2672: Attempting to start 'ora.MACLEAN_LISTENER.lsnr' on 'vrh2' CRS-2672: Attempting to start 'ora.MACLEAN_LISTENER.lsnr' on 'vrh1' CRS-2676: Start of 'ora.MACLEAN_LISTENER.lsnr' on 'vrh1' succeeded CRS-2676: Start of 'ora.MACLEAN_LISTENER.lsnr' on 'vrh2' succeeded [grid@vrh1 admin]$ lsnrctl status MACLEAN_LISTENER LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 11:00:42 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=MACLEAN_LISTENER))) STATUS of the LISTENER ------------------------ Alias MACLEAN_LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 27-NOV-2011 11:00:11 Uptime 0 days 0 hr. 0 min. 31 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora Listener Log File /g01/orabase/diag/tnslsnr/vrh1/maclean_listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=MACLEAN_LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.161)(PORT=1598))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.162)(PORT=1598))) Services Summary... Service "VPROD" has 1 instance(s). Instance "VPROD1", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully [grid@vrh1 admin]$ srvctl stop listener -l MACLEAN_LISTENER [grid@vrh1 admin]$ srvctl start listener -l MACLEAN_LISTENER [grid@vrh1 admin]$ srvctl config listener -l MACLEAN_LISTENER Name: MACLEAN_LISTENER Network: 1, Owner: grid Home: End points: TCP:1598 [grid@vrh1 admin]$ lsnrctl status MACLEAN_LISTENER LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 11:01:42 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=MACLEAN_LISTENER))) STATUS of the LISTENER ------------------------ Alias MACLEAN_LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 27-NOV-2011 11:01:10 Uptime 0 days 0 hr. 0 min. 31 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora Listener Log File /g01/orabase/diag/tnslsnr/vrh1/maclean_listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=MACLEAN_LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.161)(PORT=1598))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.162)(PORT=1598))) Services Summary... Service "VPROD" has 1 instance(s). Instance "VPROD1", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully
以上使用netca和netmgr圖形界面工具完成了新監聽的添加和靜態註冊工做。
2. 使用srvctl 工具添加監聽並手動加入靜態註冊信息
檢查默認network的network number,紅色的數字
[grid@vrh1 admin]$ srvctl config network
Network exists: 1/192.168.1.0/255.255.255.0/eth0, type static
srvctl 添加監聽的語法以下
[grid@vrh1 admin]$ 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
[grid@vrh1 admin]$ srvctl add listener -l NEW_MACLEAN_LISTENER -o $CRS_HOME -p 1601 -k 1
-k 填入方纔得到的network number,-p填入端口號,-l填入監聽名,-o 填入GI HOME路徑
[grid@vrh1 admin]$ srvctl start listener -l NEW_MACLEAN_LISTENER
srvctl start listener啓動新添加的監聽後listener.ora和endpoints_listener.ora會出現新的記錄:
[grid@vrh1 admin]$ head -1 listener.ora NEW_MACLEAN_LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=NEW_MACLEAN_LISTENER)))) # line added by Agent [grid@vrh1 admin]$ head -1 endpoints_listener.ora NEW_MACLEAN_LISTENER_VRH1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=vrh1-vip)(PORT=1601)) (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.161)(PORT=1601)(IP=FIRST)))) # line added by Agent
以上已經完成了監聽的添加,足見使用srvctl管理更爲簡便。
以後僅須要加入靜態註冊信息便可,如:
SID_LIST_NEW_MACLEAN_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = VPROD) (ORACLE_HOME = /g01/11.2.0/grid) (SID_NAME = VPROD1) ) )
加入如上信息到listener.ora配置文件中(SID_LIST_($LISTENER_NAME),並重啓監聽即完成靜態註冊:
[grid@vrh1 admin]$ srvctl stop listener -l NEW_MACLEAN_LISTENER [grid@vrh1 admin]$ srvctl start listener -l NEW_MACLEAN_LISTENER [grid@vrh1 admin]$ lsnrctl status NEW_MACLEAN_LISTENER LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 11:21:37 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=NEW_MACLEAN_LISTENER))) STATUS of the LISTENER ------------------------ Alias NEW_MACLEAN_LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 27-NOV-2011 11:21:25 Uptime 0 days 0 hr. 0 min. 11 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora Listener Log File /g01/11.2.0/grid/log/diag/tnslsnr/vrh1/new_maclean_listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=NEW_MACLEAN_LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.161)(PORT=1601))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.162)(PORT=1601))) Services Summary... Service "VPROD" has 1 instance(s). Instance "VPROD1", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully