## モジュール 1: TiDB データマイグレーションクラスタのデプロイ

### 手順 1. 仮想マシンへのログイン

+ ここをクリック - [ターミナル 1](ssh://monitor1-ssh#1) で、ハンズオン演習用に割り当てられた仮想マシンに接続された新しいターミナルを開きます。

### 手順 2. TiDB Data Migration をインストール

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

### 手順 3. ファイル `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
  ```

### 手順 4. TiDB Data Migration がインストールされているか確認する

  ```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
  ...
  ```

### 手順 5. TiDB Data Migration クラスタをデプロイする

  ```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`
  ```

### 手順 6. TiDB Data Migration クラスタを開始する

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

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

### 手順 7. TiUP で管理されている TiDB Data Migration クラスタを確認する

  ```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
  ```

### 手順 8. デプロイされた TiDB Data Migration クラスタのステータスを確認する

  ```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
  ```
