GoldenGate的安装与配置(三)oracle——oracle单向复制(linux-windows)

来源:互联网 发布:淘宝里怎么添加地址 编辑:程序博客网 时间:2024/05/19 17:23

一.GG软件在windows平台的安装:

1.官方文档要求用administrator权限安装(需要系统管理员的权限),双击C:\u01\ogg\ggsci.exe


2.GoldenGate通过抓取源端数据库重做日志进行分析,将获取的数据应用到目标端,实现数据同步。因此,源数据库需要必须处于归档模式,并启用附加日志和强制日志。

SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area  730714112 bytes
Fixed Size                  2284824 bytes
Variable Size             486540008 bytes
Database Buffers          234881024 bytes
Redo Buffers                7008256 bytes
数据库装载完毕。
SQL> alter database archivelog;
数据库已更改。
SQL> alter database open;
数据库已更改。
SQL> alter database force logging;
数据库已更改。
SQL> alter database add supplemental log data;
数据库已更改。
SQL> alter system set recyclebin=off scope=spfile;
系统已更改。

3. 创建存放DDL信息的user并赋权

SQL> create user ggate identified by ggate default tablespace users temporary tablespace temp;
用户已创建。
SQL> grant connect,resource to ggate;
授权成功。
SQL> grant execute on utl_file to ggate;
授权成功。
SQL> GRANT CREATE TABLE,CREATE SEQUENCE TO ggate;
授权成功。

4.退出所有使用Oracle 的session,然后使用SYSDBA权限的用户执行如下脚本

C:\Users\Administrator.SERVER2008>cd c:\u01\ogg\
c:\u01\ogg>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期四 10月 23 09:45:45 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>@marker_setup.sql
Marker setup script
You will be prompted for the name of a schema for the Oracle GoldenGate database
 objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter Oracle GoldenGate schema name:ggate
Marker setup table script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGATE
MARKER TABLE
-------------------------------
OK
MARKER SEQUENCE
-------------------------------
OK
Script complete.

SQL>@ddl_setup.sql
Oracle GoldenGate DDL Replication setup script
Verifying that current user has privileges to install DDL Replication...
You will be prompted for the name of a schema for the Oracle GoldenGate database
 objects.
NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Ora
cle 11g and later, it can be enabled.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter Oracle GoldenGate schema name:ggate
Working, please wait ...
Spooling to file ddl_setup_spool.txt
Checking for sessions that are holding locks on Oracle Golden Gate metadata tabl
es ...
Check complete.
Using GGATE as a Oracle GoldenGate schema name.
Working, please wait ...
DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGATE
CLEAR_TRACE STATUS:
Line/pos             Error
-------------------- -----------------------------------------------------------
No errors            No errors
CREATE_TRACE STATUS:
Line/pos             Error
-------------------- -----------------------------------------------------------
No errors            No errors
TRACE_PUT_LINE STATUS:
Line/pos             Error
-------------------- -----------------------------------------------------------
No errors            No errors
INITIAL_SETUP STATUS:
Line/pos             Error
-------------------- -----------------------------------------------------------
No errors            No errors

LOCATION OF DDL TRACE FILE
--------------------------------------------------------------------------------
C:\app\Administrator\diag\rdbms\crm\crm\trace/ggs_ddl_trace.log
Analyzing installation status...
STATUS OF DDL REPLICATION
--------------------------------------------------------------------------------
SUCCESSFUL installation of DDL Replication software components
Script complete.
SQL>@role_setup.sql
GGS Role setup script
This script will drop and recreate the role GGS_GGSUSER_ROLE
To use a different role name, quit this script and then edit the params.sql scri
pt to change the gg_role parameter to the preferred name. (Do not run the script.)
You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter GoldenGate schema name:ggate
已写入 file role_setup_set.txt
PL/SQL 过程已成功完成。
Role setup script complete
Grant this role to each user assigned to the Extract, GGSCI, and Manager process
es, by using the following SQL command:
GRANT GGS_GGSUSER_ROLE TO <loggedUser>
where <loggedUser> is the user assigned to the GoldenGate processes.
SQL> grant GGS_GGSUSER_ROLE to ggate;
授权成功。
SQL> @ddl_enable.sql
触发器已更改

