oracle 11g 同库搭建 ogg-进阶1 本文为比上一篇参数稍多,主要做记录,其中配置若有误请见谅!!!
此次为了方便就同机搭建,所以mgr端口不同,如果不同机搭建,mgr端口可以一致
搭建环境
name
version
操作系统
CentOS Linux release 7.6.1810 (Core)
数据库版本
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
ogg版本
Oracle GoldenGate Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO Linux, x64, 64bi
1. 新建ogg用户 1 2 3 4 5 6 7 8 9 10 11 12 groupadd ogg useradd -g ogg -G oinstall,dba ogg echo "oracle" | passwd --stdin oracle--上传oracle goldengate安装文件解压 rz mkdir sogg togg mkdir sogg/temp unzip V34339-01.zip tar -xf fbo_ggs_Linux_x64_ora11g_64bit.tar -C sogg/ tar -xf fbo_ggs_Linux_x64_ora11g_64bit.tar -C togg/ --rm -f V34339-01.zip OGG_WinUnix_Rel_Notes_11.2.1.0.3.pdf Oracle*
2. 配置ogg环境变量 1 2 3 4 5 6 7 8 9 export TMP=/tmpexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1export ORACLE_SID=SRMexport PATH=/u01/app/oracle/product/11.2.0/dbhome_1/bin:/usr/sbin:/u01/app/oracle/product/11.2.0/dbhome_1/OPatch:/usr/local /sbin:/usr/local /bin:/usr/sbin:/usr/bin:/root/binexport LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib:/lib:/usr/libexport CLASSPATH=/u01/app/oracle/product/11.2.0/dbhome_1/JRE:/u01/app/oracle/product/11.2.0/dbhome_1/jlib:/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/jlibexport NLS_LANG=AMERICAN_AMERICA.UTF8export LC_ALL=en_US.UTF-8
3. source和target都准备数据库 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 set lin 200 pages 30000 alter system set enable_goldengate_replication = true ;create tablespace ogg_tbs datafile '/u01/app/oracle/oradata/SRM/ogg_tbs01.dbf' size 100 M autoextend on ;create user ogg identified by oracle default tablespace ogg_tbs;grant dba to ogg;set lin 200 pages 30000 create tablespace test_tbs datafile '/u01/app/oracle/oradata/SRM/test_tbs01.dbf' size 10 M autoextend on ;create user yg1 identified by oracle default tablespace test_tbs;create user yg2 identified by oracle default tablespace test_tbs;grant dba to yg1,yg2;alter database archivelog ;alter database force logging ;alter database add supplemental log data ;select NAME ,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MIN from v$database ;@/home/ogg/sogg/marker_setup.sql @/home/ogg/sogg/ddl_setup.sql @/home/ogg/sogg/role_setup.sql @/home/ogg/sogg/ddl_enable.sql
4. 创建 GoldenGate 的工作目录 1 2 3 4 5 6 7 cd /home/ogg/sogg/./ggsci create subdirs cd /home/ogg/togg/./ggsci create subdirs
5. 源端添加checkpointtable 1 2 3 4 5 6 7 8 9 10 11 12 cd /home/ogg/sogg/./ggsci EDIT PARAMS ./GLOBALS ----------------------------------------- GGSCHEMA ogg CHECKPOINTTABLE ogg.ggschkpt1 ----------------------------------------- exit ./ggsci DBLOGIN USERID ogg, PASSWORD oracle ADD CHECKPOINTTABLE
6. 目标端添加checkpointtable 1 2 3 4 5 6 7 8 9 10 11 cd /home/ogg/togg/ ./ggsci EDIT PARAMS ./GLOBALS ----------------------------------------- GGSCHEMA ogg CHECKPOINTTABLE ogg.ggschkpt2 ----------------------------------------- exit ./ggsci DBLOGIN USERID ogg, PASSWORD oracle ADD CHECKPOINTTABLE
7. 源配置mgr 1 2 3 4 5 6 7 8 9 10 11 12 13 EDIT PARAMS MGR ----------------------------------------- PORT 7809 DYNAMICPORTLIST 7800-8000 AUTOSTART EXTRACT * AUTORESTART EXTRACT *,WAITMINUTES 2,RETRIES 5, RESETMINUTES 5 PURGEOLDEXTRACTS /home/oracle/sogg/dirdat,USECHECKPOINTS,MINKEEPDAYS 1 PURGEDDLHISTORY MINKEEPDAYS 3,MAXKEEPDAYS 7,FREQUENCYMINUTES 30 PURGEMARKERHISTORY MINKEEPDAYS 3,MAXKEEPDAYS 7 ----------------------------------------- LAGREPORTHOURS 1 LAGINFOMINUTES 30 LAGCRITICALMINUTES 45
8. 目标配置mgr 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 EDIT PARAMS MGR ----------------------------------------- PORT 8809 DYNAMICPORTLIST 8800-9000 AUTOSTART EXTRACT * AUTORESTART EXTRACT *, WAITMINUTES 2, RESETMINUTES 5, RETRIES 5 PURGEOLDEXTRACTS /home/ogg/togg/dirdat, USECHECKPOINTS, MINKEEPDAYS 3 PURGEDDLHISTORY MINKEEPDAYS 3,MAXKEEPDAYS 7,FREQUENCYMINUTES 30 PURGEMARKERHISTORY MINKEEPDAYS 3,MAXKEEPDAYS 7 LAGREPORTHOURS 1 LAGINFOMINUTES 30 LAGCRITICALMINUTES 45 ----------------------------------------- start mgr info mgr
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 EDIT PARAMS EORA_1 ----------------------------------------- EXTRACT EORA_1 SETENV (ORACLE_SID="SRM" ) SETENV (NLS_LANG=AMERICAN_AMERICA.UTF8) USERID ogg, PASSWORD oracle GETTRUNCATES REPORTCOUNT EVERY 1 MINUTES,RATE NUMFILES 5000 DISCARDROLLOVER AT 3:00 WARNLONGTRANS 2h,CHECKINTERVAL 3m DYNAMICRESOLUTION DBOPTIONS ALLOWUNUSEDCOLUMN IGNOREAPPLOPS IGNOREREPLICATES FETCHOPTIONS NOUSESNAPSHOT FETCHOPTIONS FETCHPKUPDATECOLS DISCARDFILE /home/ogg/sogg/dirrpt/eora_a.dsc,APPEND,MEGABYTES 1000 EXTTRAIL /home/ogg/sogg/dirdat/aa,MEGABYTES 100 TRANLOGOPTIONS DBLOGREADER TRANLOGOPTIONS EXCLUDEUSER ogg CACHEMGR CACHEDIRECTORY /home/ogg/sogg/temp DDL INCLUDE ALL DDLOPTIONS ADDTRANDATA,REPORT TABLE yg1.*; ----------------------------------------- ADD EXTRACT EORA_1, TRANLOG, BEGIN NOW, threads 1 info extract * ADD EXTTRAIL /home/ogg/sogg/dirdat/aa, EXTRACT EORA_1, MEGABYTES 100 start extract eora_1 info eora_1
10. 配置 Pump 进程 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 EDIT PARAMS PORA_1 ----------------------------------------- EXTRACT PORA_1 SETENV (NLS_LANG=AMERICAN_AMERICA.UTF8) PASSTHRU NUMFILES 5000 RMTHOST yg-ocm, MGRPORT 8809,COMPRESS RMTTRAIL /home/ogg/togg/dirdat/pa DYNAMICRESOLUTION TABLE yg1.*; ----------------------------------------- ADD EXTRACT PORA_1, EXTTRAILSOURCE /home/ogg/sogg/dirdat/aa ADD RMTTRAIL /home/ogg/togg/dirdat/pa, EXTRACT PORA_1, MEGABYTES 100 START EXTRACT PORA_1 info all
11. 配置目标端的 Replicat 进程 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 EDIT PARAMS RORA_1 ----------------------------------------- REPLICAT RORA_1 SETENV (NLS_LANG=AMERICAN_AMERICA.UTF8) USERID ogg, PASSWORD oracle SQLEXEC "alter session set constraints=deferred" DBOPTIONS DEFERREFCONST GETTRUNCATES REPORT AT 06:00 REPORTCOUNT EVERY 1 MINUTES,RATE REPORTROLLOVER AT 02:00 REPERROR DEFAULT,ABEND NUMFILES 5000 DISCARDFILE ./dirrpt/rep_a.dsc,APPEND,MEGABYTES 1024m DISCARDROLLOVER AT 02:00 GROUPTRANSOPS 1000 HANDLECOLLISIONS ASSUMETARGETDEFS ALLOWNOOPUPDATES DDLERROR DEFAULT IGNORE DDL INCLUDE MAPPED DDLOPTIONS REPORT MAP yg1.*, TARGET yg2.*; ----------------------------------------- add replicat RORA_1, exttrail /home/ogg/togg/dirdat/pa start REPLICAT RORA_1 info all
12. 测试数据同步 1 2 3 4 5 sqlplus yg1/oracle create table t as select * from dual;sqlplus yg2/oracle select * from t;
至此,ogg-进阶1就搭建完成了,比简单的参数复杂了一些,但还是没有导入导出数据,仅仅只是做到了2个用户的数据同步,哈哈