本文主要分介绍OGG的安装部署,下面是实验环境介绍。
实验规划:
项目 | 源环境 | 目标环境 |
操作系统 | OEL 5.7 X86_64 | OEL 5.7 X86_64 |
主机名 | dbdream | stream |
IP地址 | 192.168.249.98 | 192.168.249.99 |
数据库及版本 | ORACLE 11.2.0.3.0 | ORACLE 11.2.0.3.0 |
数据库字符集 | ZHS16GBK | ZHS16GBK |
ORACLE SID | dbdream | stream |
Goldengate用户 | ogg | ogg |
Goldengate 版本 | 112101 | 112101 |
两台服务器都需要创建ogg操作系统用户(此步骤非必须,也可以使用ORACLE用户安装)。
useradd -u 1003 -g oinstall -G dba ogg1
passwd ogg
export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib
export ORACLE_SID=dbdream
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH
运行下面的命令使变量生效。
. .bash_parfile
两台服务器都需要做同样的操作。
mkdir /ogg
chown -R ogg:oinstall /ogg
将OGG安装文件上传到两台服务器的OGG操作系统用户的家目录(默认为/home/ogg)。
ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
unzip后
fbo_ggs_Linux_x64_ora11g_64bit.tar
将fbo_ggs_Linux_x64_ora11g_64bit.tar解包到/ogg目录(源和目标端都需要操作)
tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar -C /ogg
[ogg@dbdream 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 (dbdream) 1>
如果LD_LIBRARY_PATH变量设置正确,会像上面演示一样正确进入命令行,如果提示找不到so文件,就需要 查看LD_LIBRARY_PATH变量是否正确设置。
ORACLE建议使用单独的表空间存放OGG数据,表空间大小50M就可以,但是最好设置数据文件的自动扩展。
SQL> create tablespace ogg datafile ‘+DATA/enmo10/datafile/ogg01.dbf’ size 50M autoextend on;
Tablespace created.
SQL> create user ogg identified by ogg default tablespace ogg;
User created.
OGG用户需要以下权限,也有人为了省事,直接给OGG用户DBA权限。
SQL> grant CONNECT, RESOURCE to ogg;
Grant succeeded.
SQL> grant SELECT ANY DICTIONARY, SELECT ANY TABLE to ogg;
Grant succeeded.
SQL> grant ALTER ANY TABLE to ogg;
Grant succeeded.
SQL> grant FLASHBACK ANY TABLE to ogg;
Grant succeeded.
SQL> grant EXECUTE on DBMS_FLASHBACK to ogg;
Grant succeeded.
SQL> grant insert any table to ogg;
Grant succeeded.
SQL> grant update any table to ogg;
Grant succeeded.
SQL> grant delete any table to ogg;
Grant succeeded.
不同的需求,OGG用户需要的权限也不一样,上面的权限基本可以支持大多数情况的数据复制,如上面的权限不足,需根据实际需求授权。
SQL> select NAME,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MIN from v$database;
NAME OPEN_MODE FOR SUPPLEME
——— ——————– — ——–
DBDREAM READ WRITE NO NO
上面显示数据库的附加日志和force log都没有开启,使用下面的命令开启。
SQL> alter database force logging;
Database altered.
SQL> alter database add SUPPLEMENTAL log data;
Database altered.
SQL> select NAME,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MIN from v$database;
NAME OPEN_MODE FOR SUPPLEME
——— ——————– — ——–
DBDREAM READ WRITE YES YES
如果要让OGG支持DDL操作,还需要额外运行几个脚本,这些脚本是OGG带的而不是ORACLE带的,在OGG的安装目录都可以找到,如果在OGG的安装目录登录数据库,可以直接@加脚本的名字,源端与目标端都需要运行,如下:
sqlplus / as sysdba
@marker_setup.sql
@ddl_setup.sql
@role_setup.sql
@ddl_enable.sql
如果没有在OGG的安装目录登录数据库,需要指定脚本的位置,比如我的OGG安装目录为/ogg。
sqlplus / as sysdba
@/ogg/marker_setup.sql
@/ogg/ddl_setup.sql
@/ogg/role_setup.sql
@/ogg/ddl_enable.sql
在正式配置OGG之前,首先需要创建OGG的管理目录,源端和目标端都需要创建,登录OGG,只需要执行create subdirs命令就可以了。
源端:
[ogg@dbdream 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 (dbdream) 1> create subdirs
Creating subdirectories under current directory /ogg
Parameter files /ogg/dirprm: already exists
Report files /ogg/dirrpt: created
Checkpoint files /ogg/dirchk: created
Process status files /ogg/dirpcs: created
SQL script files /ogg/dirsql: created
Database definitions files /ogg/dirdef: created
Extract data files /ogg/dirdat: created
Temporary files /ogg/dirtmp: created
Stdout files /ogg/dirout: created
目标端:
[ogg@dbdream 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 (dbdream) 1> create subdirs
Creating subdirectories under current directory /ogg
Parameter files /ogg/dirprm: already exists
Report files /ogg/dirrpt: created
Checkpoint files /ogg/dirchk: created
Process status files /ogg/dirpcs: created
SQL script files /ogg/dirsql: created
Database definitions files /ogg/dirdef: created
Extract data files /ogg/dirdat: created
Temporary files /ogg/dirtmp: created
Stdout files /ogg/dirout: created
各目录用途如下表:
名字 | 用途 |
dirprm | 存放OGG参数各的配置信息 |
dirrpt | 存放进程报告文件 |
dirchk | 存放检查点文件 |
dirpcs | 存放进程状态文件 |
dirsql | 存放SQL脚本文件 |
dirdef | 存放DEFGEN工具生成的数据定义文件 |
dirdat | 存放Trail文件,也就是Capture进程捕获的日志文件 |
dirtmp | 当事物需要的内存超过已分配内存时,默认存储在这个目录 |
之前所做的只是准备工作,现在就可以正式配置OGG了,在配置OGG之前,先看下OGG的复制流程,OGG和其他传统复制软件一样,也是通过源端捕获/挖掘ORACLE的日志信息,
目标端根据源端传送过来的日志信息进行重塑,实现源端-目标端数据同步,可以参考下图。
只有commit之后的日志信息才会被Capture进程捕获,未提交的事务OGG不会捕获。
源端基于SCOTT用户的EMP和DEPT表建立EMP_OGG和DEPT_OGG测试表,包含数据。
SQL> create table emp_ogg as select * from emp;
Table created.
SQL> create table dept_ogg as select * from dept;
Table created.
目标端基于SCOTT用户的EMP和DEPT表建立EMP_OGG和DEPT_OGG测试表,不包含数据。
SQL> create table emp_ogg as select * from emp where 1=2;
Table created.
SQL> create table dept_ogg as select * from dept where 1=2;
Table created.
源端和目标端分别在EMP_OGG和DEPT_OGG测试表上建立主键(或唯一键)。
SQL> alter table EMP_OGG add constraint PK_EMPNO_OGG primary key (EMPNO);
Table altered.
SQL> alter table DEPT_OGG add constraint PK_DEPTNO_OGG primary key (DEPTNO);
Table altered.
添加表级的trandata可以理解为需要将哪些用户的哪些表和目标库同步,其实也是添加表级的supplemental log,但是只有上文打开的minimal supplemental log后,这个才生效。
使用第7节建立的OGG用户从OGG登录源端数据库。
GGSCI (dbdream) 2> DBLOGIN USERID ogg, PASSWORD ogg
Successfully logged into database.
源端添加表级TRANDATA,本案例使用EMP_OGG和DEPT_OGG表。
GGSCI (dbdream) 3> add trandata scott.emp_ogg
Logging of supplemental redo data enabled for table SCOTT.EMP_OGG.
GGSCI (dbdream) 4> add trandata scott.dept_ogg
Logging of supplemental redo data enabled for table SCOTT.DEPT_OGG.
成功添加表级TRANDATA后,可以通过INFO命令查看哪些表被添加了TRANDATA.
GGSCI (dbdream) 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: SAL, HIREDATE, MGR, COMM, DEPTNO, ENAME, EMPNO, JOB.
Logging of supplemental redo log data is disabled for table SCOTT.SALGRADE.
源端:
GGSCI (dbdream) 8> EDIT PARAMS MGR
加入以下两行内容
PORT 7809
PURGEOLDEXTRACTS /ogg/dirdat, USECHECKPOINTS
目标端:
GGSCI (stream) 2> EDIT PARAMS MGR
加入以下两行内容
PORT 7809
PURGEOLDEXTRACTS /ogg/dirdat, USECHECKPOINTS
参数说明:
PORT 7809:OGG管理进程监控端口。
PURGEOLDEXTRACTS:清除不需要的trail文件。
/ogg/dirdat:trail文件存放位置。
USECHECKPOINTS:使用检查点队列。
本实验只用到上述参数,MGR其他参数详见下表,摘自OGG官方文档。
Manager parameters: General
名字 | 用途 |
CHARSET | Speci fies a multibyte character set for the process to us instead of the operating system default when reading the parameter file. |
COMMENT | Allows insertion of comments in a parameter file. |
SOURCEDB | Specifies a data source name as part of the login |
USERID | Provides login information for Manager when it needs to access the database. |
SYSLOG | Filters the types of Oracle GoldenGate messages that are written to the system logs. |
Manager parameters: Port management
名字 | 用途 |
DYNAMICPORTLIST | Specifies the ports that Collector can dynamically allocate. |
PORT | Establishes the TCP/IP port number on which Manager listens for requests. |
Manager parameters: Process management
名字 | 用途 |
AUTORESTART | Specifies processes to be restarted by Manager after a |
AUTOSTART | Specifies processes to be started when Manager starts. |
BOOTDELAYMINUTES | Determines how long after system boot time Manager delays until performing main processing activities. This parameter supports Windows. |
UPREPORT | Determines how often process heartbeat messages are reported. |
Manager parameters: Event management
名字 | 用途 |
DOWNCRITICAL | Reports processes that stopped gracefully or abnormally. |
DOWNREPORT | Controls the frequency for reporting stopped processes. |
LAGCRITICAL | Specifies a lag threshold that is considered critical and generates a warning to the error log. |
LAGINFO | Specifies a lag threshold at which an informational message is reported to the error log. |
LAGREPORT | Sets an interval for reporting lag time to the error log. |
Manager parameters: Maintenance
名字 | 用途 |
CHECKMINUTES | Determines how often Manager cycles through maintenance |
PURGEDDLHISTORY | Purges rows from the Oracle DDL history table when they are no longer needed. |
PURGEDDLHISTORYALT | Purges rows from the alternate Oracle DDL history table that keeps track of partition IDs that are associated with a table ID. |
PURGEMARKERHISTORY | Purges Oracle marker table rows that are no longer needed. |
PURGEOLDEXTRACTS | Purges trail data that is no longer needed. |
PURGEOLDTASKS | Purges Extract and Replicat tasks after a specified period of time. |
STARTUPVALIDATIONDELAY[CSECS] | Sets a delay time after which Manager checks that processes are still running after startup. |
配置完MGR管理进程后,就可以启动MGR管理进程(源端和目标端都需要启动)。
GGSCI (dbdream) 9> start mgr
Manager started.
可以通过INFO命令查看进程的状态(最好每次启动时在两端都查看下)。
GGSCI (dbdream) 10> info mgr
Manager is running (IP port dbdream.7809).
由于在创建测试表的时候,源端的测试表有数据,而目标端的测试表只有结构,没有数据,所以需要初始化目标端的数据,所谓初始化,就是让目标端的数据和源端的数据在这个时间点是一模一样的,所以初始化工作并不需要一定使用OGG,也可以使用EXP、EXPDP、SQLLOAD等其他工具,本文主要介绍如何使用OGG进行数据初始化,下面在源端配置捕获进程EINI_1。
GGSCI (dbdream) 11> ADD EXTRACT EINI_1, SOURCEISTABLE
EXTRACT added.
查看EINI_1进程状态。
GGSCI (dbdream) 12> INFO EXTRACT *, TASKS
EXTRACT EINI_1 Initialized 2012-11-13 22:45 Status STOPPED
Checkpoint Lag Not Available
Log Read Checkpoint Not Available
First Record Record 0
Task SOURCEISTABLE
由于只是添加了捕获进程EINI_1,还没有进行配置和启动这个进程,所以现在的状态是STOPPED状态。
源端编辑捕获进程EINI_1。
GGSCI (dbdream) 13> EDIT PARAMS EINI_1
–加入以下内容
EXTRACT EINI_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ogg
RMTHOST 192.168.249.99, 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。
目标端:
GGSCI (stream) 7> EDIT PARAMS RINI_1
–加入以下内容
REPLICAT RINI_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
ASSUMETARGETDEFS
USERID ogg, PASSWORD ogg
DISCARDFILE /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。
配置好目标端的应用进程RINI_1后,就可以启动源端的捕获进程进行捕获数据了,而目标端的应用进程RINI_1不需要手动去启动,也就是说目标端RINI_1进程不需要管。
GGSCI (dbdream) 14> START EXTRACT EINI_1
Sending START request to MANAGER …
EXTRACT EINI_1 starting
启动源端的捕获进程EINI_1后,正常情况下(如果配置没问题),源端的数据已经传送到目标端了,可以通过VIEW命令查看源端捕获进程EINI_1的工作状态。
GGSCI (dbdream) 11> VIEW REPORT EINI_1
–在最后部分会看到
Output to RINI_1:
From Table SCOTT.EMP_OGG:
# inserts: 14
# updates: 0
# deletes: 0
# discards: 0
From Table SCOTT.DEPT_OGG:
# inserts: 4
# updates: 0
# deletes: 0
# discards: 0
REDO Log Statistics
Bytes parsed 0
Bytes output 3056
如果配置正确,会看到上面的日志,日志会告诉你在目标端SCOTT.EMP_OGG表INSERT了14条记录,SCOTT.DEPT_OGG表INSERT了4条记录。如果在上面日志的最后部分出现ERROR,就需要去检查OGG的安装目录下的ggserr.log日志,这个日志相当于数据库的告警日志。
登录目标端数据库,查看初始化是否成功。
SQL> 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
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
14 rows selected.
SQL> select * from dept_ogg;
DEPTNO DNAME LOC
———- ————– ————-
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
可以看到初始化是正确的。初始化之后,上文提到的初始化进程(EINI_1、RINI_1)自动停止,因为通常情况下初始化数据工作只会做一次。可以通过INFO命令查看进程的状态。
源端:
GGSCI (dbdream) 9> INFO EXTRACT EINI_1
EXTRACT EINI_1 Last Started 2012-11-14 02:03 Status STOPPED
Checkpoint Lag Not Available
Log Read Checkpoint Table SCOTT.DEPT_OGG
2012-11-14 02:03:22 Record 4
Task SOURCEISTABLE
目标端:
GGSCI (stream) 1> INFO REPLICAT RINI_1
REPLICAT RINI_1 Initialized 2012-11-14 20:30 Status STOPPED
Checkpoint Lag 00:00:00 (updated 03:16:37 ago)
Log Read Checkpoint Not Available
Task SPECIALRUN
此步骤不是必须的,但是为了让OGG网络中断、服务器宕机、掉电等在突发情况也能正确断点续传,ORACLE建议配置OGG的检查点队列。
源端和目标端都需配置。
GGSCI (stream) 2> EDIT PARAMS ./GLOBALS
–加入以下信息
CHECKPOINTTABLE ogg.ggschkpt
这就告诉OGG检查点存放到OGG用户下的GGSCHKPT表中,但是还需要使用OGG用户登录数据库,创建检查点表,此时需要退出OGG,重新登录,否则可能会遇到下面的错误。
GGSCI (stream) 4> ADD CHECKPOINTTABLE
ERROR: Missing checkpoint table specification.
退出OGG,重新登录,并使用OGG用户登录数据库,源端和目标端都需要执行。
GGSCI (stream) 5> exit
[ogg@stream 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 (stream) 1> dblogin userid ogg,password ogg
Successfully logged into database.
只需要执行ADD CHECKPOINTTABLE命令,OGG会自动在ORACLE的OGG用户下创建检查点,源端和目标端都需要执行。
GGSCI (stream) 2> ADD CHECKPOINTTABLE
No checkpoint table specified, using GLOBALS specification (ogg.ggschkpt)…
Successfully created checkpoint table ogg.ggschkpt.
此时用OGG登录数据库,就可以看到OGG创建的检查点表。
[ogg@dbdream ogg]$ sqlplus ogg/ogg
SQL*Plus: Release 11.2.0.3.0 Production on Wed Nov 14 13:10:55 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning option
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
—————————— ——- ———-
GGSCHKPT TABLE
GGSCHKPT_LOX TABLE
现在已经可以配置数据同步了,下面在源端配置捕获进程。
GGSCI (dbdream) 10> EDIT PARAMS EORA_1
–加入以下内容
EXTRACT EORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ogg
EXTTRAIL /ogg/dirdat/aa
TABLE scott.EMP_OGG;
参数介绍:
以上参数基本都在上文提过,这里不在重复,说下EXTTRAIL参数,EXTTRAIL参数是TRAIL队列文件存放的路径和命名格式,TRAIL文件可以理解为存放捕获进程捕获的日志文件。此时还需要将捕获进程EORA_1添加到OGG。
GGSCI (dbdream) 11> ADD EXTRACT EORA_1, TRANLOG, BEGIN NOW
EXTRACT added.
GGSCI (dbdream) 12> ADD EXTTRAIL /ogg/dirdat/aa, EXTRACT EORA_1, MEGABYTES 5
EXTTRAIL added.
上面的两个命名告诉OGG,捕获进程从启动起开始捕获,捕获数据保存到TRAIL文件,及TRAIL文件的路径、命名格式,单个TRAIL文件最大大小。
现在就可以启动源端捕获进程EORA_1了。
GGSCI (dbdream) 13> START EXTRACT EORA_1
Sending START request to MANAGER …
EXTRACT EORA_1 starting
使用INFO命令查看EORA_1进程是否是RUNNING状态。
GGSCI (dbdream) 14> INFO EXTRACT EORA_1
EXTRACT EORA_1 Last Started 2012-11-14 02:06 Status RUNNING
Checkpoint Lag 00:00:58 (updated 00:00:08 ago)
Log Read Checkpoint Oracle Redo Logs
2012-11-14 02:05:58 Seqno 19, RBA 38097424
SCN 0.0 (0)
此步骤也是非必须的,如果不配置传输进程,OGG会通过EXTRACT进程传输TRAIL队列文件,但是和检查点队列一样,为了保证断点续传ORACLE建议配置PUMP传输进程。
GGSCI (dbdream) 15> EDIT PARAMS PORA_1
–加入以下内容
EXTRACT PORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
PASSTHRU
RMTHOST 192.168.249.99, MGRPORT 7809
RMTTRAIL /ogg/dirdat/pa
TABLE scott.EMP_OGG;
TABLE scott.DEPT_OGG;
添加PUMP进程PORA_1到OGG,并指定本地的TRAIL文件。
GGSCI (dbdream) 16> ADD EXTRACT PORA_1, EXTTRAILSOURCE /ogg/dirdat/aa
EXTRACT added.
此时用INFO命令可以看到PUMP进程PORA_1的状态。
GGSCI (dbdream) 17> INFO EXTRACT PORA_1
EXTRACT PORA_1 Initialized 2012-11-14 02:10 Status STOPPED
Checkpoint Lag 00:00:00 (updated 00:00:10 ago)
Log Read Checkpoint File /ogg/dirdat/aa000000
First Record RBA 0
为PUMP进程PORA_1指定将本地TRAIL文件传输到目标端后保存成目标端TRAIL文件的名字。
GGSCI (dbdream) 18> ADD RMTTRAIL /ogg/dirdat/pa, EXTRACT PORA_1, MEGABYTES 5
RMTTRAIL added.
下面就可以启动PUMP进程PORA_1了,启动后看下PORA_1的状态。
GGSCI (dbdream) 19> START EXTRACT PORA_1
Sending START request to MANAGER …
EXTRACT PORA_1 starting
–查看状态
GGSCI (dbdream) 20> INFO EXTRACT PORA_1
EXTRACT PORA_1 Last Started 2012-11-14 02:11 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:03 ago)
Log Read Checkpoint File /ogg/dirdat/aa000000
First Record RBA 0
此时在目标端/ogg/dirdat/目录下,就会看到由源端PUMP进程PORA_1传输过来的TRAIL文件。
[ogg@stream dirdat]$ pwd
/ogg/dirdat
[ogg@stream dirdat]$ ls
pa000000
[ogg@stream dirdat]$
GGSCI (stream) 5> ADD REPLICAT RORA_1, SPECIALRUN
REPLICAT added.
目标端编辑RORA_1进程。
GGSCI (stream) 7> EDIT PARAMS RORA_1
–加入以下内容
REPLICAT RORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ogg
HANDLECOLLISIONS
ASSUMETARGETDEFS
DISCARDFILE /ogg/dirrpt/RORA_aa.DSC, PURGE
MAP scott.emp_ogg, TARGET scott.emp_ogg;
目标端编辑同步进程RORA_1后,就可以启动RORA_1进程。
GGSCI (stream) 5> START REPLICAT RORA_1
Sending START request to MANAGER …
REPLICAT RORA_1 starting
启动RORA_1进程后,查看进程状态。
GGSCI (stream) 6> INFO REPLICAT RORA_1=
REPLICAT RORA_1 Last Started 2012-11-15 00:08 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:05 ago)
Log Read Checkpoint File /ogg/dirdat/pa000000
First Record RBA 0
成功配置并启动以上进程后,就可以验证OGG数据同步了,最简单的测试就是修改源库同步的表的数据,测试需要测试DML和DDL,本文此部分省略,可以参考下一篇文章《OGG补丁安装》