一、 安装前准备
(1)创建操作系统ogg用户
useradd -u 1003 -goinstall -G dba ogg1
echo ogg:ogg|chpasswd
将oracle环境变量拷贝到ogg ~/.bash_profile
环境变量path 添加$ORACLE_HOME/jdk/bin:$PATH
添加OGG_HOME至~/.bash_profile,添加OGG_HOME 到 LD_LIBRARY_PATH和PATH 中
(2)创建安装目录
mkdir /home/ogg
chown –R ogg:oinstall/home/ogg
二、 软件安装
(1)上传ogg安装介质fbo_ggs_Linux_x64_shiphome.zip
解压后直接安装。
(2)创建ogg表空间和用户
create tablespace oggdatafile '+DATA/enmo10/datafile/ogg01.dbf' size 50M autoextend on;
create user oggidentified by ogg default tablespace ogg;
grant dba to ogg;
(3)打开数据库forcelog 和 supplemental_log_data_min
Select NAME,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MINfrom v$database;
alter database forcelogging;
alter database addSUPPLEMENTAL log data;
(4)运行ogg支持的脚本
在ogg安装目录有很多ogg支持脚本,运行如下脚本
sqlplus / as sysdba
@marker_setup.sql
@ddl_setup.sql
@role_setup.sql
@ddl_enable.sql
三、 配置同步
(1)./ggsci 进入管理窗口,配置管理进程mgr
此安装程序为最新版本,mgr可以随安装后直接start,配置安装文件后需重启mgr
GGSCI (dbdream) 8>EDIT PARAMS MGR
加入以下两行内容
PORT 7809
PURGEOLDEXTRACTS /home/ogg/oggsoft/dirdat,USECHECKPOINTS
GGSCI (dbdream) 9> stopmgr
GGSCI (dbdream) 10> startmgr
GGSCI (dbdream) 11> infomgr
dblogin userid ogg,password ogg
(2) 配置初始化数据进程源端EINI_1 目的端RINI_1
配置源端进程EINI_1
GGSCI (dbdream) 11>ADD EXTRACT EINI_1, SOURCEISTABLE
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, GROUPRINI_1 TABLE oggtst.*;
配置目标端进程RINI_1
GGSCI (stream) 7> EDITPARAMS RINI_1
--加入以下内容
REPLICAT RINI_1
SETENV(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
ASSUMETARGETDEFS
USERID ogg, PASSWORD ogg
DISCARDFILE/ogg/dirrpt/RINIaa.dsc, PURGE
MAP oggtst.*, TARGET oggtst.*;
GGSCI (stream) 5> ADDREPLICAT RINI _1, SPECIALRUN.
初始化数据(只需开启源端进程,目的端进程会自动带起):
GGSCI (dbdream) 14>START EXTRACT EINI_1
Sending START request toMANAGER ...
EXTRACT EINI_1 starting
GGSCI (dbdream) 11>VIEW REPORT EINI_1
(3)配置实时同步进程
源端目的端配置ogg检查点:
GGSCI (stream) 2> EDITPARAMS ./GLOBALS
--加入以下信息
CHECKPOINTTABLEogg.ggschkpt
退出ggsci后重新登录执行:
GGSCI (stream) 4> ADDCHECKPOINTTABLE
No checkpoint tablespecified, using GLOBALS specification (ogg.ggschkpt)...
Successfully createdcheckpoint table ogg.ggschkpt.
源端捕获进程配置EORA_1:
GGSCI (dbdream) 10>EDIT PARAMS EORA_1
--加入以下内容
EXTRACT EORA_1 SETENV(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ogg
EXTTRAIL /home/ogg/oggsoft/dirdat/aaTABLE oggtst.*;
--添加抽取进程和抽取路径
GGSCI (dbdream) 11>ADD EXTRACT EORA_1, TRANLOG, BEGIN NOW
EXTRACT added.
GGSCI (dbdream) 12>ADD EXTTRAIL /home/ogg/oggsoft/dirdat/aa, EXTRACT EORA_1, MEGABYTES 5
EXTTRAIL added.
GGSCI (dbdream) 13>START EXTRACT EORA_1
配置源端pump进程PORA_1
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 /home/ogg/oggsoft/dirdat/pa
TABLE oggtst.*;
TABLE scott.DEPT_OGG;
添加PUMP进程PORA_1到OGG,并指定本地的TRAIL文件。
GGSCI (dbdream) 16>ADD EXTRACT PORA_1, EXTTRAILSOURCE /home/ogg/oggsoft/dirdat/aa
EXTRACT added.
设置remote文件位置
GGSCI (dbdream) 18>ADD RMTTRAIL /home/ogg/oggsoft/dirdat/pa, EXTRACT PORA_1, MEGABYTES 5
RMTTRAIL added.
GGSCI (dbdream) 19>START EXTRACT PORA_1
配置目标端应用进程RORA_1
GGSCI (stream) 5> ADDREPLICAT RORA_1, SPECIALRUN
REPLICAT added.
GGSCI (stream) 7> EDITPARAMS RORA_1
--加入以下内容
REPLICAT RORA_1
SETENV(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ogg
HANDLECOLLISIONS
ASSUMETARGETDEFS
DISCARDFILE /home/ogg/oggsoft/dirrpt/RORA_aa.DSC,PURGE
MAP oggtst.*, TARGET oggtst.*;
GGSCI (stream) 5>START REPLICAT RORA_1
一个配置实例:
Extract dp_test1
RmtHost xxx.xxxx.xxx.xxx, MgrPort 7809, timeout 30, Compress
RmtTrail /oggmirror/dirdat/prdxzxx/test1/lt
Passthru
---20150415
DYNAMICRESOLUTION
---20150415
--GETTRUNCATES
table USER.TABLES;
EXTRACT ext_test1
SetEnv (ORACLE_SID = "stbuf11")
SETENV (NLS_LANG=American_America.ZHS16GBK)
USERID ogg, PASSWORD ogg
EXTTRAIL /realsync/ogg/dirdat/test1/lt
PURGEOLDEXTRACTS /realsync/ogg/dirdat/qzh1/lt*, USECHECKPOINTS, MINKEEPFILES 10
--TranlogOptions RawDeviceOffset 0
--TRANLOGOPTIONS altarchivedlogformat threadid 1 %t_%s_%r.arc
--TRANLOGOPTIONS altarchivedlogformat threadid 2 %t_%s_%r.arc
--TRANLOGOPTIONS altarchivelogdest instance ztradea1 /arch11,altarchivelogdest instance tradea1 /arch21
TRANLOGOPTIONS DBLOGREADER
--DISCARDFILE exterr,APPEND,MEGABYTES 5
--FETCHOPTIONS, USESNAPSHOT, NOUSELATESTVERSION, MISSINGROW REPORT
FETCHOPTIONS FETCHPKUPDATECOLS
--STATOPTIONS REPORTFETCH
--DBOPTIONS ALLOWNOLOGGING
DynamicResolution
------20150415
DISCARDFILE ./dirrpt/ext_qzh1.dsc, APPEND, MEGABYTES 1024
discardrollover at 6:00
DBOPTIONS ALLOWUNUSEDCOLUMN
REPORTCOUNT EVERY 1 MINUTES, RATE
WARNLONGTRANS 2h,CHECKINTERVAL 3m
FETCHOPTIONS NOUSESNAPSHOT
TRANLOGOPTIONS CONVERTUCS2CLOBS
WILDCARDRESOLVE DYNAMIC
DDL include mapped
DDLOPTIONS ADDTRANDATA NOCROSSRENAME REPORT
------20150415
------20150617
--TRANLOGOPTIONS LOGRETENTION DISABLED
--TRANLOGOPTIONS _NOREADAHEAD
--20150818
TRANLOGOPTIONS _NOREADAHEAD ANY
TRANLOGOPTIONS _DISABLESTREAMLINEDDBLOGREADER
--20150818
-- CURRENT
--GETTRUNCATES
table users.tables
REPLICAT RORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ogg
HANDLECOLLISIONS
ASSUMETARGETDEFS
DISCARDFILE /home/ogg/oggsoft/dirrpt/rora_aa.DSC, PURGE
ddl include all
ddlerror default ignore
MAP oggtst.*, target oggtst.*;
完成
四、 如果需要ddl同步
源端捕获进程:
见上面例子
目的端应用进程:
见上面例子