OGG(oracle+GoldenGate)学习笔记
Oracle GoldenGate 官方学习文档

Oracle GoldenGate for Oracle to OracleObjectiveUpon completion of this lesson, you will be able to keep two Oracle databases synchronized.During this lesson, you will:⏹Prepare the database and the Oracle GoldenGate environment.⏹Configure and execute the initial data load process⏹Configure and start the change capture of database operations.⏹Configure and start the change delivery process.Oracle to Oracle configurationThe following diagram illustrates Oracle GoldenGate installed on two systems connected by TCP/IP– one containing the source data and the other the replicated data.Overview of tasksPrepare the EnvironmentIn order to execute this lesson, the GoldenGate application must be installed on both the source and target systems. The installation includes a sample database and scripts to generate initial data as well as subsequent update operations. The source and target tables are createdand loaded with initial data. The GoldenGate Manager processes are also started so that other processes may be configured and started.Configure Initial Data LoadTo initially load data, there are techniques such as Backup/Restore or Export/Import, both of which have pros and cons. Or you may use the GoldenGate application to perform your initial data load while the application remains active. This lesson demonstrates using Extract to pull data from the source tables and sending the data directly to the Replicat on the target system.Configure Change CaptureFor log-based Oracle capture, the capture process is configured to capture change data directly from the Oracle online redo logs or archive logs and store the changes in queues known as GoldenGate remote trails.Configure Change DeliveryOnce the tables have been initially loaded with data, the delivery process is configured to deliver the captured change data into the target database.Exercise 1.Prepare the EnvironmentObjectiveThe goals of this exercise are to:⏹Configure and start the Manager processes⏹Create and load practice data to Oracle tables⏹Add supplemental loggingPrepare your Oracle source environment1. Configure the Manager process on the sourceOn the <source> system, create the Manager parameter file and specify the port it should use.❍Create the Manager parameter file.Shell> cd <install location>Shell> ggsciGGSCI> EDIT PARAMS MGR❍Use the editor to assign a port.❍Start the Manager.GGSCI> START MGR❍Verify that the Manager has started.GGSCI> INFO MGR2. Create the source tables and load the initial data.Using SQL*Plus, create and populate the TCUSTMER and TCUSTORD tables by running the demo_ora_create.sql and demo_ora_insert.sql files found in the install directory.Execute the following commands on the <source> system.Shell> cd <install location>Shell> sqlplus <login>/<password>SQL> @demo_ora_createSQL> @demo_ora_insertVerify the results:SQL> select * from tcustmer;SQL> select * from tcustord;SQL> exit3. Add supplemental loggingUsing GGSCI, log in to the database on the <source> and turn on supplemental logging for the TCUSTMER and TCUSTORD tables.Shell> ggsciGGSCI> DBLOGIN USERID <login>, PASSWORD <password>GGSCI> ADD TRANDATA <owner/schema>.TCUSTMERGGSCI> ADD TRANDATA <owner/schema>.TCUSTORDVerify that supplemental logging has been turned on for these tables.GGSCI> INFO TRANDATA <owner/schema>.TCUST*Prepare your target Oracle environmentConfigure the Manager1. Configure the Manager process on the target systemExecute the following commands on the <target> system.❍Start the command interfaceShell> cd <install location>Shell> ggsci❍Specify the port that the Manager should use.GGSCI> EDIT PARAMS MGR❍Start ManagerGGSCI> START MANAGERVerify the results:GGSCI> INFO MANAGERCreate the tables2. Create target Oracle tablesExecute the following commands on the <target> system to run the script that creates the tables.Shell> cd <install location>Shell> sqlplus <login>/<password>SQL> @demo_ora_createVerify the results:SQL> desc tcustmer;SQL> desc tcustord;SQL> exitExercise 2.Initial Data Load using Direct Load MethodObjectiveThe goals of this exercise are to:⏹Configure a task to load the initial data from a source table⏹Configure the delivery of the data to the target⏹Execute the initial load of data.Initial data capture1. Add the initial load capture batch task groupExecute the following commands on the <source> system to create an Extract named EINI<unique id>1.GGSCI> ADD EXTRACT EINI<unique id>, SOURCEISTABLEVerify the result:GGSCI> INFO EXTRACT *, TASKS2. Configure the initial load capture parameter fileExecute the following commands on the <source> system.GGSCI> EDIT PARAMS EINI<unique id>1 The process names used in lab exercises, for example EINIBD, are made up of 1) one character for the GoldenGate process (E for Extract, R for Replicat); 2) three or four to describe the process type (INI for initial data load, ORA for capture from or delivery to an Oracle database, etc.) and 3) two characters to create a unique identifier (usually your initials)..Initial data delivery3. Add the initial load delivery batch taskExecute the following commands on the <target> system.GGSCI> ADD REPLICAT RINI<unique id>, SPECIALRUN Verify the results:GGSCI> INFO REPLICAT *, TASKS4. Configure the initial load delivery parameter fileExecute the following commands on the <target> system.GGSCI> EDIT PARAMS RINI<unique id>5. Execute the initial load processExecute the following commands on the <source> system.GGSCI> START EXTRACT EINI<unique id>Verify the results on the <source> system:GGSCI> VIEW REPORT EINI<unique id>Verify the results on the <target> system:GGSCI> VIEW REPORT RINI<unique id>Exercise 3.Configure Change CaptureObjectiveThe goals of this exercise are to:⏹Configure and add the Extract process that will capture changes.⏹Add the trail that will store the changes.⏹Start the Extract process.Configure change capture1. Add the Extract groupExecute the following command on the <source> system to add an Extract group named EORA<unique id>.GGSCI> ADD EXTRACT EORA<unique id>, TRANLOG, BEGIN NOW, THREADS <instances>Verify the results:GGSCI> INFO EXTRACT EORA<unique id>2. Create the Extract parameter fileExecute the following commands on the <source> system.GGSCI> EDIT PARAM EORA<unique id>Note: Record the two characters selected for your <trail id>: ______. You will need this in the next step and when you set up the Replicat.Note: When Oracle Automatic Storage Management (ASM) is in use, the TRANLOGOPTIONS ASMUSER and ASMPASSWORD must be set in the Extract parameter file. For more information refer to the GoldenGate for Windows & UNIX Administrator and Reference manuals.3. Define the GoldenGate trailExecute the following command on the <source> to add the trail that will store the changes on the target.GGSCI> ADD RMTTRAIL ./dirdat/<trail id>, EXTRACT EORA<unique id>, MEGABYTES 5Verify the results:GGSCI> INFO RMTTRAIL *4. Start the capture processGGSCI> START EXTRACT EORA<unique id>Verify the results:GGSCI> INFO EXTRACT EORA<unique id>, DETAILGGSCI> VIEW REPORT EORA<unique id>Discussion points1. Identifying a remote systemWhat parameter is used to identify the remote target system?_________________________________________________________________________ 2. Sizing the GoldenGate trailWhere do you set how large a GoldenGate trail file may get before it rolls to the next file?What option do you use?_________________________________________________________________________ _________________________________________________________________________Exercise 4.Configure Change DeliveryObjectiveThe goals of this exercise are to:⏹Set up the checkpoint table on the target system.⏹Create a named group that includes the Replicat process and the checkpoint tables.⏹Configure the Replicat group by adding parameters.⏹Start the Replicat group.Set up the checkpoint table1. Create a GLOBALS file on the target systemExecute the following commands on the <target> system.❍Create and edit the GLOBALS parameter file to add the checkpoint table.Shell> cd <install location>Shell> ggsciGGSCI> EDIT PARAMS ./GLOBALSIn the text editor, type:❍Record the checkpoint table owner and name, then save and close the file.Table owner ____________________ name ___________________Note: You could name the table anything you want, but for training purposes we areusing ggschkpt.❍Verify that the GLOBALS file was created in the root GoldenGate directory, and remove any file extension that was added.2. Activate the GLOBALS parametersFor the GLOBALS configuration to take effect, you must exit the session in which the changes were made. Execute the following command to exit GGSCI.GGSCI> EXIT3. Add a Replicat checkpoint tableOn the <target> system, execute the following commands in GGSCI:Shell> cd <install location>Shell> ggsciGGSCI> DBLOGIN USERID <login>, PASSWORD <password>GGSCI> ADD CHECKPOINTTABLEConfigure Change Delivery4. Add the Replicat groupExecute the following command on the <target> system to add a delivery group namedRORA<unique id>.GGSCI> ADD REPLICAT RORA<unique id>, EXTTRAIL ./dirdat/<trail id> Note: Refer to your Extract set up for the correct two-character <trail id>.5. Create Replicat parameter fileExecute the following commands on the <target> system to bring up the parameter file in the editor.GGSCI> EDIT PARAM RORA<unique id>Type in the following parameters6. Start the Replicat processGGSCI> START REPLICAT RORA<unique id>Verify the results:GGSCI> INFO REPLICAT RORA<unique id>Discussion pointsSearch in the Windows/UNIX Reference Guide for the information on the followingquestions.1. When to use HANDLECOLLISIONSWhen would you use HANDLECOLLISIONS? What does it do?_________________________________________________________________________ _________________________________________________________________________2. When should you use ASSUMETARGETDEFS?_________________________________________________________________________ _________________________________________________________________________3. What is the purpose of the DISCARDFILE?_________________________________________________________________________ ________________________________________________________________________Exercise 5.Generate Activity and Verify ResultsObjectiveThe goals of this exercise are to:⏹Execute miscellaneous update, insert, and delete operations on the source system.⏹Verify the delivery of the changes to the target⏹Turn off the error handling used for initial load.Generate database operations1. Execute miscellaneous update, insert, and delete operationsExecute the following commands on the <source> system.Shell> cd <install location>Shell> sqlplus <login>/<password>SQL> @demo_ora_miscVerify change capture and delivery2. Verify results on the source systemExecute the following commands on the <source> system.SQL> select * from tcustmer;SQL> select * from tcustord;SQL> exitShell> ggsciGGSCI> SEND EXTRACT EORA<unique id>, REPORTGGSCI> VIEW REPORT EORA<unique id>3. Verify your results on the target systemExecute the following commands on the <target> system to verify the target data.Shell> cd <install location>Shell> sqlplus <userid>/<password>SQL> select * from tcustmer;SQL> select * from tcustord;SQL> exitShell> ggsciGGSCI> SEND REPLICAT RORA<unique id>, REPORTGGSCI> VIEW REPORT RORA<unique id>Turn off error handling4. Turn off initial load error handling for the running delivery processGGSCI> SEND REPLICAT RORA<unique id>, NOHANDLECOLLISIONS 5. Remove initial load error handling from the parameter fileGGSCI> EDIT PARAMS RORA<unique id>Remove the HANDLECOLLISIONS parameter.Exercise Name。
Oracle GoldenGate技术详解

