操作相当简单,以下测试:
一.物理备用数据库到快照备用数据库
--查看当前备用数据库的角色
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
-------------------- ----------------
READ ONLY WITH APPLY PHYSICAL STANDBY
--关闭并启动到mount
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 482345024 bytes
Database Buffers 243269632 bytes
Redo Buffers 2842624 bytes
Database mounted.
--转换物理standby到快照standby
SQL> alter database convert to snapshot standby;
Database altered.
SQL> select status from v$instance;
STATUS
------------
MOUNTED
SQL> alter database open;
Database altered.
--查看当前备用数据库的角色
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
-------------------- ----------------
READ WRITE SNAPSHOT STANDBY
--可以看到,oracle 有建了一个还原点
SQL> select name,storage_size from v$restore_point;
NAME
--------------------------------------------------------------------------------
STORAGE_SIZE
------------
SNAPSHOT_STANDBY_REQUIRED_08/10/2015 05:33:52
52428800
--测试是否可以修改数据库
SQL> create table scott.test02 as select * from dba_objects;
Table created.
SQL> select count(1) from scott.test02;
COUNT(1)
----------
86267
二.快照备用数据库到物理备用数据库
--查看当前备用数据库的角色
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
-------------------- ----------------
MOUNTED SNAPSHOT STANDBY
--关闭并启动到mount
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 482345024 bytes
Database Buffers 243269632 bytes
Redo Buffers 2842624 bytes
Database mounted.
--转换快照standby到物理standby
SQL> alter database convert to physical standby;
Database altered.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 482345024 bytes
Database Buffers 243269632 bytes
Redo Buffers 2842624 bytes
Database mounted.
Database opened.
SQL> alter database recover managed standby database disconnect;
Database altered.
--查看当前备用数据库的角色
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
-------------------- ----------------
READ ONLY WITH APPLY PHYSICAL STANDBY
--查看在快照standby时建的测试表已经不存在了
SQL> select * from scott.test02;
select * from scott.test02
*
ERROR at line 1:
ORA-00942: table or view does not exist
备注:
物理standby是最高保护模式(maximum protection),是不能转换为snapshot standby的.
物理standby使用了standby redo log,在create restore point后,要alter system switch logfile;,以保证还原点的scn在物理standby库上是
归档的,不然可能无法成功闪回到还原点.
物理standby在切换为快照standby后,如果间隔很长时间,primary数据库产生的大量的重做日志,这样可以在转换为物理standby后,通过
对primary数据库的增量备份并recover到物理standby,来加快物理standby的还原速度.