你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle GoldenGate常用参数详解

[日期:2017-09-04] 来源:Linux社区  作者:Linux [字体:大 中 小]

三、replicat相关参数

1、常用参数

replicat提供如下方面参数:

Checkpoint
数据影射关系
    Optional row-level selection criteria
    Optional column mapping facilities
    Optional transformation services
    Optional Stored Procedure or SQL query execution
错误处理机制
其它可选参数

参数举例:

replicat repsz
setenv ( NLS_LANG = AMERICAN_AMERICA.ZHS16GBK )
userid goldengate, password *****
sqlexec "Alter session set constraints=deferred"
REPORT AT 01:59
reportrollover at 02:00
--handlecollisions
reperror default,discard
discardfile /oradata/goldengate/dirrpt/repsz.dsc,append, megabytes 10
--grouptransops 100
--batchsql
assumetargetdefs
allownoopupdates
dynamicresolution
numfiles 3000
--mapexclude CTAIS2.JC_GY_SWWSWH
--map CTAIS2.SHOULIXINXI, target CTAIS2.SHOULIXINXI, keycols ( SHOULIBIANHAO );
MAP ctais2.* ,TARGET ctais2.*; 

Map参数:

MAP <source table>, TARGET <target table>
    [, EXCEPTIONSONLY]
    [, COLMAP (<column mapping specification>)]
    [, KEYCOLS (<column list>)]
    [, WHERE (<where condition>)]
    [, FILTER (<expression>)]
;

注意map语句必须以一个分号结束;

2、完整参数示例:

示例1:

GGSCI 6> view params repsa

REPLICAT repsa
SETENV (NLS_LANG = "American_America.UTF8")  --设置字符集环境变量为UTF8
SETENV (Oracle_SID = "xxxx" )                --如果系统中存在多个数据库有时候会用参数SETENV设置ORACLE_HOME、ORACLE_SID等
USERID goldengate, PASSWORD AACAAAAAAAAAAAJAPJYATHVIMGMAOFHIUCUEPFYGGJBFJGIH, ENCRYPTKEY default
--SQLEXEC "ALTER SESSION SET CONSTRAINTS=DEFERRED"
DBOPTIONS DEFERREFCONST    --约束延迟设置。在复制进程的事物被提交之前,延迟级联删除、级联更新时的校验和实施。
GETTRUNCATES              --不捕获生产端truncate table的操作。
REPORT AT 06:00            --每天早上6点报告
REPORTCOUNT EVERY 30 MINUTES, RATE    --每隔30分钟报告一次从程序开始到现在的抽取进程或者复制进程的事物记录数,并汇报进程的统计信息
REPORTROLLOVER AT 02:00              --为了防止report file被写满,每天2:00做一次文件过期设定
REPERROR DEFAULT, ABEND  --除了特殊指定的REPERROR语句,报告所有复制期间出现的错误,回滚非正常中断的事物和进程。
--HANDLECOLLISIONS      --当灾备端已经存在数据的情况下,解决复制过程中出现的冲突。如果要重新做初始化,可以删除drop灾备端数据库后再rman恢复,这样做的话就不需要该参数了。
####ALLOWNOOPUPDATES    --当生产端有某些列但是目标表却没有,或者复制进程中配置了COLSEXCEPT 参数 在这些情况下,当生产端对那些列进行更新,目标表将不发生任何变化
assumetargetdefs        --使用ASSUMETARGETDEFS参数时,用MAP语句中指定的生产库源表和灾备端目标表具有相同的列结构。它指示的Oracle GoldenGate不在生产端查找源表的结构定义。
DISCARDFILE ./dirrpt/repsa.dsc, APPEND, MEGABYTES 1024M  --将执行失败的记录保存在discard file中,该文件位于./dirrpt/extya.dsc,大小为1024MB。 文件中已经包含记录的话,再后面继续追加,不删除之前的记录。
DISCARDROLLOVER AT 02:00  --为了防止discard file被写满,每天2:00做一次文件过期设定
—Schema名称涉及敏感字符,在此统一使用Schema来代替
—table名称涉及敏感字符,在此统一使用table来代替
map Schema1.table1, target Schema1.table1;
map Schema1.table2, target Schema1.table2;
map Schema2.table1, target Schema2.table1;
map Schema2.table2, target Schema2.table2;

示例2:

replicat repl                              --复制进程名
userid ddw,password ddw                    --目标数据库的帐号密码
assumetargetdefs                            --两台数据库数据结构一致则使用此参数
reperror default,discard                        --如果复制数据出错则忽略,
discardfile D:\repsz.dsc,append,megabytes 100  --错误信息写入XXXX文件,追加模式,最大100m
gettruncates                                    --复制truncate操作                             
map ddw.aatest, target ddw.aatest_1;            --映射关系,注意target前必须留一个空格
--map ddw.aatest, target ddw.aatest_1, keycols (name), where (TYPE1 = "1") 
--加两横杠在配置文件中进行注释;keycols指定唯一键;where筛选数据