Oracle GoldenGate技术详解<Insert Picture Here>Agenda •Oracle GoldenGate 整体架构•各模块的作用和结构•Filter/Map &转换•初始装载•高可用性结构•使用方法(Oracle Database to Oracle Database )•注意事项Manager源端Trail 文件: 保存变更信息的中间文件Extract (Capture ): 从REDO 日志文件获取变更信息,以最小10ms 间隔读取Redo 日志,将变更信息输出到Trail 文件Extract (Data Pump ): 变更信息的传输读取Trail 文件,将变更信息传输到远端REDO (Archive )日志文件Trail TrailExtract (Data Pump )Replicat端DB源DBNetwork(TCP/IP)Collector ManagerManager:管理GoldenGate 整体各进程的起动/停止、监视/管理Capture (Capture )Collector:接收Extract 传输过来的数据存为Trail 文件远程Trail 文件:保存变更信息的中间文件Replicat: 从Trail 文件获得变更信息,转换成目标DB 的SQL 语句在目标DB 上运行(以行为单位)TrailTrailExtractExtractReplicat端DB源DB Network (TCP/IP)Collector双向可同等配置,实现双向复制TrailTrailExtractExtractReplicat源DBNetwork (TCP/IP)CollectorTrailTrailCollectorExtractNetwork (TCP/IP)Oracle GoldenGate 的部署通过Capture/Data Pump、Replicat的各种组合灵活配置多主复制单向双向(Active-Active)分发集中多层分发<Insert Picture Here>Agenda •Oracle GoldenGate 整体架构•各模块的作用和结构•Filter/Map &转换•初始装载•高可用性结构•使用方法(Oracle Database to Oracle Database )•注意事项各模块结构TrailTrailExtract (主)Extract (Data Pump )Replicat端DB源DBNetwork(TCP/IP)Collector ManagerManagerExtract (Capture )-获取DB 的变更信息的变更信息--Extract (Capture )Extract (Capture )‐Extract 的两个功能的两个功能‐‐Extract(Capture)源DBREDO归档日志Trail 文件(本地本地))Extract (data Pump )Trail 文件(远程远程))Trail 文件(远程远程))Network (TCP/IP)Network (TCP/IP)•Extract 的功能•Capture从REDO/归档日志取得DB 的变更信息输出到Trail 文件•Data Pump将Trail 文件传输到远端机器Extract (Capture )‐DB 变更信息的获取变更信息的获取((1)-Extract源DBREDO归档日志•变更信息的来源在线REDO 日志(缺省)归档日志(Windows 环境的缺省)•取得的信息主键(或唯一键)的值 变更前后的值•注意:数据库并不要求必须是归档模式附加日志模式下主键和变更值输出到REDO 日志将DB 设为附加日志模式(将主键的值输出到REDO 日志日志))変更変更值值+主键值Extract (Capture )‐DB 变更信息的获取变更信息的获取((2)-Extract (Capture )源DBREDO归档日志•获取方法•以一定间隔读取REDO 日志,获取变更信息•间隔:用参数(EOFDELAY or EOFDELAYCSECS )设置•缺省:1秒、最小:10 毫秒•变更信息的输出•输出位置:本地或者远程的Trail 文件•输出时机:满足以下任一条件•Extract 的缓冲区(内存)写满的话•设置参数(FLUSHSECS or FLUSHCSECS )来指定间隔•缺省:1秒、最小:10毫秒最小最小以以10毫秒间隔定期获取变更信息缓冲缓冲((内存内存))写满or最小最小以以10毫秒间隔输出Trail 文件Extract(Capture)‐双向复制双向复制•双向复制场合的注意事项•为避免重复应用、应设置不捕获GoldenGate(Replicat)的SQL语句通过Extract(Capture)的参数可指定GETAPPLOPS /IGNOREAPPLOPS指定捕获/忽略Replicat以外的更新数据库进程的动作GETREPLICATES /IGNOREREPLICATES指定捕获/忽略Replicat对数据库的更新动作各组件的结构Trail Trail Replicat端DB源DBNetwork (TCP/IP)Collector (Server)Manager ManagerExtract (Data Pump )→ Collector-数据库变更信息的收发-Data Pump &CollectorExtract (Capture )Extract (Data Pump )Collector‐变更信息的收发变更信息的收发‐‐Extract(Data Pump )Trail 文件Network (TCP/IP)从Extract 向Collector 发送、输出Trail 文件•发送间隔:满足以下任一条件•缓存写满的时候Extract 的RMHOST 参数(TCPBUFSIZE 选项)可指定缓存尺寸缺省:30,000Byte•参数(FLUSHSECS or FLUSHCSECS )的指定间隔缺省:1秒、最小:10毫秒数据•发送时数据可压缩CollectorManager①请求②起动(动态分配端口动态分配端口,,起动进程起动进程))Data Pump‐变更信息的发送变更信息的发送((两种方式两种方式))‐Extract(Capture )Trail 文件(本地本地))Extract (data Pump )Trail 文件(远程远程))Trail 文件(远程远程))Network(TCP/IP)Network (TCP/IP)方式1:另外起动发送专用的Extract (即Data Pump )•先保存到本地的Trail 文件然后发送方式2:一个Extract 兼Capture 和Data Pump 之职•从REDO 日志取得信息然后直接向远端发送REDO方式2方式1CollectorCollectorData Pump‐多个目标发送(两种方式两种方式))‐ExtractTrail文件(本地本地))Extract(data Pump)Trail文件(远程远程))Trail文件(远程远程))Network(TCP/IP)方式2:采用一个Data Pump向多个目标发送的方式有一个进程停止的话就整体停止Extract Trail文件(本地本地))Extract(data Pump)Trail文件(远程远程))Trail文件(远程远程))Network(TCP/IP)推荐方式1:每个目标起动一个Data Pump的方式一个进程停止的话也不会影响整体CollectorCollectorCollectorCollector各部件的结构Trail TrailReplicat端DB源DBNetwork(TCP/IP)Collector Manager ManagerReplicat-应用到数据库-ReplicatExtract (Capture )Extract (Data Pump )Replicat ‐Replicat 的功能‐•Replicat 的功能•从Trail 文件生成SQL 语句在目标DB 执行•以变更的行为单位生成SQL 语句、执行•基于主键(或唯一键)和变更前的值(可选)更新(主键或唯一键的值是在源端通过附加日志方式从日志中获得)TrailReplicat端DB各部件结构Trail TrailReplicat端DB源DBNetwork(TCP/IP)CollectorManagerManagerManager-GoldenGate 整体的监控/管理-ManagerExtract (Capture )Extract (Data Pump )ManagerManager ‐GoldenGate 整体的监控/管理‐•Manager 的作用Trail 文件的管理•Trail 文件的生成/删除 进程的监控/管理•定期监控进程•进程的启动/停止、再启动 GoldenGate 整体的监控/报表执行用户的命令TrailTrailReplicat端DBNetwork (TCP/IP)CollectorExtract (Capture )Extract (Data Pump )源DBManagerManagerManager整体的监控/管理 ‐ GoldenGate整体的监控 管理 ‐ 整体的监控• Manager与各部件之间通信 • UI ⇔ Manager : TCP/IP • Extract/Replicat ⇔ Manager(本地) :共享内存• 各进程状况(如处理完的检查点等等)都保存在共享内存, Manager查询后产生相关报表• Extract(Data Pump)⇔ Manager(远端):TCP/IPGGSCI(命令行) or GUI (命令行)TCP/IP参考处理状況生成报表 参考处理状況生成报表 状況 共享内存 ・进程状况状况随时更新ManagerExtract/Replicat21Agenda • • • • • • • Oracle GoldenGate 整体架构 各模块的作用和结构 <Insert Picture Here> Filter/Map & 转换 初始装载 高可用性结构 使用方法(Oracle Database to Oracle Database) 注意事项22Filter/Map&变换 &• 可以配置Filter/Map以及变换的部件 Capture(推荐) Data Pump ReplicatFilter/Map & Transform Filter/Map & Transform Filter/Map & TransformNetwork (TCP/IP) DB Extract Trail Extract (Capture) ) (Data Pump) ) Collector Trail Replicat 端DB23Filter/Map&变换 & • 可配置的Filter/Map&变换(1)表:以表为单位指定例:MAP scott.emp TARGET james.emp MAP scott.* TARGET james.* (支持通配符)列:仅指定特定的列例:MAP scott.emp TARGET james.emp COLS (empno, ename) MAP scott.emp TARGET james.emp COLEXCEPT (salgrade)24Filter/Map&变换 &• 可配置的Filter/Map&变换(2) 行:指定满足特定条件的行 可以在特定操作(UPDATE或者INSERT等等)时来应用Filter 条件中可指定GoldenGate的函数和宏例:MAP scott.emp TARGET james.emp WHERE (sal > 100000); MAP scott.emp TARGET james.emp FILTER(ON UPDATE, @COMPUTE (sal * 100) > 100000);数据变换:可以对列进行映射和列值的变换 数据变换可以利用GoldenGate的函数和宏例:MAP hr.contact, TARGET hr.phone, COLMAP (USEDEFAULTS, name = cust_name, phone_number= @STRCAT( “(”, area_code, “)”, ph_prefix, “-”, ph_number) );注意: 注意:不支持多字节的列名或文字串作为条件25函数 • 主要函数 • 条件判断函数IF, CASE, EVAL, VALONEOF 等 例:FILTER (@IF (sal > 100, sal, 0) >100);• 文字列/数値操作函数COMPUTE, STRCAT, STRCMP, STRLEN, STRFIND等 注意: 注意:不支持对多字节文字列进行操作 例:FILTER (@STRLEN(ename ) > 40);• 日期函数DATE, DATENOW等 例:FILTER (hiredate > @DATENOW);26Agenda • • • • • • • Oracle GoldenGate 整体架构 各模块的作用和结构 <Insert Picture Here> Filter/Map & 转换 初始装载 高可用性结构 使用方法(Oracle Database to Oracle Database) 注意事项27初始装载( 初始装载(Init Load) ) • 初始装载的方法 • 利用数据库的功能• 传输表空间、备份/恢复、exp/imp等• 利用GoldenGate的功能GoldenGate的功能 的功能 File to Replicat File to Database Utility Direct load Direct bulk load Extract 的输出 Trail (GoldenGate格式) 文本文件 向Replicat直接传输 向Replicat直接传输 装载的方法 Replicat (SQL) Database utility Replicat(SQL) Replicat (SQL*Loader API)28在线初始化装载举例 • GoldenGate内部是按CSN(Change Sequence Number) 来管理事务的顺序的 • 指定CSN将特定时间的变更应用到目标端,以使源和目 标实现同步 • Step1. 在源端开始Capture时的CSN是222当前的CSN= 222CSN=222源DBCaptureTrailPumpTrail端DB29在线初始化装载举例 • Step2. 取得所有的事务的静止点 • Step3. 取得源DB的备份(RMAN Backup/传输表空间等等...) •当前的CSN= 245此时的CSN是245CSN=222开始源DBCaptureTrailPumpTrail 源DBCSN=245时的备份恢复CSN=245时的备份30在线初始化装载举例 • Step4. 通过Replicat从CSN=245开始应用Trail文件 • 与源DB同步到相同的状态,初始化装载结束当前的CSN= 300 CSN=222开始 应用CSN=245~300 部分源DBCaptureTrailPumpTrail 端DBTake Backup as of CSN 245Apply Backup as of CSN 24531Agenda • • • • • • • Oracle GoldenGate 整体架构 各模块的作用和结构 <Insert Picture Here> Filter/Map & 转换 初始装载 高可用性结构 使用方法(Oracle Database to Oracle Database) 注意事项32可用性‐故障解决‐ 故障解决‐• 各种故障的解决方法• GoldeGate的故障 • 进程故障 -> 进程自动重启 • Trail文件故障 -> Checkpoint • GoldenGate以外的故障 • 服务器/DB/网络的故障 -> Checkpoint自動重启 自動重启 自動重启 自動重启源DBExtract Trail Extract (Capture) (Data Pump) ) ) CheckpointNetwork (TCP/IP)Collector TrailReplicat端DBCheckpointCheckpoint33可用性‐进程故障的解决‐ 进程故障的解决‐• 由Manager重启GoldenGate的进程 • 対象进程Extract(Capture/Data Pump) Replicat 注意:Manager进程本身不会重启• 相关配置参数重试次数(缺省=2次) 等待时间(缺省= 20分) 等待重试次数清零的时间(缺省=20分)Manager 重启 重启Network (TCP/IP)Manager 重启源DBExtract Trail Extract (Capture) (Data Pump) ) )Collector TrailReplicat端DB34可用性文件/其他故障的解决 ‐Trail文件 其他故障的解决‐ 文件 其他故障的解决‐ 为解决Trail文件/服务器/网络故障、 GoldenGate使用Checkpoint机制• Checkpoint记录各进程处理到哪个位置的信息• Extract(Capture)最早未提交的事务的位置(SCN) 当前读取的更新位置(SCN) 已写到Trail文件的更新位置(SCN)• Extract(Data Pump)从Trail文件已读到的事务位置(SCN) 记录已写到远程Trail文件的位置• Replicat从Trail文件已读到的事务位置(SCN) 已反映到目标DB的位置• 故障恢复时,会参考Checkpoint从最后的处理位置重新开始35可用性‐Checkpoint‐ ‐最早Open的事务 的事务 最早 (未Commit)的开始点 )Begin, TX 1 Insert, TX 1 Begin, TX 2 Update, TX 1 Insert, TX 2 Commit, TX 2 Begin, TX 3 Insert, TX 3 Begin, TX 4 Commit, TX 3 Delete, TX 4Begin, TX 2 Insert, TX 2 Commit, TX 2Capture CheckpointBegin, TX 3 Insert, TX 3 Commit, TX 3当前Trail File的写 当前 的写 入点 当前的日志读 取点源DBCaptureTrail File36可用性Begin, TX 1 Insert, TX 1 Begin, TX 2 Update, TX 1 Insert, TX 2 Commit, TX 2 Begin, TX 3 Insert, TX 3 Begin, TX 4 Commit, TX 3 Delete, TX 4‐Checkpoint‐ ‐最早Open的事务 的事务 最早 (未Commit)的开始点 ) Pump CheckpointBegin, TX 2 Insert, TX 2 Commit, TX 2Begin, TX 2 Insert, TX 2 Commit, TX 2Capture CheckpointBegin, TX 3 Insert, TX 3 Commit, TX 3当前的Trail 当前的 File的读取点 的读取点当前的Trail 当前的 File的Write 点 的当前Trail File 当前 的写入点 当前的日志读 取点源DBCaptureTrail FilePumpTrail File37可用性‐Checkpoint‐ ‐Begin, TX 1 Insert, TX 1 Begin, TX 2 Update, TX 1 Insert, TX 2 Commit, TX 2 Begin, TX 3 Insert, TX 3 Begin, TX 4 Commit, TX 3 Delete, TX 4最早Open的事务 的事务 最早 (未Commit)的开始点 )Begin, TX 2 Insert, TX 2Pump CheckpointBegin, TX 2 Insert, TX 2 Commit, TX 2Delivery CheckpointCapture CheckpointCommit, TX 2 Begin, TX 3 Insert, TX 3 Commit, TX 3当前的Trail 当前的 File的读取点 的读取点当前的Trail File的 当前的 的 写入点当前的Trail File 当前的 的读取点当前Trail File 当前 的写入点 当前的日志读 取点Capture 源DBTrail FilePumpTrail FileReplicat 端DB38Agenda • • • • • • • Oracle GoldenGate 整体架构 各模块的作用和结构 <Insert Picture Here> Filter/Map & 转换 初始装载 高可用性结构 使用方法(Oracle Database to Oracle Database) 注意事项39安装步骤 • 安装 ① 介质下载包含在Fusion Middleware的Pack中 根据不同平台以及DB安装媒质也不同 源/端的服务器各自都要安装GoldenGate软件② 在安装的机器上解压• 解压到GoldenGate的安装目录 gzip -dc V18159-01.zip | tar -xvo③ 相关目录的生成• 在GoldenGate的安装目录下执行以下脚本 (利用GoldenGate的GGSCI)$ ./ggsci GGSCI () 1> CREATE SUBDIRS EXIT40备注页用GoldenGate 配置复制的例子以下环境下配置GoldenGate 复制•OS :Oracle Enterprise Linux 5、DB :11g R2•源/端主机名:ggdemo01a/ •源/端DB 名:db1 / db2•复制Schema :SCOTT (仅复制DML 操作)•GoldenGate 的DB 用户:用户名=“gg”、密码=”gg”•Capture 名:capdb1、Data Pump 名:pumpdb12、Replicat 名:repdb2•GoldenGate 安装目录:“/oracle/ggs/”Trail Trail Replicat Capture Pump SCOTT 用户源DB (db1)SCOTT 用户端DB(db2)配置步骤Step1.Manager的配置(源/端都要配置)•编辑参数文件•在GGSCI中执行以下命令编辑参数文件GGSCI> EDIT PARAM mgr参数文件例子:PORT 7809 <-Manager使用的端口号(必须)AUTORESTART ER*, WAITMINUTES 1, RETRIES 3<-指定Extract/Replicat进程的自动重启源端配置步骤Step2.源DB 的配置①指定需要复制的对象(在源端)(需要打开表级的附加日志方式)•在GGSCI 中对SCOTT 用户执行以下命令(预先配置ORACLE_HOME 和SID 等环境变量)②附加日志模式的设置(在源端)•用Sqlplus 登录到源DB 执行以下命令(需要用有ALTER SYSTEM 权限的用户登录)GGSCI> DBLOGIN USERID gg, PASSWORD ggGGSCI> ADD TRANDATA scott.*SQL>ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;SQL>ALTER SYSTEM SWITCH LOGFILE;Capture配置步骤Step3.Capture的配置(GGSCI中执行)①启动ManagerGGSCI> START MGR②增加Capture任务(capdb1)GGSCI> ADD EXTRACT capdb1, TRANLOG, BEGIN NOW③本地Trail文件的位置指定GGSCI> ADD EXTTRAIL /oracle/ggs/dirdat/lt, EXTRACT capdb1Capture 配置步骤配置步骤((续)④配置参数文件参数文件例-EXTRACT :Extract (Capture )名-SETENV :环境参数的配置(指定ORACLE_HOME 和SID )-USERID gg, PASSWORD gg :GoldenGate 使用的DB 用户名密码-EXTTRAIL /oracle/ggs/dirdat/lt :本地Trail 文件目录以及Prefix-TABLE :复制对象(用Schema.Table 名指定。
ogg概叙、架构、进程

ogg概叙、架构、进程⼀. OGG 概述OGG 全称Oracle Golden Gate。
历史:Golden Gate公司于1995年成⽴于美国加州旧⾦⼭,它的名称源⾃旧⾦⼭闻名于世的⾦门⼤桥。
两位创始⼈Eric Fish和Todd Davidson最初旨在为Tandem计算机公司设计⼀个容错系统,由于Golden Gate的健壮性和出⾊的数据复制功能,银⾏⽤它来把ATM⽹络的交易数据发送到IBM⼤型机,后来⼴泛地应⽤到⾦融⾏业及要求数据复制⾼效、健壮的各个⾏业。
该公司于2009年9⽉被Oracle公司收购,在此之前Oracle和Golden Gate 公司就有了长达超过10年的合作关系。
在Oracle收购Golden Gate以后,与Oracle原有的 Data Guard互为补充,共同为企业提供跨平台实时数据同步的解决⽅案。
Golden Gate 软件分类说明:(1)Golden Gate:包括GoldenGate Capture, Deliver 和Active Data Guard, XStream on Oracle DB,并⽀持各种开放数据系统,是我们通常讲的OGG的概念。
(2)Golden Gate Director:实际上,在下载的时候,可以发现没有Director的类⽬了,替换的是⼀个Golden Gate Management Pack的包,其实这个就是之前的OGG Director。
Management Pack是基于浏览器的管理⼯具包,有限使⽤WebLogic SE,所以配置MP,需要先安装weblogic。
(3)Golden Gate Veridata:跨平台⽐较复制的源库和⽬标库,为Golden Gate源端和⽬标端提供数据⽐对和校验的功能。
另外,也有不太常见的:(1)Golden Gate for Mainframe:包括GoldenGate Capture, Deliver for HP Non-Stop, IBM DB2 onMainframe, plus Syncfile。
GoldenGate oracle

GoldenGate原理及体系结构
Parameters, Process Groups and GGSCI
• extract 和replicat是以进程组出线的,server collector默 认情况下是自动生成的 • 一个进程组由如下几部分组成,并由GoldenGate系统中 唯一的group name所标识,由用户指定: 1. An extract or Replicat process 2. 相应的参数文件(ASCII file,由用户生成,编辑,维 护,控制相应的进程的行为,功能) 3. 相应的checkpoint文件 4. 其他相应的文件(如trail) • Process的添加,启动等,都是由GoldenGate Software Command Interface(GGSCI)完成,GGSCI还可以添加trail, 察看process状态等。
GoldenGate原理及体系结构
• 了解capture和delivery模块概念后,可以进一步了解GG的 使用平台:
GoldenGate原理及体系结构
• GoldenGate两种主要用法: 1. 主要用于change data capture and delivery from database transaction logs (online) 2. Initial load directly from database tables.(special run, batch)只执行一次
GoldenGate原理及体系结构
Checkpoint
GoldenGate原理及体系结构
Checkpoint(续)
Capture, Pump and Delivery save positions to a checkpoint file so they can recover in case of failure. 作用:保存相应进程当前的读取和写入的位置信息, 防止进程因某些原因重启后的重复读取或数据丢失
OGG故障错误处理总结

OGG故障错误处理总结OGG故障错误处理总结第⼀章 GoldenGate错误分析与处理在维护GoldenGate过程中,由于各种意外情况,难免还是会遇到各种各样的问题。
掌握⼀些常见的GoldenGate故障诊断和错误分析的⽅法是⾮常有必要的,⽽且掌握这些错误分析⼯具也进⼀步加深对GoldenGate产品的认识与对GoldenGate原理的理解。
1.1 GoldenGate常见异常处理GoldenGate运⾏起来后,随着时间的推移可能会碰到各种各样的问题,下⾯就来介绍常见的异常现象以及常见的异常处理⽅法。
1.1.1 异常处理的⼀般步骤⾸先确定是GoldenGate的哪类进程有故障(是抽取,投递还是复制进程有问题),解决故障的⼀般思路如下。
(1)通过GGSCI>view report命令查找ERROR字样,确定错误原因并根据其信息进⾏排除。
(2)通过GGSCI>view ggsevt查看告警⽇志信息。
(3)检查两端数据库是否正常运⾏,⽹络是否连通。
(4)通过logdump⼯具对队列⽂件进⾏分析。
1.1.2 RAC单节点失败在RAC环境下,GoldenGate软件安装在共享⽬录下,可以通过任⼀个节点连接到共享⽬录,启动GoldenGate运⾏界⾯。
如果其中⼀个节点失败,导致GoldenGate进程中⽌,可直接切换到另外⼀个节点继续运⾏。
操作步骤如下。
(1)以Oracle⽤户登录源系统(使⽤另外⼀个正常的节点)。
(2)确认将GoldenGate安装的所在⽂件系统装载到另⼀节点相同⽬录。
(3)确认GoldenGate安装⽬录属于Oracle⽤户及其所在组。
(4)确认Oracle⽤户及其所在组对GoldenGate安装⽬录拥有读写权限。
(5)进⼊GoldenGate安装⽬录。
(6)执⾏./ggsci进⼊命令⾏界⾯。
(7)执⾏start mgr启动MGR。
(8)执⾏start er *启动所有进程。
oracle ogg详解

oracle ogg详解Oracle GoldenGate (OGG) 是Oracle公司开发的一款高性能的实时数据复制与数据同步工具。
它能够在不同的数据库之间实现数据的实时复制与同步,确保数据的一致性和可靠性。
本文将详细介绍Oracle GoldenGate的原理、特点、使用场景以及一些常见的问题和解决方案。
一、Oracle GoldenGate的原理Oracle GoldenGate的原理可以简单概括为:先抓取源数据库中的数据变更,将其记录为日志,然后通过网络传输这些日志,最后在目标数据库中重新应用这些变更,实现数据的实时复制与同步。
具体的步骤如下:1. 捕获源数据库中的数据变更:Oracle GoldenGate通过挂载在源数据库上的提供商或通过数据库日志挖掘技术,捕获所有的数据变更操作,例如插入、更新、删除等。
2. 将数据变更记录为日志:GoldenGate将源数据库中的数据变更操作记录为一组序列化的日志记录,以便在接下来的步骤中进行传输与应用。
3. 传输日志:GoldenGate使用高效的网络传输协议,将记录的日志从源数据库传输到目标数据库。
4. 应用数据变更:在目标数据库中,GoldenGate根据日志记录的顺序重新应用这些数据变更,确保目标数据库与源数据库的数据保持一致。
二、Oracle GoldenGate的特点1. 高性能:Oracle GoldenGate具有高度优化的数据捕获、传输和应用机制,能够实现实时数据的传输与同步,保证数据的实时性和准确性。
它采用基于日志的增量复制方式,避免了全量数据复制的高开销。
2. 异构性:Oracle GoldenGate支持在不同的数据库平台之间实现数据的实时复制与同步,如Oracle、DB2、SQL Server等。
这使得企业可以根据实际需求选择最适合自己的数据库平台,而不用担心数据的迁移和同步问题。
3. 灵活性:Oracle GoldenGate支持灵活的数据过滤和转换功能,可以根据需求选择复制和同步的特定表、特定列或特定行。
ogg 检查点详解 -回复

ogg 检查点详解-回复OGG,全称为Oracle GoldenGate,是一种用于数据复制和数据集成的软件产品。
它允许用户在异构的数据库之间进行实时数据同步和转换,同时提供了高可用性和扩展性。
本文将详细介绍OGG检查点的概念、工作原理以及如何进行配置和管理。
一、OGG检查点的概念1.1 什么是OGG检查点?OGG检查点是指Oracle GoldenGate对待复制的数据进行记录和跟踪的一种机制。
它用于标记数据同步的进程,并确保在故障发生时能够从断点继续复制。
1.2 OGG检查点的作用OGG检查点的作用主要体现在以下几个方面:- 管理数据同步进程:OGG通过检查点标记数据同步的进程,确保在源数据库和目标数据库之间的数据一致性。
- 提供故障恢复功能:当发生故障时,OGG可以根据检查点从故障发生点继续复制数据,减少数据丢失。
- 实现高可用性:通过检查点的方式,OGG可以确保数据同步进程的持久性和可恢复性,提高系统的可用性。
二、OGG检查点的工作原理2.1 检查点的生成OGG检查点的生成是由相应的进程负责的,主要包括Capture进程、Extract进程和Replicat进程。
这些进程会周期性地生成检查点,将检查点信息写入OGG的检查点表中。
2.2 检查点的同步一旦产生检查点,OGG会将该检查点信息复制到目标数据库中,然后同步到目标数据库的检查点表中。
通过这种方式,源数据库和目标数据库之间的检查点信息保持一致,以确保数据同步的持久性和可恢复性。
2.3 检查点的应用在数据同步过程中,OGG会根据检查点信息来确定数据同步的起始点和终止点。
当发生故障或中断时,OGG可以根据检查点信息进行数据恢复,从检查点的位置继续进行数据复制。
三、设置和管理OGG检查点3.1 配置OGG检查点参数在配置OGG时,可以通过参数设置来调整OGG检查点的相关属性。
具体的参数包括CHECKPOINTTABLE、CHECKPOINTPERIOD和PRESERVE_CHECKPOINTS等,用户可以根据需求自定义这些参数。
oracle ogg使用注意事项

oracle ogg使用注意事项
在使用Oracle GoldenGate (OGG)时,有以下几个注意事项:
1. 版本兼容性:确保使用的OGG版本与目标和源数据库的版本兼容。
OGG有不同的版本和插件,要根据数据库版本选择正确的OGG版本和插件。
2. 网络带宽:OGG会在源数据库和目标数据库之间传输数据,因此确保网络带宽足够以支持数据同步的需求。
如果网络带宽不足,可能会导致延迟和性能问题。
3. 数据库配置和权限:在源和目标数据库上配置必要的权限和参数以支持OGG 的运行。
确保OGG用户具有足够的权限来读取源数据库的日志文件并写入目标数据库。
4. 数据一致性:在进行实时同步或实时复制时,确保源和目标数据库之间的数据保持一致。
这可以通过配置校验和验证、数据过滤和转换来实现。
5. 日志文件管理:对于大型数据库或高频率更新的数据库,要定期管理和清理OGG生成的日志文件,以避免磁盘空间耗尽或性能下降。
6. 监控和故障排除:设置适当的监控和警报机制,以便及时发现并解决OGG 同步过程中的任何故障或延迟。
7. 定期备份:尽管OGG提供实时同步和复制,但仍建议定期备份源和目标数据库,以防止任何数据丢失或用户错误。
8. 测试和验证:在正式生产环境使用OGG之前,建议在测试环境中进行全面的测试和验证。
这样可以确保OGG能按预期进行数据同步和复制。
总之,使用OGG时,需要注意版本兼容性、网络带宽、数据库配置和权限、数据一致性、日志文件管理、监控和故障排除、定期备份以及测试和验证等方面。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Oracle GoldenGate测试文档1.Oracle GoldenGate介绍 (1)2.Oracle GoldenGate For Oracle(windows 平台) 安装 (5)3.数据库复制实施文档(DML) (7)3.1准备工作 (7)3.2配置GoldenGate (8)3.2.1配置SourceDB的GoldenGate (8)3.2.2 配置TargetDB的GoldenGate (9)3.3 测试DML操作 (11)4.GoldenGate Support DDL安装 (15)5.玩玩GoldenGate (23)1.Oracle GoldenGate介绍GoldenGate TDM(交易数据管理)软件是一种基于日志的结构化数据复制软件,它通过解析源数据库在线日志或归档日志获得数据的增删改变化,再将这些变化应用到目标数据库,实现源数据库与目标数据库同步、双活。
GoldenGate TDM 软件可以在异构的IT基础结构(包括几乎所有常用操作系统平台和数据库平台)之间实现大量数据亚秒一级的实时复制,其复制过程简图如下:如上图所示,GoldenGate TDM的数据复制过程如下:利用捕捉进程(Capture Process)在源系统端读取Online Redo Log或Archive Log,然后进行解析,只提取其中数据的变化如增、删、改操作,并将相关信息转换为GoldenGate TDM自定义的中间格式存放在队列文件中。
再利用传送进程将队列文件通过TCP/IP传送到目标系统。
捕捉进程在每次读完log中的数据变化并在数据传送到目标系统后,会写检查点,记录当前完成捕捉的log位置,检查点的存在可以使捕捉进程在中止并恢复后可从检查点位置继续复制;目标系统接受数据变化并缓存到GoldenGate TDM队列当中,队列为一系列临时存储数据变化的文件,等待投递进程读取数据;GoldenGate TDM投递进程从队列中读取数据变化并创建对应的SQL语句,通过数据库的本地接口执行,提交到数据库成功后更新自己的检查点,记录已经完成复制的位置,数据的复制过程最终完成。
由此可见,GoldenGate TDM是一种基于软件的数据复制方式,它从数据库的日志解析数据的变化(数据量只有日志的四分之一左右)。
GoldenGate TDM将数据变化转化为自己的格式,直接通过TCP/IP网络传输,无需依赖于数据库自身的传递方式,而且可以通过高达9:1的压缩率对数据进行压缩,可以大大降低带宽需求。
在目标端,GoldenGate TDM可以通过交易重组,分批加载等技术手段大大加快数据投递的速度和效率,降低目标系统的资源占用,可以在亚秒级实现大量数据的复制,并且目标端数据库是活动的GoldenGate TDM提供了灵活的应用方案,基于其先进、灵活的技术架构可以根据用户需求组成各种拓扑结构,如图所示:GoldenGate TDM 可以提供可靠的数据复制,主要体现在下面三点:保证事务一致性GoldenGate TDM 在灾备数据库应用复制数据库交易的顺序与在生产中心数据库上的顺序相同,并且按照相同的事务环境提交,确保在目标系统上数据的完整性和读一致性,为实时查询和事务处理创造了条件。
检查点机制保障数据无丢失GoldenGate TDM的抽取和复制进程使用检查点机制记录完成复制的位置。
对于抽取进程,其检查点记录当前已经抽取日志的位置和写队列文件的位置;对于投递进程,其检查点记录当前读取队列文件的位置。
检查点机制可以保证在系统、网络或GoldenGate TDM进程故障重启后数据无丢失。
可靠的数据传输机制GoldenGate TDM 用应答机制传输交易数据,只有在得到确认消息后才认为数据传输完成,否则将自动重新传输数据,从而保证了抽取出的所有数据都能发送到备份端。
数据传输过程中支持128位加密和数据压缩功能。
Oracle 公司的GoldenGate产品,可以在异构的IT基础结构之间实现大量数据的秒一级的数据捕捉、转换和投递。
GoldenGate可以支持几乎所有常用操作系统如和数据库平台,如下表所示:2.Oracle GoldenGate For Oracle(windows 平台) 安装GoldenGate 的安装非常简单,将解压缩安装文件到指定目录。
比如安装文件解压缩后的路径为d:\ggs安装步骤如下:1.进入命令行2.切换到ggs目录下3.输入命令install addservice addevents4.输入ggsci进入GoldenGate的命令行5.输入create subdirsOK,GoldenGate安装就已经完成了。
实际操作如下C:\Documents and Settings\PONY>d:D:\>cd ggsD:\ggs>install addservice addeventsOracle GoldenGate messages installed successfully.Service 'GGSMGR' created.Install program terminated normally.D:\ggs>ggsciOracle GoldenGate Command Interpreter for OracleVersion 10.4.0.19 Build 002Windows (optimized), Oracle 10 on Sep 18 2009 15:54:55Copyright (C) 1995, 2009, Oracle and/or its affiliates. All rights reserved.GGSCI (PONY) 1> create subdirsCreating subdirectories under current directory D:\ggsParameter files D:\ggs\dirprm: createdReport files D:\ggs\dirrpt: created Checkpoint files D:\ggs\dirchk: created Process status files D:\ggs\dirpcs: createdSQL script files D:\ggs\dirsql: created Database definitions files D:\ggs\dirdef: createdExtract data files D:\ggs\dirdat: created Temporary files D:\ggs\dirtmp: created Veridata files D:\ggs\dirver: created Veridata Lock files D:\ggs\dirver\lock: created Veridata Out-Of-Sync files D:\ggs\dirver\oos: created Veridata Out-Of-Sync XML files D:\ggs\dirver\oosxml: created Veridata Parameter files D:\ggs\dirver\params: created Veridata Report files D:\ggs\dirver\report: created Veridata Status files D:\ggs\dirver\status: created Veridata Trace files D:\ggs\dirver\trace: created Stdout files D:\ggs\dirout: created3.数据库复制实施文档(DML)3.1准备工作◆准备两台机器,分别为SourceDB, TargetDB,通过TCP/IP网络进行互连SourceDB :WIN XP环境,Oracle 10g 10.2.0.1.0TargetDB :WIN 2003 环境 Oracle 10g 10.2.0.1.0◆必须保证SourceDB是运行在归档模式下。
◆目的:将SourceDB中相关Schema中的数据同步复制到TargetDB相对应的Sechema 中本文中要同步的是SouceDB中的SAJET,SJ,SMT,LANG到Target中的SAJET,SJ,SMT,LANG 用户下◆首先要保持SourceD, TargetDB相关Schema中的初始数据一致,可以通过Exp/Imp,Rman,冷备等方式实现.◆双方DB建立GoldenGate用户,赋予DBA权限,用于GoldenGate连接DB.◆双方DB安装GoldenGate,安装方式如第二章节所示◆SourceDB必须开始最小附加日志模式通过以下语句查看DB是否开启了最小附加日志模式SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;SUPPLEME--------YES如果没有开启数据库的最小附加日志,则通过以下语句开启SQL>alter database add supplemental log data;◆开启表的最小附加日志,通过GoldenGate命令行来添加GGSCI (PONY) 1> dblogin userid sajet password techSuccessfully logged into database.GGSCI (PONY) 2> add trandata sajet.*第一条命令表示登录到Database第二条命令表示添加Sajet用户下所有表的最小附加日志同样的命令开启SJ,LANG,SMT用户下的表的最小附加日志。
3.2配置GoldenGate3.2.1配置SourceDB的GoldenGateSourceDB端需要配置mgr进程,添加一个extract进程,和一个远端队列。
1.配置mgr参数GGSCI (PONY) 2> edit param mgr此时系统自动会新建一个名为mgr的参数文件,填入以下内容后保存PORT 7809--mgr进程使用的TCP/IP端口侦听请求2.新增一个抽取进程,在GGSCI命令行中输入如下命令:GGSCI (PONY) 1> add extract ext1,tranlog,begin nowEXTRACT added.---新增一个抽取进程,负责抓取SourceDB中变化的数据,基于日志方式,立即生效3.配置抽取进程GGSCI (PONY) 2> edit param ext1此时系统会自动新建一个名为ext1的参数文件,填入以下内容后保存extract ext1userid goldengate,password goldengatermthost 172.17.17.61, mgrport 7809rmttrail d:\ggs\dirdat\r1dynamicresolutiongettruncatestable sajet.*;table sj.*;table smt.*;table lang.*;--抽取进程名为ext2连接本机DB的账号和密码远程主机地址以及服务端口号(TargetDB)远程队列的位置(TargetDB)优化参数,动态分析表结构是否抓取Truncate的数据需要抽取哪些table。