首页 > 代码库 > oracle 利用flashback将备库激活为read wirte(10g 及上)

oracle 利用flashback将备库激活为read wirte(10g 及上)

oracle 利用flashback将备库激活为read wirte(10g 及上)环境:OS: CENTOS 6.5 X64DB: ORACLE 10.2.0.5主库操作:SQL> alter system switch logfile;System altered.SQL> 备库操作取消归档应用SQL> alter database recover managed standby database cancel;Database altered.SQL> 创建还原点SQL>  create restore point restore_point_dg guarantee flashback database;Restore point created.SQL> 主库操作将备库的归档目的设置为defer(这样后台不会报错,防止主库传输数据到备库)官方解释deferSpecifies that valid destination information and attributes are preserved, but the destination is excluded from archiving operations until re-enableSQL> alter system set log_archive_dest_state_2=defer;将备库激活为read/wirteSQL> alter database activate standby database;Database altered.SQL> alter database open;Database altered.SQL> 备库状态为read/writeSQL> select open_mode from v$database;OPEN_MODE----------READ WRITESQL> 这样我们可以在备库Export操作了[oracle@oracle10g-dg2-213-101 backup]$ expdp directory=backup dumpfile=test1`date +%F`.dmp logfile=test1`date +%F`.log schemas=test1Export: Release 10.2.0.5.0 - 64bit Production on Monday, 15 September, 2014 22:37:17Copyright (c) 2003, 2007, Oracle.  All rights reserved.Username: / as sysdbaConnected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsStarting "SYS"."SYS_EXPORT_SCHEMA_01":  /******** AS SYSDBA directory=backup dumpfile=test12014-09-15.dmp logfile=test12014-09-15.log schemas=test1 Estimate in progress using BLOCKS method...Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATATotal estimation using BLOCKS method: 64 KBProcessing object type SCHEMA_EXPORT/USERProcessing object type SCHEMA_EXPORT/SYSTEM_GRANTProcessing object type SCHEMA_EXPORT/ROLE_GRANTProcessing object type SCHEMA_EXPORT/DEFAULT_ROLEProcessing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMAProcessing object type SCHEMA_EXPORT/TABLE/TABLEProcessing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS. . exported "TEST1"."TEST"                              4.960 KB       5 rowsMaster table "SYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded******************************************************************************Dump file set for SYS.SYS_EXPORT_SCHEMA_01 is:  /u01/app/oracle/dump/test12014-09-15.dmpJob "SYS"."SYS_EXPORT_SCHEMA_01" successfully completed at 22:37:31[oracle@oracle10g-dg2-213-101 backup]$ 主库操作主库上添加记录SQL> insert into test values(10);1 row created.SQL> insert into test values(10);1 row created.SQL> insert into test values(10);1 row created.SQL> insert into test values(11);1 row created.SQL> insert into test values(11);1 row created.SQL> commit;Commit complete.System altered.SQL> SQL> conn / as sysdbaConnected.SQL> alter system switch logfile;System altered.SQL> 备库操作备库上删除表[oracle@oracle10g-dg2-213-101 backup]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.5.0 - Production on Mon Sep 15 22:40:53 2014Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> conn test1/test1Connected.SQL> drop table test purge;Table dropped.SQL> 准备重新恢复到dg备库环境SQL> startup mount force;ORACLE instance started.Total System Global Area  704643072 bytesFixed Size		    2098912 bytesVariable Size		  192940320 bytesDatabase Buffers	  503316480 bytesRedo Buffers		    6287360 bytesDatabase mounted.SQL> 闪回数据库SQL>  flashback database to restore point restore_point_dg;Flashback complete.SQL> SQL> shutdown immediate;ORA-01507: database not mountedORACLE instance shut down.SQL> startup nomount;ORACLE instance started.Total System Global Area  704643072 bytesFixed Size		    2098912 bytesVariable Size		  192940320 bytesDatabase Buffers	  503316480 bytesRedo Buffers		    6287360 bytesSQL> alter database mount standby database; #或者alter database convert to physical standby;Database altered.主库操作SQL> alter system set log_archive_dest_state_2=enable scope=both;System altered.SQL> 备库操作,检查进程是否正常SQL> select process,status from v$managed_standby;PROCESS   STATUS--------- ------------ARCH	  CONNECTEDARCH	  CONNECTEDARCH	  CONNECTEDMRP0	  WAIT_FOR_LOGRFS	  IDLERFS	  IDLE6 rows selected.SQL> 主库操作切换日志SQL> alter system switch logfile;System altered.SQL> 备库已正常FS[1]: Successfully opened standby log 8: ‘/u01/app/oracle/oradata/netdata/st_redo08a.log‘Mon Sep 15 22:50:22 CST 2014Media Recovery Log /u01/app/oracle/archive/netdata/1_79_857898543.arcMedia Recovery Waiting for thread 1 sequence 80

 

oracle 利用flashback将备库激活为read wirte(10g 及上)