3、全部可选参数

(1)通用参数

CHECKPARAMS    Verifies parameter file syntax.检查参数语法然后停止。

COMMENT | --    Denotes comments in a parameter file. 注释行。

GETENV          Retrieves variables that were set with the  SETENV parameter.
SETENV          Specifies a value for a UNIX environment variable from within the GGSCI interface.
                示例:SETENV (NLS_LANG = "American_America.UTF8")  --设置字符集环境变量为UTF8
                示例:SETENV (ORACLE_SID = "xxxx" )                --如果系统中存在多个数据库有时候会用参数SETENV设置ORACLE_HOME、ORACLE_SID等

OBEY            Processes parameter statements contained in a different parameter file.将外部文件包含到参数文件中。

TRACETABLE | NOTRACETABLE    Specifies a trace table to which Replicat adds a record whenever it updates the target database. Supports Oracle.

(2)Processing method

BEGIN            Specifies a starting point for Replicat processing. Required when  SPECIALRUN is specified.

BULKLOAD        Loads data directly into the interface of the Oracle SQL*Loader utility.

END              Specifies a stopping point for Replicat processing. Required when using  SPECIALRUN .

GENLOADFILES    Generates run and control files that are compatible with a database load utility.

REPLICAT        Specifies a Replicat group for online change synchronization.定义进程名称。示例:replicat repsz

SPECIALRUN      Used for one-time processing that does not require checkpointing from run to run.

(3)Database login

TARGETDB        Specifies the data source as part of the login information.

USERID          Specifies database connection information. 指定登陆目标数据库的用户名和密码。
                示例:Userid goldengate, password 123456
                    USERID goldengate, PASSWORD AACAAAAAAAAAAAJAPJYATHVIMGMAOFHIUCUEPFYGGJBFJGIH, ENCRYPTKEY default

(4)Selecting, converting, and mapping data

ALLOWDUPTARGETMAP |
NOALLOWDUPTARGETMAP    Allows the same source-target  MAP statement to appear more than once in the parameter file.
                   
ASCIITOEBCDIC          Converts incoming ASCII text to EBCDIC for DB2 on z/OS systems running UNIX System Services.
                   
ASSUMETARGETDEFS        Assumes that source and target tables have the same column structure.假定两端数据结构一致使用此参数。
                        示例: assumetargetdefs    --使用ASSUMETARGETDEFS参数时,用MAP语句中指定的生产库源表和灾备端目标表具有相同的列结构。它指示的Oracle GoldenGate不在生产端查找源表的结构定义。
                                       
COLMATCH            Establishes global column-mapping rules.
                   
DDL                  Enables and filters the capture of DDL operations.

DDLSUBST            Enables string substitution in DDL processing.

GETDELETES | IGNOREDELETES              Controls the replication of delete operations.是否复制delete操作,缺省为复制。
                   
GETINSERTS | IGNOREINSERTS              Controls the replication of insert operations.是否复制insert操作,缺省为复制。

GETUPDATEAFTERS | IGNOREUPDATEAFTERS    Controls the replication of update after images. 是否读取后影像,缺省为读取

GETUPDATEBEFORES | IGNOREUPDATEBEFORES  Controls the replication of update before images. 是否读取前影像,缺省为不读取。

GETUPDATES | IGNOREUPDATES              Controls the replication of update operations.是否复制update操作,缺省为复制。

GETTRUNCATES | IGNORETRUNCATES          Includes or excludes the replication of  TRUNCATE statements.是否复制truncate操作,缺省为不复制。
                                        示例:GETTRUNCATES              --不捕获生产端truncate table的操作。
                                   
INSERTALLRECORDS                  Inserts a new record into the target table for every change operation made to a record.

INSERTDELETES | NOINSERTDELETES  Converts deletes to inserts.

INSERTMISSINGUPDATES |
NOINSERTMISSINGUPDATES            Converts an update to an insert when the target row does not exist.

INSERTUPDATES | NOINSERTUPDATES  Converts updates to inserts.

MAP for Replicat      Specifies a relationship between one or more source and target tables and controls column mapping and conversion.

MAPEXCLUDE              Excludes tables from being processed by a wildcard specification supplied in  MAP statements.
                        用于使用在map中使用*匹配时排除掉指定的表,类似于于源端的tablexclude。
                       示例:mapexclude CTAIS2.JC_GY_SWWSWH
                              MAP ctais2.* ,TARGET ctais2.*;

