## Module 1: Deploying TiDB Data Migration Cluster

### Step 1. Log into the remote Linux

+ Click here - [Terminal 1](ssh://monitor1-ssh#1) to open a new terminal connected to the virtual machine assigned for your hands-on lab.

### Step 2. Install `TiDB Data Migration`

  ```bash
  tiup install dm dmctl:v7.5.1
  ```

### Step 3. Read the file `solution-dm-topology-six-nodes.yaml`

  ```bash
  cat solution-dm-topology-six-nodes.yaml
  ```

  ```output
  # The topology template is used deploy a minimal DM cluster, which suitable
  # for scenarios with only three machines. The minimal cluster contains
  # - 3 master nodes
  # - 3 worker nodes
  # You can change the hosts according your environment
  ---
  global:
     user: "tidb"
     ssh_port: 22
     deploy_dir: "/tidb-deploy"
     data_dir: "/tidb-data"
     arch: "amd64"

  master_servers:
     - host: 10.90.2.84
     - host: 10.90.2.134
     - host: 10.90.2.214

  worker_servers:
     - host: 10.90.3.239
     - host: 10.90.3.119
     - host: 10.90.3.181

  monitoring_servers:
     - host: 10.90.2.84

  grafana_servers:
     - host: 10.90.2.84

  alertmanager_servers:
     - host: 10.90.2.84
  ```

### Step 4. Verify that the `TiDB Data Migration` is installed

  ```bash
  tiup list dm-master
  ```

  ```output
  Available versions for dm-master:
  Version                                   Installed  Release                    Platforms
  -------                                   ---------  -------                    ---------
  v7.5.1                                               2022-06-10T14:27:38+08:00  linux/amd64,linux/arm64
  ...
  ```

### Step 5. Deploy a `TiDB Data Migration` cluster

  ```bash
  tiup dm deploy dm-test v7.5.1 --user ec2-user -i ~/.ssh/pe-class-key-${LAB:REGION_NAME}.pem ./solution-dm-topology-six-nodes.yaml --yes
  ```

  ```output
  ...
  Cluster `dm-test` deployed successfully, you can start it with command: `tiup dm start dm-test`
  ```

### Step 6. Start the `TiDB Data Migration` cluster

  ```bash
  tiup dm start dm-test
  ```

  ```output
  ...
  Started cluster `dm-test` successfully
  ```

### Step 7. Check the `TiDB Data Migration` cluster managed by TiUP

  ```bash
  tiup dm list
  ```

  ```output
  tiup is checking updates for component dm ...
  Starting component `dm`: /home/ec2-user/.tiup/components/dm/v1.12.1/tiup-dm list
  Name     User  Version  Path                                              PrivateKey
  ----     ----  -------  ----                                              ----------
  dm-test  tidb  v7.5.1   /home/ec2-user/.tiup/storage/dm/clusters/dm-test  /home/ec2-user/.tiup/storage/dm/clusters/dm-test/ssh/id_rsa
  ```

### Step 8. Check the status of the deployed `TiDB Data Migration` cluster

  ```bash
  tiup dm display dm-test
  ```

  ```output
  tiup is checking updates for component dm ...
  Starting component `dm`: /home/ec2-user/.tiup/components/dm/v1.12.1/tiup-dm display dm-test
  Cluster type:       dm
  Cluster name:       dm-test
  Cluster version:    v7.5.1
  Deploy user:        tidb
  SSH type:           builtin
  Grafana URL:        http://10.90.4.231:3000
  ID                Role          Host         Ports      OS/Arch       Status     Data Dir                      Deploy Dir
  --                ----          ----         -----      -------       ------     --------                      ----------
  10.90.4.231:9093  alertmanager  10.90.4.231  9093/9094  linux/x86_64  Up         /tidb-data/alertmanager-9093  /tidb-deploy/alertmanager-9093
  10.90.1.34:8261   dm-master     10.90.1.34   8261/8291  linux/x86_64  Healthy|L  /tidb-data/dm-master-8261     /tidb-deploy/dm-master-8261
  10.90.2.38:8261   dm-master     10.90.2.38   8261/8291  linux/x86_64  Healthy    /tidb-data/dm-master-8261     /tidb-deploy/dm-master-8261
  10.90.3.188:8261  dm-master     10.90.3.188  8261/8291  linux/x86_64  Healthy    /tidb-data/dm-master-8261     /tidb-deploy/dm-master-8261
  10.90.1.162:8262  dm-worker     10.90.1.162  8262       linux/x86_64  Free       /tidb-data/dm-worker-8262     /tidb-deploy/dm-worker-8262
  10.90.2.108:8262  dm-worker     10.90.2.108  8262       linux/x86_64  Free       /tidb-data/dm-worker-8262     /tidb-deploy/dm-worker-8262
  10.90.3.12:8262   dm-worker     10.90.3.12   8262       linux/x86_64  Free       /tidb-data/dm-worker-8262     /tidb-deploy/dm-worker-8262
  10.90.4.231:3000  grafana       10.90.4.231  3000       linux/x86_64  Up         -                             /tidb-deploy/grafana-3000
  10.90.4.231:9090  prometheus    10.90.4.231  9090       linux/x86_64  Up         /tidb-data/prometheus-9090    /tidb-deploy/prometheus-9090
  Total nodes: 9
  ```
