环境:Oracle Linux 5.8/Windows Server 2003 + Oracle Database 11.2.0.4 + Golengate 11.2
解压安装文件里的内容到/opt/goldengate,然后创建工作目录:
在Windows环境下,需要将manager进程添加到Windows服务,否则注销后进程就会退出
--如果要删除服务,进入根目录后
C:\goldengate>install deleteevents deleteservice
Service 'GGMGR' removed.
Install program terminated normally.
二、数据库设置
数据库要设置为归档模式、并打开数据库级别的补充日志,以及设置启用GoldenGate复制的参数
创建用户并赋予权限:
在trandata添加需要同步的表和schema
源端进入GGSCI
目标端添加checkpoint表
三、 GG进程
编辑并启动源端Manager进程
配置Extract进程组
创建名为eora的Extract进程组
源端配置Pump进程组
配置目的端MGR
配置目的端Replicate进程
进程状态不正常时,查看错误日志,文件名是ggserr.log,在程序根目录下。
解压安装文件里的内容到/opt/goldengate,然后创建工作目录:
点击(此处)折叠或打开
- [oracle@oltp ~]$ cd /opt/goldengate/
- [oracle@oltp goldengate]$ 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 (oltp.demo.com) 1> create subdirs
-
- Creating subdirectories under current directory /opt/goldengate
-
- Parameter files /opt/goldengate/dirprm: already exists
- Report files /opt/goldengate/dirrpt: created
- Checkpoint files /opt/goldengate/dirchk: created
- Process status files /opt/goldengate/dirpcs: created
- SQL script files /opt/goldengate/dirsql: created
- Database definitions files /opt/goldengate/dirdef: created
- Extract data files /opt/goldengate/dirdat: created
- Temporary files /opt/goldengate/dirtmp: created
- Stdout files /opt/goldengate/dirout: created
在Windows环境下,需要将manager进程添加到Windows服务,否则注销后进程就会退出
点击(此处)折叠或打开
- GGSCI (hum-cf0bf98919e) 2> EDIT PARAMS ./GLOBALS
- --编辑以下文字
- MGRSERVNAME GGMGR
-
- GGSCI (hum-cf0bf98919e) 4> exit
-
- C:\goldengate>install addservice
-
- Service 'GGMGR' created.
-
-
- Install program terminated normally.
--如果要删除服务,进入根目录后
C:\goldengate>install deleteevents deleteservice
Service 'GGMGR' removed.
Install program terminated normally.
二、数据库设置
数据库要设置为归档模式、并打开数据库级别的补充日志,以及设置启用GoldenGate复制的参数
点击(此处)折叠或打开
- SQL> select supplemental_log_data_min from v$database;
-
- SUPPLEMENTAL_LOG
- ----------------
- NO
-
- SQL> alter database add supplemental log data;
-
- Database altered.
-
- SQL> select supplemental_log_data_min from v$database;
-
- SUPPLEMENTAL_LOG
- ----------------
- YES
--以下参数在11.2.1.0.26下必须改,否则extract进程无法启动
- SQL> alter system set enable_goldengate_replication=TRUE scope=both;
System altered.
点击(此处)折叠或打开
- --创建专属表空间
- create tablespace ogg datafile size 100M autoextend on;
- --源和目的都执行
- create user ggs identified by ggs default tablespace ogg temporary tablespace temp;
- grant connect, resource, unlimited tablespace to ggs;
- grant execute on utl_file to ggs;
-
- --源端执行
- grant connect,resource 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 insert any table to ggs;
- grant delete any table to ggs;
- grant update any table to ggs;
-
- --如果不讲究,可以直接给DBA权限
- grant dba to ggs;
源端进入GGSCI
点击(此处)折叠或打开
- dblogin userid ggs,password ggs
- GGSCI (oltp.demo.com) 3> add trandata soe.*
2015-01-26 21:43:25 WARNING OGG-00869 No unique key is defined for table 'ADDRESSES'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SOE.ADDRESSES.
2015-01-26 21:43:27 WARNING OGG-00869 No unique key is defined for table 'CARD_DETAILS'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SOE.CARD_DETAILS.
2015-01-26 21:43:28 WARNING OGG-00869 No unique key is defined for table 'CUSTOMERS'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SOE.CUSTOMERS.
2015-01-26 21:43:28 WARNING OGG-00869 No unique key is defined for table 'INVENTORIES'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SOE.INVENTORIES.
2015-01-26 21:43:28 WARNING OGG-00869 No unique key is defined for table 'LOGON'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SOE.LOGON.
2015-01-26 21:43:28 WARNING OGG-00869 No unique key is defined for table 'ORDERENTRY_METADATA'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SOE.ORDERENTRY_METADATA.
2015-01-26 21:43:28 WARNING OGG-00869 No unique key is defined for table 'ORDERS'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SOE.ORDERS.
2015-01-26 21:43:28 WARNING OGG-00869 No unique key is defined for table 'ORDER_ITEMS'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SOE.ORDER_ITEMS.
Logging of supplemental redo data enabled for table SOE.PRODUCT_DESCRIPTIONS.
Logging of supplemental redo data enabled for table SOE.PRODUCT_INFORMATION.
2015-01-26 21:43:28 WARNING OGG-00869 No unique key is defined for table 'WAREHOUSES'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SOE.WAREHOUSES.
点击(此处)折叠或打开
- GGSCI (hum-cf0bf98919e) 1> edit params ./GLOBALS
-
- --添加一行
- checkpointtable ggs.checkpoint
-
- GGSCI (hum-cf0bf98919e) 2> dblogin userid ggs,password ggs
- Successfully logged into database.
-
- GGSCI (hum-cf0bf98919e) 3> add checkpointtable ggs.checkpoint
-
- Successfully created checkpoint table ggs.checkpoint.
-
- GGSCI (hum-cf0bf98919e) 4>
三、 GG进程
编辑并启动源端Manager进程
点击(此处)折叠或打开
- GGSCI (oltp.demo.com) 5> edit params mgr
- port 7500
- dynamicportlist 7501-7505
- autorestart extract *,waitminutes 2,retries 5
-
- GGSCI (oltp.demo.com) 6> view params mgr
-
- port 7500
- dynamicportlist 7501-7505
- autorestart extract *,waitminutes 2,retries 5
-
-
- GGSCI (oltp.demo.com) 7> start mgr
-
- Manager started.
创建名为eora的Extract进程组
点击(此处)折叠或打开
- GGSCI (oltp.demo.com) 8> edit params eora
- extract eora
- dynamicresolution
- userid ggs,password ggs
- exttrail /opt/goldengate/dirdat/et
- table soe.*;
-
- GGSCI (oltp.demo.com) 9> add extract eora,tranlog,begin now
- EXTRACT added.
-
- GGSCI (oltp.demo.com) 11> add exttrail /opt/goldengate/dirdat/et,extract eora
- EXTTRAIL added.
-
GGSCI (oltp.demo.com) 12> start extract eora
Sending START request to MANAGER ...
EXTRACT EORA starting
点击(此处)折叠或打开
- GGSCI (oltp.demo.com) 19> edit params pump_so
- extract pump_so
- dynamicresolution
- passthru
- rmthost 192.168.226.13,mgrport 7809,compress
- rmttrail C:\goldengate\dirdat\pt
- table soe.*;
-
- GGSCI (oltp.demo.com) 20> add extract pump_so,exttrailsource /opt/goldengate/dirdat/et
- EXTRACT added.
-
-
- GGSCI (oltp.demo.com) 21> add rmttrail C:\goldengate\dirdat\pt,extract pump_so
- RMTTRAIL added.
- GGSCI (oltp.demo.com) 24> start pump_so
Sending START request to MANAGER ...
EXTRACT PUMP_SO starting
GGSCI (oltp.demo.com) 25> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EORA 00:00:00 00:00:08
EXTRACT RUNNING PUMP_SO 00:00:00 00:21:32
配置目的端MGR
点击(此处)折叠或打开
- GGSCI (hum-cf0bf98919e) 5> view params mgr
- port 7809
- dynamicportlist 7800-8000
- autostart er *
- autorestart extract *,waitminutes 2,retries 5
- lagreporthours 1
- laginfominutes 3
- lagcriticalminutes 5
- purgeoldextracts c:\goldengate\dirdat\rt*,usecheckpoints,minkeepdays 3
-
-
- GGSCI (hum-cf0bf98919e) 6> start mgr
-
- Starting Manager as service ('GGMGR')...
- Service started.
-
-
- GGSCI (hum-cf0bf98919e) 7> info all
-
- Program Status Group Lag at Chkpt Time Since Chkpt
-
- MANAGER RUNNING
点击(此处)折叠或打开
- GGSCI (hum-cf0bf98919e) 8> edit params repl
-
-
- GGSCI (hum-cf0bf98919e) 9> view params repl
- replicat repl
- userid ggs, password ggs
- assumetargetdefs
- reperror default,discard
- discardfile ./dirrpt/repl.dsc,append,megabytes 50
- dynamicresolution
- map soe.*, target soe.*;
-
- GGSCI (hum-cf0bf98919e) 11> add replicat repl,exttrail c:\goldengate\dirdat\pt checkpointtable ggs.checkpoint
- REPLICAT added.
-
- GGSCI (hum-cf0bf98919e) 12> start repl
Sending START request to MANAGER ('GGMGR') ...
REPLICAT REPL starting
进程状态不正常时,查看错误日志,文件名是ggserr.log,在程序根目录下。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22621861/viewspace-1416225/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22621861/viewspace-1416225/