REPLACEBADCHAR      Replaces invalid character values with another value.

REPLACEBADNUM      Replaces invalid numeric values with another value.

SOURCEDEFS          Specifies a file that contains source data definitions created by the  DEFGEN utility.
                    假定两端数据结构不一致,使用此参数指定源端的数据结构定义文件。该文件需要由GoldenGate工具产生。

SPACESTONULL | NOSPACESTONULL  Controls whether or not a target column containing only spaces is converted to  NULL .

TABLE for Replicat            Specifies a table or tables for which event actions are to take place when a row satisfies the given filter criteria.

TRIMSPACES | NOTRIMSPACES    Controls whether trailing spaces are trimmed or not when mapping  CHAR to  VARCHAR columns.

UPDATEDELETES | NOUPDATEDELETES    Changes deletes to updates.

USEDATEPREFIX              Prefixes data values for  DATE data types with a  DATE literal, as required by Teradata databases.
   
USETIMEPREFIX              Prefixes data values for  TIME datatypes with a  TIME literal, as required by Teradata databases.
   
USETIMESTAMPPREFIX        Prefixes data values for  TIMESTAMP datatypes with a TIMESTAMP literal, as required by Teradata databases.

(5)Routing data

EXTFILE            Defines the name of an extract file on the local system that contains data to be replicated. Used for one-time processing.

EXTTRAIL            Defines a trail containing data to be replicated. Used for one-time processing.

(6)Custom processing

CUSEREXIT              Invokes a user exit routine during processing.

DEFERAPPLYINTERVAL      Specifies a length of time for Replicat to wait before applying replicated operations to the target database.

INCLUDE                References a macro library in a parameter file.

MACRO                  Defines an Oracle GoldenGate macro.

SQLEXEC                Executes a stored procedure or query during Replicat processing.
                        调用存储过程或者执行sql语句。可以将返回值作为依据进行过滤条件,或者用户改变session变量。
                        示例:SQLEXEC "ALTER SESSION SET CONSTRAINTS=DEFERRED"

(7)Reporting

CMDTRACE            Displays macro expansion steps in the report.

LIST | NOLIST      Displays or suppresses the listing of macros in the report file.

REPORT              Schedules a statistical report at a specified date or time.
                    示例:REPORT AT 06:00            --每天早上6点报告
                   
REPORTCOUNT        Reports the number of records processed.
                    示例:REPORTCOUNT EVERY 30 MINUTES, RATE   
                        --每隔30分钟报告一次从程序开始到现在的抽取进程或者复制进程的事物记录数,并汇报进程的统计信息

SHOWSYNTAX          Causes Replicat to print its SQL statements to the report file.

STATOPTIONS        Specifies information to include in statistical displays.

TRACE/TRACE2        Shows Replicat processing information to assist in revealing bottlenecks.

(8)Error handling

CHECKSEQUENCEVALUE |
NOCHECKSEQUENCEVALUE    Controls whether or not Replicat verifies that a target sequence value is higher than the one on the source and corrects any disparity that it finds.

DDLERROR                Controls error handling for DDL replication.

DISCARDFILE            Contains records that could not be processed.
                        定义出错数据的输出文件。当数据出现错误后,可以用于查找错误原因。
                        示例:discardfile /oradata/goldengate/dirrpt/repsz.dsc,append, megabytes 10
                            DISCARDFILE ./dirrpt/repsa.dsc, APPEND, MEGABYTES 1024M  --将执行失败的记录保存在discard file中,该文件位于./dirrpt/extya.dsc,大小为1024MB。 文件中已经包含记录的话,再后面继续追加,不删除之前的记录。

HANDLECOLLISIONS |      自动过滤重复时段的数据冲突,用于不能停机执行初始化。打开该参数后不会将数据错误报到discard文件中。
NOHANDLECOLLISIONS      Handles errors for duplicate and missing records.
                        示例:--HANDLECOLLISIONS 
                            --当灾备端已经存在数据的情况下,解决复制过程中出现的冲突。如果要重新做初始化,可以删除drop灾备端数据库后再rman恢复,这样做的话就不需要该参数了。


HANDLETPKUPDATE        Prevents constraint errors associated with replicating transient primary key updates.

OVERRIDEDUPS |
NOOVERRIDEDUPS          Overlays a replicated insert record onto an existing target record whenever a duplicate-record error occurs.

RESTARTCOLLISIONS |    Controls whether or not Replicat applies
NORESTARTCOLLISIONS    HANDLECOLLISIONS logic after Oracle GoldenGate has abended because of a conflict.

