开启的ogg的安装和使用篇幅
总结了一下,安装ogg总共分为一下几个步骤
在Linux上安装OGG很简单,总体分为以下几个部分:
1.Downloading Oracle GoldenGate software.
2.Setting ORACLE_HOMEand ORACLE SID
3.Setting library paths for dynamic builds
4. Installing the Oracle GoldenGate software
根据官方文档进行安装。这里不做讲解。
有两种方式安装ogg:
选择自己对应的系统,因为我这里是linux系统,所以我选择下载第一个。
这里直接给出下载地址点击即可下载
环境介绍,为了节省资源OGG我选择和原库安装在了同一台服务器
软件版本 | IP地址 |
---|---|
OGG19.1 | 192.168.234.128 |
MYSQL5.7 | 192.168.234.128 |
MYSQL5.7 | 192.168.234.129 |
安装之前,介绍一下ogg的目录用途说明:
名字 | 用途 |
---|---|
dirprm | 存放ogg参数的配置信息 |
dirrpt | 存放进程报告文件 |
dirchk | 存放检查点文件 |
dirpcs | 存放进程状态文件 |
dirsql | 存放sql的简脚本文件 |
dirdef | 存放DEFGEN工具生成数据定义文件 |
dirdat | 存放trail,也就capture的进程捕获日志文件 |
dirtmp | 当事务需要内存超过已分配内存时候,默认存储的目录 |
介绍完成以后,我们首先来配置源库和目标库
OGG19C可以使用基于日志的DDL复制,要求添binlog_row_metadata为full模式才可以实现
目标库配置
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
user=mysql
port=3306
character-set-server=utf8mb4
symbolic-links=0
server_id = 1
log_bin = mysql-bin
expire_logs_days = 1
binlog_format = row
binlog_row_metadata=full
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
主备数据库创建同步用户并附权
CREATE USER 'ogg'@'%' IDENTIFIED BY 'Sandata@123';
GRANT ALL PRIVILEGES ON *.* TO 'ogg'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
在19C的OGG中ogg可以单独部署并不需要每台服务器都安装,只要网络可达即可
[root@master 191003_ggs_Linux_x64_MySQL_64bit]# ./ggsci
Oracle GoldenGate Command Interpreter for MySQL
Version 19.1.0.0.3 OGGCORE_19.1.0.0.0_PLATFORMS_190907.0144
Linux, x64, 64bit (optimized), MySQL Enterprise on Sep 7 2019 08:41:32
Operating system character set identified as UTF-8.
Copyright (C) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
GGSCI (master) 4> edit param mgr
PORT 17809
DYNAMICPORTLIST 17810-17909
AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 3
PURGEOLDEXTRACTS ./dirdat/*,usecheckpoints, minkeepdays 3
1.3.2 配置EXTRACT进程
GGSCI (master) 5> edit param EXM8
extract exm8
sourcedb wutong@192.168.2.251:3306, userid ogg, password Sandata@123
tranLogOptions altlogDest REMOTE
ddl include mapped
exttrail ./dirdat/m8
table wutong.*;
GGSCI (master) 6> add ext exm8, tranlog, begin now
GGSCI (master) 7> add exttrail ./dirdat/m8, ext exm8
1.3.3配置REPLICAT进程,配置pump进程并不是必须的,这里选择没有配置
GGSCI (master) 8> edit param REP252
replicat rep252
targetdb wutong@192.168.2.252:3306, userid ogg, password Sandata@123
DDLERROR DEFAULT IGNORE RETRYOP
map wutong.*, target wutong.*;
1.3.4 启动所有的进程
GGSCI (master) 10> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXM8 00:00:00 00:00:08
REPLICAT RUNNING REP252 00:00:00 00:00:00
主库
mysql> use kayleigh;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+------------------—+
| Tables_in_kayleigh|
+------------------+
| test2 |
+------------------+
1 row in set (0.00 sec)
目标库
mysql> use kayleigh;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+------------------+
| Tables_in_kayleigh|
+------------------+
| test2 |
+------------------+
1 row in set (0.00 sec)
主库
mysql> create table sandata (id int,name varchar(20));
Query OK, 0 rows affected (0.07 sec)
mysql> insert into sandata values (1,'wutong');
Query OK, 1 row affected (0.04 sec)
mysql> select * from sandata
-> ;
+------+--------+
| id | name |
+------+--------+
| 1 | wutong |
+------+--------+
1 row in set (0.00 sec)
目标库
mysql> show tables;
+------------------+
| Tables_in_wutong |
+------------------+
| test2 |
+------------------+
1 row in set (0.00 sec)
mysql> show tables;
+------------------+
| Tables_in_wutong |
+------------------+
| sandata |
| test2 |
+------------------+
2 rows in set (0.00 sec)
mysql> select * from sandata;
+------+--------+
| id | name |
+------+--------+
| 1 | wutong |
+------+--------+
1 row in set (0.00 sec)