脚踏实地、勇往直前!
全部博文(1005)
分类: Oracle
2014-02-11 10:42:10
环境:
OS:Red Hat Linux As 5
DB:11.2.0.1
1.查看网络号
[grid@node1 ~]srvctl config network
Network exists: 1/192.168.50.0/255.255.255.0/eth0, type static
该命令需要在11.2.0.2以上的版本才有.
2.手工添加监听器
只需要在一个节点上操作
[grid@node1 ~]srvctl add listener -l listener_01 -o $ORACLE_HOME -p 1530 -k 1
这里的-k后面紧跟的数字1就是步骤1获取的网络号,这里的$ORACLE_HOME是grid用户下的目录.
3.查看监听情况
[grid@node1 ~]$ lsnrctl
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-FEB-2014 22:44:02
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> set current_listener listener_01
Current Listener is listener_01
LSNRCTL> status
TNS-01101: Could not find service name listener_01
LSNRCTL>
原因是刚才添加的监听器没有启动,下面启动监听器,没有指定节点的话,每个节点都会启动该监听器.
[grid@node1 admin]$ srvctl start listener -l listener_01
LSNRCTL> set current_listener listener_01
Current Listener is listener_01
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_01)))
STATUS of the LISTENER
------------------------
Alias LISTENER_01
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 08-FEB-2014 22:46:43
Uptime 0 days 0 hr. 0 min. 47 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/11.2.0/network/admin/listener.ora
Listener Log File /u01/app/grid/11.2.0/log/diag/tnslsnr/node1/listener_01/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_01)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.50.199)(PORT=1530)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.50.251)(PORT=1530)))
The listener supports no services
The command completed successfully
目前没有注册到任何服务.
[grid@node1 admin]$ more endpoints_listener.ora
LISTENER_01_NODE1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1530))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168
.50.199)(PORT=1530)(IP=FIRST)))) # line added by Agent
[grid@node2 admin]$ more endpoints_listener.ora
LISTENER_01_NODE2=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip)(PORT=1530))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168
.50.200)(PORT=1530)(IP=FIRST)))) # line added by Agent
启动监听器后,会在每个节点下的文件endpoints_listener.ora添加如上的内容,这是11G区别于以前版本的地方.
4.修改参数local_listener注册服务
查看当前节点的该参数
[grid@node1 admin]$ su - oracle
Password:
[oracle@node1 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Sat Feb 8 22:48:57 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> connect / as sysdba
Connected.
SQL> show parameters local_listener;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=192.
168.50.251)(PORT=1521))))
SQL>
发现这里local_listener指向默认的监听器,通过如下方法分别修改节点1和节点2的改参数.
节点1:
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.50.251)(PORT=1530))))' scope=both sid='racdb1';
System altered.
节点2:
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.50.252)(PORT=1530))))' scope=both sid='racdb2';
System altered.
修改完成后,数据库会自动注册服务到local_listener参数指向的监听器(也可以在oracle用户下使用命令alter system register手工注册).
LSNRCTL> set current_listener listener_01
Current Listener is listener_01
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_01)))
STATUS of the LISTENER
------------------------
Alias LISTENER_01
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 08-FEB-2014 22:46:43
Uptime 0 days 0 hr. 6 min. 11 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/11.2.0/network/admin/listener.ora
Listener Log File /u01/app/grid/11.2.0/log/diag/tnslsnr/node1/listener_01/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_01)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.50.199)(PORT=1530)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.50.251)(PORT=1530)))
Services Summary...
Service "RACDB" has 1 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
Service "racdbXDB" has 1 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
Service "s1" has 1 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
Service "s2" has 1 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
The command completed successfully
5.同时修改asm实例下监听器
节点1:
SQL> connect / as sysasm
Connected.
SQL> show parameters list;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=node
1-vip)(PORT=1521))))
remote_listener string
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1530))))' scope=both sid='+ASM1';
System altered.
节点2:
SQL> connect / as sysasm
Connected.
SQL> show parameters list;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=node
2-vip)(PORT=1521))))
remote_listener string
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip)(PORT=1530))))' scope=both sid='+ASM2';
System altered.
-- The End --