Oracle搭建GoldenGate的只有为复制环境

配备环境:

Oracle 1

提议在同一版本OGG(即Oracle
GoldenGate)之间开展复制,我于此用选取不同版本的OGG,便于后续的于上。

同一、准备OGG的运转用户

于此间,我一直使用oracle用户作为OGG的运作用户。

 

老二、确认OGG的安目录

在源端,即Linux环境下,我选择/u01/app/goldengate作为OGG的设置目录,注意:/u01/app/goldengate目录的属主必须为OGG的运转用户,在此,该目录的属主必须为oracle。

于目标端,即Win环境下,我选择G:\app\goldengate作为OGG的安目录

 

其三、打开数据库的存档模式

SQL> archive log list 
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     5
Current log sequence           7
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
 

 

季、打开源端数据库最小附加日志

因此地搭建之只是独自为复制,OGG捕捉的是源端数据库的改变,所以仅需要对源端数据库被最小附加日志

SQL> select supplemental_log_data_min from v$database;

SUPPLEME
--------
NO

SQL> alter database add supplemental log data;

Database altered.

SQL> alter system switch logfile;   --切换日志使附加日志生效

System altered.

 

五、在数据库被树立OGG用户并予以响应的权杖

为了简化授权,直接以dba角色与给gg用户。

SQL> create user gg identified by gg;
SQL> grant dba to gg;

 

六、上传软件包到指定目录,进行设置

在源端:

[oracle@node1 ~]$ cd /u01/app/goldengate/
[oracle@node1 goldengate]$ ls
ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
[oracle@node1 goldengate]$ unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip 
Archive:  ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
  inflating: fbo_ggs_Linux_x64_ora11g_64bit.tar  
  inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf  
  inflating: Oracle GoldenGate 11.2.1.0.1 README.txt  
  inflating: Oracle GoldenGate 11.2.1.0.1 README.doc  
[oracle@node1 goldengate]$ tar xvf fbo_ggs_Linux_x64_ora11g_64bit.tar 

当当前目录下,执行ggsci命令

[oracle@node1 goldengate]$ ./ggsci 
./ggsci: error while loading shared libraries: libnnz11.so: cannot open shared object file: No such file or directory

回报以上错误,在/home/oracle/.bash_profile添加如下内容:export
LD_LIBRARY_PATH=$ORACLE_HOME/lib,添加了后,记得要配置文件生效:source /home/oracle/.bash_profile。

留神:为了ggsci命令在其它目录下足实行,可当/home/oracle/.bash_profile设置如下环境变量:

export GG_HOME=/u01/app/goldengate
export PATH=$GG_HOME:$PATH

再次履行ggsci命令

[oracle@node1 goldengate]$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.



GGSCI (node1.being.com) 1> 

意味着入成功

当ggsci环境下开创GoldenGate子目录

[oracle@node1 goldengate]$ ggsci 

GGSCI (node1.being.com) 1> create subdirs

Creating subdirectories under current directory /u01/app/goldengate

Parameter files                /u01/app/goldengate/dirprm: already exists
Report files                   /u01/app/goldengate/dirrpt: created
Checkpoint files               /u01/app/goldengate/dirchk: created
Process status files           /u01/app/goldengate/dirpcs: created
SQL script files               /u01/app/goldengate/dirsql: created
Database definitions files     /u01/app/goldengate/dirdef: created
Extract data files             /u01/app/goldengate/dirdat: created
Temporary files                /u01/app/goldengate/dirtmp: created
Stdout files                   /u01/app/goldengate/dirout: created

每当靶端:即Win8环境下,注意,Win8的OGG版本是12.1.2.1.0,需图形界面安装,而11.2.1.0.1虽说非需,直接铲除压缩即可。

将12.1.2.1.0版的OGG解压缩后,双击里面的setup文件。

率先步:选择OGG对应的数据库版本

Oracle 2

次步:指定OGG的周转目录

Oracle 3

其余直接点击下一致步即可。    

安收尾后,会启动一个mgr进程的窗口。

一样需要以目标端ggsci环境下创办GoldenGate子目录,因该OGG安装了后,以上目录均就自行创建,故不再创建。

 

七、配置Manager进程

于ggsci环境下安排Manager进程

源端配置如下:

[oracle@node1 goldengate]$ ggsci 

GGSCI (node1.being.com) 1> edit param mgr

GGSCI (node1.being.com) 2> start mgr

Manager started.

GGSCI (node1.being.com) 3> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING         --可见MGR进程已启动

对象端同样如此。

 

八、在源端上丰富表级附加日志

以印证搭建之职能,在此处我们新建一个test用户,并新建一张test表。

SQL> create user test identified by test;

User created.

SQL> grant connect,resource to test;

Grant succeeded.

SQL> conn test/test
Connected.

SQL> create table test (id number);

Table created.

每当ggsci命令行中登录数据库,为富有需要复制的表添加trandata 

