设为首页 收藏本站
查看: 802|回复: 0

[经验分享] 基于alibaba开源的分布式数据同步系统安装配置文档otter之环境配置

[复制链接]

尚未签到

发表于 2017-2-28 11:25:38 | 显示全部楼层 |阅读模式

otter项目开源地址:https://github.com/alibaba/otter
canal项目开源地址:https://github.com/alibaba/canal
我们的用这个系统的背景:主要是做异地容灾,可是我们需要的现网的数据需要同步到容灾区。
  工作原理:
   DSC0000.jpg

原理描述:
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

组件安装配置:
  配置数据库的字符集编码:
  查看字符编码:
   show variables like 'character%';
       设置字符集:uft8
       [client]
       default-character-set=utf8
         [mysqld]
       character-set-server=utf8


  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即可
    一条命令查看zk的:
      echo stat |nc 192.168.158.140 2181


  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单实例配置

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-348385-1-1.html 上篇帖子: 用Kotlin写一个基于Spring Boot的RESTful服务 下篇帖子: 使用CruiseControl+Ant的构建环境
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表