首页 > 其他分享 >tidb-dm工具迁移使用

tidb-dm工具迁移使用

时间:2022-10-11 21:44:06浏览次数:47  
标签:dm 1.13 tiup tidb dmctl 172.16 迁移 NULL root

参考官方文档:

https://docs.pingcap.com/zh/tidb-data-migration/v5.3/migrate-data-using-dm

 

常用命令:

tiup dm display dm-test  查看dm集群状态

 


1、安装dm,dmctl完成后,先加载数据源配置文件

[root@mysql-4 ~]# tiup dmctl --master-addr=172.16.1.13:8261 operate-source create mysql-source-conf1.yaml
tiup is checking updates for component dmctl ...
Starting component `dmctl`: /root/.tiup/components/dmctl/v6.3.0/dmctl/dmctl --master-addr=172.16.1.13:8261 operate-source create mysql-source-conf1.yaml
{
"result": true,
"msg": "",
"sources": [
{
"result": true,
"msg": "",
"source": "mysql-replica-01",
"worker": "dm-172.16.1.13-8262"
}
]
}

 


2、查看数据源配置文件

[root@mysql-4 ~]# tiup dmctl --master-addr=172.16.1.13:8261 get-config source mysql-replica-01
tiup is checking updates for component dmctl ...
Starting component `dmctl`: /root/.tiup/components/dmctl/v6.3.0/dmctl/dmctl --master-addr=172.16.1.13:8261 get-config source mysql-replica-01
{
"result": true,
"msg": "",
"cfg": "enable-gtid: false\nauto-fix-gtid: false\nrelay-dir: relay-dir\nmeta-dir: \"\"\nflavor: mysql\ncharset: \"\"\nenable-relay: false\nrelay-binlog-name: \"\"\nrelay-binlog-gtid: \"\"\nsource-id: mysql-replica-01\nfrom:\n host: 172.16.1.10\n port: 3306\n user: root\n password: '******'\n max-allowed-packet: null\n session: {}\n security: null\npurge:\n interval: 3600\n expires: 0\n remain-space: 15\nchecker:\n check-enable: true\n backoff-rollback: 5m0s\n backoff-max: 5m0s\n check-interval: 5s\n backoff-min: 1s\n backoff-jitter: true\n backoff-factor: 2\nserver-id: 429557913\ntracer: {}\ncase-sensitive: false\nfilters: []\n"
}

 

3、查看数据源和 work 节点对应关系
[root@mysql-4 ~]# tiup dmctl --master-addr=172.16.1.13:8261 operate-source show
tiup is checking updates for component dmctl ...
Starting component `dmctl`: /root/.tiup/components/dmctl/v6.3.0/dmctl/dmctl --master-addr=172.16.1.13:8261 operate-source show
{
"result": true,
"msg": "",
"sources": [
{
"result": true,
"msg": "",
"source": "mysql-replica-01",
"worker": "dm-172.16.1.13-8262"
}
]
}


4、配置DM任务文件,其中主要是源和目标端,及过滤规则,以单库同步为例。

name: "dm-taskX"
task-mode: all
ignore-checking-items: ["auto_increment_ID"]
target-database:
  host: "172.16.1.12"
  port: 4000
  user: "root_admin"
  password: "123456"

mysql-instances:
 -
  source-id: "mysql-replica-01"
  route-rules: ["instance-1-ceshi-rule"]
  block-allow-list: "global"
  mydumper-config-name: "global"
  loader-config-name: "global"
  syncer-config-name: "global"

# 所有实例的共有配置
routes:
  instance-1-ceshi-rule:
    schema-pattern: "ceshi"
    target-schema: "ceshi2"
mydumpers:
  global:
    threads: 4
    chunk-filesize: 64
loaders:                             # load 处理单元的运行配置参数
  global:                            # 配置名称
    pool-size: 16                    # load 处理单元并发执行 dump 处理单元的 SQL 文件的线程数量,默认值为 16,当有多个实例同时向 TiDB 迁移数据时可根据负载情况适当调小该值
    dir: "./dumped_data"             # dump 处理单元输出 SQL 文件的目录,同时也是 load 处理单元读取文件的目录。该配置项的默认值为 "./dumped_data"。同实例对应的不同任务必须配置不同的目录
syncers:                             # sync 处理单元的运行配置参数
  global:                            # 配置名称
    worker-count: 16                 # 应用已传输到本地的 binlog 的并发线程数量,默认值为 16。调整此参数不会影响上游拉取日志的并发,但会对下游产生显著压力。
    batch: 100                       # sync 迁移到下游数据库的一个事务批次 SQL 语句数,默认值为 100,建议一般不超过 500。
    enable-ansi-quotes: true         # 若 `session` 中设置 `sql-mode: "ANSI_QUOTES"`,则需开启此项
