您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。