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

本文详细介绍了DTLE集群的环境搭建、安装、配置及启动流程,通过具体实例展示了跨数据中心的数据同步配置,适用于追求高可用性的分布式系统架构师和运维工程师。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

博主首页 : 「**亮总说数**」 ,同名公众号 :「**亮总说数**」,wx号 : 「leonpenn」

一、环境说明

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官方文档

Allway Sync是一款专业好用的 Windows 文件同步软件。软件支持在本机不同的文件夹、网上邻居、FTP 、SFTP 等多种不同类型的设备之间进行差异分析及数据同步。值得一提的是软件自带一个小型数据库,监视每次更新后的文件状态。如果一次同步之后,你删除了同步文件夹中某些文件,它在同步的时候将其它的几个文件夹的副本也删除,而不会将未删除的旧文件重复拷贝到更新的文件夹。更棒的是,它强大的网络功能,帮您实现通过网络和任意一台电脑进行数据和文件的同步更新。是用户实现Windows 文件同步功能的好帮手。需要的朋友快来下载吧! Allway Sync功能 它可以在几个文件夹之间进行文件同步同步方式有源文件夹同步和各向同步两种方式: 一、源文件夹同步方式将以一个文件夹为基准,删除或覆盖其余文件夹与源文件相比较不相同的文件。 二、各向同步方式则自动将更新的文件覆盖几个同步文件夹中的旧文件。软件带有一个小型数据库,监视每次更新后的文件状态。如果在一次同步之后,你删除了同步文件夹中某些文件,它在同步的时候将其它的几个文件夹的副本也删除,而不会将不需要的未删除文件重复拷贝到已更新的文件夹。由于软件自己会对文件进行删除和覆盖,它提供了使用回收站进行文件备份的措施,使用者可以在不慎执行错误的同步动作之后,从回收站将错误删除或覆盖的文件找回来(默认禁用该功能,请到软件选项处激活相应设置)。 此外,该软件还具有自动同步功能,可以在指定的条件下自动执行同步任务。 该软件还可以通过指定文件筛选列表,过滤一些不希望同步的文件或文件夹。 如果您要同步的文件大小和数量不是很多,这个软件是免费的,您可以一直使用下去。如果您要同步的文件和数量太多,而且经常需要进行同步,那么可能就会超过它的使用许可,那您应该购买它的”专业版”使用许可,才能进行频繁的大量文件同步操作。 Allway Sync截图
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值