Data Guard中Snapshot Standby Database配置是怎样的,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
Data Guard - Snapshot Standby Database配置
概述
--------
一般情况下,物理standby数据库处于mount状态接收和应用主库的REDO日志,物理standby数据库不能对外提供访问。如果需要只读访问,那么可以临时以read-only的方式open物理备库,或者配置ACTIVE DATA GUARD,那么物理standby数据库可以进行只读(read-only)访问(比如报表业务查询),但是物理standby数据库不能进行读写操作(read-write)。
有些情况下,为了实现系统的压力测试或者Real Application Testing(RAT)或者其他读写操作测试,那么可以临时将物理standby数据库转换为snapshot standby数据库然后进行测试,因为snapshot standby数据库是独立于主库的,并且是可以进行读写操作(read-write)。测试过程中snapshot standby数据库正常接收主库的归档日志,保证主库的数据安全,但是不会应用这些日志,当压力测试结束后,可以非常简单的再将snapshot standby转换为物理standby数据库,继续同步主库日志。
配置
---------
1.物理standby配置闪回日志
SQL> Alter system set db_recovery_file_dest_size=500M;
System altered.
SQL> Alter system set db_recovery_file_dest='/u01/app/oracle/snapshot_standby';
System altered.
2.物理standby停止应用日志
SQL> alter database recover managed standby database cancel;
Database altered.
3.物理standby转换为snapshot standby,并且open snapshot standby
SQL> alter database convert to snapshot standby;
Database altered.
SQL> alter database open;
Database altered.
检查snapshot standby数据库角色是SNAPSHOT STANDBY,open模式是READ WRITE:
SQL> select DATABASE_ROLE,name,OPEN_MODE from v$database;
DATABASE_ROLE NAME OPEN_MODE
---------------- --------- --------------------
SNAPSHOT STANDBY FSDB READ WRITE
4.对snapshot standby数据库进行压力测试或者Real Application Testing(RAT)或者其他读写操作。
5.测试结束后,再将snapshot standby转换为physical standby,并且重新开始应用日志
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Database mounted.
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
Database altered.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Database mounted.
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.
5.转换为物理standby后,查看备库角色是PHYSICAL STANDBY,open模式是MOUNTED
SQL> select DATABASE_ROLE,name,OPEN_MODE from v$database;
DATABASE_ROLE NAME OPEN_MODE
---------------- --------- --------------------
PHYSICAL STANDBY FSDB MOUNTED
6.检查主库和物理备库日志是同步的
主库日志:
SQL> select ads.dest_id,max(sequence#) "Current Sequence",
max(log_sequence) "Last Archived"
from v$archived_log al, v$archive_dest ad, v$archive_dest_status ads
where ad.dest_id=al.dest_id
and al.dest_id=ads.dest_id
and al.resetlogs_change#=(select max(resetlogs_change#) from v$archived_log )
group by ads.dest_id;
DEST_ID Current Sequence Last Archived
---------- ---------------- -------------
1 361 361
2 361 362
--备库日志
SQL> select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd;
Thread Last Seq Received Last Seq Applied
---------- ----------------- ----------------
1 361 361
看完上述内容,你们掌握Data Guard中Snapshot Standby Database配置是怎样的的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!