TiDB Cluster Installation

1) Create tidb user & base dirs (run on all nodes)
sudo useradd -m -s /bin/bash tidb || true
sudo mkdir -p /mnt/tidb/{deploy,data,backup} # (This path is your choice based on your database size or drive size.)
sudo chown -R tidb:tidb /mnt/tidb
2) Setup passwordless SSH (only on control node, e.g. 10.0.0.11)

Login as tidb user:

sudo -u tidb -i
ssh-keygen -t ed25519 -N “” -C tidb -f ~/.ssh/id_ed25519

for h in 10.0.0.11 10.0.0.12 10.0.0.13 10.0.0.14 10.0.0.15; do
ssh-copy-id -i ~/.ssh/id_ed25519.pub tidb@$h
done

for h in 10.0.0.{11..15}; do ssh -o BatchMode=yes tidb@$h “hostname”; done

3) Install TiUP on control node (10.0.0.11)
sudo -u tidb -i
curl –proto ‘=https’ –tlsv1.2 -fsSL https://tiup-mirrors.pingcap.com/install.sh | sh
source ~/.bash_profile
tiup update –self && tiup update cluster

4) Create topology file

As tidb on 10.0.0.11:

cat > ~/topo.yaml <<'EOF'
global:
  user: "tidb"
  ssh_port: 22
  os: "linux"
  arch: "amd64"
  deploy_dir: "/mnt/tidb/deploy"
  data_dir: "/mnt/tidb/data"

pd_servers:
  - host: 10.0.0.11
  - host: 10.0.0.12
  - host: 10.0.0.13
  - host: 10.0.0.14
  - host: 10.0.0.15

tikv_servers:
  - host: 10.0.0.11
  - host: 10.0.0.12
  - host: 10.0.0.13
  - host: 10.0.0.14
  - host: 10.0.0.15

tidb_servers:
  - host: 10.0.0.11
  - host: 10.0.0.12
  - host: 10.0.0.13
  - host: 10.0.0.14
  - host: 10.0.0.15

monitoring_servers:
  - host: 10.0.0.11
grafana_servers:
  - host: 10.0.0.11
alertmanager_servers:
  - host: 10.0.0.11
EOF

5) Deploy & start cluster

#Run precheck (auto-fix some configs with –apply)
tiup cluster check ./topo.yaml –apply –user tidb -i ~/.ssh/id_ed25519

#Deploy (example version v8.5.1, adjust if newer available)
tiup cluster deploy tidb-az-5 v8.5.1 ./topo.yaml –user tidb -i ~/.ssh/id_ed25519 -y

#Start Service
tiup cluster start tidb-az-5

#Verify service and cluster running or not
tiup cluster display tidb-az-5

listen tidb
bind 0.0.0.0:4000
mode tcp
balance roundrobin
option tcp-check
server n11 10.0.0.11:4000 check
server n12 10.0.0.12:4000 check
server n13 10.0.0.13:4000 check
server n14 10.0.0.14:4000 check
server n15 10.0.0.15:4000 check

Comments are closed.