搭建otter数据库远程备份系统

刚好公司有远程数据备份的需求,网上找了一下,发现只有阿里的otter比较合适,而且是经过生产环境的验证,自己就在虚拟机下抢建试试,其实主要步骤如下:


MYSQL配置

两个MYSQL地址
192.168.230.128 root 123456
192.168.230.129 root 123456

两个库同时创建数据库:

DROP TABLE IF EXISTS `user_tab`;
CREATE TABLE `user_tab` (
  `id` int(4) NOT NULL,
  `name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

128的配置/etc/my.cnf添加

log-bin=mysql-bin
binlog_format=ROW
server-id=1
character_set_server=utf8

确认启动两个数据库,并可以跨机访问

配置zookeeper

zookeeper为大型分布式计算提供开源的分布式配置服务、同步服务和命名注册。 —— [ 维基百科 ]

ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、名字服务、分布式同步、组服务等。 —— [ 百度百科 ]

conf\zoo_sample.cfg 复制并重命名为zoo.cfg
在zoo.cfg后面添加

server.1=127.0.0.1:2887:3887

启动zookeeper

[root@localhost bin]# ./zkServer.sh start

配置manager

针对128数据库,初始化otter manager系统表:

[root@localhost bin]# wget https://raw.github.com/alibaba/otter/master/manager/deployer/src/main/resources/sql/otter-manager-schema.sql 
[root@localhost bin]# mysql -u root -p
mysql> source otter-manager-schema.sql

解压manager.deployer-4.2.12.tar.gz,修改conf/otter.properties

## otter manager domain name
otter.domainName = 192.168.230.128 
## 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://localhost/otter
otter.database.driver.username = root
otter.database.driver.password = 123456

## 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

启动

[root@localhost manager]# cd bin
[root@localhost bin]# ./startup.bat

查看日志

cat logs/manager.log
2013-08-14 13:19:45.911 [] WARN  com.alibaba.otter.manager.deployer.JettyEmbedServer - ##Jetty Embed Server is startup!
2013-08-14 13:19:45.911 [] WARN  com.alibaba.otter.manager.deployer.OtterManagerLauncher - ## the manager server is running now ......

出现类似日志,代表启动成功

验证

访问: http://192.168.230.128:8080/,出现otter的页面,即代表启动成功

访问:http://192.168.230.128:8080/login.htm,初始密码为:admin/admin,即可完成登录. 目前:匿名用户只有只读查看的权限,登录为管理员才可以有操作权限

关闭

./stop.sh

配置node

解压node.deployer-4.2.12.tar.gz

nid配置 :将环境准备中添加机器后获取到的序号,保存到conf目录下的nid文件,比如我添加的机器对应序号为1

echo 1 > conf/nid

启动node之前,需要先在manager之中配置node 节点,可以参考官方视频

配置完成之后,启动node

[root@localhost manager]# cd bin
[root@localhost bin]# ./startup.bat

查看日志

如果manager页面的ip配置不正确,会出现类似错误:

打开日志:

cat logs/node/node.log
Exception in thread "main" java.lang.IllegalArgumentException: node[1] ip[127.0.0.1] port[2088] , but your host ip[10.12.48.215] is not matched!
        at com.alibaba.otter.node.etl.OtterController.checkNidVaild(OtterController.java:245)
        at com.alibaba.otter.node.etl.OtterController.initNid(OtterController.java:230)
        at com.alibaba.otter.node.etl.OtterController.start(OtterController.java:73)
        at com.alibaba.otter.node.deployer.OtterLauncher.main(OtterLauncher.java:25)

此时修改ip为对应的host ip后,再次启动即可。

cat logs/node/node.log
2013-08-14 15:42:16.886 [main] INFO  com.alibaba.otter.node.deployer.OtterLauncher - INFO ## the otter server is running now ......

看到如下日志,代表node启动完成.

编译

安装好maven

java -version
mvn -version

执行命令

 mvn clean install -Dmaven.test.skip -Denv=release

进入目录maven\otter\target,可以看到Jar包

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