昨天突然接到消息说有一个线上的ogg出现了问题,看是否能修复,由于ogg以前玩的少,所以就加急搞了个测试环境,练习了一把

环境

db1,db2(单实例)
ip: 1*,1*
sid: orcl,ogg1
os: centos 6.5,centos 6.5
oracle version: 11.2.0.4,11.2.0.4

1 --可以创建ogg用户,也可以使用oracle用户

useradd -u 2100 -g oinstall -G dba ogg
passwd ogg

[ogg@DSI ~]$ vim .bash_profile
export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH
[ogg@DSI ~]$ source .bash_profile

2 下载安装ogg

[root@DSI ~]# mkdir -p /u01/app/ogg
[root@DSI ~]# chown -R oracle:oinstall /u01/app/ogg
[root@DSI opt]# unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
Archive: ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
inflating: fbo_ggs_Linux_x64_ora11g_64bit.tar
inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf
inflating: Oracle GoldenGate 11.2.1.0.1 README.txt
inflating: Oracle GoldenGate 11.2.1.0.1 README.doc
[root@DSI opt]# tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar -C /u01/app/ogg/
[root@DSI ogg]# chown -R oracle:oinstall /u01/app/ogg

解压成功之后,登录OGG测试

[oracle@DSI ogg]$ ./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (DSI) 1>
##注意:如果LD_LIBRARY_PATH变量设置正确,会像上面演示一样正确进入命令行,如果提示找不到so文件,就需要查看LD_LIBRARY_PATH变量是否配置正确

3 源端创建OGG表空间和OGG用户---两个服务器都要做

SYS@ orcl > create tablespace ogg datafile '/u01/app/oracle/oradata/orcl/ogg01.dbf' size 50m autoextend on;
Tablespace created.
SYS@ orcl > create user ogg identified by ogg default tablespace ogg;
User created
SYS@ orcl >grant CONNECT, RESOURCE to ogg;
Grant succeeded.
SYS@ orcl >grant SELECT ANY DICTIONARY, SELECT ANY TABLE to ogg;
Grant succeeded.
SYS@ orcl >grant ALTER ANY TABLE to ogg;
Grant succeeded.
SYS@ orcl >grant FLASHBACK ANY TABLE to ogg;
Grant succeeded.
SYS@ orcl >grant EXECUTE on DBMS_FLASHBACK to ogg;
Grant succeeded.
SYS@ orcl >grant insert any table to ogg;
Grant succeeded.
SYS@ orcl >grant update any table to ogg;
Grant succeeded.
SYS@ orcl >grant delete any table to ogg;
Grant succeeded.
或者
grant resource,connect,dba to ogg; 打开数据库的附加日志和 force log
SYS@ orcl >select NAME,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MIN from v$database;
NAME OPEN_MODE FOR SUPPLEME
--------- -------------------- --- --------
ORCL READ WRITE NO YES
SYS@ orcl >alter database force logging;
Database altered.
SYS@ orcl >alter database add SUPPLEMENTAL log data;
Database altered.
SYS@ orcl >select NAME,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MIN from v$database;
NAME OPEN_MODE FOR SUPPLEME
--------- -------------------- --- --------
ORCL READ WRITE YES YES
SYS@ orcl >alter system switch logfile;
---运行 OGG 支持 DDL 脚本
如果要让 OGG 支持 DDL 操作,还需要额外运行几个脚本,这些脚本是 OGG 带的而不是 ORACLE 带的,源端与目标端都需要
---SYS@ orcl >@/u01/app/ogg/marker_setup.sql
---SYS@ orcl >@/u01/app/ogg/ddl_setup.sql
---SYS@ orcl >@/u01/app/ogg/role_setup.sql
---SYS@ orcl >@/u01/app/ogg/ddl_enable.sql

ogg实例是刚搭建的新环境

