重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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步结论是一样的 。