Loading...
Tungsten Replicator 4.0 Mysql主从复制环境配置

数据存储篇 2015/09/23

前置条件:

两台CentOS 6.7虚拟机:centos1、centos2

分配的IP地址:centos1:192.168.42.133、centos2:192.168.42.134

Tungsten Replicator安装包:tungsten-replicator-oss-4.0.1-123.tar.gz 下载地址:https://code.google.com/p/tungsten-replicator/

MySql安装包:MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle.tar   下载地址:http://dev.mysql.com/downloads/mysql/

JDK1.7


服务器主机和网络环境配置:

1、将centos1主机名称更改为centos1

uname -a 查看hostname

hostname centos1.imethan.cn 修改让hostname立刻生效

vi /etc/hosts 修改原hostname为 centos1.imethan.cn

vi  /etc/sysconfig/network 修改原hostname为 centos1.imethan.cn,这样可以让reboot重启后也生效

reboot重启,uname -a 重新检查


2、将centos2主机名称更改为centos2

同1


3、主机dns host配置 vi /etc/hosts

#centos1配置

#127.0.0.1 centos1.imethan.cn  centos1

::1 centos16.imethan.cn centos16

192.168.42.133  centos1.imethan.cn  centos1

192.168.42.134  centos2.imethan.cn  centos2


#centos2配置

#127.0.0.1 centos2.imethan.cn   localhost

::1 centos26.imethan.cn  centos26

192.168.42.133  centos1.imethan.cn   centos1

192.168.42.134  centos2.imethan.cn   centos2

3、添加用户tungsten

sudo adduser tungsten

sudo usermod -G mysql tungsten

4、ssh免密码登录配置,使得centos1和centos2相互免密码登录

ssh-keygen -t rsa -P ''

scp /home/tungsten/.ssh/id_rsa.pub tungsten@centos1:/home/tungsten/.ssh/authorized_keys

service sshd restart

5、安装JDK1.7(安装略

6、安装mysql(安装略

编辑配置文件,vi /usr/my.cnf在最后面添加如下内容

#other config

server-id = 1

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

innodb_flush_method=O_DIRECT

binlog-format = row

binlog-row-image = full

service mysql restart


添加配置mysql用户

CREATE USER tungsten@'%' IDENTIFIED BY '123456';GRANT ALL ON *.* TO tungsten@'%'  WITH GRANT OPTION;

CREATE USER tungsten@'centos1' IDENTIFIED BY '123456';GRANT ALL ON *.* TO tungsten@'centos1'  WITH GRANT OPTION;

CREATE USER tungsten@'centos2' IDENTIFIED BY '123456';GRANT ALL ON *.* TO tungsten@'centos2'  WITH GRANT OPTION;


防火墙端口开放:

ssh默认端口:22

mysql默认端口3306

Tungsten端口

ComponentSourceDestinationPortPurpose
Database ServiceDatabase HostDatabase Host7Checking availability
2112THL replication
10000-10001Replication connection listener port
ComponentPortPurpose
2114THL replication
10002-10003Replication connection listener ports
Client Application13306MySQL port for Connectivity
Manager Hosts7Communication between managers within multi-site, multi-master clusters


安装Tungsten Replicator

mkdir /opt/continuent/software

cd /opt/continuent/software

解压tungsten-replicator-oss-4.0.1-123.tar.gz至/opt/continuent/software

tar -zxvf tungsten-replicator-oss-4.0.1-123.tar.gz

cd tungsten-replicator-oss-4.0.1-123

#添加配置文件

vi /etc/tungsten/tungsten.ini

[one]

user=tungsten

topology=master-slave

install-directory=/opt/continuent

master=centos1

members=centos1,centos2

replication-user=tungsten

replication-password=123456

replication-port=3306

datasource-mysql-conf=/usr/my.cnf

start-and-report=true

profile-script=~/.bash_profile

#开始安装
./tools/tpm install

source /opt/continuent/share/env.sh


8、command命令使用

开机自启动:deployall

取消开机自启动:undeployall


cd /opt/continuent/tungsten/tungsten-replicator/bin

关闭:replicator stop

启动:replicator start


查看状态

trepctl services

trepctl status

trepctl -host host2 status


参考:

http://pubs.vmware.com/continuent/tungsten-replicator-4.0/index.html

https://code.google.com/p/tungsten-replicator/



Comments