read write Open PHYSICAL STANDBY, flashbacks and restore test

The following are the most STANDBY execution, the main library will be prompted to perform (twice) of

[STANDBY read write Open Test]
to check standby status
SQL> SELECT NAME, DATABASE_ROLE, OPEN_MODE , SWITCHOVER_STATUS FROM V $ DATABASE;

NAME DATABASE_ROLE OPEN_MODE SWITCHOVER_STATUS
--------- ---------------- -------------------- --------------------
testdb PHYSICAL STANDBY MOUNTED NOT ALLOWED

FLASHBACK_ON want to open, so that flashback
SQL> SELECT FLASHBACK_ON FROM V $ DATABASE ;

FLASHBACK_ON
------------------
NO

SQL> alter database flashback on;

Database altered.

Set the flash recovery area, where the size of the log is generated based on short-term estimates of the size of the
SQL> Line the SET 200
SQL> Show the Parameter DB_RECOVERY_FILE_DEST

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/fast_recovery_area
db_recovery_file_dest_size big integer 167280M

取消日志应用,刚提前cancel了
SQL> alter database recover managed standby database cancel;
alter database recover managed standby database cancel
*
ERROR at line 1:
ORA-16136: Managed Standby Recovery not active

Create a restore point
SQL> the Create Restore Point Guarantee Your restore_point_readonly the Flashback Database;

Restore point created.

Primary database log switch temporarily synchronized log
the SQL> ALTER log Current Archive System;
the System Altered.

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

激活standby为read write并open
SQL> alter database activate standby database;

Database altered.

SQL> select name,open_mode,database_role,db_unique_name from v$database;

NAME OPEN_MODE DATABASE_ROLE DB_UNIQUE_NAME
--------- -------------------- ---------------- ------------------------------
testdb MOUNTED PRIMARY testdbdg2

SQL> alter database open;

Database altered.

SQL> set timing on;
SQL> select name,open_mode,database_role,db_unique_name from v$database;

NAME OPEN_MODE DATABASE_ROLE DB_UNIQUE_NAME
--------- -------------------- ---------------- ------------------------------
testdb READ WRITE PRIMARY testdbdg2

Elapsed: 00:00:00.00

write测试
SQL> create table scott.t as select * from dba_objects;

Table created.

Elapsed: 00:00:02.33
SQL> select count(*) from scott.t;

COUNT(*)
----------
98160

Elapsed: 00:00:00.01
SQL> truncate table scott.t;

Table truncated.

Elapsed: 00:00:09.43
SQL> select count(*) from scott.t;

COUNT(*)
----------
0

Elapsed: 00:00:00.00
SQL> drop table scott.t;

Table dropped.

Elapsed: 00:00:01.44

After the test is complete go back to a certain point in time, this time to determine a good point

【闪回测试】
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 4.2758E+10 bytes
Fixed Size 2262656 bytes
Variable Size 2.7380E+10 bytes
Database Buffers 1.5301E+10 bytes
Redo Buffers 74420224 bytes
Database mounted.

You can select sysdate- 5/1440 from dual; determine the need flashback time

SQL> flashback database to timestamp sysdate- 5/1440;

Flashback complete.

Elapsed: 00:02:19.84
SQL>
SQL> alter database open resetlogs;

Database altered.

Elapsed: 00:02:02.26
SQL> select count(*) from scott.t;

COUNT(*)
----------
98160

Elapsed: 00:00:00.03


[Test] reduction (to the standby state)

SQL> startup mount force
ORACLE instance started.

Total System Global Area 4.2758E+10 bytes
Fixed Size 2262656 bytes
Variable Size 2.7380E+10 bytes
Database Buffers 1.5301E+10 bytes
Redo Buffers 74420224 bytes
Database mounted.

SQL> flashback database to restore point restore_point_readonly;
Flashback complete.

再次回到PHYSICAL STANDBY
SQL> alter database convert to physical standby;
Database altered.

Forced to mount again, the application log
SQL> the Startup mount Force
ORACLE instance Started.

Total System Global Area 4.2758E+10 bytes
Fixed Size 2262656 bytes
Variable Size 2.7380E+10 bytes
Database Buffers 1.5301E+10 bytes
Redo Buffers 74420224 bytes
Database mounted.

SQL> alter database recover managed standby database disconnect from session;
Database altered.

Primary library (execution) enable logging
the SQL> ALTER System SET log_archive_dest_state_2 = enable;
the System Altered.

SQL> alter system archive log current;
System altered.

Standby alter normal observation log

Guess you like

Origin www.cnblogs.com/ritchy/p/11357090.html