客户的测试环境,原本默认连接到节点1上,但是现在连接会跑到节点2上。
这一篇描述问题的现象和解决。
这是一个11.2.0.2的RAC for Linux X86-64环境,当时为了满足客户对于连接方面的需求,部署了SERVICES,将节点1作为优先节点,当节点1发生DOWN机是FAILOVER到节点2上。
利用默认的SERVICES来连接数据库,检查连接情况:
SQL> conn test/test@10.0.10.57/rac_xshdb
Connected.
SQL> select instance_number, instance_name from v$instance;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
2 xshdb2
SQL> select inst_id, service_name, count(*)
2
from gv$session
3
group by inst_id, service_name
4
order by 1, 2;
INST_ID
SERVICE_NAME
COUNT(*)
---------- ----------------------------------------------------------------
----------
1 SYS$BACKGROUND
54
1 SYS$USERS
6
1 rac_xshdb 11
2 SYS$BACKGROUND
54
2 SYS$USERS
5
2 rac_xshdb 57
2 xshdb
1
7 rows selected.
SQL> show parameter service
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names
string rac_xshdb, raclb_xshdb
可以看到,使用rac_xshdb连接数据库,默认连接到节点2上的实例2,而正常情况下应该连接到实例1。
目前绝大部分通过rac_xshdb的连接都连接到节点2,少部分连接到节点1的会话,可能是问题发生之前建立连接的。
采用其他的连接方式登录数据库:
SQL> conn test/test@10.0.10.57/xshdb
Connected.
SQL> select instance_number, instance_name from v$instance;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
1 xshdb1
SQL> show parameter service_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names
string raclb_xshdb
可以看到,通过其他的连接方式是可以连接到实例1上,节点1的实例以及监听并没有问题。
对比两个节点上的service_names参数可以发现,实例1上rac_xshdb服务名消失,自然无法通过rac_xshdb来连接到实例1。
通过srvctl检查服务状态:
[oracle@xsh-server1 trace]$ srvctl
status service -d xshdb
Service rac_xshdb is running on instance(s) xshdb2
Service raclb_xshdb is running on instance(s) xshdb1,xshdb2
服务rac_xshdb已经漂移到节点2上,显然这是导致问题的原因。
解决问题很简单,关闭并重启服务即可:
[oracle@xsh-server1 trace]$ srvctl
stop service -d xshdb -s "rac_xshdb"
[oracle@xsh-server1 trace]$ srvctl start service -d xshdb -s
"rac_xshdb"
[oracle@xsh-server1 trace]$ srvctl status service -d xshdb
Service rac_xshdb is running on instance(s) xshdb1
Service raclb_xshdb is running on instance(s) xshdb1,xshdb2
现在利用rac_xshdb来连接数据库:
SQL> conn test/test@10.0.10.57/rac_xshdb
Connected.
SQL> select instance_number, instance_name from v$instance;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
1 xshdb1
SQL> show parameter service_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names
string raclb_xshdb, rac_xshdb
现在服务恢复正常,通过rac_xshdb服务连接到实例1上,此时SERVICE_NAMES参数也恢复正常。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4227/viewspace-703290/,如需转载,请注明出处,否则将追究法律责任。