## Module 4: Run the DM Task and Verify the Migration Result

### Step 1. Start the TiDB Data Migration task

+ Start a migration task by using `tiup dmctl:v7.5.1` command.

  ```bash
  tiup dmctl:v7.5.1 --master-addr=${HOST_PD1_PRIVATE_IP}:8261 start-task dm-task.yaml
  ```

  ```output
  Starting component dmctl: /home/ec2-user/.tiup/components/dmctl/v7.5.1/dmctl/dmctl --master-addr=10.90.3.251:8261 start-task dm-task.yaml
  {
     "result": true,
     "msg": "",
     "sources": [
        {
              "result": true,
              "msg": "",
              "source": "mysql-replica-01",
              "worker": "dm-10.90.3.231-8262"
        },
        {
              "result": true,
              "msg": "",
              "source": "mysql-replica-02",
              "worker": "dm-10.90.3.7-8262"
        }
     ],
     "checkResult": "pre-check is passed. "
  }
  ```

+ View the status of the task.

  ```bash
  tiup dmctl:v7.5.1 --master-addr=${HOST_PD1_PRIVATE_IP}:8261 query-status dm-task.yaml
  ```

  ```output
  Starting component dmctl: /home/ec2-user/.tiup/components/dmctl/v7.5.1/dmctl/dmctl --master-addr=10.90.3.251:8261 query-status dm-task.yaml
  {
        "result": true,
        "msg": "",
        "sources": [
           {
              "result": true,
              "msg": "",
              "sourceStatus": {
                    "source": "mysql-replica-01",
                    "worker": "dm-10.90.3.231-8262",
                    "result": null,
                    "relayStatus": null
              },
              "subTaskStatus": [
                    {
                    ...
                    }
              ]
           },
           {
              "result": true,
              "msg": "",
              "sourceStatus": {
                    "source": "mysql-replica-02",
                    "worker": "dm-10.90.3.7-8262",
                    "result": null,
                    "relayStatus": null
              },
              "subTaskStatus": [
                    {
                    ...
                    }
              ]
           }
        ]
  }
  ```

### Step 2. Verify the result of TiDB Data Migration task

+ Verify that the downstream database TiDB contains the full data from the migration task.

  ```bash
  mysql -h${HOST_DB1_PRIVATE_IP} -P4000 -uroot
  ```

  ```sql
  USE user_east;
  SHOW TABLES;
  SELECT * FROM information;
  SELECT * FROM trace;
  USE user_north;
  SHOW TABLES;
  SELECT * FROM information;
  SELECT * FROM trace;
  USE store;
  SHOW TABLES;
  SELECT * FROM store_bj;
  SELECT * FROM store_tj;
  SELECT * FROM store_suzhou;
  SELECT * FROM store_sh;
  USE salesdb;
  SELECT * FROM sales;
  ```

  ```output
  mysql> USE user_east;
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A

  Database changed
  mysql> SHOW TABLES;
  +---------------------+
  | Tables_in_user_east |
  +---------------------+
  | information         |
  | trace               |
  +---------------------+
  2 rows in set (0.00 sec)

  mysql> SELECT * FROM information;
  +----+-------+
  | id | info  |
  +----+-------+
  |  1 | andy  |
  |  2 | candy |
  +----+-------+
  2 rows in set (0.00 sec)

  mysql> SELECT * FROM trace;
  +----+---------+
  | id | content |
  +----+---------+
  |  1 | error   |
  +----+---------+
  1 row in set (0.00 sec)

  ...

  mysql> USE salesdb;
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A

  Database changed
  mysql> SELECT * FROM sales;
  +----+-------+------+
  | id | pname | cnt  |
  +----+-------+------+
  |  1 | book  |  100 |
  |  2 | cup   |  200 |
  +----+-------+------+
  2 rows in set (0.00 sec)
  ```

  + Exit to the shell terminal.

   ```bash
   EXIT;
   ```

### Step 3. Insert new values in the upsteam database

+ Verify that after inserting data into the upstream database, the downstream database can also receive the value.
  + On `PD1`

    ```bash
    ./ssh-to-pd1.sh
    ```

    ```bash
    mysql -u root -p -h 127.0.0.1 -P 3306 -pq1w2e3R4_
    ```

    ```sql
    INSERT INTO salesdb.sales VALUES(3,'shoes',120);
    ```

    ```output
    mysql> INSERT INTO salesdb.sales VALUES(3,'shoes',120);
    Query OK, 1 row affected (0.01 sec)
    ```

    ```sql
    SELECT * FROM salesdb.sales;
    ```

    ```output
    mysql> SELECT * FROM salesdb.sales;
    +----+-------+------+
    | id | pname | cnt  |
    +----+-------+------+
    |  1 | book  |  100 |
    |  3 | shoes |  120 |
    +----+-------+------+
    2 rows in set (0.00 sec)
    ```

    ```sql
    EXIT
    ```

    ```output
    mysql> EXIT;
    Bye
    ```

    ```bash
    exit
    ```

    ```output
    logout
    Connection to XX.XX.XX.XX closed.
    ```

  + On the `Control Machine`

    ```bash
    mysql -h ${HOST_DB1_PRIVATE_IP} -P 4000 -uroot
    ```

    ```sql
    SELECT * FROM salesdb.sales;
    ```

    ```output
    mysql> SELECT * FROM salesdb.sales;
    +----+-------+------+
    | id | pname | cnt  |
    +----+-------+------+
    |  1 | book  |  100 |
    |  2 | cup   |  200 |
    |  3 | shoes |  120 |
    +----+-------+------+
    3 rows in set (0.00 sec)
    ```

    ```sql
    EXIT
    ```

    ```output
    mysql> EXIT
    Bye
    ```
