--第四篇 驗證DATA GUARD
--手動切換log,確認log file是否自動同步到備援機
--主要資料庫
SQL> ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SQL> SELECT sequence#, first_time, next_time FROM v$archived_log ORDER BY sequence#;
SQL> alter system switch logfile;
--備援資料庫
SQL> ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SQL> SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;
--在主要資料庫上
C:\Windows\system32>sqlplus / as sysdba
SQL> create user test identified by test;
SQL> grant connect, resource to test;
SQL> conn test/test@myorcl
SQL> create table test(name varchar2(20));
SQL> insert into test values('data guard');
SQL> commit;
SQL> conn / as sysdba
SQL> alter system switch logfile;
--查目前ARCHIVE_LOG
SQL> SELECT sequence#, first_time, next_time FROM v$archived_log ORDER BY sequence#;
SEQUENCE# FIRST_TIME NEXT_TIME
---------- --------------- ---------------
13 30-JUL-14 30-JUL-14
14 30-JUL-14 30-JUL-14
14 30-JUL-14 30-JUL-14
14 30-JUL-14 30-JUL-14
15 30-JUL-14 30-JUL-14
15 30-JUL-14 30-JUL-14
15 30-JUL-14 30-JUL-14
16 30-JUL-14 30-JUL-14
16 30-JUL-14 30-JUL-14
16 30-JUL-14 30-JUL-14
--在備援資料庫上
C:\Windows\system32>sqlplus / as sysdba
--查ARCHIVE LOG APPLIED狀況
SQL> SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDERBY sequence#;
SEQUENCE# FIRST_TIME NEXT_TIME APPLIED
---------- --------------- --------------- ---------
13 30-JUL-14 30-JUL-14 YES
14 30-JUL-14 30-JUL-14 YES
15 30-JUL-14 30-JUL-14 YES
16 30-JUL-14 30-JUL-14 YES
--用READ ONLY方式打開備援資料庫查看剛剛建立的帳號及資料是否有複寫過來
SQL> alter database recover managed standby database cancel;
SQL> alter database open read only;
SQL> conn test/test
SQL> select * from test;
NAME
------------------------------------------------------------
data guard
--恢復備援資料庫STANDBY模式
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE recover managed standby database disconnect from session;
第一篇 本地資料庫建置
第二篇 本地Data Guard建置
第三篇 異地Data Guard建置
第五篇 本地資料庫切換到異地DATA GUARD
沒有留言:
張貼留言