基于Linux环境使用ogg19版本从oracle 19c ADG备库远程同步数据

基于Linux环境使用ogg19版本对oracle 19c同步数据

在之前一期文章中提到了 "基于Windows测试OGG远程从ADG备库抽取数据"。文章的最后提到了在Linux环境测试失败的情况,在这一期的文章中测试了Linux环境,但是使用的数据库版本和OGG版本均是19的。之前那一期的数据库版本是11.2.0.4 ,ogg版本是12.1.0.1。有可能是因为版本的问题导致。

此次案例测试中,数据可以成功抽取成功。

说明:代码有些部分对不上,是因为测试过程种来回切换,有些关键字也虚拟模糊了,步骤和方法是正确的。

静默安装OGG

复制代码
./runInstaller -silent -nowait -responseFile /so/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp

数据库ADG搭建请翻阅前面的文章

链接: oracle 19c搭建dataguard(ADG)全过程

源端和目标端创建OGG同步用户

复制代码
源端(10.120.84.25)和目标端创建同步管理账号
--84.25

create tablespace tbsogg datafile '+DATA/xx/DATAFILE/tbsogg.dbf' size 1024m autoextend on next 10m;

--103.54
create tablespace tbsogg datafile 'D:\APP\ADMINISTRATOR\ORADATA\xxx\tbsogg01.dbf' size 1024m autoextend on next 10m;


create user ggs identified by xxx default tablespace tbsogg temporary tablespace temp;
grant connect ,resource,unlimited tablespace to ggs;
grant execute on utl_file to ggs;
grant select any dictionary,select any table to ggs;
grant alter any table to ggs;
grant flashback any table to ggs;
grant execute on dbms_flashback to ggs;
grant execute on sys.DBMS_STREAMS to ggs;
grant execute on dbms_xstream_gg_adm to ggs;
grant execute on DBMS_CAPTURE_ADM to ggs;
grant SELECT ANY TRANSACTION to ggs;
EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE('ggs');
grant execute on sys.DBMS_STREAMS to ggs;
grant execute on dbms_xstream_gg_adm to ggs;
grant execute on dbms_streams_adm to ggs;
grant execute on DBMS_CAPTURE_ADM to ggs;
grant execute on dbms_xstream_gg_adm to ggs;
grant SELECT ANY TRANSACTION to ggs;

数据库连接串配置

复制代码
#primary
ORA104 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.104)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = woo)
    )
  )

#standby
ORA105 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.105)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = woo)
    )
  )

MGR进程配置

