ogg12c 配置

环境:
source 192.168.2.182 :
系统:Windows Server 2012
oracle: Release 12.1.0.2.0
ogg: 12.2.0.2.3

target 192.168.2.171:
系统:Linux CentOs 7
oracle: Release 12.2.0.1.0
ogg: 12.3.0.1.0

 

一、配置准备工作:
source端:
1.打开归档:

shutdown immediate 
startup mount
alter database archivelog;
alter database open;
alter pluggable database all open;
archive log list;

 

2.开启数据库级别日志补充:

SQL> ALTER DATABASE FORCE LOGGING; --强制日志
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;    --追加日志

SQL> col open_mode for a10
SQL> SELECT name,open_mode,force_logging,supplemental_log_data_min FROM v$database;

3.目标和原库都要配置

SQL> alter system set enable_goldengate_replication=true;

二、配置ogg

source端:

1、create user
  --12c source库需要在root容器中创建OGG管理用户(12c使用intergated extract 需要在cdb创建管理用户)

PS F:\ogg> sqlplus / as sysdba
SQL> create user C##GGADMIN identified by ggadmin;
SQL> exec dbms_goldengate_auth.grant_admin_privilege('C##GGADMIN',container=>'ALL');
SQL> grant dba to c##ggadmin container=all;
SQL> connect c##ggadmin/ggadmin

2、设置全局参数ogg global

GGSCI (WIN-GRANHIGH6KV) 13> view params ./GLOBALS
GGSCHEMA c##ggadmin

3、配置管理进程

GGSCI (WIN-GRANHIGH6KV) 11> view params mgr
PORT 7809
AUTOSTART EXTRACT *
AUTORESTART EXTRACT *,RETRIES 3, WAITMINUTES 5, RESETMINUTES 10

4、开启表级别日志补充需要加上PDB,追加对象为用户diss2.dissuser下所有表

ADD SCHEMATRANDATA diss2.dissuser
ADD TRANDATA diss2.dissuser.*

5、创建初级 集成 提取组ex8271

ADD EXTRACT ex8271,integrated TRANLOG,BEGIN NOW

 --为初级提取组ex1指定本地trail文件(extract文件量比较大的话,需要足够的磁盘)
 ADD EXTTRAIL F:\ogg\dirdat\ex, EXTRACT ex8271 MEGABYTES 5

6、注册extract ex8271

REGISTER EXTRACT ex8271 DATABASE CONTAINER (diss2)
注:注册可能报错无法注册:检查 ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; 最好重新执行一边。

7、抽取进程配置:

GGSCI (WIN-GRANHIGH6KV) 14> view params ext8271
extract ext8271
SETENV(ORACLE_SID='orcl')
userid c##ggadmin,password ggadmin
EXTTRAIL F:\ogg\dirdat\ex
TABLE diss2.dissuser.sys_log;

8、创建投递组p8271,设置本地trail文件

ADD EXTRACT p8271 EXTTRAILSOURCE F:\ogg\dirdat\ex

--为投递进组p8271设置target端trail文件地址
 ADD RMTTRAIL /home/oracle/ogg/dirdat/ep, EXTRACT p8271

9、配置投递进程:

GGSCI (WIN-GRANHIGH6KV) 15> view params p8271
extract p8271
SETENV(ORACLE_SID='orcl')
userid c##ggadmin,password ggadmin
rmthost 192.168.2.171, mgrport 7809
rmttrail /home/oracle/ogg/dirdat/ep
table diss2.dissuser.sys_log;

由于source端是Windows,所以需要将ogg添加为系统服务。

 

先停止所有进程:
GGSCI (WIN-GRANHIGH6KV) 15> stop mgr

    然后退出来,在oog目录下,运行下面代码:

 ./install addservice 

启动进程:
GGSCI (WIN-GRANHIGH6KV) 15> start mgr

target端:

1、12c target库需要在pdb 中创建OGG管理用户及其表空间

[oracle@Node1 ogg]$ sqlplus / as sysdba
SQL> alter session set container=diss2;
SQL> CREATE TABLESPACE goldengate DATAFILE '/home/oracle/DISS/diss2ogg01.dbf' SIZE 100m AUTOEXTEND ON;
SQL> CREATE USER oggadmin IDENTIFIED BY oggadmin DEFAULT TABLESPACE goldengate;
SQL> GRANT dba to oggadmin;

2、设置全局参数

GGSCI> EDIT PARAMS ./GLOBALS
GGSCHEMA oggadmin

3、配置管理进程:

GGSCI (Node1) 2> view params mgr

PORT 7809
AUTOSTART EXTRACT *
AUTORESTART EXTRACT *,RETRIES 3, WAITMINUTES 5, RESETMINUTES 10

4、创建检查点表

DBLOGIN USERID oggadmin@diss2,PASSWORD oggadmin
ADD CHECKPOINTTABLE oggadmin.checkpointtable

5、在全局环境中添加检查点表

EDIT PARAMS ./GLOBALS
GGSCHEMA oggadmin
CHECKPOINTTABLE oggadmin.checkpointtable

6、创建复制组rep8271,设置读取trail文件路径以及检查点表加上PDB

ADD REPLICAT rep8271, EXTTRAIL /home/oracle/ogg/dirdat/ep, checkpointtable diss2.oggadmin.checkpointtable

为复制组rep8271配置参数文件初始化的时候加上HANDLECOLLISIONS,初始化之后去掉.

7、配置复制进程:

GGSCI (Node1) 3> view params rep8271

REPLICAT rep8271
SETENV (ORACLE_SID='orcl')
USERID oggadmin@diss2, PASSWORD oggadmin
HANDLECOLLISIONS
ASSUMETARGETDEFS
ddloptions report
DISCARDFILE /home/oracle/ogg/discards.dsc, append, megabytes 1024 
MAP diss2.dissuser.sys_log, TARGET diss2.dissuser.sys_log;

8、测试

先启动source端:
strat mgr
start ext8271
start p8271

9、初始化数据

--初始化数据导出的时候指定flashback_scn

SELECT current_scn FROM v$database;
--4245953

--导出:

[oracle@Node1 ogg]$ expdp dissuser/disspass@diss2 directory=dump dumpfile=diss2_scn_4345953_0105.dmp logfile=0105.log flashback_scn=4245953 compression=all
--encryption_password=123456 可加密

--导入:

[oracle@Node1 ogg]$ impdp dissuser/disspass@diss2 directory=dump dumpfile=DISS2_SCN_4345953_0105.DMP logfile=0105impdp.log remap_schema=dissuser:dissuser TABLE_EXISTS_ACTION=replace include=table
启动target端:
start replicat rep8271,aftercsn 4245953

10、检验。 

posted on 2018-01-05 10:44  ajistyle  阅读(631)  评论(0编辑  收藏  举报

导航