Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching

Oracle Engineered System


当前位置: 首页 » 技术文章 » Oracle 12c+

How to build far sync instance for RAC DG

Oracle 12c在Data Guard方面引入了新功能Active Data Guard Far Sync,她的实现原理也很简单,在距离主库相对较近的地方配置Far Sync实例,主库通过SYNC传输Redo到Far Sync实例,然后通过Far Sync实例再将Redo通过ASYNC的方式传输到终端的备库,这里的Far Sync起到中继的作用。通过这种方式,可以减少主库传输Redo的压力,相对来说对主库的性能影响也会减少很多。

Far Sync 需要初始化参数文件、密码文件、控制文件,没有数据文件。可以配置为单实例,也可以配置为RAC。


Far Sync单实例


在距离生产数据中心较近的地方建立Far Sync实例,通过SYNC的方式把Redo传输到Far Sync实例,然后通过ASYNC的方式传输到终端灾备数据库。在此过程中,如果Far Sync实例出现问题,生产数据库可以直接通过ASYNC方式把Redo传输到灾备数据库。

log_archive_dest_2='service=prodfs sync affirm max_failure=1 alternate=log_archive_dest_3 valid_for=(online_logfiles,primary_role) db_unique_name=prodfs'
log_archive_dest_3='service=stdby async noaffirm delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=15 net_timeout=30  valid_for=(online_logfile,primary_role) db_unique_name=stdby'
log_archive_dest_state_3=alternate


Far Sync HA架构


可以配置两个Far Sync实例,当一个Far Sync实例出问题,另外一个可以接替

log_archive_dest_2='service=prodfs sync affirm max_failure=1 alternate=log_archive_dest_3 valid_for=(online_logfiles,primary_role) db_unique_name=prodfs'
log_archive_dest_3='service=prodfs1 sync affirm max_failure=1 alternate=log_archive_dest_2 valid_for=(online_logfiles,primary_role) db_unique_name=prodfs1'

我们还可以配置为log_archive_dest_2------->log_archive_dest_3------->log_archive_dest_4


Far Sync Role Transition


当主备库角色切换后,由于先前配置的Far Sync实例距离新的主库较远。这时,我们可以在距离新的主库较近的地方,建立新的Far Sync实例。


测试环境

测试环境为RAC + DG,配置了单实例Far Sync

配置Far Sync主要步骤为

在主库上创建far sync controlfile,pfile

alter database create far sync instance controlfile as '/tmp/controlfs01.ctl';
把控制文件,密码文件,pfile传到far sync服务器

编辑pfile,启动Far Sync

SQL> startup                        
ORACLE instance started.
Total System Global Area  209715200 bytes
Fixed Size                  2922712 bytes
Variable Size             109053736 bytes
Database Buffers           92274688 bytes
Redo Buffers                5464064 bytes
Database mounted.
ORA-16476: far sync instance does not allow Open operation

SQL>


在far sync实例上创建standby logfile

alter database add standby logfile thread 1 group 7 '/pgold/oradata/sredo7.dbf' size 50m;
alter database add standby logfile thread 1 group 8 '/pgold/oradata/sredo8.dbf' size 50m;
alter database add standby logfile thread 1 group 9 '/pgold/oradata/sredo9.dbf' size 50m;
alter database add standby logfile thread 1 group 10 '/pgold/oradata/sredo10.dbf' size 50m;

alter database add standby logfile thread 2 group 11 '/pgold/oradata/sredo11.dbf' size 50m;
alter database add standby logfile thread 2 group 12 '/pgold/oradata/sredo12.dbf' size 50m;
alter database add standby logfile thread 2 group 13 '/pgold/oradata/sredo13.dbf' size 50m;
alter database add standby logfile thread 2 group 14 '/pgold/oradata/sredo14.dbf' size 50m;

生产库信息

SQL> select instance_name from gv$instance;

INSTANCE_NAME
----------------
prod1
prod2

SQL> select * from gv$dataguard_config;
DB_UNIQUE_NAME  PARENT_DBUN   DEST_ROLE         CURRENT_SCN     CON_ID
--------------- ------------- ----------------- ----------- ----------
prod            NONE          PRIMARY DATABASE      5396377          0
prodfs          prod          FAR SYNC INSTANCE     5333670          0
stdby           prodfs        PHYSICAL STANDBY      5333670          0
prod            NONE          PRIMARY DATABASE      5396376          0
prodfs          prod          FAR SYNC INSTANCE     5333670          0
stdby           prodfs        PHYSICAL STANDBY      5333670          0
6 rows selected.
SQL> 
Far Sync Instance信息

SQL> select instance_name from gv$instance;

INSTANCE_NAME
----------------
prodfs
SQL> select * from gv$dataguard_config;
DB_UNIQUE_NAME  PARENT_DBUN  DEST_ROLE         CURRENT_SCN     CON_ID
-------------- ------------- ----------------- ----------- ----------
prodfs          prod         FAR SYNC INSTANCE     5333670          0
stdby           prodfs       PHYSICAL STANDBY      5333670          0
prod            NONE         PRIMARY DATABASE            0          0            
SQL> 
备库信息

SQL> select instance_name from gv$instance;

INSTANCE_NAME
----------------
stdby1
stdby2
SQL> select * from gv$dataguard_config;
DB_UNIQUE_NAME  PARENT_DBUN   DEST_ROLE         CURRENT_SCN     CON_ID
--------------- ------------- ----------------- ----------- ----------
stdby           prodfs        PHYSICAL STANDBY      5333670          0
prod            NONE          PRIMARY DATABASE            0          0
prodfs          UNKNOWN       FAR SYNC INSTANCE           0          0
stdby           prodfs        PHYSICAL STANDBY      5333670          0
prod            NONE          PRIMARY DATABASE            0          0
prodfs          UNKNOWN       FAR SYNC INSTANCE           0          0
6 rows selected.
SQL> 


Reference
http://docs.oracle.com/database/121/SBYDB/create_fs.htm#SBYDB5416


Top
Cell186-9589-1286
QQ 375349564
E-mail ohsdba@qq.com