RAC 攻击 - Oracle 集群数据库在家/服务故障转移
外观
- 以 **oracle** 用户登录到 **collabn1**。创建新的服务 **svctest**,将 RAC1 作为首选实例,将 RAC2 作为可用实例。这意味着它通常将在 RAC1 实例上运行,但如果 RAC1 变得不可用,则会故障转移到 RAC2 实例。collabn1:/home/oracle[RAC1]$ srvctl add service -d RAC -s svctest -r RAC1 -a RAC2 -P BASIC collabn1:/home/oracle[RAC1]$ srvctl start service -d RAC -s svctest
- 检查两个节点上的 **lsnrctl** 并查看两个节点上的 **SERVICE_NAMES** 初始化参数,检查服务在哪里运行。您永远不应该直接更改 RAC 数据库上的 SERVICE_NAMES 初始化参数!此参数由集群软件自动维护。
collabn1:/home/oracle[RAC1]$ srvctl status service -d RAC -s svctest Service svctest is running on instance(s) RAC1 collabn1:/home/oracle[RAC1]$ lsnrctl services Service "svctest.vm.ardentperf.com" has 1 instance(s). Instance "RAC1", status READY, has 2 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready REMOTE SERVER (ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.vm.ardentperf.com)(PORT=1521)) "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER collabn1:/home/oracle[RAC1]$ ssh collabn2 Last login: Sun Aug 3 13:13:16 2008 from collabn1 The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 is /u01/app/oracle Set environment by typing 'oenv' - default is instance RAC1. collabn2:/home/oracle[RAC2]$ lsnrctl services collabn2:/home/oracle[RAC2]$ lsnrctl services Service "svctest.vm.ardentperf.com" has 1 instance(s). Instance "RAC1", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready REMOTE SERVER (ADDRESS=(PROTOCOL=TCP)(HOST=collabn1.vm.ardentperf.com)(PORT=1521)) SQL> col value format a60 SQL> select inst_id, value from gv$parameter where NAME='service_names'; INST_ID VALUE ---------- ------------------------------------------------------------ 1 svctest, RAC.vm.ardentperf.com 2 RAC.vm.ardentperf.com
- 使用 SHUTDOWN ABORT 杀死运行服务 **svctest** 的实例。SQL> show user USER is "SYS" SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- RAC1 SQL> shutdown abort; ORACLE instance shut down. SQL>
- 等待片刻,然后重复步骤 2。发生了什么?collabn1:/home/oracle[RAC1]$ srvctl status service -d RAC -s svctest
- 重启您杀死的实例。这不会启动任何实例恢复。你知道为什么吗?
collabn1:/home/oracle[RAC1]$ srvctl status database -d RAC Instance RAC1 is not running on node collabn1 Instance RAC2 is running on node collabn2 collabn1:/home/oracle[RAC1]$ srvctl start instance -d RAC -i RAC1 collabn1:/home/oracle[RAC1]$ srvctl status database -d RAC Instance RAC1 is running on node collabn1 Instance RAC2 is running on node collabn2 collabn1:/home/oracle[RAC1]$
- 重复步骤 2。服务现在在哪里运行?collabn1:/home/oracle[RAC1]$ srvctl status service -d RAC -s svctest
- 手动将服务故障转移。确认它现在在哪里运行。请注意,这不会断开任何当前会话collabn1:/home/oracle[RAC1]$ srvctl relocate service -d RAC -s svctest -i RAC2 -t RAC1 collabn1:/home/oracle[RAC1]$ srvctl status service -d RAC -s svctest