一、查看参数
tiup dm --help
EXPERIMENTAL: This is an experimental feature, things may or may not work,
please backup your data before process.
Usage:
tiup dm [command]
Available Commands:
deploy Deploy a DM cluster for production
start Start a DM cluster
stop Stop a DM cluster
restart Restart a DM cluster
list List all clusters
destroy Destroy a specified DM cluster
audit Show audit log of cluster operation
exec Run shell command on host in the dm cluster
edit-config Edit DM cluster config
display Display information of a DM cluster
prune Clear etcd info
reload Reload a DM cluster's config and restart if needed
upgrade Upgrade a specified DM cluster
patch Replace the remote package with a specified package and restart the service
scale-out Scale out a DM cluster
scale-in Scale in a DM cluster
import Import an exist DM 1.0 cluster from dm-ansible and re-deploy 2.0 version
help Help about any command
Flags:
-h, --help help for tiup
--ssh string The executor type: 'builtin', 'system', 'none'
--ssh-timeout uint Timeout in seconds to connect host via SSH, ignored for operations that don't need an SSH connection. (default 5)
-v, --version version for tiup
--wait-timeout uint Timeout in seconds to wait for an operation to complete, ignored for operations that don't fit. (default 60)
-y, --yes Skip all confirmations and assumes 'yes'
Use "tiup dm help [command]" for more information about a command.
二、参数详解
1.查看dm集群名
tiup dm list
2.启动dm集群
tiup dm start dm-name(集群名)
3.检查dm集群状态
tiup dm display dm-name
4.缩容节点
tiup dm scale-in <cluster-name> -N <node-id>
它需要指定至少两个参数,一个是集群名字,另一个是节点 ID。节点 ID 可以参考上一节使用 tiup dm display
命令获取。
5.扩容节点
5.1 编辑配置文件,加入组件
5.2 输入命令
tiup dm scale-out dm-name scale.yaml
6.升级dm
tiup dm upgrade dm-name v2.0.1
7.更新dm配置
7.1 编辑配置文件
tiup dm edit-config dm-name
7.2 将新的配置文件应用到集群
tiup dm reload dm-name
8.更新组件(patch)
8.1 patch功能
tiup dm patch --help
Replace the remote package with a specified package and restart the service
Usage:
tiup dm patch <cluster-name> <package-path> [flags]
Flags:
-h, --help help for patch
-N, --node strings Specify the nodes
--overwrite Use this package in the future scale-out operations
-R, --role strings Specify the roles
Global Flags:
--ssh string The executor type: 'builtin', 'system', 'none'
--ssh-timeout uint Timeout in seconds to connect host via SSH, ignored for operations that don't need an SSH connection. (default 5)
--wait-timeout uint Timeout in seconds to wait for an operation to complete, ignored for operations that don't fit. (default 60)
-y, --yes Skip all confirmations and assumes 'yes'
例如,有一个 DM-master 的 hotfix 包放在 /tmp/dm-master-hotfix.tar.gz
,如果此时想要替换集群上的所有 DM-master,则可以执行:
tiup dm patch dm-name /tmp/dm-master-hotfix.tar.gz -R dm-master
或者只替换其中一个 DM-master:
tiup dm patch dm-name /tmp/dm--hotfix.tar.gz -N 172.16.4.5:8261
9.import的使用
导入一个 DM Ansible 集群
tiup dm import --dir=/path/to/dm-ansible --cluster-version v2.0.0
10.查看操作日志
tiup dm audit --help
Show audit log of cluster operation
Usage:
tiup dm audit [audit-id] [flags]
Flags:
-h, --help help for audit
Global Flags:
--ssh string The executor type: 'builtin', 'system', 'none'
--ssh-timeout uint Timeout in seconds to connect host via SSH, ignored for operations that don't need an SSH connection. (default 5)
--wait-timeout uint Timeout in seconds to wait for an operation to complete, ignored for operations that don't fit. (default 60)
-y, --yes Skip all confirmations and assumes 'yes'
tiup dm audi
tiup dm audit fzv7mjCQdPq
11.在集群节点机器上执行命令
tiup dm exec dm-name --command='ls /tmp'
官网链接:https://docs.pingcap.com/zh/tidb-data-migration/stable/maintain-dm-using-tiup