基于alibaba开源的分布式数据同步系统安装配置文档otter之环境配置,alibabaotter
基于alibaba开源的分布式数据同步系统安装配置文档otter之环境配置,alibabaotter
otter项目开源地址:https://github.com/alibaba/otter canal项目开源地址:https://github.com/alibaba/canal 我们的用这个系统的背景:主要是做异地容灾,可是我们需要的现网的数据需要同步到容灾区。 |
工作原理:
原理描述: 1.基于Canal开源产品,获取数据库增量日志数据。 什么是Canal, 请点击 2.典型管理系统架构,manager(web管理)+node(工作节点) a. manager运行时推送同步配置到node节点 b. node节点将同步状态反馈到manager上 3.基于zookeeper,解决分布式状态调度的,允许多node节点之间协同工作. |
组件解释: canal: 什么是canal? otter之前开源的一个子项目,开源链接地址:http://github.com/alibaba/canal 定位:基于数据库增量日式解析,提供增量数据订阅&消费,目前主要支持了mysql 工作原理: 原理相对简单:类似MYSQL原有的主从复制机制。 1.canal模拟mysql slave 的交互协议,伪装自己为mysql slave,想mysql master发送dump协议 2.mysql master收到dump请求,开始推送binary log给slave(也就是canal) 3.canal解释binary log 对象(原始为byte流) 相关文档: See the wiki page for : wiki文档 |
环境配置: canal、otter依赖jdk环境、node依赖 aria2启动: apt-get update && apt-get install default-jdk aria2 -y |
组件安装配置:
canal:
a. canal原理基于mysql binlog技术;需要binlog的支持,而且log的format格式为ROW:
[mysqld]
log-bin=mysql-bin #添加这一行就ok
binlog-format=ROW #选择row模式
server_id=1 #配置mysql replaction需要定义,不能和canal的slaveId重复
b. 授权slave同步:
CREATE USER canal IDENTIFIED BY 'canal';
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
或者:GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;
FLUSH PRIVILEGES;
解压直接使用。
配置文件:
vi conf/example/instance.properties
#################################################
## mysql serverId
canal.instance.mysql.slaveId = 1234
# position info,需要改成自己的数据库信息
canal.instance.master.address = 127.0.0.1:3306 #指定master 的ip:port
canal.instance.master.journal.name = #配置binlog的file 可以不用配置(默认是以当前启动)
canal.instance.master.position = #配置binlog的postion 可以不用配置(默认是以当前启动)
canal.instance.master.timestamp =
#canal.instance.standby.address =
#canal.instance.standby.journal.name =
#canal.instance.standby.position =
#canal.instance.standby.timestamp =
# username/password,需要改成自己的数据库信息
canal.instance.dbUsername = canal #配置为授权的账号
canal.instance.dbPassword = canal #配置授权的密码
canal.instance.defaultDatabaseName = #可以指定数据库
canal.instance.connectionCharset = UTF-8 #配置编码格式
# table regex
canal.instance.filter.regex = .*\\..*
#################################################
启动、停止:
bin/startup.sh bin/stop.sh
zookeeper:
安装配置:
配置所有的zk主机的hosts文件
192.168.56.1 zk
192.168.56.2 re
192.168.56.3 yt
zk配置文件: vim conf/zoo.cfg ################################################# # The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/usr/local/zk_cluster/zookeeper-3.4.6_node1/data #目录需要创建 #dataLogDir # the port at which the clients will connect clientPort=2181 #每一个节点的port也不一样 server.1=zk:2887:3892 #不管是前面的port还是后面的port。每一个节点都不一样 server.2=zk:2888:3893 server.3=zk:2889:3894 server.4=re:3386:3388:observer #远端的zkobserver角色 server.5=re:3387:3389:observer #远端的zkobserver角色 server.6=yt:2892:3895:observer #远端的zkobserver角色 # the maximum number of client connections. # increase this if you need to handle more clients observer配置: # The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 peerType=observer #指定此节点为observer类型 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/usr/local/zk_cluster/zookeeper-3.4.6_node4/data #dataLogDir # the port at which the clients will connect clientPort=2184 server.1=zk:2887:3892 server.2=zk:2888:3893 server.3=zk:2889:3894 server.4=re:2890:3890:observer server.5=re:2891:3891:observer server.6=yt:2892:3895:observer # the maximum number of client connections. # increase this if you need to handle more clients 启动、停止: zookeeper-3.4.6_node4/bin/zkServer.sh start zookeeper-3.4.6_node4/bin/zkServer.sh stop 注意:每一个节点都有一个唯一的myid,这个需要在data目录下创建一个myid文件并将本地节点对应的server.x x的id写入myid中。data目录需要建立哦 列如: 第一个节点: server.1=zk:2887:3892 只需要在myid文件中输入 1即可 otter: manager: manager是web管理界面,需要mysql数据库的支持,在manager上部署mysql、授权。还需要原始的数据、载入原始数据;网上下载即可: wget https://raw.github.com/alibaba/otter/master/manager/deployer/src/main/resources/sql/otter-manager-schema.sql 配置文件: vim conf/otter.properties ## otter manager domain name #修改为正确访问ip,生成URL使用 otter.domainName = 192.168.56.4 #配置访问的域名或者ip ## otter manager http port otter.port = 8080 #配置web访问的port ## 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.01:3306/ottermanager #配置manager链接数据库 otter.database.driver.username = otter #配置连接数据库的用户名 otter.database.driver.password = otter #配置连接数据库的密码 ## otter communication port otter.communication.manager.port = 1099 #配置node链接的port ## otter communication pool size otter.communication.pool.size = 10 ## default zookeeper address,修改为正确的地址,手动选择一个地域就近的zookeeper集群列表 otter.zookeeper.cluster.default = 192.168.56.1:2181,192.168.56.1 :2182,192.168.56.1:2183,192.168.56.2:3384,192.168.56.2:3385,192.168.56.3:2186 #配置一个就近的zk群集地址 写离manager最近的一个也可以 例如:192.168.56.1:2181 ## default zookeeper sesstion timeout = 90s otter.zookeeper.sessionTimeout = 90000 ## otter arbitrate connect manager config otter.manager.address = ${otter.domainName}:${otter.communication.manager.port 启动、停止: bin/startup.sh bin/stop.sh 访问url: http://192.168.168.4:8080 默认账号密码:admin/admin node: vim conf/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 = 192.168.56.4:1099 # 指定manager的ip:port 启动、停止:注:node启动需要先配置nid,下面解释。 bin/startup.sh bin/stop.sh 注意:这里提到一个nid,这是node唯一的标识 我们如何得到这个nid的标识号呢?这个在manager上面添加的node产生的,下面会提到。 这个nid文件需要在node的conf目录;也是只是添加标识号即可。nid位于conf目录下。 下回文档: 基于alibaba开源的分布式数据同步系统安装配置文档otter之manager单实例配置 |
评论暂时关闭