Home  >  Article  >  Database  >  快照DataGuard

快照DataGuard

WBOY
WBOYOriginal
2016-06-07 14:59:141243browse

快照DataGuard是11R2的一个功能,可以用于临时的测试后回到主从模式,测试坏境为LGWR ASYNC的最大性能模式。

快照DataGuard是11R2的一个功能,可以用于临时的测试后回到主从模式,测试坏境为LGWR ASYNC的最大性能模式。

一、设置snapshot standby

关闭日志应用进程MRP
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
关闭备数据库,启动到MOUNT阶段
SHUTDOWN IMMEDIATE;
STARTUP NOMOUNT;
设置快速回复区域,但是注意这里并不需要FLASHBACK DATABASE支持,但是实际上应该还是FLASHBACK DATABASE
(Ensure that a fast recovery area has been configured. It is not necessary for
flashback database to be enabled.)

SQL> alter system set db_recovery_file_dest_size=30g;

System altered.

SQL> alter system set db_recovery_file_dest='/home/oradba/flash_area';

System altered.
如果不设置会报错
ERROR at line 1:
ORA-38784: Cannot create restore point 'SNAPSHOT_STANDBY_REQUIRED_04/24/2015
10:30:47'.
ORA-38786: Recovery area is not enabled.

执行转换
ALTER DATABASE CONVERT TO SNAPSHOT STANDBY;

转换操作可能比较慢,Oracle 可能会为备库建立日志文件如果没有的话,这比较耗时

SQL> ALTER DATABASE CONVERT TO SNAPSHOT STANDBY;

Database altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival            Enabled
Archive destination            /oradba/archive
Oldest online log sequence    1
Next log sequence to archive  1
Current log sequence          1

完成后完全是一个新的数据库

List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1      1      TEST    2151380215      PARENT  1          17-SEP-11
2      2      TEST    2151380215      PARENT  995548    18-JUL-14
3      3      TEST    2151380215      PARENT  142690086  10-NOV-14
4      4      TEST    2151380215      CURRENT 168265840  24-APR-15

最后就是打开数据库可以使用了
SQL> alter database open;

Database altered.

SQL> select DATABASE_ROLE from v$database;

DATABASE_ROLE
----------------
SNAPSHOT STANDBY

注意:
1、snapshot standby 产生自身的归档日志,但是ALTER SYSTEM SWITCH LOGFILE 并不会马上归档,会等待5分钟归档1个日志
2、snapshot standby 确实会接受来自主库的日志,同时STANDBY LOGFILE也会接受来自主库的日志

SNAPSHOT STANDBY 日志归档和STANDBY归档速度从日志来看为5分钟归档一个,也就是说如果测试量巨大会造成日志组使用完,而造成HANG,
但是STANDBY LOG即使不能分配了也会接受归档到FLASH BACK AREA中。
从日志来看:
Fri Apr 24 11:05:43 2015
Archived Log entry 9 added for thread 1 sequence 807 ID 0x80d48cbc dest 1:
Fri Apr 24 11:07:36 2015
Thread 1 advanced to log sequence 4 (LGWR switch)
  Current log# 8 seq# 4 mem# 0: /oradba/data/test/redo04
Thread 1 advanced to log sequence 5 (LGWR switch)
  Current log# 9 seq# 5 mem# 0: /oradba/data/test/redo05
Thread 1 advanced to log sequence 6 (LGWR switch)
  Current log# 10 seq# 6 mem# 0: /oradba/data/test/redo06
Thread 1 advanced to log sequence 7 (LGWR switch)
  Current log# 11 seq# 7 mem# 0: /oradba/data/test/redo07
Thread 1 advanced to log sequence 8 (LGWR switch)
  Current log# 12 seq# 8 mem# 0: /oradba/data/test/redo08
Thread 1 advanced to log sequence 9 (LGWR switch)
  Current log# 13 seq# 9 mem# 0: /oradba/data/test/redo09
Thread 1 advanced to log sequence 10 (LGWR switch)
  Current log# 14 seq# 10 mem# 0: /oradba/data/test/redo10
Thread 1 advanced to log sequence 11 (LGWR switch)
  Current log# 15 seq# 11 mem# 0: /oradba/data/test/redo11
Thread 1 advanced to log sequence 12 (LGWR switch)
  Current log# 1 seq# 12 mem# 0: /oradba/data/test/redo01.log
Thread 1 advanced to log sequence 13 (LGWR switch)
  Current log# 2 seq# 13 mem# 0: /oradba/data/test/redo02.log
Fri Apr 24 11:07:46 2015
Thread 1 cannot allocate new log, sequence 14
Checkpoint not complete
  Current log# 2 seq# 13 mem# 0: /oradba/data/test/redo02.log
ORACLE Instance test - Can not allocate log, archival required
Thread 1 cannot allocate new log, sequence 14
All online logs needed archiving
  Current log# 2 seq# 13 mem# 0: /oradba/data/test/redo02.log
Fri Apr 24 11:10:44 2015
Archived Log entry 10 added for thread 1 sequence 3 ID 0x81b3f444 dest 1:
Fri Apr 24 11:10:44 2015
Thread 1 advanced to log sequence 14 (LGWR switch)
  Current log# 3 seq# 14 mem# 0: /oradba/data/test/redo03.log
Fri Apr 24 11:15:44 2015
Archived Log entry 11 added for thread 1 sequence 4 ID 0x81b3f444 dest 1:
 
注意这里11:05:43 2015进行了一次归档,,然后我大量的进行切换,观察到ALTER SYSTEM switchlog HANG住,
观察到日志:
Checkpoint not complete
  Current log# 2 seq# 13 mem# 0: /oradba/data/test/redo02.log
ORACLE Instance test - Can not allocate log, archival required
而等待到Fri Apr 24 11:10:44 2015 日志进行了归档
Archived Log entry 10 added for thread 1 sequence 3 ID 0x81b3f444 dest 1
而Fri Apr 24 11:15:44 2015 有进行了一个日志的归档
Archived Log entry 11 added for thread 1 sequence 4 ID 0x81b3f444 dest 1:

而对于RFS 进程来说即使STANDBY LOG 不够也会接受进行到FLASHBACK AREA中
如下也能够证明:
SQL> select COMPLETION_TIME,SEQUENCE#,NAME FROM v$archived_log;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:SQL 新手指南Next article:Sqoop数据导出导入命令