日期:2014-05-16 浏览次数:20633 次
ORACLE 11g PHYSICAL STANDBY已经不仅仅只提供灾难恢复功能,其ACTI VE DATA GUARD 特性让备库处于
RED ONLY状态,可以提供做报表查询、读写分离使用;还新增了SNAPSHOT STANDBY 特性,此特性能让备库
暂时处于可读可写状态,为各种性能、压力测试提供了环境,重要的是测试完成后又可转换回PHYSICAL STANDBY,
备库的数据继续与主库保持一致。
1. 只有PHYSICAL STANDBY能转换为SNAPSHOT STANDBY。
2. DB_RECOVERY_FILE_DEST必需设置,这里FLASHBACK DATABASE不是必须的。
3.只有PHYSICAL STANDBY 处于mount模式才能转换为SNAPSHOT STANDBY。
SQL> alter system set DB_RECOVERY_FILE_DEST_SIZE=500m scope=both;
System altered.
SQL> alter system set db_recovery_file_dest='/u01/arch/flasharch' scope=both;
System altered.
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
NO
SQL> select database_role,db_unique_name,open_mode from v$database;
DATABASE_ROLE DB_UNIQUE_NAME OPEN_MODE
---------------- ------------------------------ --------------------
PHYSICAL STANDBY ogg READ ONLY WITH APPLY
此时备库为PHYSICAL STANDBY,正处于READ ONLY REAL TIME APPLY 模式
SQL> alter database recover managed standby database cancel;
Database altered.
创建SNAPSHOT STANDBY 命令非常简单
SQL> alter database convert to snapshot standby;
Database altered.
查看alter log 里面的信息,命令已经执行完成,ORACLE创建了guaranteed restore point
Managed Standby Recovery Canceled (ogg)
Completed: alter database recover managed standby database cancel
Wed Oct 30 11:08:18 2013
alter database convert to snapshot standby
Starting background process RVWR
Wed Oct 30 11:08:18 2013
RVWR started with pid=26, OS id=5156
Allocated 3981204 bytes in shared pool for flashback generation buffer
Created guaranteed restore point SNAPSHOT_STANDBY_REQUIRED_10/30/2013 11:08:18
查看备库模式已经变为SNAPSHOT STADNBY
SQL> select database_role,db_unique_name,open_mode from v$database;
DATABASE_ROLE DB_UNIQUE_NAME OPEN_MODE
---------------- ------------------------------ --------------------
SNAPSHOT STANDBY ogg MOUNTED
查看闪回恢复区已经产生文件
SQL> !ls -lt /u01/arch/flasharch/OGG/flashback
total 102528
-rw-r----- 1 oracle oinstall 52436992 Oct 30 11:37 o1_mf_970y12xh_.flb
-rw-r----- 1 oracle oinstall 52436992 Oct 30 11:08 o1_mf_970y15og_.flb
SQL> alter database open;
Database altered.
SQL> create user xhl_snapstb identified by xhl;
User created.
SQL> grant dba to xhl_snapstb;
Grant succeeded.
SQL> create table xhl_snapstb.xhl as select * from dba_users;
Table created.
SQL> select count(*) from xhl_snapstb.xhl;
COUNT(*)
----------
9
SQL> select table_name,TABLESPACE_NAME from dba_tables where tablespace_name = 'TBS_XHL';
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
XHL TBS_XHL
SQL> DROP TABLE XHL PURGE;
Table dropped.
Wed Oct 30 11:23:47 2013
drop tablespace TBS_XHL including c