GoldenGate Extract+datapump+replicat 配置

GoldenGate的安装很简单,下面一起来学习下GG的一些简单配置。


GG软件主要是通过抓取redo log 和 archive log 日志的信息,然后传输到目标库重做来实现数据的同步。

1.前提条件: 开启归档日志、force logging和supplemental 日志


### 用以下命令查看归档日志是否开启
SQL> archive log list          ##如果不是enable可以使用如下命令开启归档日志功能;
SQL>shutdown immediate;
SQL>startup mount;
SQL>alter database archivelog;   ##归档日志需要在mount模式下开启
## 查看force logging 和 supplemental 日志是否开启
SQL> select name,open_mode,force_logging,supplemental_log_data_min from v$database;
NAME      OPEN_MODE            FOR SUPPLEME
--------- -------------------- --- --------
NODE1     READ WRITE           NO  NO
SQL> alter database force logging;
Database altered.
SQL> select name,open_mode,force_logging,supplemental_log_data_min from v$database;
NAME      OPEN_MODE            FOR SUPPLEME
--------- -------------------- --- --------
NODE1     READ WRITE           NO  NO
SQL> alter database force logging;
Database altered.
SQL> select name,open_mode,force_logging,supplemental_log_data_min from v$database;
NAME      OPEN_MODE            FOR SUPPLEME
--------- -------------------- --- --------
NODE1     READ WRITE           YES YES


2.创建GG与Oracle交互的用户ggadmin

SQL> create tablespace ggtb datafile '/paic/app/oracle/oradata/ggtb.dbf' size 100M autoextend off;
Tablespace created.
SQL> create user ggadmin identified by ggadmin default tablespace ggtb;
User created.
SQL> grant connect,resource,dba to ggadmin;
Grant succeeded.


3.创建GG角色并授予给GG用户。(注直接这个脚本必须到GG目录下,不然可能不成功)

SQL> !pwd
/paic/app/gg
SQL> @role_setup
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 script 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:ggadmin
Wrote file role_setup_set.txt
PL/SQL procedure successfully completed.
Role setup script complete
Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, 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 ggadmin;
Grant succeeded.

   在目标端和源端最好都配置。


4.在源端和目标端创建EXTRACT、DATAPUMP、REPLICAt对象并配置相关参数文件


#####################源端配置如下信息#########################
1)创建MGR参数文件
[oracle@node1 gg]$ ggsci
GGSCI (node1) 1> edit params mgr
###配置如下信息:
port 7809
2)配置全局参数文件
GGSCI (node1) 2> edit params ./GLOBALS
###配置如下信息:
GGSCHEMA ggadmin
3)配置EXTRACT文件
GGSCI (node1) 3> edit params ext1
###配置如下信息:
extract ext1
userid ggadmin,password ggadmin
exttrail /paic/app/gg/dirdat/ex
table keeny.*;
4)配置DataPump参数文件
GGSCI (node1) 5> edit params dp1
###配置如下信息:
extract dp1
userid ggadmin,password ggadmin
rmthost 192.168.1.152,mgrport 7809
rmttrail /paic/app/gg/dirdat/rt
table keeny.*;
#####################目标端配置如下信息#########################
1)创建MGR参数文件
[oracle@node1 gg]$ ggsci
GGSCI (node1) 1> edit params mgr
###配置如下信息:
port 7809
2)配置全局参数文件
GGSCI (node1) 2> edit params ./GLOBALS
###配置如下信息:
GGSCHEMA ggadmin
3)配置EXTRACT文件
GGSCI (node2) 1> edit params rep1
###配置如下信息:
replicat rep1
userid ggadmin,password ggadmin
assumetargetdefs
discardfile /paic/app/gg/dirdat/discard.dsc,purge
map keeny.*,target keeny.*;


5.整合上面所创建的对象


##1)在源端配置
GGSCI (node1) 1> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     STOPPED                  ###只有一个MGR
##2)将表开启附加日志和强制日志
GGSCI (node1) 13> dblogin userid ggadmin,password ggadmin
Successfully logged into database.
GGSCI (node1) 14> add trandata keeny.test;
##3)向MGR里面添加EXTRACT
GGSCI (node1) 2> view params ext1
extract ext1
userid ggadmin,password ggadmin
exttrail /paic/app/gg/dirdat/ex
table keeny.*;
GGSCI (node1) 3> add extract ext1,tranlog,begin now
EXTRACT added.
##4)添加TRAIL文件
GGSCI (node1) 4> add exttrail /paic/app/gg/dirdat/ex,extract ext1  ### 这里还不太明白为什么ext1参数文件里面指定了,这里还要添加
##5)添加DATAPUMP文件
GGSCI (node1) 8> add extract dp1,exttrailsource /paic/app/gg/dirdat/ex
EXTRACT added.
##6)指定远程TRAIL文件的目录
GGSCI (node1) 9> add rmttrail /paic/app/gg/dirdat/rt,extract dp1
RMTTRAIL added.
##7)添加REPLICAT
GGSCI (node2) 1> dblogin userid ggadmin,password ggadmin
Successfully logged into database.
GGSCI (node2) 4> add replicat rep1,exttrail /paic/app/gg/dirdat/rt,checkpointtable ggadmin.checkptable
REPLICAT added.
##8)开启源端进程
GGSCI (node1) 15> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     STOPPED                                        
EXTRACT     STOPPED     DP1         00:00:00      00:16:04 
EXTRACT     STOPPED     EXT1        00:00:00      00:21:27
GGSCI (node1) 17> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                        
EXTRACT     STOPPED     DP1         00:00:00      00:16:31 
EXTRACT     STOPPED     EXT1        00:00:00      00:21:54
GGSCI (node1) 18> start ext1
Sending START request to MANAGER ...
EXTRACT EXT1 starting
GGSCI (node1) 19> start dp1
Sending START request to MANAGER ...
EXTRACT DP1 starting
GGSCI (node1) 21> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                        
EXTRACT     RUNNING     DP1         00:00:00      00:17:01 
EXTRACT     RUNNING     EXT1        00:00:00      00:00:00 
##9)开启目标端进程
GGSCI (node2) 7> start mgr
Manager started.
GGSCI (node2) 8> start rep1
Sending START request to MANAGER ...
REPLICAT REP1 starting
GGSCI (node2) 9> info
ERROR: Invalid command.
GGSCI (node2) 10> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                        
REPLICAT    RUNNING     REP1        01:31:51      00:00:04



    以上步骤完成之后,就可以验证一 下了。

######################

    alter extract ext1,extseqno 0,extrba 0

   alter replicat rep1,extseqno 0,extrba 0

你可能感兴趣的:(配置,datapump,extract,gg,goldengate)