REPERROR                Determines how Replicat responds to database errors.
                        定义出错以后replicat的响应,一般可以定义为两种:
                            Abend,即一旦出现错误即停止复制,此为缺省配置;
                            Discard,出现错误后继续复制,只把错误的数据放到discard文件中。
                        示例:REPERROR DEFAULT, DISCARD
                            REPERROR DEFAULT, ABEND  --除了特殊指定的REPERROR语句,报告所有复制期间出现的错误,回滚非正常中断的事物和进程。


REPFETCHEDCOLOPTIONS    Determines how Replicat responds to operations for which a fetch from the source database was required.

SQLDUPERR                Specifies the database error number that indicates a duplicate record. Use with  OVERRIDEDUPS .

WARNRATE                Determines how often database errors are reported.

(9)Tuning

ALLOCFILES          Controls the amount of incremental memory that is allocated when the amount of memory specified with NUMFILES is reached.

BATCHSQL            Increases the throughput of Replicat processing by arranging similar SQL statements into arrays and applying them at an accelerated rate.          针对批处理中针对某个表的大批量重复操作进行优化,提高批处理的处理速度。

CHECKPOINTSECS      Controls how often Replicat writes a checkpoint when checkpoints are not being generated as the result of transaction commits.

DBOPTIONS          Specifies database options.定义与数据库类型相关的特殊处理方式。
                    示例:DBOPTIONS DEFERREFCONST    --约束延迟设置。在复制进程的事物被提交之前,延迟级联删除、级联更新时的校验和实施。

DDLOPTIONS          Specifies DDL processing options.

DYNAMICRESOLUTION |    使replicat动态解析表的结构,加快启动速度。缺省为每次启动解析所有要复制表的结构。
NODYNAMICRESOLUTION    Makes Replicat start faster when there is a large number of tables specified for synchronization.

DYNSQL | NODYNSQL        Causes Replicat to use literal SQL statements rather than a compile-once, execute-many strategy.

EOFDELAY | EOFDELAYCSECS  Determines how many seconds Replicat delays before looking for more data to process.

FUNCTIONSTACKSIZE      Controls the size of the memory stack that is used for processing Oracle GoldenGate functions.

GROUPTRANSOPS          Controls the number of records that are grouped into a Replicat transaction.
                        将小的交易合并成为一个大的交易进行提交,减少提交次数,降低系统IO消耗。示例:grouptransops 100

INSERTAPPEND |
NOINSERTAPPEND          Controls whether or not Replicat uses an  APPEND hint when applying  INSERT operations to Oracle target tables.

MAXDISCARDRECS          Limits the number of discarded records reported to the discard file.

MAXSQLSTATEMENTS        Controls the number of prepared SQL statements that can be used by Replicat.

MAXTRANSOPS  Divides large source transactions into smaller ones on the target system.
              将大交易拆分,每若干条纪录提交一次。示例:maxtransops 1000

NUMFILES      Controls the initial allocation of memory that is dedicated to storing information about tables to be processed by Oracle GoldenGate.
              定义进程中表的最大数据量,缺省为 500.

RETRYDELAY                Specifies the delay between attempts to retry a failed SQL operation.

TRANSACTIONTIMEOUT        Specifies a time interval after which Replicat will commit its open target transaction and roll back any incomplete source transactions that it contains, saving them for when the entire source transaction is ready to be applied.

TRANSMEMORY            Controls the amount of memory and temporary disk space available for caching uncommitted transaction data.

WILDCARDRESOLVE        Alters the rules by which wildcard specifications in a  MAP statement are resolved.

(10)Maintenance

DISCARDROLLOVER        Specifies when to create new discard files.
                        示例:DISCARDROLLOVER AT 02:00  --为了防止discard file被写满,每天2:00做一次文件过期设定

PURGEOLDEXTRACTS        Purges obsolete trail files. 定义自动删除队列,一般建议在mgr进程配置。

REPORTROLLOVER          Specifies when to create new report files.
                        示例: REPORTROLLOVER AT 02:00  --为了防止report file被写满,每天2:00做一次文件过期设定

(11)Security

DECRYPTTRAIL            Decrypts data in a trail or extract file.

补充:

allownoopupdates  参数含义:允许执行无实际变化的update。例如,update a=a会纪录一条update,但是没有后影像,无法正确构筑where语句。
ALLOWNOOPUPDATES  --当生产端有某些列但是目标表却没有,或者复制进程中配置了COLSEXCEPT 参数 在这些情况下,当生产端对那些列进行更新,目标表将不发生任何变化

四、定义文件参数

DEFSFILE            Identifies the name of the file to which  DEFGEN writes the definitions

SOURCEDB            Specifies the data source as part of the login information.

TABLE for DEFGEN    Identifies a table for which you want to capture a definition.

USERID              Specifies database connection information.

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-09/146727.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款