本篇内容介绍了“GoldenGate的基本原理介绍”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
什么是GoldenGate
官方定义:
Oracle GoldenGate is a comprehensive software package for real-time data integration and replication in heterogeneous IT environments.The product set enables high availability solutions, real-time data integration, transactional change data capture, data replication, transformations, and verification between operational and analytical enterprise systems.
大白话版:
Oracle GoldenGate(OGG)只会做一件事:复制数据。除此之外,啥也不会。
专一
高效
跨平台
OGG支持的平台
支持的数据库:
Oracle
MySQL
DB2
SQL Server
NonStop SQL/MX
Sybase
Teradata
TimesTen
PostgreSQL
Informix
支持的平台:
Unix(Solaris,AIX,HP-UX)
Linux
Windows
z/OS
HP NonStop
支持的操作:
DML
DDL
OGG支持的架构
OGG基本原理-Oracle的Redo Log机制
LGWR: Log Writer Process
日志写进程,将缓存中的Change Vector写入到文件(Online Redo Log)中
ARCn: Archiver Processes
归档进程,对Online Redo Log进行拷贝
Redo Log:
记录数据库的变更数据(Change Vector)。
分为:Online Redo Log和Archived Redo Log
OGG基本原理-工作机制
主要进程:
Manager
总控进程
管理其它进程
管理网络端口
管理TRAIL文件
管理运行日志
Extract
数据抓取
数据分发(Data Pump)
Replicat
数据应用
Collector
数据接收
主要文件:
Trail
数据的记录
Checkpoints
数据检查点信息
OGG的安装
环境: CentOS 6.7/Oracle 11.2.0.4/GoldenGate 11.2.1.0.32
Step 1. 设置环境变量
export ORACLE_HOME=/u01/app/oracle/product/database/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
Step 2. 解压缩软件包
cd /u01/app/oracle/product/ogg/gghome/11.2.1/gghome_1
tar xf fbo_ggs_Linux_x64_ora11g_64bit.tar
Step 3. 安装运行目录
cd /u01/app/oracle/product/ogg/gghome/11.2.1/gghome_1
./ggsci
GGSCI> create subdirs
OGG实施的基本步骤
场景:源库的表J.T1实时同步到目标库的J.T1
Step 1. 源端OGG账号配置
SQL> CREATE TABLESPACE GGS DATAFILE '+DATA01' SIZE 4G;
SQL> CREATE USER GGS IDENTIFIED BY GGS123 DEFAULT TABLESPACE GGS QUOTA UNLIMITED ON GGS;
SQL> GRANT DBA TO GGS;
$ ./keygen 128 1
0xD63ED81A1DA4DA0596004362410C5522
$ cat > ENCKEYS
DEFKEY 0xD63ED81A1DA4DA0596004362410C5522
GGSCI> encrypt password GGS123 encryptkey DEFKEY
Encrypted password: AADAAAAAAAAAAAGAJDSJTIIEHJJBOBPDNEZBYIAAPDOCCFGILFMAOGNCMCCAXABIQIFIJAXCKBLFQIMC
Algorithm used: AES128
Step 2. 源端数据库配置
SQL> ALTER DATABASE FORCE LOGGING;
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
GGSCI> dblogin userid ggs, password AADAAAAAAAAAAAGAJDSJTIIEHJJBOBPDNEZBYIAAPDOCCFGILFMAOGNCMCCAXABIQIFIJAXCKBLFQIMC, encryptkey DEFKEY
GGSCI> add trandata J.T1
Step 3. 源端Manager进程配置
GGSCI> edit params MGR
PORT 7809
PURGEOLDEXTRACTS /data01/oracle/ogg/dirdat/ta*, USECHECKPOINTS, MINKEEPDAYS 30
AUTORESTART ER *, RETRIES 5, WAITMINUTES 1, RESETMINUTES 30
LAGREPORTMINUTES 30
LAGCRITICALMINUTES 60
GGSCI> start MGR
Step 4. 源端Extract进程配置
GGSCI> edit params EJT
EXTRACT EJT
SETENV (ORACLE_HOME="/u01/app/oracle/product/database/11.2.0/db_1")
SETENV (ORACLE_SID="stest")
USERID GGS, PASSWORD AADAAAAAAAAAAAGAJDSJTIIEHJJBOBPDNEZBYIAAPDOCCFGILFMAOGNCMCCAXABIQIFIJAXCKBLFQIMC, ENCRYPTKEY DEFKEY
TRANLOGOPTIONS DBLOGREADER, DBLOGREADERBUFSIZE 2097152
EXTTRAIL /data01/oracle/ogg/dirdat/ta
DISCARDFILE /u01/app/oracle/product/ogg/gghome/11.2.1/gghome_1/dirrpt/EJT.dsc, APPEND Megabytes 256
DISCARDROLLOVER AT 00:00 on SUNDAY
REPORTROLLOVER AT 00:00 on SUNDAY
REPORTCOUNT EVERY 4 HOURS, RATE
FETCHOPTIONS, FETCHPKUPDATECOLS, USESNAPSHOT, NOUSELATESTVERSION, MISSINGROW REPORT
STATOPTIONS REPORTFETCH
WARNLONGTRANS 1H, CHECKINTERVAL 5M
TABLE J.T1 ;
Step 5. 源端添加Extract进程
GGSCI> add extract EJT, tranlog, begin now
GGSCI> add exttrail /data01/oracle/ogg/dirdat/ta, extract EJT, megabytes 256
GGSCI> start extract EJT
Step 6. 目标端数据库配置
SQL> ALTER SYSTEM SET enable_goldengate_replication=TRUE;
Step 7. 目标端OGG账号配置
参见Step 1. 源端OGG账号配置
Step 8. 目标端Checkpoint配置
GGSCI> dblogin userid ggs, password AADAAAAAAAAAAAGAJDSJTIIEHJJBOBPDNEZBYIAAPDOCCFGILFMAOGNCMCCAXABIQIFIJAXCKBLFQIMC, encryptkey DEFKEY
GGSCI> add checkpointtable ggs.checkpoint
Step 9. 目标端Manager进程配置
GGSCI> edit params ./GLOBALS
CHECKPOINTTABLE ggs.checkpoint
ALLOWOUTPUTDIR /data01/oracle/ogg/dirdat
GGSCI> edit params MGR
PORT 7809
PURGEOLDEXTRACTS /data01/oracle/ogg/dirdat/ta*, USECHECKPOINTS, MINKEEPDAYS 30
AUTORESTART ER *, RETRIES 5, WAITMINUTES 1, RESETMINUTES 30
LAGREPORTMINUTES 30
LAGCRITICALMINUTES 60
GGSCI> start MGR
Step 10. 源端Data Pump进程配置
GGSCI> edit params PJT
EXTRACT PJT
SETENV (ORACLE_HOME="/u01/app/oracle/product/database/11.2.0/db_1")
PASSTHRU
RMTHOST tj, MGRPORT 7809
RMTTRAIL /data01/oracle/ogg/dirdat/ta
DISCARDFILE /u01/app/oracle/product/ogg/gghome/11.2.1/gghome_1/dirrpt/PJT.dsc, APPEND, MEGABYTES 256
DISCARDROLLOVER AT 00:00 on SUNDAY
REPORTROLLOVER AT 00:00 on SUNDAY
REPORTCOUNT EVERY 4 HOURS, RATE
TABLE J.T1 ;
Step 11. 源端添加Data Pump进程
GGSCI> add extract PJT, exttrailsource /data01/oracle/ogg/dirdat/ta
GGSCI> add rmttrail /data01/oracle/ogg/dirdat/ta, extract PJT, megabytes 256
GGSCI> start extract PJT
Step 12. 目标端Replicat进程配置
GGSCI> edit params RJT
REPLICAT RJT
SETENV (ORACLE_HOME = "/u01/app/oracle/product/database/11.2.0/db_1" )
SETENV (ORACLE_SID="ttest")
SETENV (NLS_LANG = "AMERICAN_CHINA.ZHS16GBK")
USERID GGS, PASSWORD AADAAAAAAAAAAAGAJDSJTIIEHJJBOBPDNEZBYIAAPDOCCFGILFMAOGNCMCCAXABIQIFIJAXCKBLFQIMC, ENCRYPTKEY DEFKEY
DISCARDFILE /u01/app/oracle/product/ogg/gghome/11.2.1/gghome_1/dirrpt/RJT.dsc, APPEND Megabytes 256
DISCARDROLLOVER AT 00:00 on SUNDAY
REPORTROLLOVER AT 00:00 on SUNDAY
REPORTCOUNT EVERY 4 HOURS, RATE
ASSUMETARGETDEFS
MAP J.T1, TARGET J.T1;
Step 13. 目标端添加Replicat进程
GGSCI> dblogin userid ggs, password AADAAAAAAAAAAAGAJDSJTIIEHJJBOBPDNEZBYIAAPDOCCFGILFMAOGNCMCCAXABIQIFIJAXCKBLFQIMC, encryptkey DEFKEY
GGSCI> add replicat RJT, exttrail /data01/oracle/ogg/dirdat/ta
Step 14. 数据初始化-源端数据导出
SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
-------------
373926987
$ expdp system/systm123 directory=DUMPDIR dumpfile=JT1.dump tables=J.T1 flashback_scn=373926987 logfile=JT1.expdp.log
Step 15. 数据初始化-目标端数据导入
$ impdp system/systm123 directory=DUMPDIR dumpfile=JT1.dump logfile=JT1.impdp.log
Step 16. 目标端启Replicat进程
GGSCI> start replicat RJT, atcsn 373926987
“GoldenGate的基本原理介绍”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!