Chinaunix首页 | 论坛 | 博客
  • 博客访问: 570783
  • 博文数量: 107
  • 博客积分: 4406
  • 博客等级: 上校
  • 技术积分: 1279
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-07 16:20
文章分类

全部博文(107)

文章存档

2014年(4)

2012年(4)

2011年(16)

2010年(7)

2009年(7)

2008年(11)

2007年(49)

2006年(9)

分类: Oracle

2014-10-10 14:49:38

Oracle GoldenGate安装配置


1 简介
Oracle Golden Gate软件是一种基于日志的结构化数据复制备份软件,它通过解析源数据库在线日志或归档日志获得数据的增量变化,再将这些变化应用到目标数据库,从而实现源数据库与目标数据库同步。Oracle Golden Gate可以在异构的IT基础结构(包括几乎所有常用操作系统平台和数据库平台)之间实现大量数据亚秒一级的实时复制,从而在可以在应急系统、在线报表、实时数据仓库供应、交易跟踪、数据同步、集中/分发、容灾、数据库升级和移植、双业务中心等多个场景下应用。同时,Oracle Golden Gate可以实现一对一、广播(一对多)、聚合(多对一)、双向、点对点、级联等多种灵活的拓扑结构

2 GoldenGate安装
2.1 GoldenGate的获取
Oracle GoldenGate(下文简称ogg)软件可以通过ORACLE官方网站进行下载,根据ORACLE的版本及操作系统来下载对应版本的ogg,官方下载地址:
.

ogg安装非常简单,一般使用oracle数据库安装时的用户安装ogg软件。需在源数据库和目标数据库服务器上运行以下步骤:
1.上传文件fbo_ggs_Linux_x64_ora11g_64bit.tar 到两台数据库服务器的/home/oracle目录下面
su - oracle
mkdir ogg
mv fbo_ggs_Linux_x64_ora11g_64bit.tar ./ogg
cd  ogg
tar xf fbo_ggs_Linux_x64_ora11g_64bit.tar

2、 进入/oracle/ogg目录,运行./ggsci,进入ogg管理控制台在ogg控制台输入命令:
# GGSCI (localhost.localdomain) 1> create subdirs
 --让ogg创建其需要用到的目录 
生成的相关目录及运行程序说明:
Parameter files                /home/oracle/ogg/11.2/dirprm -- 参数文件保存
                          目录,如MGR管理进程
Report files                   /home/oracle/ogg/11.2/dirrpt -- 报告文件保存
                           目录,OGG主要诊断手段之一,使用view report
                           #GroupName查看报告
Checkpoint files               /home/oracle/ogg/11.2/dirchk -- 由Extract(抽
                           取)或Replicat(应用)进程产生对应的CHECKPOINT文
                           件,记录当前读写的位置
Process status files           /home/oracle/ogg/11.2/dirpcs -- 进程状态文件
                            保存目录,记录当前运行进程的状态,进程名以大写
                            显示扩展名为pcm表示管理进程,pcr表示replicat进
                            程,pce表示为extract进程
SQL script files               /home/oracle/ogg/11.2/dirsql -- SQL脚本保存
                           目录
Database definitions files     /home/oracle/ogg/11.2/dirdef -- 由DEFGEN生成
                             的数据库结构定义文件保存目录,主要用于异构数据
                             库
Extract data files             /home/oracle/ogg/11.2/dirdat -- TRAIL文件和
                           Extract(抽取)进程产生的文件默认目录
Temporary files                /home/oracle/ogg/11.2/dirtmp -- 由CACHE管理
                           器分配,用于保存事务数据的目录
Stdout files                   /home/oracle/ogg/11.2/dirout -- 未使用,一般
                           用于DISCARD文件保存

GGSCI> exit  //退出ogg管理控制台

3、 mkdir  discard  //手工在ogg目录下创建discard文件夹,
通过上述步骤,ogg就安装成功了。

4、 配置操作系统环境变量(请确保环境变量配置了ORACLE_HOME和ORACLE_SID)
$ vi ~/.bash_profile
      export LD_LIBRARY_PATH=/home/oracle/ogg:$ORACLE_HOME/lib
$ source ~/.bash_profile  //生效配置

 5.  配置环境变量NLS_LANG(不配置中文同步会乱码,一般在安装oracle时已经配置)
  首先在oracle中查询
   select userenv( 'language') from dual;
  然后将查询的结果配置到linux环境变量中
  如export NLS_LANG=” SIMPLIFIED CHINESE_CHINA.ZHS16GBK”

6 在两台数据库服务器上运行如下sql语句,建立ogg数据库用户。
sqlplus / as sysdba
CREATE USER ogg IDENTIFIED BY geogg default tablespace users temporary tablespace temp;
GRANT UNLIMITED TABLESPACE TO ogg;
GRANT CONNECT TO ogg;
GRANT RESOURCE TO ogg;
GRANT DBA TO ogg;

进入ogg控制台,测试用户是否成功登录数据库
GGSCI> dblogin userid ogg Password geogg
Successfully logged into database.
GGSCI>exit

