Automated Script for One-Click Deployment of TiDB and Script for Adding CDC to Existing TiDB Cluster for Synchronization

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 一键部署tidb的自动化脚本以及在原有tidb集群中增加cdc做同步用的脚本。

| username: tidb狂热爱好者

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issues: Issue Phenomenon and Impact]
[Resource Configuration]
[Attachments: Screenshots / Logs / Monitoring]

Initially deployed a TiDB cluster. Now need to capture logs for development analysis. However, the original cluster does not have the CDC component. Need to add the CDC component in production.

Since production failures are significant, I found a test server to test the entire upgrade process.

Since it’s a test machine, everything is simplified.

The original server is as follows:

Steps:

  1. Edit the cluster topology
cat > topology.yaml << EOF
global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/tidb-deploy"
  data_dir: "/home/tidb-data"
server_configs:
  tidb:
    log.slow-threshold: 300
  # tikv:
  # storage.engine: partitioned-raft-kv
pd_servers:
  - host: 192.168.137.29
tidb_servers:
  - host: 192.168.137.29
tikv_servers:
  - host: 192.168.137.29
# cdc_servers:
# - host: 192.168.137.29
monitoring_servers:
  - host: 192.168.137.29
grafana_servers:
  - host: 192.168.137.29
alertmanager_servers:
  - host: 192.168.137.29
EOF
  1. Download & Extract & Configure Passwordless SSH
curl -O https://download.pingcap.org/tidb-community-server-v6.6.0-linux-amd64.tar.gz
tar zxf https://download.pingcap.org/tidb-community-server-v6.6.0-linux-amd64.tar.gz
cd tidb-community-server-v6.6.0-linux-amd64
  1. Passwordless SSH
ssh-keygen
ssh-copyid root@127.0.0.1
  1. Install TiDB
bash local_install.sh
source /root/.bash_profile
tiup cluster check ./topology.yaml --apply
tiup cluster deploy tidb-test v6.6.0 ./topology.yaml
tiup cluster start tidb-test

At this point, the entire TiDB is started normally. The above script is automated and does not require manual intervention.

Next, let’s add the CDC server

cat > scale-out.yaml << EOF
cdc_servers:
  - host: 192.168.137.29
EOF
tiup cluster scale-out tidb-test scale-out.yaml

This completes the tutorial for scaling out TiDB with CDC.

The steps in this article can be completed in one go according to my instructions. If you have any questions, please contact me.

These steps are also for the automation I am writing. Recording them first.

| username: ffeenn | Original post link

You can write it as an article and publish it in the column.