block-allow-list:                     # 如果 DM 版本早于 v2.0.0-beta.2 则使用 black-white-list。
  global:
    do-dbs: ["ceshi"]                        # 需要迁移的上游表的白名单。

 

4.1 查询源数据库测试,会出一些错误信息,源端都是测试表,建的很随意,根据报错信息整改一下。


[root@mysql-4 ~]# tiup dmctl --master-addr=172.16.1.13:8261 check-task dm-task.yaml
tiup is checking updates for component dmctl ...
Starting component `dmctl`: /root/.tiup/components/dmctl/v6.3.0/dmctl/dmctl --master-addr=172.16.1.13:8261 check-task dm-task.yaml
{
"result": false,
"msg": "[code=26005:class=dm-master:scope=internal:level=medium], Message: fail to check synchronization configuration with type: check was failed, please see detail
detail: {
"results": [
{
"id": 7,
"name": "table structure compatibility check",
"desc": "check compatibility of table structure",
"state": "fail",
"errors": [
{
"severity": "warn",
"short_error": "table `ceshi`.`tt7` Foreign Key fk_id is parsed but ignored by TiDB.",
"instruction": "please ref document: https://docs.pingcap.com/tidb/stable/mysql-compatibility#unsupported-features"
},
{
"severity": "fail",
"short_error": "table `ceshi`.`time` primary/unique key does not exist",
"instruction": "please set primary/unique key for the table"
},
{
"severity": "fail",
"short_error": "table `ceshi`.`t2` primary/unique key does not exist",
"instruction": "please set primary/unique key for the table"
}
],
"extra": "address of db instance - 172.16.1.10:3306"
}
],
"summary": {
"passed": false,
"total": 8,
"successful": 7,
"failed": 1,
"warning": 0
}
}"
}

 

整改过后就正常了

[root@mysql-4 ~]# tiup dmctl --master-addr=172.16.1.13:8261 check-task dm-task.yaml
tiup is checking updates for component dmctl ...
Starting component `dmctl`: /root/.tiup/components/dmctl/v6.3.0/dmctl/dmctl --master-addr=172.16.1.13:8261 check-task dm-task.yaml
{
"result": true,
"msg": "check pass!!!"
}

 

4.2开始复制任务
[root@mysql-4 ~]# tiup dmctl --master-addr=172.16.1.13:8261 start-task dm-task.yaml
tiup is checking updates for component dmctl ...
Starting component `dmctl`: /root/.tiup/components/dmctl/v6.3.0/dmctl/dmctl --master-addr=172.16.1.13:8261 start-task dm-task.yaml
{
"result": true,
"msg": "",
"sources": [
{
"result": true,
"msg": "",
"source": "mysql-replica-01",
"worker": "dm-172.16.1.13-8262"
}
],
"checkResult": ""
}


4.3查看源端会话列表,看到有DM的连接了
MySQL [ceshi]> show processlist;
MySQL [ceshi]> show processlist;
+-----+------+----------------------+-------+-------------+------+---------------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+------+----------------------+-------+-------------+------+---------------------------------------------------------------+------------------+
| 93 | root | localhost:56128 | ceshi | Query | 0 | starting | show processlist |
| 252 | root | mysql-4.shared:34216 | NULL | Sleep | 10 | | NULL |
| 253 | root | mysql-4.shared:34218 | NULL | Sleep | 7 | | NULL |
| 263 | root | mysql-4.shared:34306 | NULL | Binlog Dump | 7 | Master has sent all binlog to slave; waiting for more updates | NULL |
+-----+------+----------------------+-------+-------------+------+---------------------------------------------------------------+------------------+
4 rows in set (0.000 sec)

