oracle GoldenGate学习笔记

合集下载

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技术详解

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(oracle+GoldenGate)学习笔记

OGG(oracle+GoldenGate)学习笔记

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 oracle

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. 作用:保存相应进程当前的读取和写入的位置信息, 防止进程因某些原因重启后的重复读取或数据丢失

韩顺平oracle学习笔记

韩顺平oracle学习笔记

韩顺平oracle学习笔记第0讲:如何学习oracle一、如何学习oracleOracle目前最流行的数据库之一,功能强大,性能卓越。

学习oracle需要具备一定基础:1.学习过一门编程语言(如:java ,c)2.最好学习过一门别的数据库(sql server,mysql , access)教程推荐:oracle使用教程,深入浅出oracle记住:欲速则不达,做任何事情要遵循他的规律,循序渐进,信心很重要成为一个oracle高手过程:理解小知识点->做小练习->把小的只是点连成线->做oracle项目->形成只是面->深刻理解Oracle基础部分:oracle基础使用; oracle用户管理; oracle表管理Oracle高级部分:oracle表的查询; oracle的函数; oracle数据库管理;oracle 的权角色; pl/sql 编程;索引,约束和事物。

期望目标:1 学会安装、启动、卸载oracle2 使用sql *plus工具3 掌握oracle用户管理4 学会在oracle中编写简单的select语句第1讲:基础语法内容介绍:1.为什么学习oracle2.介绍oracle及其公司的背景3.学会安装、启动、卸载oracle4.oracle开发工具5.Sql*plus的常用命令6.oracle用户管理一、主流数据库包括:●微软:sql server 和 access●瑞典:mysql AB公司●IBM公司:DB2●美国sybase公司:sybase●IBM公司:infromix●美国oracle公司:oracle(目前最流行的之一)二、oracle安装,启动及卸载1.系统要求:操作系统最好为windows2000内存最好在256M以上硬盘空间需要2G以上2.oracle安装会自动的生成sys和system两个用户说明:○1Sys用户是超级用户,具有最高权限,具有sysdba角色,create database 的权限,默认密码是manager○2System 用户是管理操作员,权限也很大,具有sysoper角色,没有create database权限,默认密码是 change_on_install○3一般讲,对数据库维护,使用system用户登录就可以了3.启动oracle右键单击我的电脑->服务和应用程序:服务->启动OracleServiceMYORA1(MYORA1是安装oracle时起的名字各有不同)和OracleOracleHome90TNSLlistener4.卸载oracle1、先关掉oralce,net stop OracleServiceORCL(ORCL是我的实例名字,换成你的),或者去我的电脑服务中关闭2、开始->程序->Oracle - oracle的版本号,我的是10ghome->Oracle Installation Products->Universal Installer 卸载oracle3、进注册表,regedit,删除选择HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE下所有的key。

ORACLE数据库学习心得1

ORACLE数据库学习心得1

ORACLE数据库结课论文一个好的程序, 必然联系着一个庞大的数据库网路...今年我们学习了oracle数据库这门课程, 起初的我, 对这个字眼是要多陌生有多陌生, 后来上课的时候听一会老师讲课, 偶尔再跟上上机课, 渐渐的学会了不少东西, 但我感觉, 我学到的仍是一些皮毛而已, 怀着疑惑和求知的心态, 我在网上搜索了关于oracle数据库的一些知识。

1.ORACLE的特点:可移植性ORACLE采用C语言开发而成, 故产品与硬件和操作系统具有很强的独立性。

从大型机到微机上都可运行ORACLE的产品。

可在UNIX、DOS、Windows等操作系统上运行。

可兼容性由于采用了国际标准的数据查询语言SQL, 与IBM的SQL/DS、DB2等均兼容。

并提供读取其它数据库文件的间接方法。

可联结性对于不同通信协议, 不同机型与不同操作系统组成的网络也可以运行ORAˉCLE数据库产品。

2.ORACLE的总体结构(1)ORACLE的文件结构一个ORACLE数据库系统包括以下5类文件:ORACLE RDBMS的代码文件。

数据文件一个数据库可有一个或多个数据文件, 每个数据文件可以存有一个或多个表、视图、索引等信息。

日志文件须有两个或两个以上, 用来记录所有数据库的变化, 用于数据库的恢复。

控制文件可以有备份, 采用多个备份控制文件是为了防止控制文件的损坏。

参数文件含有数据库例程起时所需的配置参数。

