博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux下单节点oracle数据库间ogg搭建
阅读量:5820 次
发布时间:2019-06-18

本文共 7951 字,大约阅读时间需要 26 分钟。

环境说明:   linux为Linux 2.6.32-573.el6.x86_64     oracle为 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

                 ogg为 ogg112101_fbo_ggs_Linux_x64_ora11g_64bit

技术背景:

 

 

 

说明:  goldengate为ogg管理用户                 oggdemo为生产用户

源库操作:

  1.  上传ogg安装包与安装ogg软件。

[oracle@11g ~]$ mkdir ogg

[oracle@11g ~]$ cd ogg

[oracle@11g ogg]$ ls
ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip

[oracle@11g 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.1 README.txt 
inflating: Oracle GoldenGate 11.2.1.0.1 README.doc 
[oracle@11g ogg]$ tar vxf fbo_ggs_Linux_x64_ora11g_64bit.tar 
UserExitExamples/
UserExitExamples/ExitDemo_more_recs/
UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.HPUX
UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.SOLARIS

。。。。省略大量输出。。。。。

ucharset.h

ulg.sql
usrdecs.h
zlib.txt

2.  数据库为ogg传递数据做环境调整。  (归档,数据库级最小附加日志)

[oracle@11g ogg]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Nov 9 03:03:20 2014

SQL> archive log list;

Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 21
Next log sequence to archive 23
Current log sequence 23
SQL> alter database add supplemental log data;

Database altered.

SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;

System altered.

3. 创建专用的ogg表空间与ogg用户,ogg用户授权 (以后卸载ogg直接删除表空间即可)

SQL> create tablespace goldgate datafile '/home/oracle/app/oradata/orcl/ogg01.dbf' size 2G AUTOEXTEND ON NEXT 5M MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;

Tablespace created.

SQL> CREATE USER goldengate IDENTIFIED BY goldengate DEFAULT TABLESPACE goldgate;

User created.

SQL> GRANT CONNECT TO goldengate;

Grant succeeded.

SQL> GRANT CREATE SESSION TO goldengate;

Grant succeeded.

SQL> GRANT ALTER SESSION TO goldengate;

Grant succeeded.

SQL> GRANT RESOURCE TO goldengate;

Grant succeeded.

SQL> GRANT SELECT ANY DICTIONARY TO goldengate;

Grant succeeded.

SQL> GRANT SELECT ANY TABLE TO goldengate;

Grant succeeded.

SQL> GRANT FLASHBACK ANY TABLE TO goldengate;

Grant succeeded.

SQL> GRANT ALTER ANY TABLE TO goldengate;

Grant succeeded.

 

说明:

在goldengate目录下,执行 ./ggsci 进入命令行界面,左侧提示出现GGSCI (myhost) 1>,

表示进入成功
如果ggsci进入出错,设置一下环境变量:
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

 

[oracle@11g ~]$ cd ogg                  --验证是否可以进入ggsci命令界面

[oracle@11g ogg]$ ./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 (11g) 1>      -- 成功进入界面

——————————————————————————————————————————————————————————————————

目标库操作:

 

说明 : 目标库的操作与源库以上操作全部相同(请参考上面的部分),操作完以上部分后,目标库的附加操作如下>

SQL> GRANT INSERT ANY TABLE TO goldengate;

Grant succeeded.

SQL> GRANT UPDATE ANY TABLE TO goldengate;

Grant succeeded.

SQL> GRANT DELETE ANY TABLE TO goldengate;

Grant succeeded.

 ————————————————————————————————————————————————————————————————————

4.  创建ogg子目录

源库与目标库都执行如下:  

GGSCI (11g) 3> create subdirs

Creating subdirectories under current directory /home/oracle/ogg

Parameter files /home/oracle/ogg/dirprm: already exists

Report files /home/oracle/ogg/dirrpt: created
Checkpoint files /home/oracle/ogg/dirchk: created
Process status files /home/oracle/ogg/dirpcs: created
SQL script files /home/oracle/ogg/dirsql: created
Database definitions files /home/oracle/ogg/dirdef: created
Extract data files /home/oracle/ogg/dirdat: created
Temporary files /home/oracle/ogg/dirtmp: created
Stdout files /home/oracle/ogg/dirout: created

参数说明:

该命令会在OGG安装目录下建立若干子目录,其中几个主要目录如下所示:

dirchk:用于存放各个进程的检查点
dirdat:用于存放数据队列文件
dirprm:用于存放各进程参数文件
dirrpt:用于存放各进程报告
dirpcs:存放各个正在运行的进程信息

 

 5. 创建mgr进程

 

GGSCI (11g) 4> edit param mgr    (--在mgr文件中加入  port 7809)

GGSCI (11g) 8> view param mgr

port 7809

GGSCI (11g) 5> start mgr

Manager started.

GGSCI (11g) 6> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING

————————————————————————————————————————————————————

源库操作:

6. 创建oggdemo测试用户

SQL> create user oggdemo identified by oggdemo;

User created.

SQL> grant dba to oggdemo;

Grant succeeded.

SQL> conn oggdemo;

Enter password: 
Connected.

SQL> create table oggdemo(id int);

Table created.

7.   GGSCI命令行中登录数据库,为所有要复制的数据表添加trandata

 

GGSCI (11g) 9> dblogin userid oggdemo , password oggdemo

Successfully logged into database.

GGSCI (11g) 10> add trandata oggdemo.oggdemo

2014-11-09 04:12:37 WARNING OGG-00869 No unique key is defined for table 'OGGDEMO'. 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 OGGDEMO.OGGDEMO.

————————————————————————————————————————————————————————————————

目标端操作:

SQL> create user oggdemo identified by oggdemo;

User created.

SQL> grant dba to oggdemo;

Grant succeeded.

SQL> conn oggdemo;

Enter password: 
Connected.

SQL> create table oggdemo(id int);

Table created.

————————————————————————————————————————————————————————

源库操作:

8.   创建ext进程,tail文件,data_pump进程

GGSCI (11g) 11> add ext exta, tranlog, begin now

EXTRACT added.

GGSCI (11g) 12> add exttrail /home/oracle/ogg/dirdat/la, ext exta, MEGABYTES 20      -- 创建源trail文件
EXTTRAIL added.

GGSCI (11g) 13> add extract dpea, EXTTRAILSOURCE /home/oracle/ogg/dirdat/la        -- 创建data_pump进程
EXTRACT added.

GGSCI (11g) 14> add rmttrail /home/oracle/ogg/dirdat/ra, ext dpea, MEGABYTES 20     --创建目标端trail文件
RMTTRAIL added.

GGSCI (11g) 15> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING 

EXTRACT STOPPED DPEA 00:00:00 00:02:48 
EXTRACT STOPPED EXTA 00:00:00 00:09:36

GGSCI (11g) 17> edit param exta    --exta文件添加内容显示如下

GGSCI (11g) 35> view param exta

EXTRACT exta

setenv (NLS_LANG = AMERICAN_AMERICA.ZHS16GBK )
setenv (ORACLE_SID = orcl)
USERID goldengate, PASSWORD goldengate
EXTTRAIL /home/oracle/ogg/dirdat/la
dynamicresolution
table oggdemo.oggdemo;

GGSCI (11g) 33> start exta

Sending START request to MANAGER ...

EXTRACT EXTA starting

GGSCI (11g) 34> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING 

EXTRACT STOPPED DPEA 00:00:00 01:40:39 
EXTRACT RUNNING EXTA 01:47:26 00:00:01

GGSCI (11g) 36> edit param dpea         --dpea文件添加内容显示如下

GGSCI (11g) 39> view param dpea

extract dpea

setenv (NLS_LANG = AMERICAN_AMERICA.ZHS16GBK )
passthru
rmthost 10.100.25.14,mgrport 7809, compress
rmttrail /home/oracle/ogg/dirdat/ra
dynamicresolution
table oggdemo.oggdemo;

 

参数说明:

passthru表示本进程是一个传输进程data pump,无需跟数据库交互,只需要搬运数据即可;

因为data pump要传输数据到目标,所以需要配置rmthost和rmttrail指定目标主机和队列信息

 

GGSCI (11g) 37> start dpea

Sending START request to MANAGER ...

EXTRACT DPEA starting

GGSCI (11g) 38> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING 

EXTRACT RUNNING DPEA 00:00:00 00:00:00 
EXTRACT RUNNING EXTA 00:00:00 00:00:04

————————————————————————————————————————————————————————————

 

目标数据库操作:

9.     创建目标数据库的replicate进程

GGSCI (11g) 6> add rep repa, exttrail /home/oracle/ogg/dirdat/ra, nodbcheckpoint

REPLICAT added.

参数说明: 

repa为进程名,一般为rep开头表示是replicat进程,后面可以加1-2位字符标识,一般与ext进程对应;

exttrail表示要抽取的数据队列,注意是目标端的队列位置;

nodbcheckpoint表示不使用数据库检查点。

 

GGSCI (11g) 17> edit param repa     -- repa文件添加内容显示如下

GGSCI (11g) 20> view param repa

replicat repa

setenv (NLS_LANG = AMERICAN_AMERICA.ZHS16GBK)
setenv (ORACLE_SID = orcl)
userid goldengate, password goldengate
reperror default,abend
discardfile /home/oracle/ogg/dirrpt/repa.dsc,append, megabytes 10
assumetargetdefs
dynamicresolution
map oggdemo.oggdemo, target oggdemo.oggdemo;

 

GGSCI (11g) 18> start repa

Sending START request to MANAGER ...

REPLICAT REPA starting

GGSCI (11g) 19> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING 

REPLICAT RUNNING REPA 00:00:00 00:00:01

 ————————————————————————————————————————————

ok 一切正常结束。

本文转自 张冲andy 博客园博客,原文链接:   http://www.cnblogs.com/andy6/p/6155488.html,如需转载请自行联系原作者

你可能感兴趣的文章
开源虚拟化解决方案-RHEV3.0
查看>>
手动升级 Confluence - 开始升级之前
查看>>
Docker快速入门(3)——Dockerfile构建镜像
查看>>
svnserve.conf:12: Option expected的问题解决方法
查看>>
python3使用django2.0的seeting配置文件详解
查看>>
男人不能没钱女人不能没爱
查看>>
redmine手机版-RedMiner Droid,Android与project_tree_view插件冲突
查看>>
Content-Disposition的作用(转)
查看>>
搜索引擎命令
查看>>
十二、Elasticsearch安装
查看>>
kubernetes集群安装部署
查看>>
我的友情链接
查看>>
可扩展Web架构与分布式系统
查看>>
我的友情链接
查看>>
java面向对象综合练习
查看>>
MySQL编译安装全过程
查看>>
Web前端实践经验总结
查看>>
Mybatis源码研究1:从JDBC到Mybatis
查看>>
推荐一个技术论坛 金蝶和通达为主的
查看>>
浅谈java中的static关键字
查看>>