记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。
 
0

Linux 系统安装GoldenGate

发表者:admin分类:数据库2015-08-29 10:44:14 阅读[1968]

Linux 系统安装GoldenGate,实现oracle数据同步

一、检查数据库配置情况

检查归档模式、附加日志、强制日志参数是否开启。

10g要检查回收站功能是否关闭;11g则不必检查。这里咱们用的11g,所以不检查。

SQL> selectlog_mode,supplemental_log_data_min,force_logging from v$database;

 

LOG_MODE     SUPPLEMENTAL_LOG_DATA_MIN      FORCE_LOGGING

------------------------------------------ ---------------

ARCHIVELOG   NO                             NO

   

这里归档模式已开,附加日志和强制日志是关闭的。需要开启附加日志和强制日志。

SQL> alter database addsupplemental log data;

 

数据库已更改。

 

SQL> alter databaseforce logging;

 

数据库已更改。

 

LOG_MODE     SUPPLEMENTAL_LOG_DATA_MIN      FORCE_LOGGING

------------------------------------------ ---------------

ARCHIVELOG   YES                YES

 

 

二、安装GoldenGate

1 先在/u01/下创建ogg目录,用来安装GoldenGate程序。当然也可以选择别的路径。

$ cd /u01

$ mkdir ogg

 

2 用xshell工具把ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip传到/u01 /ogg/目录下,并解压缩

$ cd ogg/

$ 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.1README.txt 

  inflating: Oracle GoldenGate 11.2.1.0.1README.doc 

$ tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar

 

3 运行ggsci,进入ogg管理控制台

$ ./ggsci

 

Oracle GoldenGate Command Interpreterfor Oracle

Version 11.2.1.0.1OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO

Linux, x64, 64bit (optimized), Oracle11g on Apr 23 2012 08:32:14

 

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

 

 

 

GGSCI (localhost) 1>

 

4 运行create subdirs来创建ogg所需要的目录

GGSCI (localhost) 1> create subdirs

 

Creating subdirectories under currentdirectory /u01/ogg

 

Parameter files                /u01/ogg/dirprm: already exists

Report files                   /u01/ogg/dirrpt: created

Checkpoint files               /u01/ogg/dirchk: created

Process status files           /u01/ogg/dirpcs: created

SQL script files               /u01/ogg/dirsql: created

Database definitions files     /u01/ogg/dirdef: created

Extract data files             /u01/ogg/dirdat: created

Temporary files                /u01/ogg/dirtmp: created

Stdout files                   /u01/ogg/dirout: created

 

 

GGSCI (localhost) 2>

 

各个目录的作用:

(1)dirprm

用于存放GG的参数文件,这些参数文件可以通过系统文本编辑器直接编辑,也可以通过在ggsci命令行下edit params来编辑,达到的效果是一样的。

文件格式如下:

<group name/user-defined name>.prm

比如mgr.prm

 

(2)dirrpt

用于存放各个进程的报告文件,内容为extract、replicat和manager进程运行相关的统计报告信息。

文件格式如下:

<groupname><sequencenumber>.rpt

 

(3)dirchk

用于存放由extract抽取进程和replicat复制进程创建的checkpoint文件,checkpoint文件保存当前读和写的时间戳信息,通过这些信息保证了数据的准确性和数据容错功能。

文件格式如下:<groupname><sequencenumber>.<ext>

group name就是我们配置的进程名称,序列号,加上后缀名成,后缀名称分为cpe(checkpoint extract)和cpr(checkpoint replicat)。

 

(4)dirpcs

用于存放各个进程的状态信息,当相关进程运行的时候,这些进程的相关信息,比如程序名称,进程名称,进程监听端口,进程ID等等都将被写入各自状态信息文件。

文件格式如下:

<group>.<extension>

其中extension有3个:pce(extract) pcr(replicat)  pcm(manager)

 

(5)dirsql

用于存放由TRIGGEN组件创建的SQL脚本文件,这些SQL脚本用于创建GG相关的记录触发器和日志表。

文件格式如下:

用户自定义名称.sql

或者

表名称.sql

注意都是SQL结尾的脚本文件。

 

(6)dirdef

用于存放由DEFGEN组件创建的定义文件,包含在异构环境同步中的源或者目标端的数据定义。是一个可编辑的文本文件,比如你要添加一个新进创建表的相关的同步定义就可以在此直接编辑。

文件格式如下:

用户通过DEFGEN参数文件自定义

 

(7)dirdat

用于存放GG跟踪文件和由extract进程创建的抽取文件,这些文件将被复制进程(或者其他需要的)进一步处理和使用。

文件格式如下:

