利用XAG在RAC环境下实现GoldenGate自动Failover(3)

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

Database altered.

SQL> ALTER DATABASE FORCE LOGGING;

Database altered.

SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;

SUPPLEME FORCE_LOGGING

-------- ---------------------------------------

YES YES

SQL> ALTER SYSTEM SWITCH LOGFILE;

System altered.

SQL> alter system set ENABLE_GOLDENGATE_REPLICATION=true;

System altered.

l 在源端和目标端创建OGG数据库用户及授权,我的例子里创建的用户是GGADM。

OGG用户需要的权限可以参阅联机文档《Installing and Configuring Oracle GoldenGate for Oracle Database 12c (12.2.0.1)》中的章节 4.1.4.1 Oracle 11.2.0.4 or Later Database Privileges,我们这个测试为了方便,授予用户DBA角色,以及使用特定系统包的授权:

SQL> BEGIN

dbms_goldengate_auth.grant_admin_privilege

2 3 (

grantee => 'GGADM',

privilege_type => 'CAPTURE',

grant_select_privileges => TRUE

);

END;

/ 4 5 6 7 8 9

PL/SQL procedure successfully completed.

源端OGG设置

l 登录数据库:

GGSCI (rac1.hthorizontest.com) 1> dblogin userid ggadm password ggadm

Successfully logged into database.

l 注册集成式抽取

GGSCI (rac1.hthorizontest.com as ggadm@tdb1) 2> register extract ext1 database;

2016-04-07 23:44:38 INFO OGG-02003 Extract EXT1 successfully registered with database at SCN 1291634.

l 增加抽取进程

GGSCI (rac1.hthorizontest.com as ggadm@tdb1) 3> ADD EXTRACT ext1 INTEGRATED TRANLOG, BEGIN NOW

EXTRACT (Integrated) added.

GGSCI (rac1.hthorizontest.com as ggadm@tdb1) 4> ADD EXTTRAIL /u01/app/grid/acfsmounts/data_vol1/ogg12/dirdat/et, EXTRACT ext1

EXTTRAIL added.

l 增加传送进程

GGSCI (rac1.hthorizontest.com as ggadm@tdb1) 5> ADD EXTRACT pump1 EXTTRAILSOURCE /u01/app/grid/acfsmounts/data_vol1/ogg12/dirdat/et

EXTRACT added.

GGSCI (rac1.hthorizontest.com as ggadm@tdb1) 6>EDIT PARAMS EXT1

加入下面内容:

EXTRACT ext1

USERID ggadm, PASSWORD ggadm

TRANLOGOPTIONS INTEGRATED PARAMS (MAX_SGA_SIZE 100)

EXTTRAIL /u01/app/grid/acfsmounts/data_vol1/ogg12/dirdat/et

TABLE test.*;

GGSCI (rac1.hthorizontest.com as ggadm@tdb1) 7>EDIT PARAMS PUMP1

加入下面内容:

EXTRACT pump1

USERID ggadm, PASSWORD ggadm

RMTHOST 192.168.0.11, MGRPORT 7809

RMTTRAIL /u01/app/grid/acfsmounts/ogg_vol1/ogg12/dirdat/rt

TABLE TEST.*;

然后启动所有进程。

在11.2.0.4版本,如果实现集成的capture模式,在启动抽取进程时,会提示需要安装补丁17030189,主要是因为使用集成的capture,需要修改数据字典表。

但是在安装了PSU后,有时会导致这个补丁和其他补丁冲突,也可以手工执行prvtlmpg.plb来解决问题。

(EXTRACT Abending With OGG-02912 (Doc ID 2091679.1))

目标端OGG设置

GGSCI (oel65vm11.hthorizon.com) 8> dblogin userid ggadm password ggadm

Successfully logged into database.

GGSCI (oel65vm11.hthorizon.com as ggadm@racdb1) 9>ADD CHECKPOINTTABLE ggadm.checkpointtab

Successfully created checkpoint table ggadm.checkpointtab

GGSCI (oel65vm11.hthorizon.com as ggadm@racdb1) 10> ADD REPLICAT rep1, EXTTRAIL /u01/app/grid/acfsmounts/ogg_vol1/ogg12/dirdat/rt checkpointtable ggadm.checkpointtab

REPLICAT added.

GGSCI (oel65vm11.hthorizon.com as ggadm@racdb1) 11>EDIT PARAMS REP1

加入下面内容:

REPLICAT rep1

USERID ggadm, PASSWORD ggadm

ASSUMETARGETDEFS

DISCARDFILE /u01/app/grid/acfsmounts/ogg_vol1/ogg12/dirdat/rt, PURGE

