RAC 攻击 - Oracle 集群数据库实战/运行时故障转移
外观
- 从 VMware 控制台中打开 collabn1 的电源。启动后,以 oracle 用户身份登录,并将我们之前在本实验室中创建的 svctest 服务回滚。
[root@collabn1 ~]# srvctl status database -d RAC Instance RAC1 is running on node collabn1 Instance RAC2 is running on node collabn2 collabn1:/home/oracle[RAC1]$ srvctl status service -d RAC -s svctest Service svctest is running on instance(s) RAC2 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 Service svctest is running on instance(s) RAC1
- 在您的本地计算机上,编辑即时客户端使用的 TNSNAMES.ORA 文件。添加一个名为 SVCTEST 的新条目,它连接到 svctest 服务,并确保连接正常工作。连接后,还要检查您的 TAF 设置。(旁注:我们没有使用域名配置此服务,但是除非您在 TNSNAMES 条目中指定域名,否则您无法连接到它。试试看。这个域名从哪里来?) C:\instantclient_11_2> notepad c:\instantclient_11_2\tnsnames.ora SVCTEST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collab-scan)(PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = svctest.vm.ardentperf.com) ) ) SVCTEST-NOVIP = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = collabn1)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = collabn2)(PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = svctest.vm.ardentperf.com) ) ) C:\instantclient_11_2> sqlplus sh/sh@svctest SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- RAC1 SQL> col service_name format a20 SQL> col username format a10 SQL> select username, service_name, failover_method, failover_type 2 from v$session where sid=(select max(sid) from v$mystat); USERNAME SERVICE_NAME FAILOVER_M FAILOVER_TYPE ---------- -------------------- ---------- ------------- SH svctest NONE NONE
- 从您的 Windows SQLPlus 会话中,更新 svctest 服务的服务器端 TAF(透明应用程序故障转移)设置。 begin dbms_service.modify_service( service_name=>'svctest', failover_type=>dbms_service.failover_type_select, failover_method=>dbms_service.failover_method_basic, failover_delay=>5, failover_retries=>60 ); end; / PL/SQL procedure successfully completed.
- 重新连接并再次检查会话的 TAF 设置。 SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options C:\instantclient_11_2> sqlplus sh/sh@svctest SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- RAC1 SQL> col service_name format a20 SQL> col username format a10 SQL> select username, service_name, failover_method, failover_type 2 from v$session where sid=(select max(sid) from v$mystat); USERNAME SERVICE_NAME FAILOVER_M FAILOVER_TYPE ---------- -------------------- ---------- ------------- SH svctest BASIC SELECT
- 同时打开第二个连接到 NOVIP 服务的 sqlplus 会话。 C:\> cd \instantclient_11_2 C:\instantclient_11_2> set TNS_ADMIN=c:\instantclient_11_2 C:\instantclient_11_2> sqlplus sh/sh@svctest-novip SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- RAC1 SQL> col service_name format a20 SQL> col username format a10 SQL> select username, service_name, failover_method, failover_type 2 from v$session where sid=(select max(sid) from v$mystat); USERNAME SERVICE_NAME FAILOVER_M FAILOVER_TYPE ---------- -------------------- ---------- ------------- SH svctest BASIC SELECT
- 在两个查询中启动一个长时间运行的查询。在查询运行期间,关闭它们连接到的节点的电源。每个会话发生了什么? select c.cust_last_name, p.prod_name, s.quantity_sold from products p, sales s, customers c where p.prod_id = s.prod_id and c.cust_id = s.cust_id;