7 双向复制的配置
ogg相关进程的一些概念:
 Manager:ogg所有服务必须依赖Manager,Manger如同ogg的总调度。
 Extract :ogg用来获取源数据库数据更新的,将变更的数据发送到目标数据库
 Replicat :ogg用来接收源数据库的更新,一旦源数据库Extract将数据发送过来后,Replicat会自动将更新脚本同步到目标数据库。

3.1 源和目的数据库服务器均进行如下配置
# su - oracle
# mkdir /opt/oracle/archivelog         //建立新的归档日志存储位置   
1、开启ORACLE归档模式,设置日志模式
[oracle@local ~]$ sqlplus / as sysdba

SQL> shutdown immediate;

SQL> startup mount;

SQL> alter database archivelog;

SQL> alter database force logging;

SQL> alter database add supplemental log data;
  当数据库启用了补充日志(supplemental logging),每一条update 语句写redo 的时候会附加列值唯一信息
 1. 如果表定义了主键,则主键值会随同被更新列一起做为update 语句的一部分,以便执行时区别哪些列应该被更新。
 2. 如果没有主键,则非空的唯一索引/约束会随同被更新列做为update 语句的一部分,以便执行时区分哪些列应该被更新,如果该表有多个唯一索引/约束,则oracle 自动选择最短的那个。
 3. 如果表即无主键,也没有定义唯一索引/约束,所有可定长度的列连同被更新列作为update 语句的一部分。更明确的话,可定长度的列是指那些除:long,lob,long raw,object type,collection 类型外的列。(停止supplemental log的命令
SQL> alter database drop supplemental log data)
某个表上的列数量较多时且没有主键或唯一索引和非空约束的情况下,开启补全日志可能导致重做日志总量大幅提高。

 回收站功能会影响同步,需要关闭回收站(11g以后版本可以允许)

SQL>alter session set recyclebin=off;

SQL>alter system set recyclebin=off DEFERRED;

调整归档日志存储位置
SQL> alter database flashback off;
SQL> alter system set db_recovery_file_dest='';
SQL> alter system set log_archive_dest_1='location=/opt/oracle/archivelog';              
SQL> shutdown immediate
SQL> startup
 
检查各项设置是否正确  
SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;
SQL> archive log list;
SQL> show parameter recyclebin
SQL> show parameter arch
SQL> select FLASHBACK_ON from v$database;

归档日志维护(非常重要,否则数据库日志区一旦满,数据库会停止工作)
在删除归档日志后,必须用RMAN维护控制文件,否则空间显示仍然不释放。删除截止到前一天的所有archivelog,加入以下内容.
# vi /hoem/oracle/rman.cmd
connect target /
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog all completed before 'SYSDATE - 1';

vi /hoem/oracle/rman.sh
#!/bin/bash
cd /home/oracle/
rman cmdfile=rman.cmd msglog=rman.log

chmod 744 /hoem/oracle/rman.cmd /hoem/oracle/rman.sh

# crontab -e 加入以下内容:
0 1 * * * /home/oracle/rman.sh > /dev/null 2>&1

在ogg的安装目录下登陆sqlplus,使用sys登陆sqlplus,然后执行如下配置
[oracle@local ~]$ sqlplus / as sysdba
SQL> @marker_setup.sql  //配置DDL复制。输入 GoldenGate数据库用户 :ogg
SQL> @ddl_setup.sql   //配置DDL复制。输入 GoldenGate数据库用户 :ogg
SQL> @role_setup.sql
SQL> grant GGS_GGSUSER_ROLE to ogg;
SQL> @ddl_enable.sql
SQL> exit

4、登陆ogg控制台,设置需要进行同步GEDB用户的表

GGSCI (local) 1> dblogin userid ogg Password geogg

GGSCI (local) 1> add trandata GEDB.*

5、配置ogg manager&启动manager(配置界面操作类似vi)

GGSCI (local) 1> edit param mgr

