以讀寫(read write)方式打開PHYSICAL STANDBY數據庫,進行測試,然後還原

 

a. 檢查standby的狀態

SQL> select name,database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;
NAME      DATABASE_ROLE    OPEN_MODE  SWITCHOVER_STATUS
--------- ---------------- ---------- --------------------
ORCLDB    PHYSICAL STANDBY MOUNTED    NOT ALLOWED

b.判斷flashback_on是否開啓

SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES

c.閃回恢復區設置檢測

SQL> show parameter db_recovery_file_dest
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      /u01/oracle/flash_recovery_are
a
db_recovery_file_dest_size           big integer 2G

d.取消日誌應用

SQL> alter database recover managed standby database cancel;
Database altered.

e.創建還原點

SQL> create restore point restore_point_readonly guarantee flashback database;
Restore point created.

f.在主庫上進行日誌切換,日誌發送設置爲延遲

SQL> alter system archive log current;
System altered.
SQL> alter system set log_archive_dest_state_2=defer;
System altered.

 

h.激活備庫到read write狀態,並打開

SQL> alter database activate standby database;
Database altered.
SQL> alter database open;
Database altered.
SQL> select name,open_mode,database_role,db_unique_name from v$database;
NAME      OPEN_MODE  DATABASE_ROLE    DB_UNIQUE_NAME
--------- ---------- ---------------- ------------------------------
ORCLDB    READ WRITE PRIMARY          PHYSTDBY

i.進行read write測試

SQL> create table scott.t as select * from dba_objects;
Table created.
SQL> select count(*) from scott.t;
COUNT(*)
----------
49745
SQL> truncate table scott.t;
Table truncated.
SQL> select count(*) from scott.t;
COUNT(*)
----------
0

j.測試結束,準備還原備庫。   先強制啓動到mount狀態,然後進行數據庫閃回

 

SQL> startup mount force
ORACLE instance started.
Total System Global Area  390070272 bytes
Fixed Size                  2021024 bytes
Variable Size             142608736 bytes
Database Buffers          243269632 bytes
Redo Buffers                2170880 bytes
Database mounted.
SQL> flashback database to restore point restore_point_readonly;
Flashback complete.

k.將數據庫轉換爲physical standby

SQL> alter database convert to physical standby;
Database altered.

 

l.再次強制啓動到mout狀態,然後應用日誌

 

SQL> startup mount force
ORACLE instance started.
Total System Global Area  390070272 bytes
Fixed Size                  2021024 bytes
Variable Size             142608736 bytes
Database Buffers          243269632 bytes
Redo Buffers                2170880 bytes
Database mounted.
SQL> alter database recover managed standby database disconnect from session;
Database altered.

m.在主庫把日誌傳送啓用,切換日誌

SQL> alter system set log_archive_dest_state_2=enable;
System altered.
SQL> alter system archive log current;
System altered.

n.觀察備庫日誌,即可發現已經正常切換至physical standby,應用日誌正常。

 

alter database recover managed standby database disconnect from session
Sun Jan  5 07:43:47 2014
Attempt to start background Managed Standby Recovery process (PHYSTDBY)
MRP0 started with pid=22, OS id=13951
Sun Jan  5 07:43:47 2014
MRP0: Background Managed Standby Recovery process started (PHYSTDBY)
Managed Standby Recovery not using Real Time Apply
Clearing online redo logfile 1 /u01/oracle/oradata/ORCLDB/redo01.log
Clearing online log 1 of thread 1 sequence number 1
Sun Jan  5 07:43:53 2014
Completed: alter database recover managed standby database disconnect from session
Sun Jan  5 07:43:55 2014
Clearing online redo logfile 1 complete
Media Recovery Log /u01/oracle/arch1/PHYSTDBY/1_39_795970778.dbf
Media Recovery Log /u01/oracle/arch1/PHYSTDBY/1_40_795970778.dbf
Media Recovery Waiting for thread 1 sequence 41
Sun Jan  5 07:44:56 2014
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[1]: Assigned to RFS process 13953
RFS[1]: Identified database type as 'physical standby'
Primary database is in MAXIMUM AVAILABILITY mode
Changing standby controlfile to RESYNCHRONIZATION level
Sun Jan  5 07:44:56 2014
RFS LogMiner: Client disabled from further notification
Primary database is in MAXIMUM AVAILABILITY mode
Changing standby controlfile to MAXIMUM AVAILABILITY level
RFS[1]: Successfully opened standby log 4: '/u01/oracle/oradata/ORCLDB/stdby_redo04.log'
Sun Jan  5 07:44:56 2014
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[2]: Assigned to RFS process 13955
RFS[2]: Identified database type as 'physical standby'
RFS[2]: Successfully opened standby log 5: '/u01/oracle/oradata/ORCLDB/stdby_redo05.log'
Sun Jan  5 07:45:01 2014
Media Recovery Log /u01/oracle/arch1/PHYSTDBY/1_41_795970778.dbf
Media Recovery Waiting for thread 1 sequence 42 (in transit)
Sun Jan  5 07:45:16 2014
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[3]: Assigned to RFS process 13959
RFS[3]: Identified database type as 'physical standby'

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章