ogg12.3.0.1.4 可以支持oracle 11.2.0.4,但是需要打补丁17030189
1.配置 tnsname (xag100,xag101)
TNS_DB100 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xag100)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB100)
)
)
TNS_DB101 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xag101)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB101)
)
)
#测试
[oracle@xag100 admin]$ sqlplus sys/123456@TNS_DB100 as sysdba
[oracle@xag100 admin]$ sqlplus sys/123456@TNS_DB101 as sysdba
2.源和目标归档模式设置
[oracle@xag100 ~]$ sqlplus / as sysdba
SQL> archive log list
#如为非归档模式则运行如下4语句
SQL>shutdown immediate;
SQL>startup mount;
SQL>alter database archivelog;
SQL> alter database open;
SQL>alter system archive log start;
#关闭回收站
SQL>show parameter recyclebin
SQL>alter session set recyclebin=off;
SQL>alter system set recyclebin=off scope=spfile;
3.启用最少的补充日志记录和强制日志记录(源端-xag100)
[oracle@xag100 ~]$ sqlplus / as sysdba
SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;
SUPPLEME FOR
-------- ---
NO NO
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
SQL> ALTER DATABASE FORCE LOGGING;
SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;
SUPPLEME FOR
-------- ---
YES YES
SQL> alter system switch logfile;
4.OGG用户和权限分配(xag100,xag101)
[oracle@xag100 ~]$ sqlplus / as sysdba
SQL>
create tablespace tbs_ggs datafile
\'/u02/oradata/DB100/tbs_ggs_1.dbf\' size 512M AUTOEXTEND ON NEXT 256M MAXSIZE UNLIMITED,
\'/u02/oradata/DB100/tbs_ggs_2.dbf\' size 512M AUTOEXTEND ON NEXT 256M MAXSIZE UNLIMITED;
SQL>
create user ogg_admin identified by 123456 default tablespace tbs_ggs quota unlimited on tbs_ggs;
grant dba to ogg_admin;
or
grant unlimited tablespace to ogg_admin;
grant connect, resource to ogg_admin;
grant create session, alter session to ogg_admin;
grant alter system to ogg_admin;
grant select any dictionary to ogg_admin;
grant flashback any table to ogg_admin;
grant select any table, insert any table, update any table, delete any table, drop any table to ogg_admin;
grant create table, create sequence to ogg_admin;
grant select on dba_clusters to ogg_admin;
grant select on v_$database to ogg_admin;
grant select on sys.logmnr_buildlog to ogg_admin;
grant select any transaction to ogg_admin;
grant lock any table to ogg_admin;
grant execute on dbms_flashback to ogg_admin;
grant execute on dbms_logmnr_d to ogg_admin;
grant execute on dbms_capture_adm to ogg_admin;
grant execute on dbms_streams to ogg_admin;
grant execute on utl_file to ogg_admin;
exec dbms_streams_auth.grant_admin_privilege(\'ogg_admin\');
exec dbms_goldengate_auth.grant_admin_privilege(\'ogg_admin\');
5.创建用户表空间及创建普通用户us01
create tablespace MY_UD datafile
\'/u02/oradata/DB100/MY_UD_1.dbf\' size 32M AUTOEXTEND ON NEXT 32M MAXSIZE UNLIMITED;
create tablespace I_MY_UD datafile
\'/u02/oradata/DB100/I_MY_UD_1.dbf\' size 16M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED;
CREATE SMALLFILE TEMPORARY TABLESPACE MY_TD1
TEMPFILE
\'/u02/oradata/DB100/MY_TD1_1.dbf\' SIZE 128M,
\'/u02/oradata/DB100/MY_TD1_2.dbf\' SIZE 128M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
ALTER TABLESPACE MY_TD1 TABLESPACE GROUP MY_TEMPGROUP01;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE MY_TEMPGROUP01;
select * from dba_tablespace_groups;
CREATE USER us01 IDENTIFIED BY us01
DEFAULT TABLESPACE MY_UD TEMPORARY TABLESPACE MY_TEMPGROUP01;
GRANT DBA to us01;
grant connect,resource to us01;
#创建测试表
SQL> conn us01/us01
create table t1
(
dbha_seq number(10),
source_name varchar2(20),
source_time date,
dest_time date
)TABLESPACE MY_UD;
ALTER TABLE t1 ADD CONSTRAINT pk_t1 PRIMARY KEY(dbha_seq) USING INDEX TABLESPACE I_MY_UD;
--source:xag100
create sequence dbha_seq
minvalue 1000000001
maxvalue 999999999999999999999999999
start with 1000000001
increment by 1
nocache;
--target:xag101
create sequence dbha_seq
minvalue 2000000001
maxvalue 999999999999999999999999999
start with 2000000001
increment by 1
nocache;
# insert 1 条测试数据(xag100)
insert into t1(dbha_seq,source_name,source_time,dest_time)
select dbha_seq.nextval,utl_inaddr.get_host_name,sysdate,sysdate from dual;
commit;
6.在数据库中启用Oracle GoldenGate (xag100,xag101)
#必须为Oracle 11.2.0.4或更高版本的数据库显式启用支持Oracle GoldenGate捕获和应用所需的数据库服务
SQL> alter system set enable_goldengate_replication=true;
7.启用架构(用户)级别的补充日志记录(source端:xag100)
GGSCI > dblogin userid ogg_admin,password 123456
GGSCI > add schematrandata us01
or 指定对 us01.t1 表补充日志记录
#在源端添加表及附加日志(在某些情况下即使你启用了用户级别的附加日志,你也可以启用表级别的附加日志使主键附加日志替代每一个在用户级别为GoldenGate指定的键)
GGSCI > add trandata us01.t1
8.设置闪回查询(xag100,xag101)
SQL>
ALTER SYSTEM SET UNDO_MANAGEMENT=AUTO SCOPE=spfile;
ALTER SYSTEM SET undo_retention=86400 SCOPE=both;
GRANT FLASHBACK ANY TABLE TO us01;
9.管理服务器资源(xag100,xag101)
#默认情况下,一个集成的捕获摘录请求日志挖掘服务器以MAX_SGA_SIZE1GB 的速度运行。
#因此,如果在同一数据库实例中以集成捕获模式运行三个提取,则需要至少3 GB的内存分配给Streams池。
#最佳做法是保持25%的流池可用。例如,如果在集成捕获模式下有3个摘录,请将STREAMS_POOL_SIZE数据库设置为以下值:
# 3 GB * 1.25 = 3.75 GB
SQL> alter system set streams_pool_size=3.75 GB
10.source端配置认证证书(可选)-xag100
$ ggsci
GGSCI > add credentialstore
GGSCI > alter credentialstore add user ogg_admin@TNS_DB100,password 123456 alias ogg100
GGSCI > info credentialstore
GGSCI > dblogin useridalias ogg100
11.source端配置全局参数(xag100)
#创建 ogg 工作目录
一些比较重要的目录
1、dirchk:用来存放检查点(Checkpoint)文件
2、dirdat:用来存放Trail文件,以后详述;
3、dirdef:用来存放通过DEFGEN工具生成的源或目标端数据定义文件;
4、dirpcs:用来存放进程状态文件
5、dirprm:用来存放配置参数文件
6、dirrpt:用来存放进程报告文件
7、dirsql:用来存放SQL脚本文件
8、dirtmp:当事务所需要的内存超过已分配内存时,缺省存储在这个目录。
[oracle@xag100 ogg]$ cd $OGG_HOME
GGSCI > create subdirs
GGSCI > add checkpointtable ogg_admin.checkpointtable
GGSCI > edit params ./GLOBALS
加如下内容(第二行 checkpointtable 相关源端可不用加):
ENABLEMONITORING
CHECKPOINTTABLE ogg_admin.checkpointtable
GGSCHEMA ogg_admin
12.source端配置 manager(xag100)
GGSCI > edit params mgr
PORT 7809
DYNAMICPORTLIST 7810-7990
AUTOSTART ER *
AUTORESTART ER *, RETRIES 3, WAITMINUTES 2,RESETMINUTES 30
PURGEOLDEXTRACTS /u01/app/oracle/product/ogg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 10
PURGEDDLHISTORY MINKEEPDAYS 7, MAXKEEPDAYS 10
PURGEMARKERHISTORY MINKEEPDAYS 7, MAXKEEPDAYS 10
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45
----------------------------------------------------
注:
PORT 7839
通信端口7839, 源端和目标端需要保持一致。
DYNAMICPORTLIST 7810-7990
动态端口列表的范围从7810到7990。当制定端口被占用或者出现通信故障,管理进程将会从列表中选择下一个端口尝试连接,避免通信端口的单点故障。
AUTOSTART ER *
当MGR进程启动后启动EXTRACT进程
AUTORESTART ER *, RETRIES 3, WAITMINUTES 2,RESETMINUTES 30
当EXTRACT进程中断后尝试自动重启,每隔2分钟尝试启动一次,尝试3次,如未成功30分钟重复此尝试。
AUTORESTART {EXTRACT | REPLICAT | ER} group_name
[, RETRIES number]
[, WAITMINUTES {minutes | seconds}]
[, RESETMINUTES {minutes | seconds}]
EXTRACT :Restarts Extract automatically.
REPLICAT :Restarts Replicat automatically.
ER :Restarts Extract and Replicat automatically.
PURGEOLDEXTRACTS /u01/app/oracle/product/ogg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 5
(相对路径写法)PURGEOLDEXTRACTS ./dirdat/*, USECHECKPOINTS, MINKEEPDAYS 5
定期清理dirdat路径下的本地队列(local trail)。保留期限10天,过期后自动删除。从而控制队列文件的目录不会增长过大。
LAGREPORTHOURS 1
每隔一小时检查各进程延时情况,并记录到goldengate report文件。
LAGINFOMINUTES 30
进程复制延时超过30分钟,向日志文件记录一条错误日志
LAGCRITICALMINUTES 45
传输延时超过45分钟将写入警告日志
----------------------------------------------------
GGSCI > stop mgr
#启动mgr进程
GGSCI > start mgr
GGSCI > info all
13.源端配置Extract进程参数
#在源端添加extract 进程 ex1 (ex1 同Extract进程参数名)
#传统抽取模式(Classic Capture)
GGSCI > ADD EXTRACT ex1, TRANLOG, BEGIN NOW
or
#集成抽取模式(Integrated Capture)-- 已存在则alter 否则 add 命令
GGSCI > ADD EXTRACT ex1, INTEGRATED TRANLOG,BEGIN now
GGSCI > add exttrail /u01/app/oracle/product/ogg/dirdat/e1, extract ex1, MEGABYTES 20
GGSCI > edit params ex1
extract ex1
SETENV (ORACLE_SID="DB100")
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
USERID ogg_admin, PASSWORD 123456
TRANLOGOPTIONS INTEGRATEDPARAMS (max_sga_size 300,_LOGMINER_READ_BUFFERS 128,parallelism 2)
REPORTCOUNT EVERY 30 MINUTES, RATE
DISCARDFILE /u01/app/oracle/product/ogg/dirrpt/extsr1.dsc, APPEND, MEGABYTES 1024
DISCARDROLLOVER AT 3:00
EXTTRAIL /u01/app/oracle/product/ogg/dirdat/e1
DYNAMICRESOLUTION
DBOPTIONS ALLOWUNUSEDCOLUMN
FETCHOPTIONS NOUSESNAPSHOT
FETCHOPTIONS FETCHPKUPDATECOLS
TABLE us01.t1;
----------------------------------------------------------------------
注: 有 TRANLOGOPTIONS 表示 集成抽取模式(Integrated Capture)
SETENV (ORACLE_SID="DB100")
设置Oracle数据库实例sid
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
设置goldengate的字符集变量信息,此处值会覆盖操作系统级别的变量。该值需要和数据库字符集匹配一致。
REPORTCOUNT EVERY 30 MINUTES, RATE
每隔30分钟报告一次从程序开始到现在的抽取进程或者复制进程的事物记录数,并汇报进程的统计信息
DISCARDFILE /u01/app/oracle/product/ogg/dirrpt/extsr1.dsc, APPEND, MEGABYTES 1024
将执行失败的记录保存在discard file中,discard file文件记录了GoldenGate进程错误、数据库错误、GoldenGate操作等信息。该文件位于/data/oracle/product/ogg_src/dirrpt/extsr.dsc,大小为1024MB。 文件中已经包含记录的话,再后面继续追加,不删除之前的记录。
DISCARDROLLOVER AT 3:00
为了防止discard file被写满,每天3:00做一次文件过期设定
EXTTRAIL /u01/app/oracle/product/ogg/dirdat/e1
队列文件路径, trail文件存放路径。
DYNAMICRESOLUTION
有时候开启OGG进程的时候较慢,可能是因为需要同步的表太多,OGG在开启进程之前会将需要同步的表建立一个记录并且存入到磁盘中,这样就需要耗费大量的时间。使用该参数来解决此问题。
DBOPTIONS ALLOWUNUSEDCOLUMN
用于阻止抽取进程抽取数据时由于表含有unused列而导致进程异常终止(abend)。使用该参数,抽取进程抽取到unused列时也会向日志文件记录一条警告信息。
FETCHOPTIONS NOUSESNAPSHOT
默认值为 usesnapshot,表示利用数据库闪回读取数据。Nousesnapshot表示直接从原表读取相关数据。
FETCHOPTIONS FETCHPKUPDATECOLS
当使用了HANDLECOLLISIONS时,请使用该参数。
复制进程出现丢失update记录(missing update)并且更新的是主键,update将转换成insert。由于插入的记录可能不是完整的行,若要保证完整需要加入此参数
TABLE us01.t1;
需要复制的对象列表
----------------------------------------------------------------------
GGSCI > start extract ex1
14.源端配置Data Pump进程参数
#在源端配置添加Data Pump进程 dp1读取原数据时从 extract 进程 ex1所写入的文件中读取
GGSCI > ADD EXTRACT dp1 EXTTRAILSOURCE /u01/app/oracle/product/ogg/dirdat/e1
#在源端配置 Data Pump进程 dp1 生成的文件传输到远端的目录及文件名前缀
GGSCI >ADD RMTTRAIL /u01/app/oracle/product/ogg/dirdat/r1, EXTRACT dp1, MEGABYTES 20
edit params dp1
extract dp1
SETENV (ORACLE_SID="DB100")
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
USERID ogg_admin, PASSWORD 123456
RMTHOST xag101, MGRPORT 7809, COMPRESS
PASSTHRU
RMTTRAIL /u01/app/oracle/product/ogg/dirdat/r1
--DYNAMICRESOLUTION
table us01.t1;
----------------------------------------------------------------------
注:
RMTHOST xag101, mgrport 7809, COMPRESS
目标端主机IP,管理进程端口号,投递前压缩队列文件
PASSTHRU
表示传输进程直接跟抽取进程交互,而不再和数据库进行交互,减少数据库资源的利用。
RMTTRAIL /u01/app/oracle/product/ogg/dirdat/r1
目标端保存队列文件的目录
DYNAMICRESOLUTION
动态解析表名
table us01.t1;
复制范围和抽取进程对应即可
源端可以配置多个主抽取进程,也可以配置多个Data Pump进程,但必须为每个要同步的目标端配置一个Data Pump进程;
指定Data Pump进程发送trail文件到目标端的位置(目标端trail文件添加到队列中)
如: ADD RMTTRAIL /u01/app/oracle/product/ogg/dirdat/r1, EXTRACT dp1
----------------------------------------------------------------------
15.管理pump投递进程
GGSCI > start extract dp1 –启动pump进程
GGSCI > stop extract dp1 –关闭pump进程
16.target端配置认证证书
GGSCI > add credentialstore
GGSCI > alter credentialstore add user ogg_admin@TNS_DB101,password 123456 alias ogg101
GGSCI > info credentialstore
GGSCI > dblogin useridalias ogg101
17.目标端配置全局参数(xag101)
#创建 ogg 工作目录
[oracle@xag101 ogg]$ cd $OGG_HOME
GGSCI > create subdirs
#目标端创建checkpoint table
GGSCI > dblogin userid ogg_admin,password 123456
or
GGSCI > dblogin useridalias ogg101
GGSCI > add checkpointtable ogg_admin.checkpointtable
GGSCI > edit params ./GLOBALS
加如下内容:
ENABLEMONITORING
CHECKPOINTTABLE ogg_admin.checkpointtable
GGSCHEMA ogg_admin
18.target端配置 manager
GGSCI (node2) 1> edit params mgr
PORT 7809
USERID ogg_admin,password 123456
DYNAMICPORTLIST 7810-7990
AUTOSTART REPLICAT *
AUTORESTART REPLICAT *, RETRIES 5, WAITMINUTES 2
PURGEOLDEXTRACTS /u01/app/oracle/product/ogg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 10
PURGEDDLHISTORY MINKEEPDAYS 7, MAXKEEPDAYS 10
PURGEMARKERHISTORY MINKEEPDAYS 7, MAXKEEPDAYS 10
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45
--------------------------------------------------------------------------------
注:
USERID ogg_admin,password 123456
GoldenGate用户登录数据库的用户名和密码,密码未做加密处理。
如果密码需要加密使用:GGSCI (dbtrg) 1> encrypt password pwd ,ENCRYPTKEY default
可以得到加密后的密码字符串,之后配置进程若使用加密过的密码,需要带参数(ENCRYPTKEY default)。
例如:USERID ogg, PASSWORD xxx(加密过的密码) ,ENCRYPTKEY default
AUTOSTART REPLICAT *
当MGR进程启动后启动REPLICAT进程
AUTORESTART REPLICAT *, RETRIES 5, WAITMINUTES 2
当REPLICAT进程中断后尝试自动重启,每隔2分钟尝试启动一次,尝试5次。
PURGEDDLHISTORY MINKEEPDAYS 7, MAXKEEPDAYS 10
删除DDL历史表,最小保存7天,最大保存10天。
PURGEMARKERHISTORY MINKEEPDAYS 7, MAXKEEPDAYS 10
删除MARKER历史表,最小保存7天,最大保存10天
LAGREPORTHOURS 1
每隔一小时检查各进程延时情况,并记录到goldengate report文件。
LAGINFOMINUTES 30
进程复制延时超过30分钟,向日志文件记录一条错误日志
LAGCRITICALMINUTES 45
传输延时超过45分钟将写入警告日志
--------------------------------------------------------------------------------
19.target端配置 replicat
GGSCI > dblogin useridalias ogg101
#在目标端添加Replicat进程rt1
#传统Replicat模式(Classic Replicat)
GGSCI > ADD REPLICAT rt1, EXTTRAIL /u01/app/oracle/product/ogg/dirdat/r1, checkpointtable ogg_admin.checkpointtable
or
#集成Replicat模式(Replicat-Integrated)
GGSCI > ADD REPLICAT rt1 integrated EXTTRAIL /u01/app/oracle/product/ogg/dirdat/r1 , checkpointtable ogg_admin.checkpointtable
GGSCI > edit params rt1
REPLICAT rt1
SETENV (ORACLE_SID="DB101")
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
USERID ogg_admin,password 123456
DBOPTIONS INTEGRATEDPARAMS(parallelism 4)
REPORT AT 06:00
REPORTCOUNT EVERY 30 MINUTES, RATE
REPORTROLLOVER AT 02:00
REPERROR DEFAULT, ABEND
ALLOWNOOPUPDATES
ASSUMETARGETDEFS
HANDLECOLLISIONS
DISCARDFILE /u01/app/oracle/product/ogg/dirout/reptr1.desc, APPEND, MEGABYTES 1024
DISCARDROLLOVER AT 02:00
MAP us01.t1,TARGET us01.t1;
----------------------------------------------------------------------
注: DBOPTIONS INTEGRATEDPARAMS(parallelism 4) 表示 集成Replicat模式(Replicat-Integrated)
REPORT AT 06:00
每天06:00定期生成一个report文件
REPORTCOUNT EVERY 30 MINUTES, RATE
每隔30分钟报告一次从程序开始到现在的抽取进程或者复制进程的事物记录数,并汇报进程的统计信息
REPORTROLLOVER AT 02:00
为了防止report file被写满,每天2:00做一次文件过期设定
REPERROR DEFAULT, ABEND
除了特殊指定的REPERROR语句,报告所有复制期间出现的错误,回滚非正常中断的事物和进程。遇到不能处理的错误就自动abend,启动需要人工干预处理
ALLOWNOOPUPDATES
当源表有排除列情况或者有目标表不存在的列时,当更新这列goldengate默认报错。应用该参数后,即可让goldengate生成一条警告信息而不是报错。
ASSUMETARGETDEFS
使用ASSUMETARGETDEFS参数时,用MAP语句中指定的生产库源表和灾备端目标表具有相同的列结构。它指示的Oracle GoldenGate不在生产端查找源表的结构定义。
HANDLECOLLISIONS
用于goldengate自动过滤不能出来的冲突记录,为了严格保证数据一致性
DISCARDFILE /u01/app/oracle/product/ogg/dirout/reptr1.desc, APPEND, MEGABYTES 1024
将执行失败的记录保存在discard file中,discard file文件记录了GoldenGate进程错误、数据库错误、GoldenGate操作等信息。该文件位于./dirout/reptr.desc,大小为1024MB。 文件中已经包含记录的话,再后面继续追加,不删除之前的记录。
DISCARDROLLOVER AT 02:00
为了防止discard file被写满,每天2:00做一次文件过期设定
MAP us01.t1,TARGET us01.t1;
对应需要复制的对象,默认一一对应传输进程
----------------------------------------------------------------------
20.初始化数据
#通过如下方法将目标端的数据同步成和源端一致
同步数据的方式可以通过DBLINK、EXP/IMP、SQLLDR或者表空间迁移等方式同步
#启动源端GoldenGate进程
GGSCI > start mgr
#启动源端extract进程
GGSCI > start extract ex1
GGSCI > start extract dp1
[oracle@xag100 ogg]$ sqlplus / as sysdba
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
982934
[oracle@xag100 ogg]$ sqlplus us01/us01@TNS_DB100
SQL> select dbha_seq,source_name,to_char(source_time,\'yyyy-mm-dd hh24:mi:ss\') as source_time,to_char(dest_time,\'yyyy-mm-dd hh24:mi:ss\') from t1;
DBHA_SEQ SOURCE_NAME SOURCE_TIME TO_CHAR(DEST_TIME,\'
---------- -------------------- ------------------- -------------------
1000000001 xag100 2020-04-13 22:51:09 2020-04-13 22:51:09
#启动目标端GoldenGate进程
GGSCI > start mgr
#使用 expdp、impdp初始化后,通过添加 afterscn 参数启动 rep
[oracle@xag101 ~]$ sqlplus us01/us01@TNS_DB101
[oracle@ogg1 ~]$ expdp us01/us01 directory=dmp dumpfile=us01.dmp schemas=us01 flashback_scn=982934
#把导出的文件拷贝到目标端,进行还原
[oracle@ogg2 ~]$ impdp us01/us01 directory=dmp dumpfile=us01.dmp schemas=us01
or 数据量少直接用如下 insert 语句插入
insert into t1(dbha_seq,source_name,source_time,dest_time)
values(1000000001,\'xag100\',to_date(\'2020-04-13 22:51:09\',\'yyyy-mm-dd hh24:mi:ss\'),to_date(\'2020-04-13 22:51:09\',\'yyyy-mm-dd hh24:mi:ss\'));
commit;
SQL> select dbha_seq,source_name,to_char(source_time,\'yyyy-mm-dd hh24:mi:ss\') as source_time,to_char(dest_time,\'yyyy-mm-dd hh24:mi:ss\') from t1;
DBHA_SEQ SOURCE_NAME SOURCE_TIME TO_CHAR(DEST_TIME,\'
---------- -------------------- ------------------- -------------------
1000000001 xag100 2020-04-13 22:51:09 2020-04-13 22:51:09
GGSCI > start replicat rt1,aftercsn 982934
21.启动(有顺序)
#目标端
[oracle@xag101 ~]$ cd $OGG_HOME
[oracle@xag101 ogg]$ ggsci
GGSCI (xag101) 1> start mgr
Manager started.
GGSCI (xag101) 2> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
JAGENT STOPPED
PMSRVR STOPPED
REPLICAT RUNNING RT1 00:00:00 00:00:06
GGSCI (xag101) 3> stats rt1
Sending STATS request to REPLICAT RT1 ...
No active replication maps.
#源端
[oracle@xag100 ~]$ cd $OGG_HOME
[oracle@xag100 ogg]$ ggsci
GGSCI (xag100) 1> start mgr
Manager started.
GGSCI (xag100) 2> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
JAGENT STOPPED
PMSRVR STOPPED
EXTRACT RUNNING DP1 00:00:00 00:33:40
EXTRACT RUNNING EX1 00:00:00 00:00:03
GGSCI (xag100) 3> stats ex1
Sending STATS request to EXTRACT EX1 ...
No active extraction maps.
GGSCI (xag100) 4> stats dp1
Sending STATS request to EXTRACT DP1 ...
No active extraction maps.
#如以上存在启动失败 则 查看日志文件ggserr.log
日志文件存储路径:GoldenGate安装目录下($OGG_HOME/ggserr.log)
tail -50f $OGG_HOME/ggserr.log
22.测试
#source端启动相关进程
GGSCI > start mgr
GGSCI > start extract ext1
GGSCI > start extract dp1
GGSCI > info all
GGSCI > stats ex1
GGSCI > stats dp1
GGSCI > view report ex1
GGSCI > view report dp1
GGSCI > info ex1
GGSCI > info ex1,detail
# insert 1 条测试数据(xag100)
insert into t1(dbha_seq,source_name,source_time,dest_time)
select dbha_seq.nextval,utl_inaddr.get_host_name,sysdate,sysdate from dual;
commit;
SQL> select dbha_seq,source_name,to_char(source_time,\'yyyy-mm-dd hh24:mi:ss\') as source_time,to_char(dest_time,\'yyyy-mm-dd hh24:mi:ss\') from t1;
DBHA_SEQ SOURCE_NAME SOURCE_TIME TO_CHAR(DEST_TIME,\'
---------- -------------------- ------------------- -------------------
1000000002 xag100 2020-04-14 21:09:14 2020-04-14 21:09:14
1000000001 xag100 2020-04-13 22:51:09 2020-04-13 22:51:09
#target端启动相关进程
GGSCI > start mgr
GGSCI > start replicat rt1
GGSCI > info all
GGSCI > stats rt1
GGSCI > view report rt1
SQL> select dbha_seq,source_name,to_char(source_time,\'yyyy-mm-dd hh24:mi:ss\') as source_time,to_char(dest_time,\'yyyy-mm-dd hh24:mi:ss\') from t1;
23.停ogg
#停源端
GGSCI (xag100) 6> stop extract dp1
GGSCI (xag100) 7> stop extract ex1
GGSCI (xag100) 8> stop mgr
GGSCI (xag100) 9> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
JAGENT STOPPED
PMSRVR STOPPED
EXTRACT STOPPED DP1 00:00:00 00:00:19
EXTRACT STOPPED EX1 00:00:00 00:00:14
#停目标端
GGSCI (xag101) 5> stop replicat rt1
GGSCI (xag101) 6> stop mgr
GGSCI (xag101) 7> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
JAGENT STOPPED
PMSRVR STOPPED
REPLICAT STOPPED RT1 00:00:00 00:00:13
参考: https://www.cnblogs.com/lanston/p/ogg_configAndUse.html
参考:https://blog.csdn.net/ctypyb2002/article/details/81069650
参考:https://www.cnblogs.com/VoiceOfDreams/p/8576973.html
Oracle GoldenGate错误集:https://wenku.baidu.com/view/e78f9dd402d276a201292e14.html
OGG 拆分EXTRACT进程 https://blog.csdn.net/leo__1990/article/details/92578729
Oracle 环境下 GoldenGate (Integrated Capture)与(Classic Capture)间的切换 https://www.cnblogs.com/autopenguin/p/6269868.html
24.错误处理
2020-04-15T23:00:18.850+0800 ERROR OGG-02912 Oracle GoldenGate Capture for Oracle, ex1.prm: Patch 17030189 is required on your Oracle mining database for trail format RELEASE 12.2 or later.
2020-04-15T23:00:18.850+0800 ERROR OGG-01668 Oracle GoldenGate Capture for Oracle, ex1.prm: PROCESS ABENDING.
-------------------------------------------------------------------------------------------------------------------------
#解决错误的方法如下:
# su - oracle
$ cd $OGG_HOME
$ ls -lrt prvtlmpg.plb
-rwxr-xr-x 1 oracle oinstall 9487 May 27 2015 prvtlmpg.plb
$ sqlplus / as sysdba
SQL> @prvtlmpg.plb
-------------------------------------------------------------------------------------------------------------------------
2020-04-15T22:58:27.074+0800 ERROR OGG-02022 Oracle GoldenGate Capture for Oracle, ex1.prm: Logmining server does not exist on this Oracle database.
2020-04-15T22:58:27.083+0800 ERROR OGG-01668 Oracle GoldenGate Capture for Oracle, ex1.prm: PROCESS ABENDING.
-------------------------------------------------------------------------------------------------------------------------
解决错误的方法:注册extract进程到 db(11g) 或 pdb(12c以上)
#11G
register extract ex1 database
#12C或以上
register extract ex1 database container(pdb名称)
-------------------------------------------------------------------------------------------------------------------------