复制代码
port 5000
dynamicportlist 5001-5050
autorestart extract *,retries 5,waitminutes 3
purgeoldextracts ./dirdat/*, usecheckpoints,minkeepdays 3
accessrule, prog *, ipaddr *, allow
lagreporthours 1
laginfominutes 30
lagcriticalminutes 45

创建OGG登录别名

复制代码
--创建用户凭证别名
add credentialstore
--创建到源端的登录别名
--登录源端主库别名
alter credentialstore add user ggs@xxx, password Caecaodb2017 alias xx
alter credentialstore add user ggs@xxx, password Caecaodb2017 alias xx
alter credentialstore add user ggs@xxx, password Caecaodb2017 alias xxx

--登录源端备库别名
alter credentialstore add user ggs@xxx, password Caecaodb2017 alias xxx
alter credentialstore add user ggs@xxx, password Caecaodb2017 alias xxx
alter credentialstore add user ggs@xxx, password Caecaodb2017 alias xxx

--目标端登录别名
alter credentialstore add user ggs@xxx, password Caecaodb2017 alias xx

--测试验证
dblogin useridalias xxx

添加抽取进程

复制代码
add extract escims3, tranlog, begin now, threads 1    <<<<< 如果是RAC,修改为2
add exttrail ./dirdat/e3, extract escims3, megabytes 50

edit params escims3

extract escims3
SETENV (TNS_ADMIN='/app/oracle/product/19.3.000/db_home/network/admin')
userid ggs@ora105, password xxxx
exttrail ./dirdat/e3
discardfile ./dirrpt/escims3.dsc, append, megabytes 20
discardrollover at 05:30 on monday
warnlongtrans 3h, checkinterval 10m
tranlogoptions logretention enabled
tranlogoptions dblogreader
tranlogoptions minefromactivedg
--tables
table ggs.testtab;

添加应用进程(有些关键字做了虚拟)

复制代码
dblogin useridalias xxxx
add checkpointtable ggs.xxxx

--非并行进程
add replicat rs3t, exttrail ./dirdat/e3, checkpointtable ggs.xxxx

edit param rs3t

replicat rs3t
useridalias xxxx
discardfile ./dirrpt/rs3t.dsc, append, megabytes 100
discardrollover at 05:30 on monday
--tables
gettruncates
map ggs.testtab ,target maintain.testtab;

数据初始化的方式有2种

复制代码
>>>>> 数据初始化 数据泵初始化方式
SET NUMWIDTH 20;   
select current_scn from v$database;
12346555158664
expdp \"/ as sysdba\" dumpfile=testtabt320251103.dmp logfile=exptesttabt320251103.log exclude=statistics ggs.testtab flashback_scn=21870773

 (根据同步当时获取的值填写)

目标端 10.128.103.54 导入数据
impdp \"/ as sysdba\" dumpfile=testtabt320251103.dmp logfile=imptesttabt320251103.log remap_schema=ggs:testtab table_exists_action=truncate 



>>>>> 数据初始化 load init方式

add extract ext_init,sourceistable

参数配置
edit param ext_init

extract ext_init
SETENV (TNS_ADMIN='/OSdata/oraclient/instantclient_19_28/network/admin')
useridalias SCIMS8422
rmthost 10.128.255.146, mgrport 5000
rmttask replicat,group rep_init
table ggs.testtab;



add replicat rep_init,specialrun

edit param rep_init

replicat rep_init
useridalias tn_ncdb10338
assumetargetdefs
discardfile ./dirrpt/rep_init.dsc, append, megabytes 100
map ggs.testtab, target maintain.testtab;

测试数据

复制代码
GGSCI (ora19 as ggs@woo) 27> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     ESCIMS3     00:00:01      00:00:02    


GGSCI (ora19 as ggs@woo) 28> stats escims3,daily

Sending STATS request to EXTRACT ESCIMS3 ...

Start of Statistics at 2025-11-05 21:34:07.

Output to ./dirdat/e3:

Extracting from GGS.TESTTAB to GGS.TESTTAB:

*** Daily statistics since 2025-11-05 21:33:46 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total upserts                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

End of Statistics.


GGSCI (ora19 as ggs@woo) 29> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     ESCIMS3     00:00:00      00:00:09    
相关推荐
Slow菜鸟4 小时前
Java开发规范(十一)| 数据全生命周期治理规范—Java应用的“数据资产化手册”
java·servlet·oracle
fruge4 小时前
前端文档自动化:用 VitePress 搭建团队技术文档(含自动部署)
运维·前端·自动化
z***56564 小时前
Nginx实现接口复制
运维·nginx·junit
y***86694 小时前
DevOps在云中的自动化部署
运维·自动化·devops
运维-大白同学4 小时前
2025最全面开源devops运维平台功能介绍
linux·运维·kubernetes·开源·运维开发·devops
梦在深巷、4 小时前
linux系统防火墙之iptables
linux·运维·服务器
踏浪无痕5 小时前
线上偶发 502 排查:用 Netty 成功复现 KeepAlive 时间窗口案例实战(附完整源码)
运维·网络协议
放学有种别跑、6 小时前
GIT使用指南
大数据·linux·git·elasticsearch
做人不要太理性6 小时前
【Linux系统】线程的同步与互斥:核心原理、锁机制与实战代码
linux·服务器·算法
weixin_660096786 小时前
zsh中使用自动补全zsh-autosuggestions
linux·ubuntu·zsh·zshrc