# Use of DM - Configuration Files

__*Using DM*__
__*DM configuration file*__

```6
$ tiup dm template > topology.yaml

global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/dm-deploy"
  data_dir: "/dm-data"

server_configs:
  master:
    log-level: info
  worker:
    log-level: info

master_servers:
  - host: 10.0.1.11
    name: master1
    ssh_port: 22
    port: 8261
 
worker_servers:
  - host: 10.0.1.12
    ssh_port: 22
    port: 8262
  - host: 10.0.1.19
    ssh_port: 22
    port: 8262

monitoring_servers:
  - host: 10.0.1.13

grafana_servers:
  - host: 10.0.1.14

alertmanager_servers:
  - host: 10.0.1.15

```
-------------------------------------------------------------
Edit the cluster initialization configuration file required by TiUP.

Create a new configuration file topology.yaml based on the configuration file template. If there is a need for other combination scenario, please adjust it yourself according to multiple templates.

You can quickly generate a configuration file template using the tiup dm template > topology.yaml command.

The configuration for deploying 3 DM-Masters, 3 DM-Workers, and 1 monitoring component is as follows:
# Global variables apply to other components in the configuration. If a specific value is missing from the component instance, the corresponding global variable is used as the default value.
global:
  user: "tidb"
  ssh_port:22
  deploy_dir: "/dm-deploy"
  data_dir: "/dm-data"

server_configs:
  master:
    log-level:info
    # Rpc-timeout: "30s"
    # Rpc-rate-limit: 10.0
    # Rpc-rate-burst: 40
  worker:
    log-level:info

master_servers:
  - host: 10.0.1.11
    name: master1
    ssh_port:22
    port:8261
    # Peer_port:8291
    # Deploy_dir: "/dm-deploy/dm-master-8261"
    # Data_dir: "/dm-data/dm-master-8261"
    # Log_dir: "/dm-deploy/dm-master-8261/log"
    # Numa_node: "0,1"
    # The Following Configuration Item are Used to Override the server_configs.master Values.
    config:
      log-level:info
      # Rpc-timeout: "30s"
      # Rpc-rate-limit: 10.0
      # Rpc-rate-burst: 40
  - host: 10.0.1.18
    name: master2
    ssh_port:22
    port:8261
  - host: 10.0.1.19
    name: master3
    ssh_port:22
    port:8261
# If You Do Not Need to Ensure High Availability of the DM Cluster, You Can Deploy Only 1 DM-Master Node, and the Number of DM-Worker Nodes Deployed is Not Less Than the Number of MySQL/MariaDB Instances to Be Migrated Upstream.
# If You Need to Ensure High Availability of the DM Cluster, It is Recommended to Deploy 3 DM-Master Nodes, and the Number of DM-Worker Nodes Deployed is Greater Than the Number of MySQL/MariaDB Instances to Be Migrated Upstream (for Example, the Number of DM-Worker Nodes is 2 More Than the Number of Upstream Instances).
worker_servers:
  - host: 10.0.1.12
    ssh_port:22
    port:8262
    # Deploy_dir: "/dm-deploy/dm-worker-8262"
    # Log_dir: "/dm-deploy/dm-worker-8262/log"
    # Numa_node: "0,1"
    # The Following Configuration Item are Used to Override the server_configs.worker Values.
    config:
      log-level:info
  - host: 10.0.1.19
    ssh_port:22
    port:8262

monitoring_servers:
  - host: 10.0.1.13
    ssh_port:22
    port:9090
    # Deploy_dir: "/tidb-deploy/prometheus-8249"
    # Data_dir: "/tidb-data/prometheus-8249"
    # Log_dir: "/tidb-deploy/prometheus-8249/log"

grafana_servers:
  - host: 10.0.1.14
    port: 3000
    # Deploy_dir: /tidb-deploy/grafana-3000

alertmanager_servers:
  - host: 10.0.1.15
    ssh_port:22
    web_port:9093
    # Cluster_port:9094
    # Deploy_dir: "/tidb-deploy/alertmanager-9093"
    # Data_dir: "/tidb-data/alertmanager-9093"
    # Log_dir: "/tidb-deploy/alertmanager-9093/log"

notice
Running too many DM-Workers on one host is not recommended. Each DM-Worker should have a minimum of 2 core CPU and 4 GiB of memory.
You need to ensure proper connectivity between the following components:
The peer_port (default is 8291) between the DM-master nodes can be connected to each other.
Each DM-master node can connect to the port of all DM-Worker nodes (default is 8262).
Each DM-Worker node can connect to the port of all DM-Master nodes (default is 8261).
The TiUP node can connect to the port of all DM-master nodes (default is 8261).
The TiUP node can connect to the port of all DM-Worker nodes (default is 8262).