ogg 配置复习(dml>ddl>sequnce)

<strong><span style="color:#ff6666;">dml 配置过程与测试概要</span></strong>

在源端创建专用的表空间、schema、并授权。
create tablespace goldengate datafile 'goldengate01.dbf' size 100m autoextend on;
create user goldengate identified by goldengate default tablespace goldengate temporary tablespace temp;
grant connect to goldengate;
grant alter any table to goldengate;
grant alter session to goldengate;
grant create session to goldengate;
grant flashback any table to goldengate;
grant select any dictionary to goldengate;
grant select any table to goldengate;
grant resource to goldengate;
grant select any transaction to goldengate;

检查源端数据库是否在归档模式,强烈建议在归档模式。
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /arch
Oldest online log sequence     1
Next log sequence to archive   3
Current log sequence           3

端:
添加附加日志来唯一标识一行记录,要在数据库级别打开最小开关。为了减少整个数据库添加附加日志,以及减少归档量,
goldengate建议复制哪些对象,就添加哪些表的附加日志(我们到时候是拿hr用户下的表来实验)。
检查:
SQL> select supplemental_log_data_min from v$database;
SUPPLEME
--------
NO
打开:
SQL> alter database add supplemental log data;
Database altered.
再次查看:
SQL> <span style="color:#ff6666;">select supplemental_log_data_min from v$database;</span>
SUPPLEME
--------
YES
切换日志组,使附加日志开关生效。
SQL> alter system switch logfile;
System altered.
解释:在正常情况下,oracle是用rowid来唯一标示一行记录的,但goldengate这里不够,需要打开附加日志。

