环境
centos7
oracle:11.2.0.1.0
ogg:11.2.0.3 for linux-x64
环境变量
添加用户参数
[oracle@localhost ~]$ vim ~/.bash_profile
在用户参数文件中添加以下内容:
export OGG_HOME=/ora/oracle/product/ogg #ogg安装目录
export LIBPATH=$GGATE_HOME:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH:$OGG_HOME
重载用户配置文件
[oracle@localhost ~]$ source ~/.bash_profile
安装OGG软件
1.在oracle安装目录product文件夹下创建OGG文件夹
mkdir ogg
2.将下载好的OGG文件安装到刚刚创建的文件夹下面
[oracle@localhost ~]$ tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar -C /ora/oracle/product/ogg/
开始OGG配置
1.在OGG安装目录下执行./ggsci进入OGG控制台,然后创建OGG工作目录
[oracle@dmsDB ogg]$ ./ggsci
2.创建OGG工作目录
GGSCI (dmsDB) 1> create subdirs
Creating subdirectories under current directory /u01/app/oracle/product/ogg
Parameter files /u01/app/oracle/product/ogg/dirprm: already exists
Report files /u01/app/oracle/product/ogg/dirrpt: created
Checkpoint files /u01/app/oracle/product/ogg/dirchk: created
Process status files /u01/app/oracle/product/ogg/dirpcs: created
SQL script files /u01/app/oracle/product/ogg/dirsql: created
Database definitions files /u01/app/oracle/product/ogg/dirdef: created
Extract data files /u01/app/oracle/product/ogg/dirdat: created
Temporary files /u01/app/oracle/product/ogg/dirtmp: created
Stdout files /u01/app/oracle/product/ogg/dirout: created
配置源端数据库
1.创建ogg用户
[oracle@ogg1 ogg]$ sqlplus / as sysdba
SQL>create tablespace tbogg datafile '/u01/app/oracle/oradata/orcl/tbogg.dbf' size 10M autoextend on next 10M;```
SQL>create tablespace tbogg datafile '/u01/app/oracle/oradata/orcl/tbogg.dbf' size 10M autoextend on next 10M;
SQL>create user ogg identified by ogg default tablespace tbogg;
SQL>grant dba to ogg;.
2.打开附加日志
SQL> alter database force logging;
SQL> alter database add supplemental log data;
SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;
SQL> alter system switch logfile;
3.执行OGG相关配置脚本(注意:在OGG安装目录下进入sqlplus)
有提示输入用户的地方,就输入上面创建的ogg用户。
SQL> @sequence.sql --- ogg
SQL> @marker_setup.sql --- ogg
SQL> @ddl_setup.sql ---- ogg
SQL> GRANT GGS_GGSUSER_ROLE TO ogg;
SQL> @ddl_enable.sql
SQL> @?/rdbms/admin/dbmspool.sql
SQL> @ddl_pin ogg;
源端OGG配置
1.全局配置
GGSCI (bogon) 1> edit params ./GLOBALS
ggschema ogg # 添加需要同步的schema
2.配置主进程mgr
GGSCI (bogon) 2> edit param mgr
PORT 7809
DYNAMICPORTLIST 7810-7920
autostart Extract E*
autorestart Extract *, retries 5, waitminutes 1
USERID ogg@orcl, PASSWORD ogg
PURGEOLDEXTRACTS ./dirdat/*, USECHECKPOINTS, MINKEEPDAYS 7
LAGREPORTHOURS 1
LAGINFOMINUTES 3
LAGCRITICALMINUTES 5
3.配置抽取进程
GGSCI (bogon) 2> edit param extnd1
EXTRACT extnd1
USERID ogg@orcl,password ogg
DYNAMICRESOLUTION
DDL INCLUDE ALL --捕获DDL
EXTTRAIL ./dirdat/lt
TABLE ogg.*;
sequence ogg.*;
GGSCI (ogg1.localdomain) 1> add extract extnd1,tranlog,begin now
GGSCI (ogg1.localdomain) 1>add exttrail ./dirdat/lt,extract extnd1
3.配置投递进程
GGSCI (ogg1.localdomain) 3> edit params extdp1
EXTRACT extdp
USERID ogg@orcl, PASSWORD ogg
PASSTHRU
RMTHOST 192.168.1.1(目标IP), MGRPORT 7809, compress
RMTTRAIL ./dirdat/rs
DYNAMICRESOLUTION
table ogg.*;
sequence ogg.*;
GGSCI (ogg1.localdomain) 4> add extract extdp1,exttrailsource /ora/oracle/product/ogg/dirdat/rs
GGSCI (ogg1.localdomain) 5> add rmttrail /ora/oracle/product/ogg/dirdat/rs,extract extdp1
配置目标端数据库
创建ogg用户
[oracle@ogg1 ogg]$ sqlplus / as sysdba
create tablespace tbogg datafile '/ora/oracle/oradata/orcl/tbogg.dbf' size 10M autoextend on next 10M;
create user ogg identified by ogg default tablespace tbogg;
grant dba to ogg;
目标端OGG配置
进入OGG管理界面
1.全局配置
GGSCI (bogon) 1>edit params ./GLOBALS
GGSCHEMA ogg
2.登录数据库账户,添加检查点
GGSCI (bogon) 2>dblogin userid ogg,password ogg
GGSCI (bogon) 3>add checkpointtable ogg.checkpoint
Successfully created checkpoint table ogg.checkpoint.
3.配置主进程mgr
GGSCI (bogon) 4> edit params mgr
PORT 7809
DYNAMICPORTLIST 7810-7920
autostart Replicat R*
autorestart Replicat *, retries 5, waitminutes 1
USERID ogg@orcl, PASSWORD ogg
PURGEOLDEXTRACTS ./dirdat/*, USECHECKPOINTS, MINKEEPDAYS 7
LAGREPORTHOURS 1
LAGINFOMINUTES 3
LAGCRITICALMINUTES 5
4.配置复制进程
GGSCI (bogon) 5> edit param repnd1
REPLICAT repnd1
USERID ogg@orcl, PASSWORD ogg
ASSUMETARGETDEFS
REPERROR default,discard
discardfile ./dirrpt/repnd.dsc,append,megabytes 50
APPLYNOOPUPDATES
DDL INCLUDE ALL
DDLOPTIONS REPORT
BATCHSQL
DBOPTIONS DEFERREFCONST
DBOPTIONS LOBWRITESIZE 102400
DDLERROR DEFAULT DISCARD RETRYOP MAXRETRIES 5 RETRYDELAY 20
map ogg.*,target ogg.*;
add checkpointtable OGG.checkpoint
5.添加复制进程
GGSCI (bogon) 6> add replicat repnd1 integrated exttrail ./dirdat/rs , checkpointtable ogg.checkpoint
开启同步
1.将源库导出并导入到目标库
2.导入成功后分别再源端和目标端开启进程
源端:
GGSCI (ogg1.localdomain) 1> start mgr
Managerstarted.
GGSCI (ogg1.localdomain) 2> start extnd1
Sending START request to MANAGER ...
EXTRACT EXTDP1 starting
GGSCI (ogg1.localdomain) 3> start extdp1
Sending START request to MANAGER ...
EXTRACT EXTDP1 starting
GGSCI (ogg1.localdomain) 3> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXTDP1 00:00:00 00:00:08
EXTRACT RUNNING EXTND1 00:00:00 00:00:07
目标端:
GGSCI (bogon) 1> start mgr
Managerstarted.
GGSCI (bogon) 2> start repnd1
Sending START request to MANAGER ...
EXTRACT REPND1 starting
GGSCI (bogon) 2> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT RUNNING REPND1 00:00:00 00:00:02
看到 RUNNING 就表示进程已经正常运行了。
如果看到 STOPPED 或者 ABENDED 表示进程出错。通过具体日志信息排查。
通过view report查看进行日志
GGSCI (bogon) 3>view report REPND1
***********************************************************************
Oracle GoldenGate Delivery for Oracle
Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:37:31
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
Starting at 2022-03-23 14:11:37
***********************************************************************
Operating System Version:
Linux
Version #1 SMP Thu Nov 8 23:39:32 UTC 2018, Release 3.10.0-957.el7.x86_64
Node: bogon
Machine: x86_64
soft limit hard limit
Address Space Size : unlimited unlimited
Heap Size : unlimited unlimited
File Size : unlimited unlimited
CPU Time : unlimited unlimited
Process id: 16006
--More--(4%)
到这基本的安装就已经结束。可以分别到源端和目标端测试数据是否正常同步。