Job 示例
复制整个实例的所有数据库
job.hcl 中ReplicateDoDb配置:
ReplicateDoDb = []
复制指定数据库
ReplicateDoDb = [{
TableSchema = "action_db_1"
}]
复制一个库中的多个表
job.hcl 中ReplicateDoDb配置:
ReplicateDoDb = [{
TableSchema = "action_db_1"
Tables = [{
TableName = "sbtest1"
}, {
TableName = "sbtest2"
}, {
TableName = "sbtest3"
}]
}]
复制多个库中的多个表
job.hcl 中ReplicateDoDb配置:
ReplicateDoDb = [{
TableSchema = "action_db_1"
Tables = [{
TableName = "sbtest1"
}, {
TableName = "sbtest2"
}, {
TableName = "sbtest3"
}]
}, {
TableSchema = "action_db_2"
Tables = [{
TableName = "sbtest1"
}, {
TableName = "sbtest2"
}, {
TableName = "sbtest3"
}]
}]
带where条件复制任务
使用正则挑选复制库表
忽略指定的库
job.hcl通过以下配置忽略表db1及db1内所有的表
ReplicateDoDb = []
ReplicateIgnoreDb = [{
TableSchema = "db1"
}]
job.hcl通过以下配置在ReplicateDoDb指定的范围内忽略表db1和db1下的所有表,最终效果是没有要复制的库表
ReplicateDoDb = [{
TableSchema = "db1"
Tables = [{
TableName = "tb1"
}]
}]
ReplicateIgnoreDb = [{
TableSchema = "db1"
}]
忽略指定的表
job.hcl通过以下配置在ReplicateDoDb指定的范围内忽略db1.tb1,最终复制库db1下除了tb1以外的表
ReplicateDoDb = [{
TableSchema = "db1"
}]
ReplicateIgnoreDb = [{
TableSchema = "db1"
Tables = [{
TableName = "tb1"
}]
}]
job.hcl通过以下配置在ReplicateDoDb指定的范围内忽略db1.tb1,最终只复制库db1结构,但不复制db1下的任何表
ReplicateDoDb = [{
TableSchema = "db1"
Tables = [{
TableName = "tb1"
}]
}]
ReplicateIgnoreDb = [{
TableSchema = "db1"
Tables = [{
TableName = "tb1"
}]
}]
限定故障转移域
源端任务和目标端任务在指定datacenter
上故障转移
dtle配置文件:
name = "dtle-1" # rename for each node
datacenter = "shanghai"
...
job示例:
job "test_constraint" {
# 此处表示该job可以运行在datacenter为"shanghai"和"beijing"的节点上
datacenters = ["shanghai", "beijing"]
group "Src" {
constraint {
attribute = "${node.datacenter}"
operator = "="
value = "shanghai"
}
task "src" {
driver = "dtle"
config {
ReplicateDoDb = [{
TableSchema = "test"
}]
ConnectionConfig = {
...
}
}
}
}
group "Dest" {
constraint {
attribute = "${node.datacenter}"
operator = "="
value = "beijing"
}
task "dest" {
driver = "dtle"
config {
ConnectionConfig = {
...
}
}
}
}
}