安装与配置
GGSCI (gg2) 2><span style="color:#ff6666;"> create subdirs</span>
GGSCI (oratest) 80> view params mgr
port 7839
DYNAMICPORTLIST 7840-7850
AUTOSTART EXTRACT *
AUTORESTART EXTRACT *
PURGEOLDEXTRACTS ./dirdat/*,usecheckpoints, minkeepdays 7
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45

启动配置的管理进程
GGSCI (gg2) 4> start mgr
Manager started.

select owner||'.'||table_name table_name,logging
from dba_tables
where owner='SENDER';

SQL> alter table SENDER.A1 logging;

源端:
配置hr下面表的表级附加日志。配置登陆用户。并检查日志是否添加成功。
以goldengate这个schema登陆数据库。
GGSCI (gg1) 10><span style="color:#ff6666;"> dblogin userid goldengate, password goldengate</span>
Successfully logged into database.

查看:
GGSCI (gg1) 11> info trandata hr.*
add extract ext_demo, tranlog, begin now, threads 1

参数分析:
tranlog:表示数据抓取的来源是数据库的redo数据。
begin now:表示我们在启动这个抓取进程的就去抓取数据。
threads 1:表示我们数据库有多少个redo threads,单实例基本上是1或者不设,rac就自己设置了,配置过RAC的基本都了解

添加源端的队列文件。
GGSCI (gg1) 15> <span style="color:#3333ff;">add extract ext_demo,<span style="background-color: rgb(102, 102, 204);">tranlog</span>, begin now, threads 1</span>
GGSCI (gg1) 15> <span style="color:#ff0000;">add EXTTRAIL ./dirdat/r1, extract ext_demo,megabytes 100</span>
EXTTRAIL added

./dirdat:表示trail文件的目录
r1:trail文件的前缀
extract ext_demo:值指定给那个进程用的(ext_demo)。
megabytes 100:文件大小是100m

编辑我们刚刚在源端配置的抓取进程的参数:
GGSCI (gg1) 16><span style="color:#ff6666;"> edit param ext_demo</span>
EXTRACT EXT_DEMO
userid goldengate,password goldengate
REPORTCOUNT EVERY 1 MINUTES, RATE
numfiles 5000
DISCARDFILE ./dirrpt/ext_demo.dsc,APPEND,MEGABYTES 1000
DISCARDROLLOVER AT 3:00
exttrail ./dirdat/r1,megabytes 100
dynamicresolution
TRANLOGOPTIONS EXCLUDEUSER goldengate
TRANLOGOPTIONS convertucs2clobs
TRANLOGOPTIONS DBLOGREADER
TABLE SENDER.*;

setenv (ORACLE_SID=ogg):指定oracle的sid,单机环境下可以不设或者bashprofile文件中设置了默认的,也可以不设,但是集群环境就要指定了,这里我们强烈建议指定。
setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK):源端数据库的字符集,一定要跟数据库中匹配。
userid goldengate,password goldengate:告诉抓取进程是通过这个用户登陆数据库的。
exttrail ./dirdat/r1,megabytes 100:与我们上面配置抓取进程的设置要一致,路径和大小嘛。
TABLE HR.*:最重要的,告诉抓取进程抓取的是哪些用户哪些表的数据

配置datapump进程,将抓取数据传到目标主机。负责TCPIP通讯。
GGSCI (gg1) 31> <span style="color:#ff0000;">add extract dpe_demo, exttrailsource ./dirdat/r1</span>
EXTRACT added.

输出:目标主机怎么写,也是定义datapumo进程的输出。
GGSCI (gg1) 33><span style="color:#ff6666;"> add rmttrail ./dirdat/t1,EXTRACT dpe_demo,MEGABYTES 100</span>
RMTTRAIL added.

分析:
exttrailsource:抓取进程的来源,因为这个进程不否则到数据库中取抓取,所以抓取的来源
是通过抓取进程已经生成好的trail文件中的内容。

17、
配置datapump进程参数:
GGSCI (oratest) 83> <span style="color:#ff0000;">view params dpe_demo</span>
extract dpe_demo
dynamicresolution
passthru
rmthost 192.168.175.139, mgrport 7840, compress
rmttrail ./dirdat/t1
numfiles 5000
TABLE SENDER.*;

GGSCI (oratest) 84> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     DPE_DEMO    00:00:00      00:00:00
EXTRACT     RUNNING     EXT_DEMO    00:00:00      00:00:06
GGSCI (oratest) 85> 

passthru:上面已经说过不需要连接数据库,所以用这个指令。
rmthost:目标主机的IP地址,就是说我们的rmttrail进程发送到的主机。
mgrport:目标主机管理进程的端口号,我们上面已经配置了。
compress:在传输的过程中启用压缩。
rmttrail:路径和文件与上面配置的一致。
TABLE SENDER.*:上面说过,哪些表的redo信息传输。

目标端:
创建golengate软件使用的schema,并授权一些必要的特殊权限,注意与源端有所区别,保证我们能DML。
create tablespace goldengate datafile 'goldengate01.dbf' size 100m autoextend on;
create user goldengate identified by goldengate default tablespace goldengate temporary tablespace temp;
grant connect to goldengate;
grant alter any table to goldengate;
grant alter session to goldengate;
grant create session to goldengate;
grant flashback any table to goldengate;
grant select any dictionary to goldengate;
grant select any table to goldengate;
grant resource to goldengate;
grant insert any table to goldengate;
grant update any table to goldengate;
grant delete any table to goldengate;
grant create any index to goldengate;
grant select any transaction to goldengate;

目标端:
为replicat进程创建checkpoint表:
GGSCI (gg2) 1> <span style="color:#ff0000;">dblogin userid goldengate,password goldengate</span>
Successfully logged into database.

GGSCI (gg2) 2> <span style="color:#ff0000;">add checkpointtable goldengate.rep_demo_ckpt</span>
Successfully created checkpoint table goldengate.rep_demo_ckpt.

21、
配置目标端replicate进程:
GGSCI (gg2) 3> <span style="color:#ff6666;">add replicat rep_demo,exttrail ./dirdat/t1,checkpointtable goldengate.rep_demo_ckpt</span>
REPLICAT added.

分析:
exttrail:表示这个进程获取数据的来源是什么地方,是我们源端rmttrail所设置过的。

22、
配置目标端replicate参数:
GGSCI (oratest) 13> <span style="color:#ff6666;">view params rep_demo</span>
REPLICAT rep_demo
USERID goldengate,PASSWORD goldengate
REPORTCOUNT EVERY 30 MINUTES, RATE
REPERROR DEFAULT, ABEND
numfiles 5000
--HANDLECOLLISIONS
assumetargetdefs
DISCARDFILE ./dirrpt/rep_demo.dsc, APPEND, MEGABYTES 1000
ALLOWNOOPUPDATES
MAP SENDER.*,TARGET SENDER.*;

分析:重要的地方与上面基本一致,有兴趣可以查查其他参数的信息。
MAP:源端和目标端的对应。

添加表格的时候 先在目标添加,再元端,数据库可以自动同步!

<strong><span style="color:#ff6666;">1.4 启用DDL</span></strong>
SQL>@marker_setup.sql    --提示输入目标schema
SQL>@ddl_setup.sql       --提示输入目标schema,输入initialsetup最后输入yes
SQL>@role_setup.sql
SQL>grant GGS_GGSUSER_ROLE to ddw; --不进行该步赋权后面起进程会报错
SQL>@ddl_enable.sql                --使触发器生效

1.5 清除DDL 同步设置
如果因为DDL 同步出现很多问题,最简单的方法就是卸载之后重建。安装目录下只提供了清除对象的脚本,可以如下操作:
首先要求把所有的GG进程停掉,包括mgr进程

SQL>@ddl_disable.sql  --首先使DDL触发器失效
SQL>@ddl_remove.sql
SQL>@marker_remove.sql

alter table OGG1.A1 logging;
info trandata OGG1.*
add extract ext2,tranlog, begin now, threads 1
add EXTTRAIL ./dirdat/r3, extract ext2,megabytes 100

EXTRACT ext2
userid goldengate,password goldengate
REPORTCOUNT EVERY 1 MINUTES, RATE
numfiles 5000
DISCARDFILE ./dirrpt/ext_demo1.dsc,APPEND,MEGABYTES 1000
DISCARDROLLOVER AT 3:00
exttrail ./dirdat/r2,megabytes 100
ddl include all
TABLE OGG1.*;

add extract dpe_ext2, exttrailsource ./dirdat/r3
add rmttrail ./dirdat/t3,EXTRACT dpe_ext2,MEGABYTES 100

extract dpe_ext2
dynamicresolution
passthru
rmthost 192.168.175.139, mgrport 7840, compress
rmttrail ./dirdat/t3
numfiles 5000
TABLE OGG1.*;

add replicat rep_ext2,exttrail ./dirdat/t3,checkpointtable goldengate.rep_demo_ckpt

REPLICAT rep_ext2
USERID goldengate,PASSWORD goldengate
REPORTCOUNT EVERY 30 MINUTES, RATE
REPERROR DEFAULT, ABEND
numfiles 5000
--HANDLECOLLISIONS
assumetargetdefs
DISCARDFILE ./dirrpt/rep_rep2.dsc, APPEND, MEGABYTES 1000
ALLOWNOOPUPDATES
MAP OGG1.*,TARGET OGG1.*;
<strong><span style="color:#ff6666;">启用序列:</span><span style="color:#ff6666;">目标端:</span></strong>
SQL> @sequence.sql
Please enter the name of a schema for the GoldenGate database objects:
goldengate
Setting schema name to GOLDENGATE
UPDATE_SEQUENCE STATUS:
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
GETSEQFLUSH
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
SEQTRACE
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
REPLICATE_SEQUENCE STATUS:
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
STATUS OF SEQUENCE SUPPORT
--------------------------------------------------------------
SUCCESSFUL installation of Oracle Sequence Replication support
SQL> GRANT EXECUTE on goldengate.replicateSequence to ogg1;
Grant succeeded.
SQL> 

目标端:
SQL> @sequence.sql
Please enter the name of a schema for the GoldenGate database objects:
goldengate
Setting schema name to GOLDENGATE
UPDATE_SEQUENCE STATUS:
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
GETSEQFLUSH
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
SEQTRACE
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
REPLICATE_SEQUENCE STATUS:
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
STATUS OF SEQUENCE SUPPORT
--------------------------------------------------------------
SUCCESSFUL installation of Oracle Sequence Replication support
SQL> GRANT EXECUTE on goldengate.replicateSequence to ogg1;
Grant succeeded.
SQL> 

复制进程:

传输进程:
GGSCI (oratest) 41> edit params DPE_EXT2

extract dpe_ext2
dynamicresolution
passthru
rmthost 192.168.175.139, mgrport 7840, compress
rmttrail ./dirdat/t3
numfiles 5000
TABLE OGG1.*;
SEQUENCE OGG1.*;
~
"dirprm/dpe_ext2.prm" 8L, 158C written

GGSCI (oratest) 42> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
EXTRACT     RUNNING     DPE_DEMO    00:00:00      00:00:00
EXTRACT     RUNNING     DPE_EXT2    00:00:00      00:00:04
EXTRACT     RUNNING     EXT1        00:00:00      00:00:09
EXTRACT     RUNNING     EXT2        00:00:00      00:00:06
EXTRACT     RUNNING     EXT_DEMO    00:00:00      00:00:09    

GGSCI (oratest) 43> stop DPE_EXT2

Sending STOP request to EXTRACT DPE_EXT2 ...
Request processed.

GGSCI (oratest) 44> start DPE_EXT2

Sending START request to MANAGER ...
EXTRACT DPE_EXT2 starting
GGSCI (oratest) 45> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     DPE_DEMO    00:00:00      00:00:00
EXTRACT     RUNNING     DPE_EXT2    00:00:00      00:00:05
EXTRACT     RUNNING     EXT1        00:00:00      00:00:00
EXTRACT     RUNNING     EXT2        00:00:00      00:00:03
EXTRACT     RUNNING     EXT_DEMO    00:00:00      00:00:09    

GGSCI (oratest) 46> 

抽取进程:
GGSCI (oratest) 48> edit params EXT2

EXTRACT ext2
userid goldengate,password goldengate
REPORTCOUNT EVERY 1 MINUTES, RATE
numfiles 5000
DISCARDFILE ./dirrpt/ext2.dsc,APPEND,MEGABYTES 1000
DISCARDROLLOVER AT 3:00
exttrail ./dirdat/r3,megabytes 100
ddl include all
TRANLOGOPTIONS DBLOGREADER
TABLE OGG1.*;
SEQUENCE OGG1.*;
~
"dirprm/ext2.prm" 11L, 284C written

GGSCI (oratest) 49> stop ext2

Sending STOP request to EXTRACT EXT2 ...
Request processed.

GGSCI (oratest) 50> start ext2

Sending START request to MANAGER ...
EXTRACT EXT2 starting

GGSCI (oratest) 51> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     DPE_DEMO    00:00:00      00:00:07
EXTRACT     RUNNING     DPE_EXT2    00:00:00      00:00:02
EXTRACT     RUNNING     EXT1        00:00:00      00:00:06
EXTRACT     RUNNING     EXT2        00:00:03      00:00:07
EXTRACT     RUNNING     EXT_DEMO    00:00:00      00:00:05    

GGSCI (oratest) 52> 

提前修改该文件:
修改文件:
GGSCI (oratest) 79> EDIT PARAMS ./GLOBALS
GGSCHEMA goldengate
~
FLUSH SEQUENCE ogg1.*
<strong><span style="color:#ff0000;">重启更加有效果!</span></strong>

时间: 2024-10-11 22:58:25

ogg 配置复习(dml>ddl>sequnce)的相关文章

CENTOS6.5一步一步安装OGG实现DML DDL单向复制及服务器故障恢复

一.环境描述 操作系统版本: CentOS-6.5-x86_64 系统分区: sda:40G sda1:500M /boot EXT4 sda2: 39.5G /为LVM,包括:lv_swap 4G,lv_root 35.6G 源端[A]系统数据库 IP: 192.168.81.211 目标端[B]系统数据库 IP: 192.168.81.212 Vip:192.168.81.210(规划中,暂未使用) 数据库版本: oracle_112030_Linux-x86-64 Oracle Base:

【OGG】OGG的单向DML复制配置(一)

[OGG]OGG的单向DML复制配置(一) BLOG文档结构图 前言部分 导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~: ① OGG的单向DML实时复制功能 ② 数据库的静默安装 ③ OGG的安装 ④ OGG下数据的初始化工作 注意:本篇BLOG中代码部分需要特别关注的地方我都用***背景和红色字体来表示,比如下边的例子中,thread 1的最大归档日志号为33,thread 2的最大归档日志号为43是需要特别关注的地方. Lis

PLSQL_PLSQL中DML DDL DCL的概念和区分(概念)

2014-06-20 BaoXinjian 一.摘要 DML(data manipulation language): 它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样,这4条命令是用来对数据库里的数据进行操作的语言 DDL(data definition language): DDL比DML要多,主要的命令有CREATE.ALTER.DROP等,DDL主要是用在定义或改变表(TABLE)的结构,数据类型,表之间的链接和约束等初始化工作上,他们大多在建立表时使用 D

dljd_(007_008)_jdbc执行DQL/DML/DDL语句

一.使用JDBC执行DQL/DML/DDL语句示例 1.1数据库设计 create database jdbc; use jdbc; create table test( id int primary key auto_increment, name varchar(10) ); insert into test values(1,"name1"); insert into test values(2,"name2"); insert into test value

oracle ogg配置

http://www.dataguru.cn/thread-171156-1-1.html GoldenGate几个重要进程介绍: 1.Manager管理进程在两端开启,监控和重启其他进程:分配数据存储和报告错误及事件: 2.Extract进程从日志中抓取并传输到target端事务数据: 3.Server Collector进程在target(接受)端接受数据并写入trail文件: 4.Replicat进程读取trail文件,并应用到traget数据库: 5.trail文件时gg自己抓捕信息的文

Oracle DML,DDL,DCL,DQL

DML(data manipulation language): 数据操作语言,对数据库里的数据进行操作的语言,包括命令SELECT.UPDATE.INSERT.DELETE.CALL.EXPLAIN PLAN.LOCK TABLE.详解如下: 1)SELECT - retrieve data from the a database 查询 即数据查询语言DQL,基本结构是由SELECT子句,FROM子句,WHERE子句组成的查询块: SELECT <字段名表> FROM <表或视图名&g

SQLite中DML DDL DML命令的区别[转]

总体解释: DML(data manipulation language):       它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样,这4条命令是用来对数据库里的数据进行操作的语言DDL(data definition language):       DDL比DML要多,主要的命令有CREATE.ALTER.DROP等,DDL主要是用在定义或改变表(TABLE)的结构,数据类型,表之间的链接和约束等初始化工作上,他们大多在建立表时使用DCL(Data Con

SQL语句 DML,DDL,DCL

数据控制语言(DCL)是用来设置或者更改数据库用户或角色权限的语句,这些语句包括GRANT.DENY.REVOKE等语句,在默认状态下,只有 sysadmin.dbcreator.db_owner或db_securityadmin等角色的成员才有权利执行数据控制语言. GRANT语句是授权语句,它可以把语句权限或者对象权限授予给其他用户和角色. DENY语句用于拒绝给当前数据库内的用户或者角色授予权限,并防止用户或角色通过其组或角色成员继承权限. REVOKE语句是与GRANT语句相反的语句,它

DML,DDL,DCL,DQL的区别

DML 英文缩写 DML = Data Manipulation Language,数据操纵语言,命令使用户能够查询数据库以及操作已有数据库中的数据的计算机语言.具体是指是UPDATE更新.INSERT插入.DELETE删除. DML = Data Media Laboratory,数据媒体实验室. DML = Doctor of Modern Languages,现代语言博士. DML(DataManipulation Language)数据操纵语言,SQL的分类之一,此外还有DDL(Data