实例ogg//开启归档,ogg方式同上
SYS@ ogg >archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 71
Current log sequence 73
SYS@ ogg >shutdown immediate;
SYS@ ogg >startup mount;
SYS@ ogg >alter database archivelog;
SYS@ ogg >alter database open;
SYS@ ogg >archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 71
Next log sequence to archive 73
Current log sequence 73 export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib
export ORACLE_SID=ogg
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH
# source /home/ogg/.bash_profile
create tablespace ogg datafile '/u01/app/oracle/oradata/ogg/ogg01.dbf' size 50m autoextend on; alias ggsci="/u01/app/ogg/ggsci"

4 开始进行搭建

源 orcl
1 创建 OGG 的管理目录

GGSCI (DSI) 1> create subdirs
Creating subdirectories under current directory /u01/app/ogg Parameter files /u01/app/ogg/dirprm: already exists
Report files /u01/app/ogg/dirrpt: created
Checkpoint files /u01/app/ogg/dirchk: created
Process status files /u01/app/ogg/dirpcs: created
SQL script files /u01/app/ogg/dirsql: created
Database definitions files /u01/app/ogg/dirdef: created
Extract data files /u01/app/ogg/dirdat: created
Temporary files /u01/app/ogg/dirtmp: created
Stdout files /u01/app/ogg/dirout: created
2 建立测试表
SYS@ ogg >@/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/utlsampl.sql
--实例orcl
SYS@ orcl> conn scott/*
Connected.
SCOTT@ orcl >create table emp_ogg as select * from emp;
Table created.
SCOTT@ orcl >create table dept_ogg as select * from dept;
Table created.
SCOTT@ orcl >alter table EMP_OGG add constraint PK_EMPNO_OGG primary key (EMPNO);
Table altered.
SCOTT@ orcl >alter table DEPT_OGG add constraint PK_DEPTNO_OGG primary key (DEPTNO);
Table altered.
--实例ogg
SYS@ ogg >conn scott/*
Connected.
SCOTT@ ogg > create table emp_ogg as select * from emp where 1=2;
Table created.
SCOTT@ ogg >create table dept_ogg as select * from dept where 1=2;
Table created.
SCOTT@ ogg >alter table EMP_OGG add constraint PK_EMPNO_OGG primary key (EMPNO);
Table altered.
SCOTT@ ogg >alter table DEPT_OGG add constraint PK_DEPTNO_OGG primary key (DEPTNO);
Table altered.

3 源端添加表级 TRANDATA

GGSCI (DSI) 2> DBLOGIN USERID ogg, PASSWORD ogg
Successfully logged into database.
GGSCI (DSI) 3> add trandata scott.emp_ogg
Logging of supplemental redo log data is already enabled for table SCOTT.EMP_OGG.
GGSCI (DSI) 4> add trandata scott.dept_ogg
Logging of supplemental redo log data is already enabled for table SCOTT.DEPT_OGG.
GGSCI (DSI) 5> INFO TRANDATA scott.*
Logging of supplemental redo log data is disabled for table SCOTT.BONUS.
Logging of supplemental redo log data is disabled for table SCOTT.DEPT.
Logging of supplemental redo log data is enabled for table SCOTT.DEPT_OGG.
Columns supplementally logged for table SCOTT.DEPT_OGG: DEPTNO.
Logging of supplemental redo log data is disabled for table SCOTT.EMP.
Logging of supplemental redo log data is enabled for table SCOTT.EMP_OGG.
Columns supplementally logged for table SCOTT.EMP_OGG: EMPNO.
Logging of supplemental redo log data is disabled for table SCOTT.SALGRADE.

4 配置 MGR 管理进程

GGSCI (DSI) 6> edit params mgr
PORT 7809
PURGEOLDEXTRACTS /u01/app/ogg/dirdat, USECHECKPOINTS
参数说明:
PORT 7809: OGG 管理进程监控端口。
PURGEOLDEXTRACTS:清除不需要的 trail 文件。
/u01/app/ogg/dirdat: trail 文件存放位置。
USECHECKPOINTS:使用检查点队列
GGSCI (DSI) 7> start mgr
Manager started.
GGSCI (DSI) 8> info mgr
Manager is running (IP port DSI.7809).

5 配置初始化数据进程

由于在创建测试表的时候,源端的测试表有数据,而目标端的测试表只有结构,没有数据,所以需要初始
化目标端的数据,所谓初始化,就是让目标端的数据和源端的数据在这个时间点是一模一样的, 所以初始化工
作并不需要一定使用 OGG,也可以使用 EXP、 EXPDP、 SQLLOAD 等其他工具
##使用 OGG 进行数据初始化, 下面在源端配置捕获进程 EINI_1

GGSCI (DSI) 9> ADD EXTRACT EINI_1, SOURCEISTABLE
EXTRACT added.
GGSCI (DSI) 10> INFO EXTRACT *, TASKS
EXTRACT EINI_1 Initialized 2019-06-19 14:00 Status STOPPED
Checkpoint Lag Not Available
Log Read Checkpoint Not Available
First Record Record 0
Task SOURCEISTABLE
GGSCI (DSI) 11> EDIT PARAMS EINI_1
EXTRACT EINI_1
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
USERID ogg, PASSWORD ogg
RMTHOST 1*, MGRPORT 7809
RMTTASK REPLICAT, GROUP RINI_1
TABLE scott.EMP_OGG;
TABLE scott.DEPT_OGG;
参数介绍:
EXTRACT EINI_1:说明这是 EXTRACT 进程,名字是 EINI_1
SETENV:环境变量,一定要设置和数据库字符集一样,否则可能会乱码
USERID:数据库 OGG 用户
PASSWORD:数据库用户 OGG 的密码
RMTHOST:目标端地址,如果在/etc/hosts 文件里已经设置解析,可以写主机名
MGRPORT:目标端 MGR 管理进程监听的端口
RMTTASK REPLICAT:目标端 REPLICAT 应用进程的组和名字
TABLE:源端要初始化数据的表的名字

编辑好捕获进程 EINI_1 后, 还需要在目标端配置 REPLICAT 应用进程,名字要和源端的捕获进程 EINI_1 里面 RMTTASK REPLICAT 参数配置的一样,
也就是还需要在目标端配置 RMTTASK REPLICAT RINI_1

目 ogg
[oracle@ogg ~]$ alias ggsci="/u01/app/ogg/ggsci"
[oracle@ogg ~]$ ggsci
GGSCI (ogg) 1> create subdirs Creating subdirectories under current directory /u01/app/ogg Parameter files /u01/app/ogg/dirprm: already exists
Report files /u01/app/ogg/dirrpt: created
Checkpoint files /u01/app/ogg/dirchk: created
Process status files /u01/app/ogg/dirpcs: created
SQL script files /u01/app/ogg/dirsql: created
Database definitions files /u01/app/ogg/dirdef: created
Extract data files /u01/app/ogg/dirdat: created
Temporary files /u01/app/ogg/dirtmp: created
Stdout files /u01/app/ogg/dirout: created
目标端
GGSCI (ogg) 2> edit params mgr
PORT 7809
PURGEOLDEXTRACTS /u01/app/ogg/dirdat, USECHECKPOINTS
GGSCI (ogg) 3> start mgr
Manager started.
GGSCI (ogg) 4> info mgr
Manager is running (IP port ogg.7809).

7 配置目标端 REPLICAT 进程

GGSCI (ogg) 5> EDIT PARAMS RINI_1
REPLICAT RINI_1
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
ASSUMETARGETDEFS
USERID ogg, PASSWORD ogg
DISCARDFILE /u01/app/ogg/dirrpt/RINIaa.dsc, PURGE
MAP scott.*, TARGET scott.*; 参数介绍:
REPLICAT RINI_1:说明这是 REPLICAT 应用进程,名字叫 RINI_1
SETENV:语言变量,同捕获进程 EINI_1
ASSUMETARGETDEFS:告诉 OGG 目标端和源端需要同步的表的结构完全一致,不需要 OGG 去检查表的结构,包括
表名、字段名、字段类型、字段长度等,如果目标端和源端同步的表的结构不一样,需要使用 SOURCEDEFS 参
数,详见 OGG 官方文档。
USERID、 PASSWORD:同捕获进程 EINI_1 参数介绍
DISCARDFILE: 错误信息存放位置及命名规则
MAP:源端捕获的表的名字
TARGET:目标端同步的表的名字,可以不在同一 SCHEMA。

8 初始化数据

配置好目标端的应用进程 RINI_1 后, 就可以启动源端的捕获进程进行捕获数据了,而目标端的应用进程 RINI_1 不需要手动去启动,也就是说目标端 RINI_1 进程不需要管

GGSCI (DSI) 12> START EXTRACT EINI_1
Sending START request to MANAGER ...
EXTRACT EINI_1 starting
GGSCI (DSI) 16> VIEW REPORT EINI_1
2019-06-19 14:09:12 WARNING OGG-01194 EXTRACT task RINI_1 abended : Could not open checkpoint file /u01/app/ogg/dirchk/RINI_1.cpr, mode 1 (error 2, No such file
--目标端错误日志
[root@ogg ogg]# more ggserr.log | grep ERROR
2019-06-19 14:09:15 ERROR OGG-00446 Oracle GoldenGate Delivery for Oracle, rini_1.prm: Could not open checkpoint file /u01/app/ogg/dirchk/RINI_1.cpr, mode 1 (error 2, No such file or directory).
###在目标端执行
GGSCI (ogg) 9> add replicat RINI_1,specialrun
REPLICAT added.
##在执行
GGSCI (DSI) 19> START EXTRACT EINI_1
Sending START request to MANAGER ...
EXTRACT EINI_1 starting
GGSCI (DSI) 22> VIEW REPORT EINI_1
Report at 2019-06-19 14:18:35 (activity since 2019-06-19 14:18:28)
Output to RINI_1:
From Table SCOTT.EMP_OGG:
# inserts: 14
# updates: 0
# deletes: 0
# discards: 0 REDO Log Statistics
Bytes parsed 0
Bytes output 2616

9 验证初始化数据

###目标库已经有了数据
SCOTT@ ogg >set linesize 1000
SCOTT@ ogg >select * from emp_ogg; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20 EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10

初始化之后,上文提到的初始化进程(EINI_1、 RINI_1)自动停止, 因为通常情况下初始化数据工作只会做一次。 可以通过 INFO 命令查看进程的状态

源端:
GGSCI (DSI) 23> INFO EXTRACT EINI_1 EXTRACT EINI_1 Last Started 2019-06-19 14:18 Status STOPPED
Checkpoint Lag Not Available
Log Read Checkpoint Table SCOTT.EMP_OGG
2019-06-19 14:18:34 Record 14
Task SOURCEISTABLE
GGSCI (ogg) 10> INFO REPLICAT RINI_1 REPLICAT RINI_1 Initialized 2019-06-19 14:18 Status STOPPED
Checkpoint Lag 00:00:00 (updated 00:04:23 ago)
Log Read Checkpoint Not Available
Task SPECIALRUN

10 源端和目标端配置 OGG 的检查点

此步骤不是必须的,但是为了让 OGG 网络中断、服务器宕机、掉电等在突发情况也能正确断点续传, ORACLE 建议配置 OGG 的检查点队列。
源端和目标端都需配置

GGSCI (DSI) 24> EDIT PARAMS ./GLOBALS
CHECKPOINTTABLE ogg.ggschkpt
GGSCI (DSI) 25> ADD CHECKPOINTTABLE
ERROR: Missing checkpoint table specification.
GGSCI (DSI) 26> exit
[oracle@DSI ogg]$ ./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (DSI) 1> dblogin userid ogg,password ogg
Successfully logged into database.
GGSCI (DSI) 2> ADD CHECKPOINTTABLE
No checkpoint table specified, using GLOBALS specification (ogg.ggschkpt)...
Successfully created checkpoint table ogg.ggschkpt.
SYS@ orcl >conn ogg/ogg
Connected.
OGG@ orcl >select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BIN$i6WDddFkJD/gUxkHDwrYjw==$0 TABLE
BIN$i6WDddFsJD/gUxkHDwrYjw==$0 TABLE
GGSCHKPT TABLE
GGSCHKPT_LOX TABLE

11 源端配置捕获进程

GGSCI (DSI) 3> EDIT PARAMS EORA_1
EXTRACT EORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
USERID ogg, PASSWORD ogg
EXTTRAIL /u01/app/ogg/dirdat/aa
TABLE scott.EMP_OGG;
TABLE scott.DEPT_OGG;
##EXTTRAIL 参数是 TRAIL 队列文件存放的路径和命名格式, TRAIL 文件可以理解为存放捕获进程捕获的日志文件。 此时还需要将捕获进程 EORA_1 添加到 OGG
GGSCI (DSI) 4> ADD EXTRACT EORA_1, TRANLOG, BEGIN NOW
EXTRACT added.
GGSCI (DSI) 5> ADD EXTTRAIL /u01/app/ogg/dirdat/aa, EXTRACT EORA_1, MEGABYTES 5
EXTTRAIL added.
##上面的两个命名告诉 OGG,捕获进程从启动起开始捕获,捕获数据保存到 TRAIL 文件,及 TRAIL 文件的路径、命名格式,单个 TRAIL 文件最大大小
GGSCI (DSI) 6> START EXTRACT EORA_1
Sending START request to MANAGER ...
EXTRACT EORA_1 starting
GGSCI (DSI) 7> INFO EXTRACT EORA_1
EXTRACT EORA_1 Last Started 2019-06-19 14:57 Status RUNNING
Checkpoint Lag 00:01:37 (updated 00:00:06 ago)
Log Read Checkpoint Oracle Redo Logs
2019-06-19 14:56:08 Seqno 23, RBA 728592
SCN 0.0 (0)

12 源端配置 PUMP 传输进程

##此步骤也是非必须的,如果不配置传输进程, OGG 会通过 EXTRACT 进程传输 TRAIL 队列文件,但是和检查点队列一样,为了保证断点续传 ORACLE 建议配置 PUMP 传输进程

GGSCI (DSI) 8> EDIT PARAMS PORA_1
EXTRACT PORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA,AL32UTF8)
PASSTHRU
RMTHOST *, MGRPORT 7809
RMTTRAIL /u01/app/ogg/dirdat/pa
TABLE scott.EMP_OGG;
TABLE scott.DEPT_OGG;
##添加 PUMP 进程 PORA_1 到 OGG,并指定本地的 TRAIL 文件。
GGSCI (DSI) 9> ADD EXTRACT PORA_1, EXTTRAILSOURCE /u01/app/ogg/dirdat/aa
EXTRACT added.
GGSCI (DSI) 10> INFO EXTRACT PORA_1
EXTRACT PORA_1 Initialized 2019-06-19 15:00 Status STOPPED
Checkpoint Lag 00:00:00 (updated 00:00:17 ago)
Log Read Checkpoint File /u01/app/ogg/dirdat/aa000000
First Record RBA 0
##为 PUMP 进程 PORA_1 指定将本地 TRAIL 文件传输到目标端后保存成目标端 TRAIL 文件的名字。
GGSCI (DSI) 11> ADD RMTTRAIL /u01/app/ogg/dirdat/pa, EXTRACT PORA_1, MEGABYTES 5
RMTTRAIL added.
GGSCI (DSI) 12> START EXTRACT PORA_1
Sending START request to MANAGER ...
EXTRACT PORA_1 starting
GGSCI (DSI) 13> INFO EXTRACT PORA_1
EXTRACT PORA_1 Last Started 2019-06-19 15:02 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:01 ago)
Log Read Checkpoint File /u01/app/ogg/dirdat/aa000000
First Record RBA 0
GGSCI (DSI) 14> info all
Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING
EXTRACT RUNNING EORA_1 00:00:00 00:00:08
EXTRACT RUNNING PORA_1 00:00:00 00:00:07
此时在目标端/u01/app/ogg/dirdat/目录下,就会看到由源端 PUMP 进程 PORA_1 传输过来的 TRAIL 文件
[root@ogg ogg]# cd /u01/app/ogg/dirdat/
[root@ogg dirdat]# ll /u01/app/ogg/dirdat/
total 0
-rw-rw-rw- 1 oracle oinstall 0 Jun 19 15:02 pa000000

13 目标端配置同步进程 RORA_1

GGSCI (ogg) 3> ADD REPLICAT RORA_1,SPECIALRUN
REPLICAT added.
GGSCI (ogg) 4> EDIT PARAMS RORA_1
REPLICAT RORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
USERID ogg, PASSWORD ogg
HANDLECOLLISIONS
ASSUMETARGETDEFS
DISCARDFILE /u01/app/ogg/dirrpt/RORA_aa.DSC, PURGE
MAP scott.emp_ogg, TARGET scott.emp_ogg;
MAP scott.dept_ogg, TARGET scott.dept_ogg;
GGSCI (ogg) 5> START REPLICAT RORA_1
Sending START request to MANAGER ...
REPLICAT RORA_1 starting
GGSCI (ogg) 6> INFO REPLICAT RORA_1
REPLICAT RORA_1 Initialized 2019-06-19 15:04 Status STOPPED
Checkpoint Lag 00:00:00 (updated 00:01:54 ago)
Log Read Checkpoint Not Available
Task SPECIALRUN
GGSCI (ogg) 8> view report RORA_1
2019-06-19 15:06:07 ERROR OGG-00446 Invalid data source -1 in checkpoint file /u01/app/ogg/dirchk/RORA_1.cpr.
##源库错误日志
[root@ogg dirdat]# more ../ggserr.log | grep ERROR
2019-06-19 15:12:52 ERROR OGG-00446 Oracle GoldenGate Delivery for Oracle, rora_1.prm: Invalid data source -1 in checkpoint file /u01/app/ogg/dirchk/RORA_1.cpr.
2019-06-19 15:12:52 ERROR OGG-01668 Oracle GoldenGate Delivery for Oracle, rora_1.prm: PROCESS ABENDING.
##修改目标端RORA_1
GGSCI (ogg) 33> view param RORA_1
REPLICAT RORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
USERID ogg, PASSWORD ogg
HANDLECOLLISIONS
ASSUMETARGETDEFS
DISCARDFILE /u01/app/ogg/dirrpt/RORA_1.DSC, APPEND, MEGABYTES 1000
MAP scott.emp_ogg, TARGET scott.emp_ogg;
MAP scott.dept_ogg, TARGET scott.dept_ogg;
GGSCI (ogg) 28> delete RORA_1
Deleted REPLICAT RORA_1.
GGSCI (ogg) 29> add REPLICAT RORA_1,exttrail /u01/app/ogg/dirdat/pa,checkpointtable ogg.ggschkpt
REPLICAT added.
GGSCI (ogg) 30> start RORA_1
Sending START request to MANAGER ...
REPLICAT RORA_1 starting
GGSCI (ogg) 32> info RORA_1
REPLICAT RORA_1 Last Started 2019-06-19 15:42 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:06 ago)
Log Read Checkpoint File /u01/app/ogg/dirdat/pa000000
First Record RBA 0

14 插入数据测试

OGG@ orcl >conn scott/tiger
Connected.
SCOTT@ orcl >insert into dept_ogg select * from dept; 4 rows created. SCOTT@ orcl >commit; Commit complete.
源端
GGSCI (DSI) 17> stats PORA_1 Sending STATS request to EXTRACT PORA_1 ... Start of Statistics at 2019-06-19 15:46:37. Output to /u01/app/ogg/dirdat/pa: Extracting from SCOTT.DEPT_OGG to SCOTT.DEPT_OGG: *** Total statistics since 2019-06-19 15:45:59 ***
Total inserts 4.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 4.00 *** Daily statistics since 2019-06-19 15:45:59 ***
Total inserts 4.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 4.00 *** Hourly statistics since 2019-06-19 15:45:59 ***
Total inserts 4.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 4.00 *** Latest statistics since 2019-06-19 15:45:59 ***
Total inserts 4.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 4.00 End of Statistics.
目标端
GGSCI (ogg) 34> stats RORA_1 Sending STATS request to REPLICAT RORA_1 ... Start of Statistics at 2019-06-19 15:47:26. Replicating from SCOTT.DEPT_OGG to SCOTT.DEPT_OGG: *** Total statistics since 2019-06-19 15:46:07 ***
Total inserts 4.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 4.00 *** Daily statistics since 2019-06-19 15:46:07 ***
Total inserts 4.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 4.00 *** Hourly statistics since 2019-06-19 15:46:07 ***
Total inserts 4.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 4.00 *** Latest statistics since 2019-06-19 15:46:07 ***
Total inserts 4.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 4.00 End of Statistics.
数据查询
OGG@ ogg >conn scott/tiger
Connected.
SCOTT@ ogg >select * from dept_ogg; DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

更新测试

SYS@ orcl >conn scott/*
Connected.
SCOTT@ orcl >update emp_ogg set ename='hongquan' where empno=7698; 1 row updated. SCOTT@ orcl >commit; Commit complete.
SCOTT@ ogg >select * from emp_ogg where empno=7698; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7698 hongquan MANAGER 7839 01-MAY-81 2850 30

至此 简单的单实例单向同步已经完成

注明:此文档跟网上有些文档类似,因为临时的原因,在我以前下载的资料里面找的pdf进行测试,发现是一个很早的pdf,找不到原文链接---

这里的实验测试完全真实有效~~

后面会测试:修改表的同步,新增表的同步,双向同步,以及切换等

其他mgr,等一些命令参数,官网或者网上有大部分的资料,这里不做列举,因为还没研究这些(~~~)

oracle ogg 单实例单向简单搭建测试(oracle-oracle)的更多相关文章

  1. oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate

    oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate --继昨天的测试,这一篇实施单实例双向复制(完全重新搭建) --环境不变 db1,db2( ...

  2. oracle ogg 单实例双向-新增表,修改表结构(oracle-oracle

    --新增inset测试--dept 表结构orcl,ogg都存在,数据相同(但是rep1配置文件没有添加) SCOTT@ orcl ,'hongquan','BBA'); row created. S ...

  3. Oracle 11g 单实例到单实例OGG同步实施文档-OGG initial load

    Oracle 11g 单实例到单实例OGG同步实施文档-OGG initial load 2018-06-07 00:514730原创GoldenGate 作者: leo 本文链接:https://w ...

  4. Oracle 11g 单实例到单实例OGG同步实施文档-RMAN 初始化

    Oracle 11g 单实例到单实例OGG同步实施文档-RMAN 初始化 2018-06-07 13:455170原创GoldenGate 作者: leo 本文链接:https://www.cndba ...

  5. Oracle 11g 单实例到单实例OGG同步实施文档-EXPDP初始化

    Oracle 11g 单实例到单实例OGG同步实施文档-EXPDP初始化 2018-06-07 00:446470原创GoldenGate 作者: leo 本文链接:https://www.cndba ...

  6. Linux平台oracle 11g单实例 + ASM存储 安装部署 快速参考

    操作环境:Citrix虚拟化环境中申请一个Linux6.4主机(模板)目标:创建单机11g + ASM存储 数据库 1. 主机准备 2. 创建ORACLE 用户和组成员 3. 创建以下目录并赋予对应权 ...

  7. Oracle DataBase单实例使用ASM案例(1)--ASM基本概念

    版权声明:本文为博主原创文章,未经博主允许不得转载. Oracle DataBase单实例使用ASM案例(1)--ASM基本概念 系统环境: 操作系统:RH EL5-64 Oracle 软件: Ora ...

  8. centos部署oracle rac单实例11.2.0.3数据库(使用asm磁盘)

    部署oracle rac单实例数据库,需要安装grid和datavase两部分,所以首先创建两个用户oracle和grid,因为不能使用root用户进行安装,在安装之前首先需要修改一些系统参数和安装一 ...

  9. Oracle 19c单实例部署

    目录 Oracle 19c单实例部署: 1.配置yum: 2.安装rpm包: 3.设置hostname: 4.配置hostname解析: 5.配置时钟同步服务(ntp): 6.检查及配置内核参数: 7 ...

随机推荐

  1. install - 复制文件并设置属性

    SYNOPSIS[总览] install [options] [-s] [--strip] source dest install [options] [-s] [--strip] source... ...

  2. Nginx进行UDP的负载均衡

    准备工作: 服务器1:192.168.33.102     搭建nginx服务,作为反向代理的中转站 服务器2:192.168.33.103    nginx要反向代理的服务器 一.在服务器1上搭建n ...

  3. ssh远程登录故障解决方案

    问题描述: xshell远程连接服务器连接不上,如下图所示: 故障排除: . 首先查看自己系统的防火墙是否关闭,没有关闭的话关闭一下. # centos 7中关闭防火墙命令: systemctl st ...

  4. [工具] BurpSuite--快速生成CSRF POC

    我们使用工具分析出存在csrf漏洞时,可以快速生成这个请求的poc,下面我们来看看怎么快速生成 0x00 上图是通过proxy,点击action,选择上图的选项即可生成这个请求的CSRF Poc了 当 ...

  5. PHP漏洞函数

    1. is_numeric函数 bool is_numeric ( mixed $var ) 此函数用于判断变量是否数字或者数字字符串,不仅能接受十进制,还能接受十六进制,这样就有了绕过的方法 < ...

  6. HDU5840 Problem This world need more Zhu 分块 树剖

    给一颗n个点的有点权的树,有m个询问,对于每个询问u,v,k,首先将点u到点v的最短路径上的所有点按顺序编号,u的编号为1,求树链上所有点的新编号cnt满足cnt%k==0的点的权值的最大值.n,m, ...

  7. SpringMVC @RequestMapping注解详解

    @RequestMapping 参数说明 value:定义处理方法的请求的 URL 地址.(重点) method:定义处理方法的 http method 类型,如 GET.POST 等.(重点) pa ...

  8. JAVA笔记23-IO流(1)

    一.流的概念和分类 JAVA程序中,对于数据的输入.输出操作以“流”(stream)方式进行:J2SDK提供了各种各样的“流”类,用以获取不同种类的数据:程序中通过标准的方法输入或输出数据. java ...

  9. 解决postgresql在docker中无法保存状态的问题

    PS:最佳解决方式是将目录挂载到宿主机,容器出问题了,数据还在,以下方式容器出问题会丢失数据,以下思想只供参考!!! 用过docker的人都知道,docker是不适合来放数据库的,这也不是绝对的.如果 ...

  10. electron启动出现短暂的白屏

    mainWindow = new BrowserWindow({ height: 600, width: 960, frame: false, minWidth: 710, minHeight: 50 ...