用户自定义的2个前缀字符+6位序列号(跟踪文件)

或者   

用户自定义的格式(抽取文件)

 

(8)dirtmp

用于执行大事务处理过程,官方的说法是当请求的内存超过分配的内存的时候,就会……巴拉巴拉,这个怎么理解和解释呢?临时文件目录?

记住一点就是了:不要编辑里面的任何文件和内容。

 

(9)dirout

废弃,不再使用。

 

最后用表格来归纳一下:

目录

说明

dirprm

参数文件

dirrpt

报告文件

dirchk

检查点文件

dirpcs

状态文件

dirsql

sql脚本文件

dirdef

数据定义文件

dirdat

跟踪文件和抽取文件

dirtmp

临时文件

 

5 在Oracle中创建GoldenGate专属用户

SQL> create user ogg identified byoracle;

 

用户已创建。

 

SQL> grant connect,resource to ogg;

 

授权成功。

 

SQL> grant unlimited tablespace toogg;

 

授权成功。

 

SQL> grant execute on utl_file toogg;

 

授权成功。

 

SQL> grant create table,createsequence to ogg;

 

授权成功。

 

SQL>

 

6为新创建的ogg用户执行配置脚本。在ogg的安装目录下使用sys登陆sqlplus,然后执行四个配置脚本。

(1)marker_setup.sql,作用是安装DDL支持所需要的GoldenGate marker系统。

[oracle@localhost ~]$ cd /u01/ogg/

[oracle@localhost ogg]$ sqlplus / assysdba

 

SQL*Plus: Release 11.2.0.1.0 Productionon 星期二 7月 28 14:05:39 2015

 

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

 

连接到:

Oracle Database 11g Enterprise EditionRelease 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, DataMining and Real Application Testing options

 

SQL> @marker_setup

 

Marker setup script

 

You will be prompted for the name of aschema for the Oracle GoldenGate database objects.

NOTE: The schema must be created priorto running this script.

NOTE: Stop all DDL replication beforestarting this installation.

 

Enter Oracle GoldenGate schema name:ogg

 

 

Marker setup table script complete,running verification script...

Please enter the name of a schema forthe GoldenGate database objects:

Setting schema name to OGG

 

MARKER TABLE

-------------------------------

OK

 

MARKER SEQUENCE

-------------------------------

OK

 

Script complete.

SQL>

 

(2)ddl_setup.sql

SQL> @ddl_setup

 

Oracle GoldenGate DDL Replication setupscript

 

Verifying that current user hasprivileges to install DDL Replication...

 

You will be prompted for the name of aschema for the Oracle GoldenGate database objects.

NOTE: For an Oracle 10g source, thesystem recycle bin must be disabled. For Oracle 11g and later, it can beenabled.

NOTE: The schema must be created priorto running this script.

NOTE: Stop all DDL replication beforestarting this installation.

 

Enter Oracle GoldenGate schema name:ogg

 

Working, please wait ...

Spooling to file ddl_setup_spool.txt

 

Checking for sessions that are holdinglocks on Oracle Golden Gate metadata tables ...

 

Check complete.

 

(3)role_setup.sql,作用是删除和创建DDL同步需要的角色,它授权DDL对象上的DML操作。

SQL> @role_setup

 

GGS Role setup script

 

This script will drop and recreate therole GGS_GGSUSER_ROLE

To use a different role name, quit thisscript and then edit the params.sql script to change the gg_role parameter tothe preferred name. (Do not run the script.)

 

You will be prompted for the name of aschema for the GoldenGate database objects.

NOTE: The schema must be created priorto running this script.

NOTE: Stop all DDL replication beforestarting this installation.

 

Enter GoldenGate schema name:ogg

已写入 file role_setup_set.txt

 

PL/SQL 过程已成功完成。

 

 

Role setup script complete

 

Grant this role to each user assignedto the Extract, GGSCI, and Manager processes, by using the following SQLcommand:

 

GRANT GGS_GGSUSER_ROLE TO<loggedUser>

 

where <loggedUser> is the userassigned to the GoldenGate processes.

SQL>

 

根据提示,这里要执行GRANTGGS_GGSUSER_ROLE TO ogg

SQL> GRANT GGS_GGSUSER_ROLE TO ogg;

 

授权成功。

 

(4)ddl_enable.sql,作用是启用ddl触发器。

SQL> @ddl_enable    

 

触发器已更改

 

SQL>

 

7 测试用户是否创建成功

GGSCI (localhost) 2> dblogin useridogg

Password:

Successfully logged into database.

 

GGSCI (localhost) 3>



转载请标明出处【Linux 系统安装GoldenGate】。

《www.micoder.cc》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论