# **练习-3 : 缩容 `TiCDC` 节点**

## 概述
+ 在本练习中，将对当前的 TiCDC 节点进行缩容｡

## 练习环境要求
+ 1. 注意，您的实验环境（包括IP，端口号，用户名，密码和目录）可能和手册不同。
+ 2. 可以连接到实验用虚拟机。
+ 3. TiDB 数据库提前部署完毕。
+ 4. 需要完成练习-2。

## 拓扑图
<img src="../../../diagram/TiCDCLabToplogy_aa_001_20220626.png" width="50%" align="top"/>

## 步骤

-----------------------------------------------
#### 1. 停止并删除 TiCDC 数据同步任务。
+ **使用 cdc cli 工具停止同步任务，如下:**
    ```
     # ./cdc cli changefeed pause --pd=http://172.31.0.232:2379  --changefeed-id replication-task-1
    ```

+ **使用 cdc cli 工具删除同步任务，如下：**
    ```
     # ./cdc cli changefeed remove --pd=http://172.31.0.232:2379 --changefeed-id replication-task-1 
    ```
+ **使用 cdc cli 工具查询同步任务，如下：**
    ```
     # ./cdc cli changefeed list --pd=http://172.31.0.232:2379
    ```
    ```
     []
    ```
-----------------------------------------------
#### 2. 缩容 TiCDC 集群。
+ **使用 tiup cluster scale-in 命令对 TiCDC 集群进行缩容（需要输入一次 y），如下:**
    ```
    # tiup cluster scale-in tidb-test --node 172.31.0.135:8300
    ```

+ **查看缩容 TiCDC 后的集群状态，如下:**
    ```
    # tiup cluster display tidb-test
    ```

-----------------------------------------------

## 输出样例

-----------------------------------------------
#### 步骤 2-使用 tiup cluster scale-in 命令对 TiCDC 集群进行缩容输出参考**：
```
# tiup cluster scale-in tidb-test --node 172.31.0.135:8300
```
```
tiup is checking updates for component cluster ...
Starting component `cluster`: /root/.tiup/components/cluster/v1.10.2/tiup-cluster scale-in tidb-test --node 172.31.0.135:8300   
...
This operation will delete the 172.31.0.135:8300 nodes in `tidb-test` and all their data.
Do you want to continue? [y/N]:(default=N) y
...
+ Refresh instance configs
    - Generate config pd -> 172.31.0.233:2379 ... Done
    - Generate config pd -> 172.31.0.175:2379 ... Done
    - Generate config pd -> 172.31.0.232:2379 ... Done
    - Generate config tikv -> 172.31.0.234:20160 ... Done
    - Generate config tikv -> 172.31.0.79:20160 ... Done
    - Generate config tikv -> 172.31.0.95:20160 ... Done
    - Generate config tidb -> 172.31.0.135:4000 ... Done
    - Generate config tiflash -> 172.31.0.225:9000 ... Done
    - Generate config prometheus -> 172.31.0.233:9090 ... Done
    - Generate config grafana -> 172.31.0.233:3000 ... Done
    - Generate config alertmanager -> 172.31.0.233:9093 ... Done
+ Reload prometheus and grafana
    - Reload prometheus -> 172.31.0.233:9090 ... Done
    - Reload grafana -> 172.31.0.233:3000 ... Done
Scaled cluster `tidb-test` in successfully

```

-----------------------------------------------
#### 步骤 2-查看缩容 TiCDC 后的集群状态输出参考：
```
# tiup cluster display tidb-test
```
```
tiup is checking updates for component cluster ...
Starting component `cluster`: /root/.tiup/components/cluster/v1.10.2/tiup-cluster display tidb-test
Cluster type:       tidb
Cluster name:       tidb-test
Cluster version:    v6.1.0
Deploy user:        tidb
SSH type:           builtin
Dashboard URL:      http://172.31.0.232:2379/dashboard
Grafana URL:        http://172.31.0.233:3000
ID                  Role          Host          Ports                            OS/Arch       Status  Data Dir                      Deploy Dir
--                  ----          ----          -----                            -------       ------  --------                      ----------
172.31.0.233:9093   alertmanager  172.31.0.233  9093/9094                        linux/x86_64  Up      /tidb-data/alertmanager-9093  /tidb-deploy/alertmanager-9093
172.31.0.233:3000   grafana       172.31.0.233  3000                             linux/x86_64  Up      -                             /tidb-deploy/grafana-3000
172.31.0.175:2379   pd            172.31.0.175  2379/2380                        linux/x86_64  Up      /tidb-data/pd-2379            /tidb-deploy/pd-2379
172.31.0.232:2379   pd            172.31.0.232  2379/2380                        linux/x86_64  Up|UI   /tidb-data/pd-2379            /tidb-deploy/pd-2379
172.31.0.233:2379   pd            172.31.0.233  2379/2380                        linux/x86_64  Up|L    /tidb-data/pd-2379            /tidb-deploy/pd-2379
172.31.0.233:9090   prometheus    172.31.0.233  9090/12020                       linux/x86_64  Up      /tidb-data/prometheus-9090    /tidb-deploy/prometheus-9090
172.31.0.135:4000   tidb          172.31.0.135  4000/10080                       linux/x86_64  Up      -                             /tidb-deploy/tidb-4000
172.31.0.225:9000   tiflash       172.31.0.225  9000/8123/3930/20170/20292/8234  linux/x86_64  Up      /tidb-data/tiflash-9000       /tidb-deploy/tiflash-9000
172.31.0.234:20160  tikv          172.31.0.234  20160/20180                      linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
172.31.0.79:20160   tikv          172.31.0.79   20160/20180                      linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
172.31.0.95:20160   tikv          172.31.0.95   20160/20180                      linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
Total nodes: 11
```

-----------------------------------------------