查看目标端,发现有好多MD会话
mysql> show processlist;
+------+------------+-------------------+--------+---------+------+------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+------------+-------------------+--------+---------+------+------------+------------------+
| 115 | root_admin | 172.16.1.13:34120 | NULL | Sleep | 58 | autocommit | NULL |
| 149 | root_admin | 172.16.1.13:34158 | NULL | Sleep | 58 | autocommit | NULL |
| 155 | root_admin | 172.16.1.13:34164 | NULL | Sleep | 58 | autocommit | NULL |
| 103 | root_admin | 172.16.1.13:34108 | NULL | Sleep | 57 | autocommit | NULL |
| 177 | root_admin | 172.16.1.13:34186 | NULL | Sleep | 58 | autocommit | NULL |
| 161 | root_admin | 172.16.1.13:34170 | NULL | Sleep | 58 | autocommit | NULL |
| 173 | root_admin | 172.16.1.13:34182 | NULL | Sleep | 58 | autocommit | NULL |
| 183 | root_admin | 172.16.1.13:34192 | NULL | Sleep | 57 | autocommit | NULL |
| 117 | root_admin | 172.16.1.13:34122 | NULL | Sleep | 58 | autocommit | NULL |
| 129 | root_admin | 172.16.1.13:34134 | NULL | Sleep | 58 | autocommit | NULL |
| 159 | root_admin | 172.16.1.13:34168 | NULL | Sleep | 58 | autocommit | NULL |
| 169 | root_admin | 172.16.1.13:34178 | NULL | Sleep | 58 | autocommit | NULL |....

 

小插曲,dm版本5.3 DMCTL版本6.3,导致DMCTL停任务时失败,版本需要对齐
tiup uninstall dmctl --all
tiup install dmctl:v5.3.0


4.4停任务正确提示

[root@mysql-4 ~]# tiup dmctl --master-addr=172.16.1.13:8261 stop-task dm-task.yaml
tiup is checking updates for component dmctl ...
A new version of dmctl is available:
The latest version: v6.3.0
Local installed version: v5.3.0
Update current component: tiup update dmctl
Update all components: tiup update --all

Starting component `dmctl`: /root/.tiup/components/dmctl/v5.3.0/dmctl/dmctl --master-addr=172.16.1.13:8261 stop-task dm-task.yaml
{
"op": "Stop",
"result": true,
"msg": "",
"sources": [
{
"result": true,
"msg": "",
"source": "mysql-replica-01",
"worker": "dm-172.16.1.13-8262"
}
]
}

标签:dm,1.13,tiup,tidb,dmctl,172.16,迁移,NULL,root
From: https://www.cnblogs.com/nanxiang/p/16782701.html

相关文章

  • 华为云UGO携核心技术解决您的数据迁移难题 !
        数据迁移一直是所有企业都想克服的重点难题之一,想要彻底解决必然面临许多困难,比如语法不兼容、技术不支持、改造成本高......尤其对于异构数据库来说,“迁不了、移......
  • django ImportExportModelAdmin 导出的文件中中文乱码解决方案
    @admin.register(BuildFunction)classBuildFunctionAdmin(SimpleHistoryAdmin,ImportExportModelAdmin):form=BuildFunctionFormlist_display=('id','c......
  • DML操作数据
    添加数据insertinto表名(列的名称)(数据);添加全部数据的时候可以把列的名称省略;修改数据update表名 set列名=数据,列名=数据, [where列名=数据];注意:如果没有条......
  • 05. Kubernetes - Kubeadm 节点 / Token 管理
    删除节点有些时候某些机器出现问题可能需要将其下掉,或者在初始化节点的时候信息初始化的有问题需要重新加入,这时候就涉及到删除节点的问题。具体删除办法如下,Master节点......
  • neo4j图形数据库数据迁移(导入导出)
    1.准备在导入导出(迁移备份)数据库之前,首先需要关闭相应neo4j./neo4jstop2.数据导出进入$NEO4J_HOME/bin目录执行如下数据库导出命令:neo4j-admindump--database......
  • 记录一次oracle数据迁移
    背景:要把系统再部署一套,现在系统考虑用原来系统的(基础)数据。所以需要把原来的数据导出,放到新系统数据库中。 操作:--[1.1]登陆原系统sqlplus/assysdba--[1.2]查......
  • 高效的代码迁移方案(使用 git)
    1.把ics2021做个备份,存为ics2021_backup2.来到ics2021/PA,把PA1-2的所有commit压缩成一个commit,使用gitrebase-i<after-this-commit>命令来源:https://sta......
  • RedisShake迁移同步工具
    阿里开源项目地址:https://github.com/alibaba/RedisShake程序下载地址:https://github.com/alibaba/RedisShake/releases下载最新程序,里面包含了配置文件https://gith......
  • \$readmemb和\$readmemh
    1,verilog中\$readmemb和$readmemh的用法2,verilog的系统函数\$readmemh的使用3,\$readmemb和\$readmemh......
  • 【 云原生 | kubernetes 】- kubeadm部署k8s集群(超详细)
    Kubeadm是kubernetes社区为了方便普通用户学习k8s,发起的一个简单上手的部署工具。不用把大量时间花费在搭建集群上面。只需通过两条命令就可以部署一个k8s集群#创建一......