PORT 7809
DYNAMICPORTLIST 7809-7909
AUTOSTART ER *
AUTORESTART ER *, WAITMINUTES 2, RETRIES 5
PURGEOLDEXTRACTS ./dirdat/*,usecheckpoints
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45

MANAGER进程参数配置说明:
PORT:指定服务监听端口,默认端口为7809
DYNAMICPORTLIST:动态端口:可以制定最大256个可用端口的动态列表,当指定的端
         口不可用时,管理进程将会从列表中选择一个可用的端口,源端和目标段的
         Collector、Replicat、GGSCI进程通信也会使用这些端口;
COMMENT:注释行,也可以用--来代替;
AUTOSTART:指定在管理进程启动时自动启动哪些进程;
AUTORESTART:自动重启参数设置:本处设置表示每3分钟尝试重新启动所有EXTRACT进程,共尝试5次;
PURGEOLDEXTRACTS:usecheckpoints: Use USECHECKPOINTS to
                  purge when all processes are finished with a file as
                  indicated by checkpoints.
                  minkeepdays 3:设置表示对于超过3天的trail文件进行删除。
LAGREPORT、LAGINFO、LAGCRITICAL:
定义数据延迟的预警机制:本处设置表示MGR进程每隔1小时检查EXTRACT的延迟情况,如果超过了30分钟就把延迟作为信息记录到错误日志中,如果延迟超过了45分钟,则把它作为警告写到错误日志中。

GGSCI (local) 1> info all   (查看当前mgr状态)
GGSCI (local) 1> start manager
(启动manager,启动完后可以用info all再次查看状态)

6、 添加一个ogg extract进程,用于抽取源服务器数据

GGSCI (local) 1> add extract ext1,tranlog,begin now
 (增加一个抽取进程ext1,ext1名字可以根据需要修改)

GGSCI (local) 1> add exttrail /home/oracle/ogg/dirdat/wf,extract ext1,megabytes 100
(将ext1抽取的源数据变更数据写到该文件夹。Megabytes:指定队列大小,本处设置表示100M)

GGSCI (local) 1> edit params ext1 (修改ext1的配置参数)

extract ext1
userid ogg,password geogg
rmthost <对端服务器ip>,mgrport 7809
rmttrail /home/oracle/ogg/dirdat/wf
TRANLOGOPTIONS EXCLUDEUSER ogg        
ddl include all;

GGSCI (local) 1>info ext1              --查看到新添加的extract的状态

EXTRACT进程参数配置说明:
SETENV:配置系统环境变量
USERID/ PASSWORD: 指定OGG连接数据库的用户名和密码,这里使用3.4部分中创建的数据库用户OGG;
COMMENT:注释行,也可以用--来代替;
TABLE:定义需复制的表,后面需以;结尾
TABLEEXCLUDE:定义需要排除的表,如果在TABLE参数中使用了通配符,可以使用该参数指定排除掉得表。
GETUPDATEAFTERS|IGNOREUPDATEAFTERS:
是否在队列中写入后影像,缺省复制
GETUPDATEBEFORES| IGNOREUPDATEBEFORES:
是否在队列中写入前影像,缺省不复制
GETUPDATES|IGNOREUPDATES:
是否复制UPDATE操作,缺省复制
GETDELETES|IGNOREDELETES:
是否复制DELETE操作,缺省复制
GETINSERTS|IGNOREINSERTS:
是否复制INSERT操作,缺省复制
GETTRUNCATES|IGNORETRUNDATES:
是否复制TRUNCATE操作,缺省不复制;
RMTHOST:指定目标系统及其Goldengate Manager进程的端口号,还用于定义是否使用压缩进行传输,本例中的compress为压缩传输;
RMTTRAIL:指定写入到目标断的哪个队列;
EXTTRAIL:指定写入到本地的哪个队列;
SQLEXEC:在extract进程运行时首先运行一个SQL语句;
PASSTHRU:禁止extract进程与数据库交互,适用于Data Pump传输进程;
REPORT:定义自动定时报告;
STATOPTIONS:定义每次使用stat时统计数字是否需要重置;
REPORTCOUNT:报告已经处理的记录条数统计数字;
TLTRACE:打开对于数据库日志的跟踪日志;
DISCARDFILE:定义discardfile文件位置,如果处理中油记录出错会写入到此文件中;
DBOPTIONS:指定对于某种特定数据库所需要的特殊参数;
TRANLOGOPTIONS:指定在解析数据库日志时所需要的特殊参数,例如:对于裸设备,可能需要加入以下参数 rawdeviceoggset 0;EXCLUDEUSER 将同步用户进行排除,避免双向复制时循环,
WARNLONGTRANS:指定对于超过一定时间的长交易可以在gsserr.log里面写入警告信息,本处配置为每隔3分钟检查一次场交易,对于超过2小时的进行警告;

7、启动ogg extract命令 (最好等目标服务器ogg配置成功后再启动ext)

GGSCI (local) 1> start extract ext1 (等目标服务器ogg配置成功后再启动ext)

8、 添加一个ogg replicat进程,用于更新目标服务器数据

GGSCI (local) 1> edit params ./GLOBAL

GSSCHEMA OGG
CHECKPOINTTABLE OGG.checkpoint

GGSCI (local) 2> dblogin userid ogg Password geogg

GGSCI (local) 3> add checkpointtable ogg.checkpoint

GGSCI (local) 4> ADD replicat rep1 EXTTRAIL /home/oracle/ogg/dirdat/wf, checkpointtable ogg.checkpoint

GGSCI (local) 5> edit param rep1

replicat rep1
ASSUMETARGETDEFS
userid ogg, password geogg
handlecollisions
discardfile /home/oracle/ogg/discard/rep1_discard.txt, append, megabytes 10
DDL INCLUDE ALL
DDLERROR DEFAULT IGNORE RETRYOP
map gedb.*, target gedb.*;

GGSCI (local) 5>start replicat rep1
配置完成后可以通过info all查看到新添加的进程的状态
REPLICAT 进程参数配置说明:
ASSUMETARGETDEFS:假定两端数据结构一致使用此参数;
SOURCEDEFS:假定两端数据结构不一致,使用此参数指定源端的数据结构定义文件,
            该文件需要由GlodenGate工具产生。
MAP:用于指定源端与目标端表的映射关系;
MAPEXCLUDE:用于在MAP中使用*匹配时排除掉指定的表;
REPERROR:定义出错以后进程的响应,一般可以定义为两种:
         ABEND,即一旦出现错误即停止复制,此为缺省配置;
         DISCARD,出现错误后继续复制,只是把错误的数据放到discard文件中。
DISCARDFILE:定义discardfile文件位置,如果处理中油记录出错会写入到此文件
             中;
SQLEXEC:在进程运行时首先运行一个SQL语句;
GROUPTRANSOPS:将小交易合并成一个大的交易进行提交,减少提交次数,降低系统IO
               消耗。
MAXTRANSOPS:将大交易拆分,每XX条记录提交一次。
HANDLECOLLISIONS:使用该参数时,即使目标数据库环境中存在
                  数据完整性问题(如 update、delete 操作遇到缺失行或重复的
                  插入操作),replicat 进程仍然能够继续处理 trail 中的数
                  据。如果使用了 HANDLECOLLISIONS 参数,则 replicat 进程将
                  按如下方式处理数据:
                  Missing updates are ignored.
                  Missing deletes are ignored.
                  Duplicate inserts are turned into updates.

4、启动ogg manager ,replicat命令

GGSCI (local) 1> start manager

GGSCI (local) 1> start replicat rep1

4 维护相关
4.1 OGG常用命令
1、  启动manager:start manager

2、  启动extract:start extract extn

3、  启动replicat:start replicat repn

4、  停止manager:stop manager

5、  停止 extract:stop extract extn

6、  停止replicat:stop replicat repn

7、  删除extract:delete extract extn

8、  删除replicat:delete extract repn

9、  查看ogg状态:info all

10、 修改manager参数:edit params mgr

11、 修改extract参数:edit params extn

12、 修改replicat参数:edit params repn

13、 修改全局参数:edit params ./GLOBAL
14   查看ext进程报告 view report ext1
15   查看ext进程  info extract ext1

4.2 OGG日志路径
$OGG_HOME/ggserr.log

4.3 OGG开机自启
操作系统设置:

 1、用oracle用户建立/home/oracle/ogg/startmgr.txt,文件内容如下:
    start mgr
    info all
    exit

  2、chmod 744 startmgr.txt

  3、用oracle用户建立/home/oracle/ogg/startmgr.sh,文件内如下:

     /home/oracle/ogg/ggsci paramfile /home/oracle/ogg/startmgr.txt > /home/oracle/ogg/startmgr.log

  4、chmod x startmgr.sh

  5、用root用户编辑 /etc/rc.local ,添加如下信息:

       su - oracle -c "/home/oracle/ogg/startmgr.sh"

4.4 告警信息处理
GoldenGate的Extract虽然提示OGG-01423告警,但却可以通过新的API成功访问到归档日志,因此可以忽略Extract的OGG-01423告警

DDL参数语法说明 
 在配置DDL复制时,需要在Extract 和Replicat 进程的配置文件里添加ddl属性。下面简要介绍下这个属性的常用参数,参考至《OGG Windows and UNIX Reference Guide》,
DDL语句包含的主要语法如下:
 DDL [
 {INCLUDE | EXCLUDE}
 [, MAPPED | UNMAPPED | OTHER | ALL]
 [, OPTYPE ]
 [, OBJTYPE ‘’]
 [, OBJNAME “”]
 [, INSTR ‘’]
 [, INSTRCOMMENTS ‘’]
 ]
 [...]
{INCLUDE | EXCLUDE}
 Use INCLUDE and EXCLUDE to identify the beginning of an inclusion or exclusion clause.
 (1)  An inclusion clause containsfiltering criteria that identifies the DDL that this parameter will affect.
 (2)  An exclusion clause containsfiltering criteria that excludes specific DDL from this parameter.
 The inclusion orexclusion clause must consist of the INCLUDE or EXCLUDE keyword followed by anyvalid combination of other options of the parameter that is being applied.
 If you use EXCLUDE, you must create acorresponding INCLUDE clause.
--如果要使用Exclude,那么必须先指定include。
For example, the following is invalid:
 DDL EXCLUDE OBJNAME  “hr.*”
--这种语法是错误的。
However, you can use either of thefollowing:
 DDL INCLUDE ALL,EXCLUDE OBJNAME “hr.*”
 DDL INCLUDE OBJNAME “fin.*”  EXCLUDE  “fin.ss”         --正确语法
An EXCLUDE takes priority over any INCLUDEs that contain the same criteria. You can use multipleinclusion and exclusion clauses.
[, MAPPED | UNMAPPED | OTHER | ALL]
 Use MAPPED, UNMAPPED,OTHER, and ALL to apply INCLUDE or EXCLUDE based on the DDL operation scope.
 1、MAPPED applies INCLUDE or EXCLUDE to DDL operations that are of MAPPED scope. MAPPED filtering is performed before filtering that is specified with other DDL parameter options.
 2、UNMAPPED applies INCLUDE or EXCLUDE to DDL operations that are of UNMAPPED scope.
 3、OTHER applies INCLUDE or EXCLUDE to DDL operations that are of OTHER scope.
 4、ALL applies INCLUDE or EXCLUDE to DDL operations of all scopes.

关于这四种scope的具体范围详见官方文档《OGG Windows and UNIX Reference Guide》
OPTYPE
 Use OPTYPE toapply INCLUDE or EXCLUDE to a specific type of DDL operation, such as CREATE, ALTER,and RENAME. For , use any DDL command that is valid for thedatabase.
 For example, to include ALTER operations,the correct syntax is:
 DDL INCLUDE OPTYPE ALTER
OBJTYPE‘
Use OBJTYPE to apply INCLUDE or EXCLUDE to a specific type of database object. For ,use any object type that is valid for the database, such as TABLE, INDEX, and TRIGGER.For an Oracle materialized view and materialized views log, the correct typesare snapshot and snapshot log, respectively. Enclose the name of the objecttype within single quotes.
 For example:
 DDL INCLUDE OBJTYPE ‘INDEX’
DDL INCLUDE OBJTYPE ‘SNAPSHOT’
For Oracle object type USER, do not use the OBJNAME option, because OBJNAME expects “owner.object” whereas USER only has aschema.
OBJNAME“
Use OBJNAME toapply INCLUDE or EXCLUDE to the fully qualified name of an object, for example owner.table_name.This option takes a doublequoted string as input. You can use a wildcard onlyfor the object name.
 Example:
 DDL INCLUDE OBJNAME “accounts.*”
Do not use OBJNAME for the Oracle USER object,because OBJNAME expects “owner.object” whereas USER only has a schema.
 When using OBJNAMEwith MAPPED in a Replicat parameter file, the value for OBJNAME must refer tothe name specified with the TARGET clause of the MAP statement. For example,given the following MAP statement, the correct value is OBJNAME “fin2.*”.
 MAP fin.exp_*,TARGET fin2.*;
 In the following example, a CREATE TABLE statementexecutes like this on the source:
 CREATE TABLE fin.exp_phone;
 And like this on the target:
 CREATE TABLE fin2.exp_phone;
 If a target owner is not specified in the MAP statement, Replicat maps it to the database user that is specified with the USERID parameter.
 For DDL that creates triggers, synonyms, and indexes, the value for OBJNAME must be the name of the base object, not the name of the trigger, synonym, or index.
 For example, to include the following DDL statement, the correct value is “hr.accounts,” not “hr.insert_trig.”
 CREATE TRIGGER hr.insert_trig ON hr.accounts;
 For RENAME operations,the value for OBJNAME must be the new table name. For example, to include the following DDL statement, the correct value is “hr.acct.”
 ALTER TABLE hr.accounts RENAME TO acct;
 The following is an example of how tocombine DDL parameter options.
  DDL    &
 INCLUDE UNMAPPED &
     OPTYPE alter &
     OBJTYPE ‘table’ &
     OBJNAME users.tab* &
 INCLUDE MAPPED OBJNAME * &
 EXCLUDE MAPPED OBJNAME temporary.tab"


GoldenGate 基本参数含义


1. edit params命令
2. DBLOGIN USERID , PASSWORD
 3. ADD TRANDATA命令
4. ADD EXTRACT 命令
5. ADD EXTTRAIL命令
6. EXTFILESOURCE 意思
7. ADD RMTTRAIL命令
8. ADD REPLICAT命令
9. PURGEOLDEXTRACTS
 10. AUTOSTART参数
11. DYNAMICRESOLUTION
 12. SOURCEDB
 13. PASSTHRU
 14. ASSUMETARGETDEFS
 15. REPERROR
 16. 使用通配符


(1) Overview of Extract
 The Extract process runs on the source system and is the capture mechanism of
 GoldenGate. You can configure Extract in one of the following ways:
 ● Initial loads: For initial data loads, Extract extracts a current set of data directly from
 their source objects.
 ● Change synchronization: To keep source data synchronized with another set of data,
 Extract extracts transactional changes made to data (inserts, updates, and deletes)
 after the initial synchronization has taken place. DDL changes and sequences are also
 extracted, if supported for the type of database being used.

 (2) Overview of Replicat
 The Replicat process runs on the target system. Replicat reads extracted data changes and
 DDL changes (if supported) that are specified in the Replicat configuration, and then it
 replicates them to the target database. You can configure Replicat in one of the following
 ways:

 (3) Overview of trails
 To support the continuous extraction and replication of supported database changes,
 GoldenGate stores those changes temporarily on disk in a series of files called a trail. A
 trail can exist on the source or target system, or on an intermediary system, depending on
 how you configure GoldenGate. On the local system it is known as an extract trail (or local
 trail). On a remote system it is known as a remote trail.

 By using a trail for storage, GoldenGate supports data accuracy and fault tolerance (see
“Overview of checkpoints” on page 28). The use of a trail also allows extraction and
 replication activities to occur independently of each other. With these processes separated,
 you have more choices for how data is delivered. For example, instead of extracting and
 replicating changes continuously, you could extract changes continuously but store them
 in the trail for replication to the target later, whenever the target application needs them.



 1. edit params命令
==================
Use EDIT PARAMS to create or change a parameter file. By default,
 this command launches Microsoft Notepad on Windows or the vi editor
 on UNIX systems. You can change the editor with the SET EDITOR
 command.

 Syntax:
 EDIT PARAMS {MGR | | }

 MGR
 Opens a parameter file for the Manager process.

 
 Opens a parameter file for the specified Extract or Replicat group.

 
 Opens the specified file. Use the full path name.

 Example 1: EDIT PARAMS finance
 Example 2: EDIT PARAMS c:\lpparms\replp.prm


 GGSCI (testdb11.zhyhl.com) 6>


 PORT
 PORT defines the port number on which Manager runs on the local system. The default port
 is 7809. You must specify either the default port or another port. The port must be
 unreserved and unrestricted. GGSCI uses this port to request Manager to start processes.
 The Extract process uses this port to request Manager to start a remote Collector process
 or an initial-load Replicat process. PORT is the only required Manager parameter.


 Autostart parameters
 Use the AUTOSTART parameter to start Extract and Replicat processes when Manager starts.
 This can be useful, for example, if you want GoldenGate activities to begin immediately
 when you start the system, assuming Manager is part of the startup routine. You can use
 multiple AUTOSTART statements in the same parameter file.
 AUTOSTART {ER | EXTRACT | REPLICAT} {group name | wildcard}

 Use the AUTORESTART parameter to start Extract and Replicat processes again after
 abnormal termination.
 AUTORESTART {ER | EXTRACT | REPLICAT} {group name | wildcard}
 [, RETRIES ]
 [, WAITMINUTES ]
 [, RESETMINUTES ]



 2. DBLOGIN USERID , PASSWORD
 =============================================

 dblogin userid test,password test

 DBLOGIN USERID , PASSWORD
 Where: is a database user who has privilege to create triggers or enable tablelevel
 supplemental logging, and is that user’s password.


 3. ADD TRANDATA命令
===================

Use the ADD TRANDATA command in GGSCI to configure the database to log the key values
 whenever it logs a row change, so that they are available to GoldenGate in the redo record.
 By default, the database only logs column values that are changed.

 ADD TRANDATA must be performed before you start GoldenGate processing.


 add trandata test.*

 To capture key values with ADD TRANDATA
 ADD TRANDATA

[, COLS ] [, NOKEY] [, USETRIGGER]

 Where:
 ?

is the owner and name of the table. You can use a wildcard for the table
 name but not the owner name.
 ? COLS logs non-key columns that are specified with KEYCOLS.
 ? NOKEY prevents the logging of the primary key or unique key. Requires using a
 KEYCOLS clause in TABLE or MAP and logging the KEYCOLS columns with COL.
 ? USETRIGGER forces GoldenGate to install an update trigger instead of a supplemental
 log group. Required only if 8i compatibility is enabled on a 9i or later database.


 4. ADD EXTRACT 命令
===================

add extract extzq, tranlog, begin now


解释:
Use ADD EXTRACT to create an Extract group. Unless a SOURCEISTABLE
 task is specified, this command creates checkpoints so that
 processing continuity is maintained from run to run.

 ADD EXTRACT
 {, SOURCEISTABLE |
    , GGSLOG |
    , TRANLOG [bsds name> |
    , VAM |
    , EXTFILESOURCE |
    , EXTTRAILSOURCE |
    , VAMTRAILSOURCE }
 {, BEGIN |
    , EXTSEQNO , EXTRBA |
    , LOGNUM , LOGPOS |
    , LSN |
    , EXTRBA |
    , EOF | LSN |
    , PAGE , ROW }
 [, THREADS ]
 [, PASSIVE]
 [, PARAMS ]
 [, REPORT ]
 [, DESC  ]


 TRANLOG
 Specifies the transaction log as the data source. Use this option
 for log-based extraction. TRANLOG requires either the BEGIN or EXTSEQNO
 and EXTRBA options.


 The following are service options:

 BEGIN
 Specifies a timestamp in the data source at which to begin processing.
 Valid values:
 * NOW
 * A date and time in the format of:
   yyyy-mm-dd [hh:mi:[ss[.cccccc]]]


 Example 2:
 The following creates an Extract group named  finance  that extracts
 database changes from the transaction logs. Extraction starts with
 records generated at the time when the group was created.

 ADD EXTRACT finance, TRANLOG, BEGIN NOW



 5. ADD EXTTRAIL命令
====================

add exttrail  /home/test/ggs95/dirdat/zq,extract extzq,megabytes 50

 Use ADD EXTTRAIL to create a trail for online processing on the local
 system and:
 * Associate it with an Extract group.
 * Assign a maximum file size.

 Syntax:
 ADD EXTTRAIL , EXTRACT [,MEGABYTES ]

 
 The fully qualified path name of the trail. The actual trail name
 can contain only two characters. GoldenGate appends this name with
 a six-digit sequence number whenever a new file is created. For
 example, a trail named /ggs/dirdat/tr would have files named
 /ggs/dirdat/tr000001, /ggs/dirdat/tr000002, and so forth.

 
 The name of the Extract group to which the trail is bound. Only
 one Extract process can write data to a trail.

 MEGABYTES
 The maximum size, in megabytes, of a file in the trail. The
 default is 10.

 Example: ADD EXTTRAIL c:\ggs\dirdat\aa, EXTRACT finance, MEGABYTES 20


 6. EXTFILESOURCE 意思
================================

add extract dpezq,exttrailsource /home/test/ggs95/dirdat/zq

 EXTFILESOURCE
 Specifies an extract file as the data source. Use this option with a
 secondary Extract group (data pump) that acts as an intermediary
 between a primary Extract group and the target system. For ,
 specify the fully qualified path name of the file, for example
 c:\ggs\dirdat\extfile.


 7. ADD RMTTRAIL命令
===================

add rmttrail  d:\ggs95\dirdat\zq ,extract dpezq,megabytes 50

 Use ADD RMTTRAIL to create a trail for online processing on a remote
 system and:
 * Associate it with an Extract group.
 * Assign a maximum file size.

 In the parameter file, specify a RMTHOST entry before any RMTTRAIL
 entries to identify the remote system and TCP/IP port for the Manager
 process.

 Syntax:
 ADD RMTTRAIL , EXTRACT [, MEGABYTES ]

 
 The fully qualified path name of the trail. The actual trail name can
 contain only two characters. GoldenGate appends this name with a six-
 digit sequence number whenever a new file is created. For example, a
 trail named /ggs/dirdat/tr would have files named /ggs/dirdat/tr000001,
 /ggs/dirdat/tr000002, and so forth.

 
 The name of the Extract group to which the trail is bound. Only one
 Extract process can write data to a trail.

 MEGABYTES
 The maximum size, in megabytes, of a file in the trail. The default
 is 10.

 Example: ADD RMTTRAIL c:\ggs\dirdat\aa, EXTRACT finance, MEGABYTES 20



 8. ADD REPLICAT命令
===================

add replicat repzq, exttrail /home/gdora/ggs/dirdat/rt, nodbcheckpoint, begin now

 Use ADD REPLICAT to create a Replicat group. Unless a special run is
 specified, ADD REPLICAT creates checkpoints so that processing
 continuity is maintained from run to run. See the GoldenGate
 Operations Guide for Windows and UNIX for procedures that include
 creating Replicat groups.

 Syntax:
 ADD REPLICAT
 {, SPECIALRUN |
    , EXTFILE |
    , EXTTRAIL }
 [, BEGIN |
    , EXTSEQNO , EXTRBA ]
 [, CHECKPOINTTABLE | NODBCHECKPOINT]
 [, PARAMS ]
 [, REPORT ]
 [, DESC  ]

 
 The name of the Replicat group. Follow these naming conventions:
 * You can use up to eight ASCII characters, including nonalphanumeric
   characters such as the underscore (_). Any ASCII character can be
   used, so long as the operating system allows that character to be
   in a filename. This is because a group is identified by its
   associated checkpoint file.
 * Group names are not case-sensitive.
 * Use only one word.
 * Do not use the word  port  as a group name. However, you can use
   the string  port  as part of the group name.
 * Do not place a numeric value at the end of a group name, such as
   fin1, fin10, and so forth. You can place a numeric value at the
   beginning of a group name, such as 1_fin, 1fin, and so forth.
    ext_1
    ex+2t
    ex!2t


 EXTTRAIL
 Specifies a trail that was created with the ADD RMTTRAIL or ADD
 EXTTRAIL command.

 NODBCHECKPOINT
 Specifies that this Replicat group will not write checkpoints to a
 checkpoint table. This argument overrides the default CHECKPOINTTABLE
 specification in the GLOBALS file.



 9. PURGEOLDEXTRACTS
 ===================

 Trail maintenance parameter

 Use the PURGEOLDEXTRACTS parameter in a Manager parameter file to purge trail files when
 GoldenGate has finished processing them. Without using PURGEOLDEXTRACTS, no purging is
 performed, and trail files can consume significant disk space.
 Using PURGEOLDEXTRACTS as a Manager parameter is preferred over using the Extract or
 Replicat version of PURGEOLDEXTRACTS. As a Manager parameter, PURGEOLDEXTRACTS allows
 you to manage trail files in a centralized fashion and take into account multiple processes.
 NOTE When using this parameter, do not permit trail files to be deleted by any user or
 program other than GoldenGate. It will cause PURGEOLDEXTRACTS to function
 improperly


 purgeoldextracts /home/gdora/ggs/dirdat/*, usecheckpoints, minkeepdays 2


 Use USECHECKPOINTS to purge when all processes are finished with a file as indicated by
 checkpoints.

 Use the MINKEEP rules to set a minimum amount of time to keep unmodified data:
 ? Use MINKEEPHOURS or MINKEEPDAYS to keep data for hours or days.




 10. AUTOSTART参数
=================

To auto-start a process
 ● Use AUTOSTART in the Manager parameter file to start one or more processes when
 Manager starts.
 ● Use AUTORESTART in the Manager parameter file to restart a process after a failure.
 Both of these parameters reduce the need to start a process manually with the START
 command.


 Syntax AUTOSTART

  Specify one of the following:
 EXTRACT
 REPLICAT
 ER (Extract and Replicat)

  A group name or wildcard specification for multiple groups. When wildcarding
 is used, GoldenGate starts all groups of the specified that satisfy
 the wildcard on the local system, except those in PASSIVE mode.


 Example AUTOSTART ER *



 11. DYNAMICRESOLUTION
 =====================

 DYNAMICRESOLUTION | NODYNAMICRESOLUTION

 Valid for Extract and Replicat
 Use the DYNAMICRESOLUTION and NODYNAMICRESOLUTION parameters to control how table
 names are resolved.

 Use DYNAMICRESOLUTION to make processing start sooner when there is a large number of
 tables specified in TABLE or MAP statements. By default, whenever a process starts,
 GoldenGate queries the database for the attributes of the tables and then builds an object
 record for them. The record is maintained in memory and on disk, and the process of
 building it can be time-consuming if the database is large.

 DYNAMICRESOLUTION causes the object record to be built one table at a time, instead of all at
 once. A table’s attributes are added to the record the first time its object ID enters the
 transaction log, which occurs with the first extracted transaction on that table. Recordbuilding
 for other tables is deferred until activity occurs. DYNAMICRESOLUTION is the same as
 WILDCARDRESOLVE DYNAMIC.

 NODYNAMICRESOLUTION causes the object record to be built at startup. This option is not
 supported for Teradata. NODYNAMICRESOLUTION is the same as WILDCARDRESOLVE IMMEDIATE.
 For more information about WILDCARDRESOLVE, see page 368.

 Default DYNAMICRESOLUTION
 Syntax DYNAMICRESOLUTION



 12. SOURCEDB
 ============

 Valid for Manager, Extract, DEFGEN, and DDLGEN
 Use the SOURCEDB parameter for databases that require a data source name as part of the
 connection information. Tables specified in TABLE statements that follow SOURCEDB are
 assumed to be from the specified data source.

其实是不管用,而且还会报错说不识别该参数

13. PASSTHRU
 ============

 data-pump模式有的两种选择: PASSTHRU and NOPASSTHRU
 PASSTHRU: 不与数据库交互,前提是源库与目标库objects必须一致。

Use the PASSTHRU and NOPASSTHRU parameters to control whether a data-pump Extract
 processes tables in pass-through mode or normal mode. In pass-through mode, the Extract
 process does not look up table definitions, either from the database or from a datadefinitions
 file. Normally, the Extract process logs into the database to retrieve data
 definitions and, if the target is NonStop, reads a data-definitions file. The definitions are
 used to perform mapping and conversion functions.


 To use PASSTHRU mode, the names of the source and target objects must be
 identical. No column mapping, filtering, SQLEXEC functions, transformation, or other
 functions that require data manipulation can be specified in the parameter file. You
 can combine normal processing with pass-through processing by pairing PASSTHRU
 and NOPASSTHRU with different TABLE statements.


 14. ASSUMETARGETDEFS
 =====================

不查询主库的表结构信息,前提是:使用MAP statement时,原库和目标库的表的字段结构必须一致。


Valid for Replicat
 Use the ASSUMETARGETDEFS parameter when the source and target tables specified with a
 MAP statement have identical column structure, such as when synchronizing a hot site. It
 directs GoldenGate not to look up source structures from a source-definitions file.

 For structures to be identical, they must contain identical column names (including case,
 if applicable) and data types, and they must appear in the same order in each table. If
 source and target tables do not have the same structure, use the SOURCEDEFS parameter
 instead of ASSUMETARGETDEFS. See “SOURCEDEFS” on page 291.
 Default None
 Syntax ASSUMETARGETDEFS


 15. REPERROR
 ============

 REPERROR
 Valid for Replicat
 Use the REPERROR parameter to control how Replicat responds to errors. You can use one
 REPERROR statement to handle most errors in a default manner, while using one or more
 other REPERROR statements to handle specific errors differently. For example, you can ignore
 duplicate-record errors but abort processing in all other cases.


 DEFAULT Sets a global response to all errors except those for which explicit
 REPERROR statements are specified.

 DISCARD Log the error to the discard file but continue processing the transaction
 and subsequent transactions.


 DISCARDFILE
 Valid for Extract and Replicat
 Use the DISCARDFILE parameter to generate a discard file to which GoldenGate can log
 records that it cannot process. Records can be discarded for several reasons. For example,
 a record is discarded if the underlying table structure changed since the record was written
 to the trail. You can use the discard file to help you identify the cause of processing errors.
 Each entry in the discard file contains the discarded record buffer and an error code
 indicating the reason. GoldenGate creates the specified discard file in the dirrpt subdirectory
 of the GoldenGate installation directory. You can view it with a text editor or by
 using the following command in GGSCI.
 VIEW REPORT
 Where: is the fully qualified name of the discard file.


 GoldenGate creates the specified discard file in the dirrpt subdirectory
 of the GoldenGate installation directory.
 /* discard file的存放路径 */

APPEND Adds new content to existing content if the file already exists.

 MEGABYTES Sets the maximum size of the file in megabytes. The valid range is from 1
 to 2147. The default is 1 MB.


 16. 使用通配符
==============
Using wildcards in command arguments
 You can use wildcards with certain GoldenGate commands to control multiple Extract and
 Replicat groups as a unit. The wildcard symbol that is supported by GoldenGate is the
 asterisk (*). An asterisk represents any number of characters. For example, to start all
 Extract groups whose names contain the letter X, issue the following command.
 START EXTRACT *X*

阅读(2337) | 评论(0) | 转发(0) |
0

上一篇:linux lsof详解

下一篇:没有了

给主人留下些什么吧!~~