快照standby实验

利用oracle的flashback Database功能,standby先设置快照点,将standby设置为读写状态,在standby上做一些简单应用操作,如报表、测试等。然后闪回快照点,standby继续应用日志。

检查日志应用情况
primary:
SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
        47

standby:
SQL> select sequence#,applied from v$archived_log;

 SEQUENCE# APPLIED
---------- ---------
    15 YES
    18 YES
    16 YES
    ...
    45 YES
    46 YES
    47 YES

33 rows selected.

所有日志已经被应用。

standby设置
闪回区设置:
SQL> show parameter db_recovery

NAME                     TYPE                   VALUE
------------------------------------ --------------------------------- -------------------
db_recovery_file_dest             string                   /u01/app/oracle/flash_recovery_area
db_recovery_file_dest_size         big integer               2G

取消日志应用:
SQL> recover managed standby database cancel;
Media recovery complete.

创建还原点:
SQL> create restore point rpoint guarantee flashback database;

Restore point created.

primary上归档并设置归档目标状态为defer,defer参数将使redo日志不传输到目的地。

SQL> alter system archive log current;

System altered.

SQL> alter system  set log_archive_dest_state_2='defer';

System altered.

激活standby到读写状态:
SQL> alter database activate standby database;

Database altered.

SQL> alter database open;

Database altered.

select sequence#,applied from v$archived_log order by sequence#
SQL> /

 SEQUENCE# APPLIED
---------- ---------
     1 NO
    15 YES
    16 YES
    17 YES
    ...
    47 YES
    48 NO
    49 NO
有日志没有应用。

下面做一些实验:
SQL> create table scott.t_object as select * from dba_objects;

Table created.

SQL> conn scott/tiger;
Connected.
SQL> select * from tab;

TNAME                 TABTYPE        CLUSTERID
-------------------------------- --------------------- ----------
BONUS                 TABLE
DEPT                 TABLE
EMP                     TABLE
SALGRADE             TABLE
T1                     TABLE
T2                     TABLE
T_OBJECT             TABLE

7 rows selected.

SQL> select count(*) from t_object;

  COUNT(*)
----------
     68893

在scott用户下创建了一张表。

闪回还原点
用下列命令把数据库闪回:
SQL> startup mount force;
ORACLE instance started.

Total System Global Area 3340451840 bytes
Fixed Size            2149000 bytes
Variable Size         1778386296 bytes
Database Buffers     1543503872 bytes
Redo Buffers           16412672 bytes
Database mounted.
SQL> flashback database to restore point rpoint;

Flashback complete.

SQL> alter database convert to physical standby;

Database altered.


接收日志:
SQL> startup mount force;
ORACLE instance started.

Total System Global Area 3340451840 bytes
Fixed Size            2149000 bytes
Variable Size         1778386296 bytes
Database Buffers     1543503872 bytes
Redo Buffers           16412672 bytes
Database mounted.
    
SQL> alter database recover managed standby database disconnect from session;

Database altered.

primary上归档到standby目的地状态为enable;
SQL> alter system  set log_archive_dest_state_2='enable';

System altered.

SQL> select sequence#,applied from v$archived_log;

你可能感兴趣的:(sql,object,Integer,database,System,archive)