利用阿里云开源项目otter架构实现mysql跨机房双A同步

1.本地mysql安装,直接到mysql官网下载rpm包安装即可(5.6.38)

1>安装完成后,在下载manager初始化系统表
[root@localhost ~]# wget https://raw.github.com/alibaba/otter/master/manager/deployer/src/main/resources/sql/otter-manager-schema.sql
mysql> source otter-manager-schema.sql

2.安装zookerper进行调度,因整个otter架构的依赖

1>下载tar包
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz

2>解压,修改配置文件
[root@localhost ~]# tar xf zookeeper-3.4.13.tar.gz -C /tmp/
[root@localhost ~]# mv /tmp/zookeeper-3.4.13 /tmp/zookeeper
[root@localhost ~]# cd /tmp/zookeeper
[root@localhost ~]# mv conf/zoo_sample.cfg conf/zoo.cfg

[root@localhost ~]# cat zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper
clientPort=2181
autopurge.purgeInterval=1

3>启动服务,需到bin目录下启动或停止,否则报错
[root@localhost ~]# cd /tmp/zookeeper/bin
[root@localhost ~]# ./zkServer.sh start | stop

4>验证服务启动是否完成
[root@localhost ~]# netstat -tnpl | grep 2181
tcp6 0 0 :::2181 :::* LISTEN 2193/java

3.安装otter manager

1>直接下载tar包
wget https://github.com/alibaba/otter/releases/download/otter-4.2.15/manager.deployer-4.2.15.tar.gz

2>解压,修改配置文件
[root@localhost ~]# mkdir /tmp/manager
[root@localhost ~]# tar xf manager.deployer-4.2.15.tar.gz -C /tmp/manager
[root@localhost ~]# cd /tmp/manager

[root@localhost ~]# cat conf/otter.properties
## otter manager domain name
otter.domainName = 192.168.1.x —修改为自己的IP
## otter manager http port
otter.port = 8080
## jetty web config xml
otter.jetty = jetty.xml

## otter manager database config
otter.database.driver.class.name = com.mysql.jdbc.Driver
otter.database.driver.url = jdbc:mysql://127.0.0.1:3306/otter —数据库信息
otter.database.driver.username = root
otter.database.driver.password = 123

## otter communication port
otter.communication.manager.port = 1099

## otter communication pool size
otter.communication.pool.size = 10

## default zookeeper address
otter.zookeeper.cluster.default = 127.0.0.1:2181 —修改为正确地址
## default zookeeper sesstion timeout = 60s
otter.zookeeper.sessionTimeout = 60000

## otter arbitrate connect manager config
otter.manager.address = ${otter.domainName}:${otter.communication.manager.port}

## should run in product mode , true/false
otter.manager.productionMode = true

## self-monitor enable or disable
otter.manager.monitor.self.enable = true
## self-montir interval , default 120s
otter.manager.monitor.self.interval = 120
## auto-recovery paused enable or disable
otter.manager.monitor.recovery.paused = true
# manager email user config
otter.manager.monitor.email.host = smtp.gmail.com
otter.manager.monitor.email.username =
otter.manager.monitor.email.password =
otter.manager.monitor.email.stmp.port = 465

3>启动或停止服务(当前目录为/tmp/manager)
[root@localhost ~]# bin/startup.sh | bin/stop.sh

4>验证端口,若没启动或者页面打不开,则查看logs/manager.log文件
[root@localhost manager]# netstat -tnpl | grep 8080
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 2761/java

5>访问 初始账户和密码为:admin 打开默认为匿名用户,只有只读权限,需登录管理员
http://192.168.1.x:8080/login.htm

4.安装otter node

1>node节点进行跨机房传输,利用http多线程传输,所以下载一个aria2c作为下载客户端
[root@localhost ~]# yum -y install epel-release
[root@localhost ~]# yum -y install aria2

2>下载tar包
[root@localhost ~]# wget https://github.com/alibaba/otter/releases/download/otter-4.2.15/node.deployer-4.2.15.tar.gz

3>解压,修改配置文件
[root@localhost ~]# mkdir /tmp/node
[root@localhost ~]# tar xf node.deployer-4.2.15.tar.gz -C /tmp/node
[root@localhost ~]# echo 1 > /tmp/node/conf/nid
[root@localhost ~]# cd /tmp/node/conf
[root@localhost conf]# cat otter.properties
# otter node root dir
otter.nodeHome = ${user.dir}/../

## otter node dir
otter.htdocs.dir = ${otter.nodeHome}/htdocs
otter.download.dir = ${otter.nodeHome}/download
otter.extend.dir= ${otter.nodeHome}/extend

## default zookeeper sesstion timeout = 60s
otter.zookeeper.sessionTimeout = 60000

## otter communication pool size
otter.communication.pool.size = 10

## otter arbitrate & node connect manager config
otter.manager.address = 127.0.0.1:1099

4>启动或停止服务(当前目录为/tmp/node)
[root@localhost node]# bin/startup.sh | bin/stop.sh

5>验证端口启动,若启动出错则查看logs/node/node.log文件查看(一般为manager的IP配置错误)
[root@localhost conf]# netstat -tnpl | grep 1099
tcp 0 0 0.0.0.0:1099 0.0.0.0:* LISTEN 1943/java

后续操作需在web界面进行,web界面操作略。

发表评论

电子邮件地址不会被公开。 必填项已用*标注