您好,登錄后才能下訂單哦!
Snapshot Standby,此功能可將備庫置身于"可讀寫狀態"用于不方便在生產環境主庫中測試的內容,比如模擬上線測試等任務。當備庫讀寫狀態下任務完成后,可以非常輕松的完成Snapshot Standby數據庫角色切換回備庫角色,恢復與主庫數據同步。在Snapshot Standby數據庫狀態下,備庫是可以接受主庫傳過來的日志,但是不能夠將變化應用在備庫中。
物理備庫要轉換成Snapshot的前提條件
停止備庫上的日志應用。
備庫開啟數據庫閃回功能
下面演示,如果切換成snapshot。
1. 停止備庫上的日志應用。
DGMGRL> edit database 11gdg2 set state=APPLY-OFF; Succeeded. DGMGRL>
2. 開啟備庫數據庫閃回功能
SQL> alter database flashback on; Database altered.
3.將備庫轉為snapshot
DGMGRL> CONVERT DATABASE 11GDG2 TO SNAPSHOT STANDBY; Converting database "11gdg2" to a Snapshot Standby database, please wait... Database "11gdg2" converted successfully
4. 此時,我們在主庫上做些數據修改
SQL> select count(*) from t1; COUNT(*) ---------- 56 SQL> insert into t1 select * from t1; 56 rows created. SQL> commit; Commit complete.
5. 在備庫中修改數據
SQL> conn / as sysdba Connected. SQL> select open_mode from v$database; OPEN_MODE ------------------------------------------------------------ READ WRITE SQL> conn scott/tiger Connected. SQL> create table t2 as select * from t1; Table created. SQL> select count(*) from t2; COUNT(*) ---------- 56 SQL>
6. 將snapshot轉為physical standby
DGMGRL> CONVERT DATABASE 11GDG2 TO PHYSICAL STANDBY; Converting database "11gdg2" to a Physical Standby database, please wait... Operation requires shutdown of instance "dgtst" on database "11gdg2" Shutting down instance "dgtst"... Database closed. Database dismounted. ORACLE instance shut down. Operation requires startup of instance "dgtst" on database "11gdg2" Starting instance "dgtst"... ORACLE instance started. Database mounted. Continuing to convert database "11gdg2" ... Operation requires shutdown of instance "dgtst" on database "11gdg2" Shutting down instance "dgtst"... ORA-01109: database not open Database dismounted. ORACLE instance shut down. Operation requires startup of instance "dgtst" on database "11gdg2" Starting instance "dgtst"... ORACLE instance started. Database mounted. Database "11gdg2" converted successfully
將備庫打開
SQL> alter database open read only; Database altered.
7. 檢查備庫中t2表是否還存在
SQL> conn scott/tiger Connected. SQL> select * from t2; select * from t2 * ERROR at line 1: ORA-00942: table or view does not exist SQL>
8.看看轉換到snapshot后,對主庫做的更改數據有沒有被應用。
SQL> select count(*) from t1; COUNT(*) ---------- 112 SQL>
和第4步結論是一樣的 。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。