正确启动数据库
源端启动数据库
SQL> startup
源端启动goldengate
GGSCI > start mgr
GGSCI > start *
目标端启动数据库
SQL> startup
目标端启动goldengate
GGSCI > start mgr
GGSCI > start *
正确关闭数据库
源端关闭GoldenGate和数据库
源端关闭GoldenGate
GGSCI > info all 可以查看进程的各种状态(关于各状态的说明,见后面)
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING DPE_OE 00:00:00 00:00:05
EXTRACT RUNNING EXT_OE 00:00:00 00:00:08
GGSCI > stop *
Sending STOP request to EXTRACT DPE_OE ... 先停止datapump进程
Request processed.
Sending STOP request to EXTRACT EXT_OE ... 后停止capture进程
Request processed.
GGSCI > stop mgr 最后手工执行goldengate守护进程
Manager process is required by other GGS processes.
Are you sure you want to stop it (y/n)? y
Sending STOP request to MANAGER ...
Request processed.
Manager stopped.
GGSCI > info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
EXTRACT STOPPED DPE_OE 00:00:00 00:00:29
EXTRACT STOPPED EXT_OE 00:00:00 00:00:29
关闭GoldenGate后,进程的状态应该是STOPPED
源端关闭数据库
SQL> shutdown immediate
目标端关闭GoldenGate和数据库
目标端关闭GoldenGate
GGSCI > info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING DPE_OE 00:00:00 00:00:05
EXTRACT RUNNING EXT_OE 00:00:00 00:00:08
GGSCI > stop *
Sending STOP request to EXTRACT DPE_OE ... 先停止datapump进程
Request processed.
Sending STOP request to EXTRACT EXT_OE ... 后停止capture进程
Request processed.
GGSCI > stop mgr 最后手工执行goldengate守护进程
Manager process is required by other GGS processes.
Are you sure you want to stop it (y/n)? y
Sending STOP request to MANAGER ...
Request processed.
Manager stopped.
GGSCI > info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
REPLICAT RUNNING REP_OE 00:00:00 00:00:07
目标端关闭数据库
SQL> shutdown immediate
附start/stop (stop用法和start一样)命令的一般用法
GGSCI > start <进程名称>
如:GGSCI> start ext_hq 启动一个名叫ext_hq的进程;
也可以使用通配符,如:GGSCI> start er * 启动所有的extract和replicat进程;
GGSCI> start * 启动除MGR以外的所有的进程
GGSCI> start extract *d* 启动所有的包含字符‘d’extract进程;
GGSCI> start replicat rep* 启动所有以“rep“开头的replicat进程
注意,如果是只修改抽取或者复制进程参数,则不需要停止MGR。不要轻易停止MGR进程,并且慎重使用通配符er *, 以免对其他复制进程造成不利影响。
查看整体运行情况
GGSCI (hncdfdb1) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING DPE_HQ 00:00:00 00:00:06
EXTRACT RUNNING EXT_HQ 00:00:00 00:00:06
Group表示进程的名称(MGR进程不显示名字);Lag表示进程的延时;Status表示进程的状态。有四种状态:
STARTING 正在启动过程中
RUNNING 正常运行
STOPPED 正常停止或未能启动
ABENDED 异常中断,需要通过以下命令查看报告,找出出错原因
正常情况下,所有进程的状态应该为RUNNING,且Lag应该在一个合理的范围内。
查看进程状态
GGSCI > info <进程名称> 此命令可以查看进程信息,可以查看到的信息包括进程状态、checkpoint信息、延时等。
GGSCI (test-gg) 138> info rep_hq
REPLICAT REP_HQ Last Started 2014-07-01 15:22 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:06 ago)
Log Read Checkpoint File ./dirdat/d1000016
2014-07-01 15:33:44.412776 RBA 111261210
GGSCI > info <进程名称> detail 此命令查看更详细的信息。包括所使用的trail文件,参数文件、报告文件、警告日志的位置等。
GGSCI (test-gg) 142> info rep_hq detail
REPLICAT REP_HQ Last Started 2014-07-01 15:22 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:09 ago)
Log Read Checkpoint File ./dirdat/d1000016
2014-07-01 15:37:42.499365 RBA 111280166
Extract Source Begin End
./dirdat/d1000016 2014-07-01 15:22 2014-07-01 15:37
./dirdat/d1000016 2014-07-01 15:03 2014-07-01 15:22
./dirdat/d1000012 2014-07-01 15:03 2014-07-01 15:03
./dirdat/d1000012 2014-07-01 15:02 2014-07-01 15:03
./dirdat/d1000012 2014-07-01 14:54 2014-07-01 15:02
./dirdat/d1000011 2014-07-01 14:48 2014-07-01 14:54
./dirdat/d1000010 2014-07-01 14:47 2014-07-01 14:48
./dirdat/d1000010 2014-07-01 14:34 2014-07-01 14:47
./dirdat/d1000007 2014-07-01 14:33 2014-07-01 14:34
./dirdat/d1000007 2014-07-01 14:32 2014-07-01 14:33
./dirdat/d1000007 2014-07-01 14:09 2014-07-01 14:32
./dirdat/d1000006 2014-07-01 13:36 2014-07-01 14:09
./dirdat/d1000000 2014-07-01 13:11 2014-07-01 13:36
./dirdat/d1000000 2014-07-01 13:09 2014-07-01 13:11
./dirdat/d1000000 2014-07-01 13:09 2014-07-01 13:09
./dirdat/d1000000 2014-07-01 13:09 2014-07-01 13:09
./dirdat/d1000000 * Initialized * 2014-07-01 13:09
./dirdat/d1000000 * Initialized * First Record
Current directory /oradb/goldengate
Report file /oradb/goldengate/dirrpt/REP_HQ.rpt
Parameter file /oradb/goldengate/dirprm/rep_hq.prm
Checkpoint file /oradb/goldengate/dirchk/REP_HQ.cpr
Checkpoint table goldengate.rep_hq_checkpoint
Process file /oradb/goldengate/dirpcs/REP_HQ.pcr
Stdout file /oradb/goldengate/dirout/REP_HQ.out
Error log /oradb/goldengate/ggserr.log
GGSCI > info <进程名称> showch 命令可以查看到详细的关于checkpoint的信息,用于查看GoldenGate进程处理过的事务记录。其中比较重要的是extract进程的recovery checkpoint,它表示源数据中最早的未被处理的事务;通过recovery checkpoint可以查看到该事务的redo log位于哪个日志文件以及该日志文件的序列号。所有序列号比它大的日志文件,均需要保留。
GGSCI (test-gg) 143> info rep_hq showch
REPLICAT REP_HQ Last Started 2014-07-01 15:22 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:04 ago)
Log Read Checkpoint File ./dirdat/d1000016
2014-07-01 15:40:30.398558 RBA 111290983
Current Checkpoint Detail:
Read Checkpoint #1
GGS Log Trail
Startup Checkpoint (starting position in the data source):
Sequence #: 16
RBA: 1700
Timestamp: 2014-07-01 15:22:27.244566
Extract Trail: ./dirdat/d1
Current Checkpoint (position of last record read in the data source):
Sequence #: 16
RBA: 111290983
Timestamp: 2014-07-01 15:40:30.398558
Extract Trail: ./dirdat/d1
CSN state information:
CRC: 2-A5-9A-18
Latest CSN: 5563625160842
Latest TXN: 22.47.136
Latest CSN of finished TXNs: 5563625160842
Completed TXNs: 22.47.136
Header:
Version = 2
Record Source = A
Type = 1
# Input Checkpoints = 1
# Output Checkpoints = 0
File Information:
Block Size = 2048
Max Blocks = 100
Record Length = 2048
Current Offset = 0
Configuration:
Data Source = 0
Transaction Integrity = -1
Task Type = 0
Database Checkpoint:
Checkpoint table = goldengate.rep_hq_checkpoint
Key = 1695640860 (0x65116d1c)
Create Time = 2014-07-01 13:47:36
Status:
Start Time = 2014-07-01 15:22:33
Last Update Time = 2014-07-01 15:40:48
Stop Status = A
Last Result = 400
查看延时
GGSCI > lag <进程名称> 可以查看详细的延时信息。此命令比用info命令查看到的延时信息更加精确。注意,此命令只能够查看到最后一条处理过的记录的延时信息。此命令支持通配符 *。
GGSCI (test-gg) 145> lag rep_hq
Sending GETLAG request to REPLICAT REP_HQ ...
Last record lag: 14 seconds.
At EOF, no more records to process.
查看统计信息
GGSCI> stats <进程名称>, <时间频度>,table <owner name>.<table name> 可以查看进程处理的记录数。该报告会详细的列出处理的类型和记录数。如:
GGSCI> stats rep_hq, total 列出自进程启动以来处理的所有记录数。
GGSCI> stats rep_hq, daily, table gg.test 列出当天以来处理的有关gg.test表的所有记录数。
GGSCI (test-gg) 149> stats rep_hq, total
Sending STATS request to REPLICAT REP_HQ ...
Start of Statistics at 2014-07-01 15:57:54.
DDL replication statistics:
*** Total statistics since replicat started ***
Operations 0.00
Mapped operations 0.00
Unmapped operations 0.00
Other operations 0.00
Excluded operations 0.00
Errors 0.00
Retried errors 0.00
Discarded errors 0.00
Ignored errors 0.00
Replicating from DBUSRSYS.DEBUG_LOG to DBUSRSYS.DEBUG_LOG:
*** Total statistics since 2014-07-01 15:22:33 ***
Total inserts 775.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 775.00
Replicating from DBUSRSYS.OPERLOG to DBUSRSYS.OPERLOG:
*** Total statistics since 2014-07-01 15:22:33 ***
Total inserts 92.00
Total updates 5.00
Total deletes 0.00
Total discards 0.00
Total operations 97.00
查看运行报告
GGSCI> view report <进程名称> 可以查看运行报告。如:
GGSCI (test-gg) 151> view report rep_hq
***********************************************************************
Oracle GoldenGate Delivery for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 10g on Apr 23 2012 07:49:07
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
Starting at 2014-07-01 15:22:33
***********************************************************************
Operating System Version:
Linux
Version #1 SMP Wed Jun 13 18:24:36 EDT 2012, Release 2.6.32-279.el6.x86_64
Node: test-gg
Machine: x86_64
soft limit hard limit
Address Space Size : unlimited unlimited
Heap Size : unlimited unlimited
File Size : unlimited unlimited
CPU Time : unlimited unlimited
Process id: 10064
Description:
***********************************************************************
** Running with the following parameters **
***********************************************************************
2014-07-01 15:22:33 INFO OGG-03035 Operating system character set identified as US-ASC
II. Locale: en_US, LC_ALL:.
REPLICAT rep_hq
SETENV (NLS_LANG="American_America.ZHS16GBK")
Set environment variable (NLS_LANG=American_America.ZHS16GBK)
SETENV (ORACLE_SID=hncdfhq)
Set environment variable (ORACLE_SID=hncdfhq)
USERID goldengate, PASSWORD **********
REPORTCOUNT EVERY 30 MINUTES, RATE
REPERROR DEFAULT, ABEND
numfiles 5000
--HANDLECOLLISIONS
assumetargetdefs
DISCARDFILE ./dirrpt/rep_hq.dsc, APPEND, MEGABYTES 1000
ALLOWNOOPUPDATES
DDL INCLUDE MAPPED
DDLOPTIONS REPORT
mapexclude DBUSRMKT.PRCADJUSTSJHD, target DBUSRMKT.PRCADJUSTSJHD;
mapexclude DBUSRMKT.BORDERHEAD, target DBUSRMKT.BORDERHEAD;
mapexclude DBUSRSYS.FTERP_DDL_LOG, target DBUSRSYS.FTERP_DDL_LOG;
mapexclude DBUSRMKT.BINSTRHEAD, target DBUSRMKT.BINSTRHEAD;
map DBUSRSYS.*, target DBUSRSYS.*;
map CONGOU.*, target CONGOU.*;
map DBUSRPOP.*, target DBUSRPOP.*;
map PORTAL.*, target PORTAL.*;
map DBUSRXMLT.*, target DBUSRXMLT.*;
map DBUSRMKT.*, target DBUSRMKT.*;
map DBLINKUSR.*, target DBLINKUSR.*;
map DBUSRSET.*, target DBUSRSET.*;
map DBUSRPUB.*, target DBUSRPUB.*;
2014-07-01 15:22:33 INFO OGG-01815 Virtual Memory Facilities for: COM
anon alloc: mmap(MAP_ANON) anon free: munmap
file alloc: mmap(MAP_SHARED) file free: munmap
target directories:
/oradb/goldengate/dirtmp.
CACHEMGR virtual memory values (may have been adjusted)
CACHESIZE: 2G
CACHEPAGEOUTSIZE (normal): 8M
PROCESS VM AVAIL FROM OS (min): 4G
CACHESIZEMAX (strict force to disk): 3.41G
也可以进入到 <GoldenGate安装目录>/dirrpt/目录下,查看对应的报告文件。最新的报告总是以<进程名称>.rpt命名的。加后缀数字的报告是历史报告,数字越大对应的时间越久。如所示:
[[email protected] dirrpt]$ ll
总用量 940
-rw-rw-rw-. 1 oracle oinstall 10477 7月 1 15:22 MGR.rpt
-rw-rw-rw-. 1 oracle oinstall 23577 7月 1 15:22 REP_HQ0.rpt
-rw-rw-rw-. 1 oracle oinstall 19413 7月 1 15:11 REP_HQ1.rpt
-rw-rw-rw-. 1 oracle oinstall 22908 7月 1 15:09 REP_HQ2.rpt
-rw-rw-rw-. 1 oracle oinstall 23423 7月 1 15:02 REP_HQ3.rpt
-rw-rw-rw-. 1 oracle oinstall 21574 7月 1 14:55 REP_HQ4.rpt
-rw-rw-rw-. 1 oracle oinstall 20708 7月 1 14:48 REP_HQ5.rpt
-rw-rw-rw-. 1 oracle oinstall 23825 7月 1 14:47 REP_HQ6.rpt
-rw-rw-rw-. 1 oracle oinstall 19791 7月 1 14:36 REP_HQ7.rpt
-rw-rw-rw-. 1 oracle oinstall 20019 7月 1 14:34 REP_HQ8.rpt
-rw-rw-rw-. 1 oracle oinstall 16966 7月 1 14:32 REP_HQ9.rpt
-rw-rw-rw-. 1 oracle oinstall 694186 7月 1 15:22 rep_hq.dsc
-rw-rw-rw-. 1 oracle oinstall 19004 7月 1 15:57 REP_HQ.rpt
如果进程运行时有错误,则报告文件中会包括错误代码和详细的错误诊断信息。通过查找错误代码,可以帮助定位错误原因,解决问题。
查看参数设置
GGSCI > view params <进程名> 该命令支持通配符*
检查进程运行情况:
GGSCI> info all
GoldenGate mgr进程和ext_oe进程应该为RUNNING状态;
GGSCI> info ext_hq
多次运行info ext_app命令,返回的RBA参数应该是变化的说明进程正常。