这篇文章讨论将Standby数据库临时转换为主数据库,原本的主数据库不发生变化。
1.在主数据库延迟向Standby数据库传送日志。
SQL> alter system set log_archive_dest_state_2=defer;
System altered.
2.启用Standby数据库flashback database特性。
SQL> startup mount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2230600 bytes
Variable Size 281020088 bytes
Database Buffers 494927872 bytes
Redo Buffers 6819840 bytes
Database mounted.
SQL> alter database flashback on;
Database altered.
SQL> show parameter recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +DGFRA
db_recovery_file_dest_size big integer 10G
db_unrecoverable_scn_tracking boolean TRUE
recovery_parallelism integer 0
3.在备用数据库取消FAL配置。
SQL> show parameter fal
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string
fal_server string ractest
SQL> alter system set fal_server='';
System altered.
4.创建还原点。
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED
SQL>
SQL> create restore point Before_App_Test guarantee flashback database;
Restore point created.
5.激活Standby数据库。
SQL> alter database activate standby database;
Database altered.
SQL> alter database open;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
6.模拟测试数据。
SQL> create table test199(id number primary key);
Table created.
SQL> begin
2 for i in 1..1000 loop
3 insert into test199 values(i);
4 end loop;
5 end;
6 /
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL> select count(1) from test199;
COUNT(1)
----------
1000
7.将Standby数据库利用flashback database特性恢复到还原点。
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2230600 bytes
Variable Size 281020088 bytes
Database Buffers 494927872 bytes
Redo Buffers 6819840 bytes
Database mounted.
SQL> flashback database to restore point before_app_test;
Flashback complete.
8.将主数据库转换为Standby数据库。
SQL> alter database convert to physical standby;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01507: database not mounted
SQL> select status from v$instance;
STATUS
------------
STARTED
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00750: database has been previously mounted and dismounted
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2230600 bytes
Variable Size 281020088 bytes
Database Buffers 494927872 bytes
Redo Buffers 6819840 bytes
Database mounted.
SQL> alter database open;
Database altered.
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
RACTEST READ ONLY
SQL> select count(1) from test199;
select count(1) from test199
*
ERROR at line 1:
ORA-00942: table or view does not exist
9.恢复主数据库向Standby数据库的日志传递。
SQL> alter system set log_archive_dest_state_2=enable;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> select thread#,dest_id,max(sequence#) from v$archived_log where resetlogs_id=786500749 group by thread#,dest_id;
THREAD# DEST_ID MAX(SEQUENCE#)
---------- ---------- --------------
2 1 71
1 2 102
1 1 102
2 2 70
SQL> select thread#,dest_id,max(sequence#) from v$archived_log where resetlogs_id=786500749 group by thread#,dest_id;
THREAD# DEST_ID MAX(SEQUENCE#)
---------- ---------- --------------
2 1 72
1 2 102
1 1 102
2 2 72
10.恢复Standby数据库的FAL配置。
SQL> alter system set fal_server='ractest';
System altered.
参考文章:
http://blog.csdn.net/henrybai/article/details/3020068
--end--
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23135684/viewspace-750641/
,如需转载,请注明出处,否则将追究法律责任。