GGSCI (node1.being.com) 1> dblogin userid gg,password gg
Successfully logged into database.

GGSCI (node1.being.com) 2> add trandata test.*

2015-08-24 18:14:59  WARNING OGG-00869  No unique key is defined for table 'TEST'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.

Logging of supplemental redo data enabled for table TEST.TEST.

打者的WARNING我们得看来,因为test表没有唯一性约束,故OGG将该行的所有列来作为它们的唯一性约束。

 

九、在源端上加加Extract进程

GGSCI (node1.being.com) 5> add ext exta,tranlog,begin now

其间,exta为经过名,一般为ext开头表示是extract进程,后面可以加1-2个字符标识;

         tranlog表示只要抽取数据库日志;

         begin now表示于脚下日点起抽取

专注:添加完Extract进程后,我们发出些许种方法来传输数据。

率先种植,exta进程一直拿捕捉到之管事数据写入到长途队列,网络拓扑如下:

Oracle 4

 

不难看出,该办法对网络要求较高,在事实上生产条件遭到非常少使用该种方式。

次栽,首先将数据抽取到当地,然后再度由Pump进程传输到长途队列。网络拓扑如下:

Oracle 5

以此,我们利用第二种植艺术

 

十、在源端上部署Pump进程

创立完exta进程后,使用当地队列时为exta进程配置队列如下:

GGSCI (node1.being.com) 1> add exttrail /u01/app/goldengate/dirdat/la,ext exta,megabytes 20

megabytes表示每个阵文件之轻重,超过该大小则会滚动写副到下一个行文件。

此时exta复制到了地方,下面来安排Pump进程,负责用数据原封不动的盘到目标端。

GGSCI (node1.being.com) 3> add extract dpea,exttrailsource /u01/app/goldengate/dirdat/la

此时exttrailsource指定的凡本土队列的路子

否该Pump进程配置远程队列

GGSCI (node1.being.com) 4> add rmttrail G:\app\goldengate\dirdat\ra,ext dpea,megabytes 20

rmttrail也目标队列的职务,队列一般由路径加上两独标识如ra来代表。

 

十一、在源端配置Extract进程参数

GGSCI (node1.being.com) 6> edit param exta

内容如下:

EXTRACT exta
setenv ( NLS_LANG = AMERICAN_AMERICA.AL32UTF8 )
setenv ( ORACLE_SID = orcl )
USERID gg, PASSWORD gg
EXTTRAIL /u01/app/goldengate/dirdat/la
dynamicresolution
table test.*;

启动exta进程,看其能否正常启动

GGSCI (node1.being.com) 15> start exta

Sending START request to MANAGER ...
EXTRACT EXTA starting

GGSCI (node1.being.com) 17> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     STOPPED     DPEA        00:00:00      00:27:12    
EXTRACT     RUNNING     EXTA        00:55:27      00:00:07  

专注:正常情况下,exta进程启动后底status是running,如果仍是stopped,可透过view
report exta查看exta启动很的由来。

PS:第一潮配置后,启动很,后来经过view report
exta命令查看其报错信息:ERROR   OGG-00396  Command not terminated by
semi-colon,才明白table
test.*参数后没加分号。添加了后,重新起动,启动健康。

 

十二、在源端配置Pump进程参数

GGSCI (node1.being.com) 19> edit param dpea

内容如下:

extract dpea
setenv ( NLS_LANG = AMERICAN_AMERICA.AL32UTF8 )
passthru
rmthost 192.168.2.1,mgrport 7809, compress
rmttrail G:\app\goldengate\dirdat\ra
dynamicresolution
table test.*;

个中rmthost指定目标端的主机IP和端口,rmttrail指定远程队列的门路,passthru代表以进程是一个Pump进程,不需要与数据库交互。

启动查看状态

GGSCI (node1.being.com) 20> start dpea

Sending START request to MANAGER ...
EXTRACT DPEA starting

GGSCI (node1.being.com) 21> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     DPEA        00:00:00      00:42:42    
EXTRACT     RUNNING     EXTA        00:00:00      00:00:04 

启动OK。

 

十三、在目标端上初始化目标表

可以通过exp/imp、RMAN、init load进行数量初始化

倘目标端不需历史数据,可以仅建立表结构

每当此处,同源端一样,在目标端新建一个test用户,并新建一摆test表。

 

十四、在对象端上加Replicat进程

GGSCI (Lenovo-PC) 5> add rep repa,exttrail G:\app\goldengate\dirdat\ra,nodbcheckpoint
REPLICAT added.

 

十五、配置Replicat进程参数

GGSCI (Lenovo-PC) 7> edit param repa

情如下:

replicat repa
setenv (NLS_LANG = 'AMERICAN_AMERICA.ZHS16GBK')
setenv (ORACLE_SID = test)
userid gg, password gg
reperror default,abend
discardfile G:\app\goldengate\dirrpt\repa.dsc,append, megabytes 10
assumetargetdefs
dynamicresolution
map test.*, target test.*;

