加入收藏 | 设为首页 | 会员中心 | 我要投稿 源码网 (https://www.900php.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ogg异构oracle-mysql

发布时间:2020-12-24 11:16:11 所属栏目:百科 来源:网络整理
导读:副标题#e# /* 参数文件里,TABLE参数中有cols和COLSEXCEPT 项 前者用来选择要capture的字段,后者指定要排除的字段 但是官方文档上有一句 Do not exclude key columns,and do not use COLSEXCEPT to exclude columns that contain unsupported data types.
副标题[/!--empirenews.page--]

/*
参数文件里,TABLE参数中有cols和COLSEXCEPT 项
前者用来选择要capture的字段,后者指定要排除的字段
但是官方文档上有一句
Do not exclude key columns,and do not use COLSEXCEPT to exclude columns that contain unsupported data types.
*/
scott.bonus表无主键无唯一索引,若是在gg源端发出,会导致gg目的端abend,除非目的端复制进程参数文件有APPLYNOOPUPDATES 或者ALLOWNOOPUPDATES 参数)

--当目标端为oracle时 用rowid解决增量同步
--1.
--源端
--add trandata hr.ah9 cols(id) nokey
--目标端
alter table hr.ah9 add (row_id rowid);
alter table hr.ah9 add constraint ah9_pk unique (row_id) enable;
map hr.ah9,target hr.ah9 colmap (usedefaults,row_id = @token ("TKN-ROWID")) keycols (row_id);

--2.编辑ext1,排除不需要同步的列 或用COLS捕获需要同步的列
table ggs.test_pri,COLSEXCEPT (NAME2,NAME3);

一、环境描述:
源端:
ip:192.168.92.31
os:redhat5.4
Oracle: 11.2.0.1.0
goldgate:12.1.2.1.0 for oracle
字符集:gbk
目标端:
os:redhat5.4
Mysql:5.7.18
goldgate:12.1.2.1.0 for mysql
ip:192.168.92.61
字符集:utf8

二、Oracle to Mysql 需要注意的地方:
Supported data types for mysql:
CHARDOUBLETINYTEXTVARCHARDATEMEDIUMTEXTINTTIMELONGTEXTTINYINTYEARBLOBSMALL INTDATETIMETINYBLOBMEDIUM INTTIMESTAMPMEDIUMBLOBBIG INTBINARYLONGBLOBDECIMALVARBINARYENUMFLOATTEXTBIT(M)
Oracle GoldenGate supports InnoDB storage engine for a source MySQL database
goldengate对mysql只支持innodb引擎
所以,在创建mysql端的表的时候,要指定表为innodb引擎。
create table mysql (name char(10)) engine=innodb;
当然5.5默认的存储引擎就是InnoDB。

三、Oracle端的基础配置
1.安装oracle11g略过
2.初始化ogg
将ogg压缩包(V34339-01.zip)解压到 /home/oracle/app/oracle/ogg 下
cd /home/oracle/app/oracle/ogg
./ggsci

--已存在 不需要执行
create subdirs
Creating subdirectories under current directory /home/oracle/app/oracle/ogg
Parameter files /home/oracle/app/oracle/ogg/dirprm: already exists
Report files /home/oracle/app/oracle/ogg/dirrpt: created
Checkpoint files /home/oracle/app/oracle/ogg/dirchk: created
Process status files /home/oracle/app/oracle/ogg/dirpcs: created
SQL script files /home/oracle/app/oracle/ogg/dirsql: created
Database definitions files /home/oracle/app/oracle/ogg/dirdef: created
Extract data files /home/oracle/app/oracle/ogg/dirdat: created
Temporary files /home/oracle/app/oracle/ogg/dirtmp: created
Stdout files /home/oracle/app/oracle/ogg/dirout: created
3.修改oracle数据库的参数
3.1 修改数据库为归档模式
3.2 打开辅助日志
alter database add supplemental log data;
3.3 关闭回收站
alter system set recyclebin=off deferred;

--Oracle11.2.0.4版本需要更改 ENABLE_GOLDENGATE_REPLICATION
ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;

3.4 创建复制用的用户,并授权
--创建相应表空间
create tablespace oggtbs datafile ‘/home/oracle/app/oracle/oradata/ORCL/datafile/oggtbs01.dbf‘ size 500M autoextend on;

--授权
create user ggs identified by ggs default tablespace oggtbs;
GRANT create table to ggs;
GRANT CONNECT TO ggs;
GRANT ALTER ANY TABLE TO ggs;
GRANT ALTER SESSION TO ggs;
GRANT CREATE SESSION TO ggs;
GRANT FLASHBACK ANY TABLE TO ggs;
GRANT SELECT ANY DICTIONARY TO ggs;
GRANT SELECT ANY TABLE TO ggs;
GRANT RESOURCE TO ggs;
GRANT DELETE ANY TABLE TO ggs;
GRANT INSERT ANY TABLE TO ggs;
GRANT UPDATE ANY TABLE TO ggs;
GRANT RESTRICTED SESSION TO ggs;

3.5 登陆到ogg,执行初始化
在源库上执行:
GGSCI (ora11g) 2> edit params ./globals
在统计模式下输入并保存:ggschema ggs

在SQLPLUS 下去运行:
quit
sqlplus / as sysdba
@sequence.sql 根据提示输入:ggs

--#必须,针对ddl复制
alter system set recyclebin=off deferred scope=both;
--ogg安装目录执行配置脚本 prompt输入 ggs
@marker_setup.sql
@ddl_setup.sql
@role_setup.sql

grant GGS_GGSUSER_ROLE to ggs;
@ddl_enable.sql

--10g需要安装dbms_share_pool包:
@?/rdbms/admin/dbmspool.sql ho
@ddl_pin ggs;

四、Mysql端的基础配置
1.安装mysql5.7略过
2.给root配置密码:
mysql> use mysql
mysql> UPDATE user SET authentication_string =PASSWORD(‘123456‘) where USER=‘root‘ and host=‘root‘ or host=‘localhost‘;
mysql> show grants for root;
mysql> FLUSH PRIVILEGES;
mysql> exit
3.因为复制需要二进制日志,所以启动mysql的时候需要启用二进制日志
mysqld_safe --user=mysql --log-bin=/tmp/binlog.001 --log-bin-index=/tmp/binlog.index --max-binlog-size=10M --binlog-do-db=mysql &

--解压安装ogg by zhuyj
unzip V47367-01_GoldenGate V12.1.2.1.0 for MySQL on Linux x86-64.zip
mkdir /usr/local/ogg
tar -xvf ggs_Linux_x64_MySQL_64bit.tar /usr/local/ogg

4.创建ogg的初始化目录
[[email?protected] 11.2]$ ./ggsci

Oracle GoldenGate Command Interpreter for MySQL
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230
Linux,x64,64bit (optimized),MySQL Enterprise on Apr 23 2012 04:34:25
Copyright (C) 1995,2012,Oracle and/or its affiliates. All rights reserved.

(编辑:源码网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读