使用 tungsten-replicator4 实现 mysql -- > monogo 数据同步
来源:互联网 发布:抽奖软件免费下载 编辑:程序博客网 时间:2024/05/16 10:20
tungsten-replicator 是基于binlog的开源同步工具,其大概原理是 从mysql 端抓取 binlog日志,写到自己的 thl (transaction history log)中,再由 thl 发送到 nosql(mongo) 主机上thl 中,nosql 主机上的 thl 再写到 nosql 中
一 规划主机:
1、192.168.67.128 #mysql主机 (事先安装好,安装步骤详见 前一篇博客 )
2、192.168.67.129 #mongodb主机 (事先安装好,安装步骤详见 前一篇博客)
二 前置条件:(128和129)
1 创建tungsten用户
1、[root@localhost ~] useradd tungsten
2、[root@localhost ~] passwd tungsten
2 将tungsten账户添加到 mysql 用户组里
128主机:
[root@localhost ~] sudo usermod -G mysql tungsten
129主机
[root@localhost ~] sudo usermod -G mongod tungsten
3 修改sudoers权限,并且让 tungsten 用户使用 sudo 命令时免密码
[root@localhost ~] chmod 740 /etc/sudoers
[root@localhost ~] vi /etc/sudoers
添加如下一行:
tungsten ALL=(ALL) NOPASSWD: ALL
4 切换到 tungsten 用户下
[root@localhost ~] su - tungsten
5 切换到 tungsten 用户后,创建密钥对。默认在/home/tungsten/.ssh 目录下
[tungsten@localhost ~] ssh-keygen -t rsa
6 修改 limit 文件
[tungsten@localhost ~] vi /etc/security/limits.conf
添加下面一行:
* - nofile 65535
7 检查修改是否成功
[tungsten@localhost ~] ulimit -n
65535
8 配置hosts
[tungsten@localhost ~] sudo vi /etc/hosts
127.0.0.1 localhost
192.168.67.128 host1
192.168.67.129 host2
9 测试主机
[tungsten@localhost ~] uname -n
host1
10 测试ip地址
[tungsten@localhost ~] hostname –ip-address
11 防火墙设置
[tungsten@localhost ~] iptables -A INPUT -i lo -m state –state NEW -j ACCEPT
12 把生成的公钥和私钥拷贝到 tungsten用户的主目录下 。默认就在用户主目录
[tungsten@localhost ~] cp .ssh/id_rsa.pub .ssh/id_rsa /home/tungsten/.ssh
13 把公钥放到 .ssh/authorized_keys文件中,128 的公钥放到 129,129 的公钥放到 128
[tungsten@localhost ~] cat .ssh/id_rsa.pub >> .ssh/authorized_keys
14 修改权限
[tungsten@localhost ~] chmod 700 ~/.ssh
[tungsten@localhost ~] 600 ~/.ssh/*
15 测试主机间ssh
[tungsten@localhost ~] ssh tungsten@host2
16 修改mysql配置
[tungsten@localhost ~] vi /etc/my.cnf
server-id = 128
open_files_limit = 65535
log-bin = mysql-bin
sync_binlog = 1
max_allowed_packet = 52m
default-storage-engine = InnoDB
innodb_flush_log_at_trx_commit = 2
binlog-format = row
binlog-row-image = full
17 登录mysql,创建用户 tungsten 复制的 mysql 用户
[tungsten@localhost ~] /usr/bin/mysql
mysql> grant all privileges on . to tungsten_alpha@’%’ identified by ‘ts’ with grant options;
mysql> flush privileges;
三 安装服务:
1 创建 tungsten-replication 软件主目录
[tungsten@localhost ~] sudo mkdir /opt/continuent/soft
[tungsten@localhost ~] sudo chown -R tungsten /opt/continuent
[tungsten@localhost ~] sudo chmod 700 /opt/continuent
2 把下载好的 tungsten-replicator-4.0.0-2667425.tar.gz 包上传到 soft 目录
[tungsten@localhost ~] cd /opt/continuent/soft
[tungsten@host1 software] ll
[tungsten@host1 software] tungsten-replicator-4.0.0-2667425.tar.gz
[tungsten@host1 software] tar -zxvf tungsten-replicator-4.0.0-2667425.tar.gz
[tungsten@host1 software] cd tungsten-replicator-4.0.0-2667425
[tungsten@host1 tungsten-replicator-4.0.0-2667425]
128主机(mysql)上:
[tungsten@host1 tungsten-replicator-4.0.0-2667425] ./tools/tpm install alpha \
–info \
–master=192.168.67.128 \
–datasource-mysql-conf=/etc/my.cnf \
–enable-heterogenous-master=true \
–replication-user=tungsten_alpha \
–replication-password=ts \
–install-directory=/opt/continuent/alpha \
–start-and-report
129主机(mongo)上:
[tungsten@host2 tungsten-replicator-4.0.0-2667425]./tools/tpm install alpha \
–info \
–datasource-type=mongodb \
–master=192.168.67.128 \
–members=192.168.67.129 \
–enable-heterogenous-slave=true \
–topology=master-slave \
–install-directory=/opt/continuent/alpha \
–start-and-report
3 如果两个主机的 state 都是 online 说明 两个主机的 tungsten-replicator 都正常运行了
4 在mysql 主机上的 tungsten_alpha 库中 创建一张表,然后在mongo主机中查看 同步是否成功
转载于:http://my.oschina.net/wanglin123/blog/524123
- 使用 tungsten-replicator4 实现 mysql -- > monogo 数据同步
- tungsten-replicator 实现mysql 与mysql同步
- 使用tungsten-replicatior实现MySQL之间的主从复制
- MySQL数据同步实现
- 基于tungsten监测mysql数据修改系统介绍
- mysql数据双向同步实现
- 通过tungsten replicator实现mysql多主一从的备份架
- express+monogo实现ToDo Restful Api
- 使用RDS和本地mysql做主从同步,实现多服务器数据同步
- 基于tungsten API 同步mysql binlog出现EOF packet received的问题解决
- mysql-udf的使用---mysql自动同步数据到redis.redis连接池的实现
- 两台Mysql数据库数据同步实现
- 两台Mysql数据库数据同步实现
- 两台Mysql数据库数据同步实现
- MySQL UDF实现缓存数据同步
- 两台Mysql数据库数据同步实现
- 两台Mysql数据库数据同步实现
- Elasticserch与Mysql实现数据同步
- 解决eclipse插件svn不显示svn信息和显示的信息为数字的问题
- Bundle Adjustment——光束平差法
- 计算机审计数据采集、整理、分析点滴
- 新手第一次建站,在这里做个备忘录
- android性能优化总结
- 使用 tungsten-replicator4 实现 mysql -- > monogo 数据同步
- 解决“只能通过Chrome网上应用商店安装该程序”的方法
- 如何访问nc给外部访问的接口
- iOS开发UI中懒加载的使用方法
- ThreadGroup线程组使用
- Android Media显示的层次
- sql语句添加主键
- elasticsearch环境搭建与使用
- QGIS使用栅格图层