启动Replicat进程

GGSCI (Lenovo-PC) 25> start repa

Sending START request to MANAGER ...
REPLICAT REPA starting

GGSCI (Lenovo-PC) 26> info all  

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
REPLICAT    ABENDED     REPA        00:00:00      01:45:47   

发觉REPA进程的状态是ABENDED,通过view report exta命令查看该报错信息:

2015-08-24 14:39:21 ERROR OGG-02091 Operation not supported because enable_goldengate_replication is not set to true.

当对象数据库中将enable_goldengate_replication的值设为true

SQL> alter system set enable_goldengate_replication=true;

系统已更改。

又起动Replicat进程,状态OK

GGSCI (Lenovo-PC) 29> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
REPLICAT    RUNNING     REPA        00:00:00      00:00:08

至今,各进程均已正常启动,下面,通过对源端test表进行多删改,看那目标端的转变

源端新增同长数据

SQL> insert into test values(1);

1 row created.

SQL> commit;

Commit complete.

目标端的结果如下:

SQL> select * from test;

        ID
----------
         1

针对源端进行删除、改,变化同样有在目标端挨。

也可由此查阅各个进程的状态来查阅复制的情状

GGSCI (node1.being.com) 31> stats exta

Sending STATS request to EXTRACT EXTA ...

Start of Statistics at 2015-08-24 23:23:49.

Output to /u01/app/goldengate/dirdat/la:

Extracting from TEST.TEST to TEST.TEST:

*** Total statistics since 2015-08-24 23:15:07 ***
    Total inserts                                  1.00
    Total updates                                  1.00
    Total deletes                                  1.00
    Total discards                                 0.00
    Total operations                               3.00

*** Daily statistics since 2015-08-24 23:15:07 ***
    Total inserts                                  1.00
    Total updates                                  1.00
    Total deletes                                  1.00
    Total discards                                 0.00
    Total operations                               3.00

*** Hourly statistics since 2015-08-24 23:15:07 ***
    Total inserts                                  1.00
    Total updates                                  1.00
    Total deletes                                  1.00
    Total discards                                 0.00
    Total operations                               3.00

*** Latest statistics since 2015-08-24 23:15:07 ***
    Total inserts                                  1.00
    Total updates                                  1.00
    Total deletes                                  1.00
    Total discards                                 0.00
    Total operations                               3.00

End of Statistics.


GGSCI (node1.being.com) 32> stats dpea

Sending STATS request to EXTRACT DPEA ...

Start of Statistics at 2015-08-24 23:23:54.

Output to G:\app\goldengate\dirdat\ra:

Extracting from TEST.TEST to TEST.TEST:

*** Total statistics since 2015-08-24 23:15:08 ***
    Total inserts                                  1.00
    Total updates                                  1.00
    Total deletes                                  1.00
    Total discards                                 0.00
    Total operations                               3.00

*** Daily statistics since 2015-08-24 23:15:08 ***
    Total inserts                                  1.00
    Total updates                                  1.00
    Total deletes                                  1.00
    Total discards                                 0.00
    Total operations                               3.00

*** Hourly statistics since 2015-08-24 23:15:08 ***
    Total inserts                                  1.00
    Total updates                                  1.00
    Total deletes                                  1.00
    Total discards                                 0.00
    Total operations                               3.00

*** Latest statistics since 2015-08-24 23:15:08 ***
    Total inserts                                  1.00
    Total updates                                  1.00
    Total deletes                                  1.00
    Total discards                                 0.00
    Total operations                               3.00

End of Statistics.

GGSCI (Lenovo-PC) 30> stats repa

Sending STATS request to REPLICAT REPA ...

Start of Statistics at 2015-08-24 15:24:34.

Replicating from TEST.TEST to TEST.TEST:

*** Total statistics since 2015-08-24 15:15:14 ***
        Total inserts                                      1.00
        Total updates                                      1.00
        Total deletes                                      1.00
        Total discards                                     0.00
        Total operations                                   3.00

*** Daily statistics since 2015-08-24 15:15:14 ***
        Total inserts                                      1.00
        Total updates                                      1.00
        Total deletes                                      1.00
        Total discards                                     0.00
        Total operations                                   3.00

*** Hourly statistics since 2015-08-24 15:15:14 ***
        Total inserts                                      1.00
        Total updates                                      1.00
        Total deletes                                      1.00
        Total discards                                     0.00
        Total operations                                   3.00

*** Latest statistics since 2015-08-24 15:15:14 ***
        Total inserts                                      1.00
        Total updates                                      1.00
        Total deletes                                      1.00
        Total discards                                     0.00
        Total operations                                   3.00

End of Statistics.

迄今为止,基于GoldenGate的独自为复制环境搭建了。

 

相关文章