跨机房数据双向同步工具之DTLE(更新中)

一、环境说明

2节点DTLE:

test_node1:192.168.222.76

角色:server+client

test_node2:192.168.222.77

角色:client

二、安装

准备安装包:

Releases · actiontech/dtle · GitHub

rpm -ivh dtle-3.20.08.0.x86_64.rpm

三、配置

配置文件位于:/etc/dtle/consul.hcl、/etc/dtle/nomad.hcl

3.1、consul.hcl

修改:node_name = "consul_node1" # 剩余节点分别为consul_node2

3.2、nomad.hcl

node1:

name = "nomad1" # rename for each node
datacenter = "dc1"
data_dir  = "//var/lib/nomad"
plugin_dir = "//usr/share/dtle/nomad-plugin"

log_level = "Info"
log_file = "//var/log/nomad/"

disable_update_check = true

bind_addr = "192.168.222.76"
# change ports if multiple nodes run on a same machine
ports {
  http = 4646
  rpc  = 4647
  serf = 4648
}
addresses {
  # Default to `bind_addr`. Or set individually here.
}
advertise {
  http = "192.168.222.76:4646"
  rpc  = "192.168.222.76:4647"
  serf = "192.168.222.76:4648"
}

server {
  enabled          = true

  bootstrap_expect = 1
  # Set bootstrap_expect to 3 for multiple (high-availablity) nodes.
  # Multiple nomad nodes will join with consul.
}

client {
  enabled = true
  options = {
    "driver.blacklist" = "docker,exec,java,mock,qemu,rawexec,rkt"
  }

  # Will auto join other server with consul.
}

consul {
  # dtle-plugin and nomad itself use consul separately.
  # nomad uses consul for server_auto_join and client_auto_join.
  # Only one consul can be set here. Write the nearest here,
  #   e.g. the one runs on the same machine with the nomad server.
  address = "192.168.222.76:8500"
}

plugin "dtle" {
  config {
    data_dir = "//var/lib/nomad"
    nats_bind = "192.168.222.76:8193"
    nats_advertise = "192.168.222.76:8193"
    # Repeat the consul address above.
    consul = "192.168.222.76:8500"

    # By default, API compatibility layer is disabled.
    #api_addr = "127.0.0.1:8190"   # for compatibility API
    nomad_addr = "192.168.222.76:4646" # compatibility API need to access a nomad server

    publish_metrics = false
    stats_collection_interval = 15
  }
}

node2:

name = "nomad2" # rename for each node
datacenter = "dc1"
data_dir  = "//var/lib/nomad"
plugin_dir = "//usr/share/dtle/nomad-plugin"

log_level = "Info"
log_file = "//var/log/nomad/"

disable_update_check = true

bind_addr = "192.168.222.77"
# change ports if multiple nodes run on a same machine
ports {
  http = 4646
  rpc  = 4647
  serf = 4648
}
addresses {
  # Default to `bind_addr`. Or set individually here.
}
advertise {
  http = "192.168.222.77:4646"
  rpc  = "192.168.222.77:4647"
  serf = "192.168.222.77:4648"
}

server {
  enabled          = false

  bootstrap_expect = 1
  # Set bootstrap_expect to 3 for multiple (high-availablity) nodes.
  # Multiple nomad nodes will join with consul.
}

client {
  enabled = true
  options = {
    "driver.blacklist" = "docker,exec,java,mock,qemu,rawexec,rkt"
  }

  # Will auto join other server with consul.
}

consul {
  # dtle-plugin and nomad itself use consul separately.
  # nomad uses consul for server_auto_join and client_auto_join.
  # Only one consul can be set here. Write the nearest here,
  #   e.g. the one runs on the same machine with the nomad server.
  address = "192.168.222.77:8500"
}

plugin "dtle" {
  config {
    data_dir = "//var/lib/nomad"
    nats_bind = "192.168.222.77:8193"
    nats_advertise = "192.168.222.77:8193"
    # Repeat the consul address above.
    consul = "192.168.222.77:8500"

    # By default, API compatibility layer is disabled.
    #api_addr = "127.0.0.1:8190"   # for compatibility API
    nomad_addr = "192.168.222.77:4646" # compatibility API need to access a nomad server

    publish_metrics = false
    stats_collection_interval = 15
  }
}

四、启动

服务启动命令:

systemctl start dtle-nomad

systemctl start dtle-consul # 单server模式下,node2无需执行

systemctl enable dtle-consul dtle-nomad # 开机自动启动

五、测试

5.1、测试实例

mysql dc1:192.168.222.76:3306

mysql dc2:192.168.222.77:3306

5.2、job配置

dc1 => dc2

{
  "Job": {
    "ID":"demo-dc1-dc2",
    "Datacenters": ["dc1"],
    "TaskGroups": [{
        "Name": "src",
        "Tasks": [{
          "Name": "src",
          "Driver": "dtle",
          "Affinities": [{
            "LTarget": "${node.unique.name}",
            "RTarget": "nomad1",
            "Operand": "="
          }],
          "Config": {
            "Gtid":"41f102d4-d29f-11e8-8de7-0242ac130002:1-5",
            "ConnectionConfig": {
              "Host":"mysql-dc1",
              "Port": 3306,
              "User": "cdc_user",
              "Password": "123456"
            }
          }
        }]
      }, {
        "Name": "dest",
        "Tasks": [{
          "Name": "dest",
          "Driver": "dtle",
          "Affinities": [{
            "LTarget": "${node.unique.name}",
            "RTarget": "nomad2",
            "Operand": "="
          }],
          "Config": {
            "ConnectionConfig": {
              "Host":"mysql-dc2",
              "Port": 3306,
              "User": "cdc_user",
              "Password": "123456"
            }
          }
        }]
    }]
  }
}

参考文档:

DTLE官方文档

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值