(2)ORACLE的内存结构一个ORACLE例程拥有一个系统全程区(SGA)和一组程序全程区(PGA)。

SGA(System Global Area)包括数据库缓冲区、日志缓冲区与共享区域。

PGA(Program Global Area)是每一个Server进程有一个。

一个Server进程起动时, 就为其分配一个PGA区, 以存放数据与控制信息。

(3)ORACLE的进程结构ORACLE包括三类进程:①用户进程用来执行用户应用程序的。

Oracle数据库学习笔记

Oracle数据库学习笔记

Oracle数据库学习笔记Oracle数据库基础 orcale属于关系型数据库,适⽤于各类⼤,中,⼩,微机环境,是⼀种⾼效率、可靠性好的、适应⾼吞吐量的数据库⽅案。

学习,实验完全免费,商⽤需要⽀付相应费⽤。

Oracle 数据库包括数据库实例,和数据库,⼆者脱离谁都没有存在的价值。

实例是⽤来操作数据库的对象,数据库是⽤来存储数据使⽤的。

Oracle主要组件包含实例组件,数据库组件。

SGA(System Global Area)是Oracle Instance的基本组成部分,PGA(Process Global Area)是为每个连接到Oracle database的⽤户进程保留的内存。

每个实例只有⼀个SGA,所有的进程都能访SGA。

PGA是程序全局区,每个⼀个进程都⼀个PGA,PGA是私有的,只有对应进程才能访问对应的PGA。

数据库中包含:参数⽂件,⼝令⽂件,数据库⽂件,控制⽂件,⽇志⽂件以及归档⽇志⽂件。

Oracle实例进场包含⽤户进程,服务器进程和后台进程。

SGA:系统全局区 系统全局区包含共享池,数据缓冲区,⽇志缓冲区。

“共享池”:是对SQL,PL/SQL程序进⾏语法分析,编译,执⾏的内存区;由库缓存和数据字典缓存组成;其⼤⼩直接影响数据库性能。

“数据缓冲区”:临时存储从数据库读⼊的数据,所有⽤户共享,数据缓存区的⽬的是加快数据读写。

“⽇志缓冲区”:⽇志记录数据库所有修改信息,其先产⽣于⽇志缓冲区,当达到⼀定数量时,由后台进程将⽇志数据写到⽇志⽂件中。

PGA:程序全局区 PGA包含单个服务器进程所需要的数据和控制信息,在⽤户进程连接到数据库并创建⼀个会话时⾃动分配的,保存每个与数据库连接的⽤户进程所需要的信息。

PGA为⾮共享区,只能单个进程使⽤,当⼀个⽤户会话结束,PGA释放。

后台进程 后台进程中包含PMON(进程监视器(Process Monitor)),SMON(系统监视器(System Monitor)),DBWR(数据库书写器(Database Write)),LGWR(⽇志书写器(Log Write)),CKPT(检查点(Checkpoint)),以及其他。

第二部分 GoldenGate常用命令

第二部分 GoldenGate常用命令

Current Checkpoint (position of last record read in the data source):
Sequence #: 10 RBA: 20535808 Timestamp: 2008-06-01 19:05:28.000000 Redo File: /ora/oracle/oradata/ggs/redo03.log
Extract命令(五)
Info 命令举例
(接上页)
Write Checkpoint #1 GGS Log Trail Current Checkpoint (current write position): Sequence #: 2 RBA: 0 Timestamp: 2008-06-01 19:05:30.604907 Extract Trail: /home/oracle/ggs95/dirdat/r2 ... File Information: Block Size = 2048 Max Blocks = 100 Record Length = 2048 Current Offset = 0 ... Status: Start Time = 2008-06-01 19:04:14 Last Update Time = 2008-06-01 19:05:30 Stop Status = A Last Result = 400
Extract命令(一)
添加抽取日志进程 ADD EXTRACT/EXT extsz, TRANLOG, BEGIN NOW, thread 2 添加一个日志抽取进程,该进程从当前时间点开始 复制(如果需要从特定时间点开始则为BEGIN 200709-27 11:00),数据库为2个进程的RAC 11:00 2 RAC 添加传输进程( 添加传输进程(Data Pump) ) add extract dpeXX,exttrailsource /ggs/dirdat/XX 配置传输进程,从指定队列读取数据
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Oracle GoldenGate测试文档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_DA TA_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。

相关文档
最新文档