当前位置:网站首页>Migrate data from Mysql to tidb from a small amount of data
Migrate data from Mysql to tidb from a small amount of data
2022-07-03 06:05:00 【Tianxiang shop】
This document describes how to use TiDB DM ( hereinafter referred to as DM) In full quantity + Incremental mode data to TiDB. In this article “ Small data volume ” Usually refers to TiB Below grade .
generally speaking , Receive information such as the number of table structure indexes 、 Hardware and network environment impact , Migration rate at 30~50GB/h Unequal . Use TiDB DM The migration process is shown in the following figure .

Prerequisite
The first 1 Step : create data source
First , newly build source1.yaml file , Write the following :
# Unique name , Do not repeat . source-id: "mysql-01" # DM-worker Whether to use the global transaction identifier (GTID) Pull binlog. The premise of use is upstream MySQL Enabled GTID Pattern . If there is master-slave automatic switching in the upstream , Must be used GTID Pattern . enable-gtid: true from: host: "${host}" # for example :172.16.10.81 user: "root" password: "${password}" # Clear text password is supported but not recommended , It is recommended to use dmctl encrypt Encrypt the plaintext password and use port: 3306
secondly , After executing the following command in the terminal , Use tiup dmctl Load the data source configuration into DM In the cluster :
tiup dmctl --master-addr ${advertise-addr} operate-source create source1.yaml
The parameters in this command are described as follows :
| Parameters | describe |
|---|---|
--master-addr | dmctl Any of the clusters to be connected DM-master Node {advertise-addr}, for example :172.16.10.71:8261 |
operate-source create | towards DM The cluster loads the data source |
The first 2 Step : Create migration tasks
newly build task1.yaml file , Write the following :
# Task name , Multiple tasks running at the same time cannot have the same name . name: "test" # Task mode , May be set as # full: Only full data migration # incremental: binlog Real time synchronization # all: Total quantity + binlog transfer task-mode: "all" # The downstream TiDB Configuration information . target-database: host: "${host}" # for example :172.16.10.83 port: 4000 user: "root" password: "${password}" # Clear text password is supported but not recommended , It is recommended to use dmctl encrypt Encrypt the plaintext password and use # All upstream tasks required by current data migration MySQL The instance configuration . mysql-instances: - # Upstream instance or replication Group ID. source-id: "mysql-01" # The configuration item name of the black-and-white list of the library name or table name that needs to be migrated , Used to reference the black and white list configuration of the global , See the following for the global configuration `block-allow-list` Configuration of . block-allow-list: "listA" # Black and white list global configuration , Each instance refers to . block-allow-list: listA: # name do-tables: # White list of upstream tables that need to be migrated . - db-name: "test_db" # The library name of the table to be migrated . tbl-name: "test_table" # Name of the table to be migrated .
The above is the minimum task configuration for performing migration . More configuration items about tasks , You can refer to DM Introduction to the complete configuration file of the task .
The first 3 Step : Start the task
Before you start the data migration task , It is recommended to use check-task Command to check whether the configuration conforms to DM Configuration requirements for , To avoid errors in the later stage .
tiup dmctl --master-addr ${advertise-addr} check-task task.yaml
Use tiup dmctl Execute the following command to start the data migration task .
tiup dmctl --master-addr ${advertise-addr} start-task task.yaml
The parameters in this command are described as follows :
| Parameters | describe |
|---|---|
--master-addr | dmctl Any of the clusters to be connected DM-master Node {advertise-addr}, for example : 172.16.10.71:8261 |
start-task | Parameter is used to start the data migration task |
If the task fails to start , You can change the configuration according to the prompt of the returned result start-task task.yaml Command to restart the task . Please refer to Faults and handling methods as well as common problem .
The first 4 Step : View task status
If you need to know DM Whether there are running migration tasks and task status in the cluster , You can use tiup dmctl perform query-status Command to query :
tiup dmctl --master-addr ${advertise-addr} query-status ${task-name}
Detailed interpretation of query results , Please refer to State of the query .
The first 5 Step : Monitor tasks and view logs ( Optional )
To view the historical status of the migration task and more internal operation indicators , Please refer to the following steps .
If you use TiUP Deploy DM When the cluster , Deployed correctly Prometheus、Alertmanager And Grafana, Use the IP And port entry Grafana, choice DM Of Dashboard see DM Relevant monitoring items .
DM At run time ,DM-worker, DM-master And dmctl Will output relevant information through the log . The log directory of each component is as follows :
- DM-master Log directory : adopt DM-master Process parameters
--log-fileSet up . If you use TiUP Deploy DM, The log directory is located in/dm-deploy/dm-master-8261/log/. - DM-worker Log directory : adopt DM-worker Process parameters
--log-fileSet up . If you use TiUP Deploy DM, The log directory is located in/dm-deploy/dm-worker-8262/log/.
边栏推荐
- Apple submitted the new MAC model to the regulatory database before the spring conference
- [Shangshui Shuo series together] day 10
- Strategy pattern: encapsulate changes and respond flexibly to changes in requirements
- What's the difference between using the Service Worker Cache API and regular browser cache?
- CKA certification notes - CKA certification experience post
- [teacher Zhao Yuqiang] calculate aggregation using MapReduce in mongodb
- How to create your own repository for software packages on Debian
- [teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
- Leetcode solution - 01 Two Sum
- Kubernetes notes (VIII) kubernetes security
猜你喜欢
![[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram](/img/29/1644588927226a49d4b8815d8bc196.jpg)
[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram

Jedis source code analysis (II): jediscluster module source code analysis

Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation

Simple handwritten ORM framework
![[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system

多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)

一起上水碩系列】Day 9

Disruptor learning notes: basic use, core concepts and principles

从小数据量分库分表 MySQL 合并迁移数据到 TiDB

Kubernetes resource object introduction and common commands (V) - (configmap)
随机推荐
[teacher Zhao Yuqiang] use the catalog database of Oracle
Oauth2.0 - Introduction and use and explanation of authorization code mode
Redhat7系统root用户密码破解
Why is the website slow to open?
Detailed explanation of findloadedclass
[teacher Zhao Yuqiang] RDB persistence of redis
伯努利分布,二项分布和泊松分布以及最大似然之间的关系(未完成)
Understand one-way hash function
What's the difference between using the Service Worker Cache API and regular browser cache?
Using the ethtool command by example
项目总结--2(Jsoup的基本使用)
项目总结--01(接口的增删改查;多线程的使用)
Kubernetes notes (I) kubernetes cluster architecture
How to create and configure ZABBIX
Mysql database table export and import with binary
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
最大似然估计,散度,交叉熵
[set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
1. 兩數之和
Bernoulli distribution, binomial distribution and Poisson distribution, and the relationship between maximum likelihood (incomplete)