TiUP Cluster
TiUP Cluster is a tool for deploying and managing TiDB clusters in production. Unlike Playground, which is only for testing, Cluster supports multi-node deployment with full configuration.
Installation
# Install TiUP (if not already)
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source ~/.bashrc
# Install the cluster component
tiup cluster
Topology File
Create a topo.yaml file to define the cluster:
global:
user: "tidb"
ssh_port: 22
deploy_dir: "/tidb-deploy"
data_dir: "/tidb-data"
server_configs:
tidb:
instance.tidb_slow_log_threshold: 300
tikv:
readpool.storage.use-unified-pool: false
readpool.coprocessor.use-unified-pool: true
pd:
replication.enable-placement-rules: true
replication.location-labels: ["zone"]
pd_servers:
- host: 10.0.1.1
- host: 10.0.1.2
- host: 10.0.1.3
tidb_servers:
- host: 10.0.1.1
- host: 10.0.1.2
tikv_servers:
- host: 10.0.1.1
config:
server.labels: { zone: "zone-a" }
- host: 10.0.1.2
config:
server.labels: { zone: "zone-b" }
- host: 10.0.1.3
config:
server.labels: { zone: "zone-c" }
tiflash_servers:
- host: 10.0.1.4
monitoring_servers:
- host: 10.0.1.1
grafana_servers:
- host: 10.0.1.1
Basic Commands
Deploy the Cluster
tiup cluster deploy my-cluster v8.5.7 ./topo.yaml --user root -p
Start / Stop / Restart
tiup cluster start my-cluster
tiup cluster stop my-cluster
tiup cluster restart my-cluster
View Status
# List all clusters
tiup cluster list
# Display the cluster topology
tiup cluster display my-cluster
Scale Out / Scale In
# Add a TiKV node
tiup cluster scale-out my-cluster ./scale-out.yaml --user root -p
# Remove a TiKV node
tiup cluster scale-in my-cluster --node 10.0.1.3:20160
Destroy the Cluster
tiup cluster destroy my-cluster
Monitoring Components
TiUP Cluster automatically installs:
- Prometheus — metrics collection
- Grafana — visualization dashboard
- Alertmanager — alert notification
- TiDB Dashboard — web UI for cluster management
Connecting to the Cluster
# MySQL client
mysql -h 10.0.1.1 -P 4000 -u root
# TiDB Dashboard
http://10.0.1.1:2379/dashboard
In the next chapter, we will look at TiDB's compatibility with MySQL.