在很多时候客户都需要它的备库能起来让他们做个测试,并且是在读写模式,用完以后在加到dataguard里面.主要用到的是flashback这个功能.下面我做个简单的测试

1.开启备库的flashback on

[oracle@dg2 dbs]$ more initstandby.ora
db_name=DG
control_files=/u01/app/oradata/con.ctl
db_recovery_file_dest=’/u01/app/oradata/flashback’
db_recovery_file_dest_size=6g
[oracle@dg2 dbs]$ sqlplus ‘/as sysdba’;

SQL*Plus: Release 11.2.0.2.0 Production on Tue Jul 30 06:12:45 2013

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
Database mounted.
SQL> alter database flashback on;

Database altered.

SQL> select current_scn from v$database;

CURRENT_SCN
———–
277660

2.创建一个恢复的点

SQL> alter database open;

Database altered.

SQL> create restore point flash_to_dg guarantee flashback database;

Restore point created.

3.读写模式打开standby database

SQL> alter database activate standby database;

Database altered.

SQL> startup force;
ORACLE instance started.

Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
Database mounted.
Database opened.
SQL> select open_mode from v$database;

OPEN_MODE
——————–
READ WRITE

SQL> create table flash_to_table as select * from lance;

Table created.

SQL> commit;

Commit complete.

4.重新回到standby database,首先要mount然后flashback to flashback_to_dg这个点.然后切换到standby database.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
Database mounted.
SQL> flashback database to restore point flash_to_dg;

Flashback complete.

SQL>

SQL> alter database convert to physical standby;

Database altered.

SQL>

5.关闭flashback并且删除restore point

SQL> startup mount;
ORACLE instance started.

Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
Database mounted.
SQL> alter database flashback off;

Database altered.

SQL> select name from v$restore_point;

NAME
——————————————————————————–
FLASH_TO_DG

SQL> drop restore point flash_to_dg;

Restore point dropped.

SQL> alter database open;

Database altered.

6.check dataguard ok.