MAP TEST.* TARGET TEST.*;

然后启动进程,测试OGG数据复制是否正常

修改OGG MGR参数

为了让OGG的Manager进程能够自动启动复制进程,需要将下列配置加进Manager的配置文件:

AUTORESTART ER *, RETRIES 5, WAITMINUTES 1, RESETMINUTES 60

AUTOSTART ER *

重启Manager进程使之生效。

源端和目标端都要修改。

配置源端XAG

l 添加APP VIP(以root身份)

[root@rac1 ~]# /u01/app/11.2.0/grid/bin/appvipcfg create -network=1 -ip=192.168.0.36 -vipname=xag.gg_1-vip.vip -user=oracle

l 允许grid用户启动资源(以root身份)

[root@rac1 ~]# /u01/app/11.2.0/grid/bin/crsctl setperm resource xag.gg_1-vip.vip -u user:grid:r-x

l 启动VIP(以grid身份)

[root@rac1 ~]# su - grid

[grid@rac1 ~]$ /u01/app/11.2.0/grid/bin/crsctl start resource xag.gg_1-vip.vip

CRS-2672: Attempting to start 'xag.gg_1-vip.vip' on 'rac1'

CRS-2676: Start of 'xag.gg_1-vip.vip' on 'rac1' succeeded

l 查看状态

[grid@rac1 ~]$ crsctl status resource xag.gg_1-vip.vip

NAME=xag.gg_1-vip.vip

TYPE=app.appvip_net1.type

TARGET=ONLINE

STATE=ONLINE on rac1

l 创建OGG对应的CRS资源(以root身份)

[root@rac1 bin]# /u01/app/grid/xaghome/bin/agctl add goldengate gg_1 --gg_home /u01/app/grid/acfsmounts/data_vol1/ogg12 --instance_type source --nodes rac1,rac2 --vip_name xag.gg_1-vip.vip --filesystems ora.data.vologg1.acfs --databases ora.tdb.db --oracle_home /u01/app/oracle/product/11.2.0/dbhome_1 --monitor_extracts ext1,pump1

[root@rac1 ~]# cd /u01/app/grid/xaghome/bin

[root@rac1 bin]# ./agctl status goldengate gg_1

Goldengate instance 'gg_1' is not running

l 授权grid启动资源

上面的命令执行完毕,会自动创建一个对应ogg的CRS资源,需要授权grid有权管理它:

[root@oel65vm11 bin]# /u01/app/11.2.0/grid/bin/crsctl setperm resource xag.gg_1.goldengate -u user:grid:r-x

配置目标端XAG

过程和源端类似,

l 创建VIP资源:

[root@oel65vm11 ~]# /u01/app/12.1.0/grid/bin/appvipcfg create -network=1 -ip=192.168.0.26 -vipname=xag.gg_1-vip.vip -user=oracle

[root@oel65vm11 ~]# /u01/app/12.1.0/grid/bin/crsctl setperm resource xag.gg_1-vip.vip -u user:grid:r-x

[root@oel65vm11 ~]# /u01/app/12.1.0/grid/bin/crsctl start resource xag.gg_1-vip.vip

CRS-2672: Attempting to start 'xag.gg_1-vip.vip' on 'oel65vm12'

CRS-2676: Start of 'xag.gg_1-vip.vip' on 'oel65vm12' succeeded

[root@oel65vm11 ~]# /u01/app/12.1.0/grid/bin/crsctl relocate resource xag.gg_1-vip.vip -n oel65vm11

CRS-2673: Attempting to stop 'xag.gg_1-vip.vip' on 'oel65vm12'

CRS-2677: Stop of 'xag.gg_1-vip.vip' on 'oel65vm12' succeeded

CRS-2672: Attempting to start 'xag.gg_1-vip.vip' on 'oel65vm11'

CRS-2676: Start of 'xag.gg_1-vip.vip' on 'oel65vm11' succeeded

l 创建ogg 对应的CRS资源

[root@oel65vm11 bin]# /u01/app/grid/xaghome/bin/agctl add goldengate gg_2 --gg_home /u01/app/grid/acfsmounts/ogg_vol1/ogg12 --instance_type target --nodes oel65vm11,oel65vm12 --vip_name xag.gg_1-vip.vip --filesystems ora.data.vologg2.acfs --databases ora.racdb.db --oracle_home /u01/app/oracle/product/12.1.0/dbhome_1 --monitor_replicats rep1

l 授权

[root@oel65vm11 bin]# /u01/app/12.1.0/grid/bin/crsctl setperm resource xag.gg_2.goldengate -u user:grid:r-x

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/b6f9bb5094ce5f158dc2a0873a36d364.html