Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3124972
  • 博文数量: 710
  • 博客积分: 14546
  • 博客等级: 上将
  • 技术积分: 6738
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-30 10:20
文章分类

全部博文(710)

文章存档

2016年(1)

2014年(7)

2013年(22)

2012年(227)

2011年(322)

2009年(119)

2008年(12)

分类: Oracle

2012-07-18 14:15:19

引言:最近在论坛里经常会看到有朋友咨询Oracle GG 实施案例的帖子,诚然 GG 目前在各大论坛里的资料都不是很多 很全,尤其是真实实施案例就更凤毛麟角了,鉴于此我今天就为大家转一份朋友做过的GG实施给大家分享,本次分享的是“相同数据库之间的复制”,话不多说, 赶紧上干货
 

实验环境:oracle10g+redhat4+goldengate

一、安装redhat4,安装步骤略

二、安装oracle10g 安装步骤略

三、安装goldengate,注意要选对版本

1
、源端安装配置

1.1
安装goldengate

linux: mkdir /u01/oracle/ggate
cd /u01/oracle/ggate

通过ftp,将goldengatezip软件上传到/u01/oracle/ggate

unzip
解压,将生成一个tar文件

tar -xvf *.tar

1.2
配置.bash_profile


vi .bash_profile
添加:
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/oracle/ggate
export GGATE_HOME=/u01/oracle/ggate

注意LD_LIBRARY_PATH,那一行,可以在原来安装oracle的基础上添加在后面便可

配置完,运行 source ~./bash_profile

1.3
创建goldengate目录

cd /u01/oracle/ggate

./ggsci
(进入goldengate命令行界面)
Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.0.0 Build 078
Linux, x86, 32bit (optimized), Oracle 10 on Jul 28 2010 13:24:18
Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved


现在在goldengate命令行工作

create subdirs

1.4
配置数据库归档模式,进入sql命令行(如果关闭,建议开启)

sqlplus "/as sysdba"

alter system set log_archive_format='%s_%t_%r.log' scope=spfile;

alter system set log_archive_dest_1='location=/u02/oracle/arc';

shutdown immediate;

startup mount;

alter database archivelog;

开启强制日志模式:alter database force logging;

alter database open;

这下可以看一下归档是否已经起来,archive log list

1.5
开启minimal supplemental logging

--alter database add supplemental log data;
这种设置是许多文档介绍的,但是对于非主键或唯一索引表的会有问题,在测试过程中,发觉update会报错,可能其它地方没搞好!

alter database add supplemental log data(primary key,unique) columns;
这是我的配置!

1.6
关闭回收站

alter system set recyclebin=off scope=spfile;

1.7
配置复制的DDL支持

创建用户授权:

create user ggate identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;

grant connect,resource,dba to ggate;

grant execute on utl_file to ggate;

grant restricted session to ggate;

@$GGATE_HOME/marker_setup.sql;

SCHEMA:GGATE

@$GGATE_HOME/ddl_setup.sql;

这里要看清楚,选择输入,否则会有问题!

@$GGATE_HOME/role_setup.sql;

授予角色权力:
grant GGS_GGSUSER_ROLE to ggate;
@$GGATE_HOME/ddl_enable.sql;

1.8
创建源端用户(用于同步的用户)
create user sender identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;
grant dba,connect,resource to ggate;
grant select on v_$session to ggate;

2
、源端复制队列配置
2.1
配置manager
cd /u01/oracle/ggate
./ggsci (
进入goldengate命令行)
edit params mgr
输入:PORT 7809
vi操作基本相同


2.2
配置源端复制队列
同样是在goldengate命令行里做
add extract ext1, tranlog, begin now
add exttrail /u01/oracle/ggate/dirdat/lt, extract ext1
edit params ext1
输入如下内容:
extract ext1
userid ggate, password ggate
rmthost
目标机, mgrport 7809
rmttrail /u01/oracle/ggate/dirdat/lt
ddl include mapped objname sender.*;
table sender.*;
到这里,可以用info all查看一下,

关闭进程:
stop mgr
stop ext1

到这里源端基本上配置完毕
3
、目标端安装配置

3.1
安装goldengate

linux: mkdir /u01/oracle/ggate
cd /u01/oracle/ggate

通过ftp,将goldengatezip软件上传到/u01/oracle/ggate

unzip
解压,将生成一个tar文件

tar -xvf *.tar

3.2
配置.bash_profile
vi .bash_profile
添加:
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/oracle/ggate
export GGATE_HOME=/u01/oracle/ggate
注意LD_LIBRARY_PATH,那一行,可以在原来安装oracle的基础上添加在后面便可
配置完,运行 source ~./bash_profile


3.3创建goldengate目录
cd /u01/oracle/ggate
./ggsci
(进入goldengate命令行界面)
Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.0.0 Build 078
Linux, x86, 32bit (optimized), Oracle 10 on Jul 28 2010 13:24:18
Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved
现在在goldengate命令行工作
create subdirs


3.4创建目标端用户
create user ggate identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;
create user receiver identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;(
接收同步的用户)
grant connect,resource,dba to ggate;

grant execute on utl_file to ggate;

grant restricted session to ggate;

grant connect,resource,dba to receiver;

grant select on v_$session to receiver;

3.5
配置replicat
./ggsci

edit params ./GLOBALS

输入:
GGSCHEMA ggate
CHECKPOINTTABLE ggate.checkpoint

edit params mgr

输入:PORT 7809

goldengate命令行登录数据库

dblogin userid ggate,password ggate

add checkpointtable ggate.checkpoint (
增加检测点)

add replicat rep1, exttrail /u01/oracle/ggate/dirdat/lt, checkpointtable ggate.checkpoint(
增加同不队列)

edit params rep1

添加如下内容:
replicat rep1
ASSUMETARGETDEFS
userid ggate, password ggate
discardfile /u01/oracle/ggate/dirdat/rep1_discard.txt, append, megabytes 10
DDL include all
map sender.*, target receiver.*;

到这里上标端配置基本结束

四、额外增加的一个步骤,我是这样做

分别在源端、目标端增加

mkdir -p /u01/oracle/ggate/dirdat/lt

五、在goldengate命令行开启

源端:start manager
start ext1

目标:start manager
start rep1

六、测试:

源端:create table sender.test(empid number(4),names varchar2(10),oldage number(3));

目标:select * from receiver.test;

七、其它的一些错误查询等,去搜集相关资料

转http://www.dataguru.cn/blog-303-424.html

阅读(2190) | 评论(0) | 转发(0) |
0

上一篇:漫画HDFS

下一篇:跌打油

给主人留下些什么吧!~~