二.源库配置(linux平台):

1.配置mgr住进程组:

GGSCI (node1) 80> view params mgr

port 7809
dynamicportlist 7800-8000
autostart  extract  * 
autorestart extract *, waitminutes 2, resetminutes 5
lagreporthours 1
laginfominutes 3
lagcriticalminutes 5
purgeoldextracts  /u01/ggate/dirdat/rt*, usecheckpoints, minkeepdays 3

启动服务 start mgr

GGSCI (node1) 85> info mgr
Manager is running (IP port node1.7809).

2.配置EXTRACT 进程组:

GGSCI (node1) 82> view params eora
extract eora                                               
dynamicresolution
userid ggate,password ggate                                   
exttrail /u01/ggate/dirdat/et                          
tranlogoptions excludeuser ggate                           
ddl include all                                             
ddloptions addtrandata, report
table scott.*;  

添加抽取进程

add extract eora, tranlog,begin now

添加本地trail文件

add exttrail /u01/ggate/dirdat/et,extract eora

启动服务

start extract eora

GGSCI (node1) 84> info eora
EXTRACT    EORA      Last Started 2014-10-23 14:25   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:04 ago)
Log Read Checkpoint  Oracle Redo Logs
        2014-10-23 14:42:02  Seqno 34, RBA 14901248
         SCN 0.1149161 (1149161)

3.配置PUMP进程组

GGSCI (node1) 86> view params pump_so
extract pump_so                                                    
dynamicresolution
passthru
rmthost 192.168.1.120,mgrport 7809,compress                        
rmttrail C:\u01\ogg\dirdat\wt                        
table scott.*;

添加pump进程

add extract pump_so,exttrailsource /u01/ggate/dirdat/et

添加远程trail文件

add rmttrail C:\u01\ogg\dirdat\wt,extract pump_so

说明: 指定远程trail文件

启动pump进程

start extract pump_so

GGSCI (node1) 88> info pump_so

EXTRACT    PUMP_SO   Last Started 2014-10-23 14:25   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:01 ago)
Log Read Checkpoint  File /u01/ggate/dirdat/et000001
        2014-10-23 14:36:52.000000  RBA 7601

三.目标库配置(windows平台):

1.配置mgr住进程组:

GGSCI (server2008) 73> view params mgr
port 7809
dynamicportlist 7800-8000
autostart  extract  *
autorestart extract *, waitminutes 2, resetminutes 5
lagreporthours 1
laginfominutes 3
lagcriticalminutes 5
purgeoldextracts  C:\u01\ogg\dirdat\rt*, usecheckpoints, minkeepdays 3

2.添加检查表:

编辑全局配置文件

GGSCI (server2008) 67> view params ./GLOBALS
CHECKPOINTTABLE ggate.checkpoint

GGSCI (server2008) 87> dblogin userid ggate,password ggate
Successfully logged into database.

GGSCI (slave) 2> add checkpointtable ggate.checkpoint

 Successfully created checkpoint table ggate.CHECKPOINT.

3.配置REPLICAT进程组

GGSCI (server2008) 71> view params repl_win
replicat repl_win
userid ggate,password ggate
assumetargetdefs
reperror default,discard
discardfile C:\u01\ogg\dirrpt\repl_win.dsc,append,megabytes 50
dynamicresolution
map scott.*, target scott.*;

添加复制进程

add replicat repl_win,exttrail C:\u01\ogg\dirdat\wt, CHECKPOINTTABLE ggate.checkpoint

启动进程

start repl_win

GGSCI (server2008) 72> info repl_win

REPLICAT   REPL_WIN  Last Started 2014-10-23 14:33   Status RUNNING

Checkpoint Lag       00:00:00 (updated 00:00:02 ago)

Log Read Checkpoint  File C:\u01\ogg\dirdat\wt000003

 2014-10-23 14:36:51.853285  RBA 7771

四.验证数据同步:

源库(DML):

目标库(DML):

源库DDL):

目标(DDL):

0 0