TiDB集群管理-303 实例手册之TiKV在线扩容操作详解

扩容操作:
1.查看当前集群相关信息:
[tidb@node201 ~]$ tiup cluster display tidb-test

1.1新安装一台主机,IP:172.16.1.204

2.编辑扩容文件注意缩进格式:
vim scale-out-tikv.yaml
添加以下内容,其中,加入tikv节点IP地址为:172.16.1.204,端口号:20160

tikv_servers:
- host: 172.16.1.204
ssh_port: 22
status_port: 20180
deploy_dir: /tidb-deploy/tikv-20160
data_dir: /tidb-data/tikv-20160
log_dir: /tidb-deploy/tikv-20160/log

3.执行以下命令,进行扩容操作:
tiup cluster scale-out tidb-test scale-out-tikv.yaml -uroot -p

[tidb@node201 ~]$ tiup cluster scale-out tidb-test scale-out-tikv.yaml -uroot -p
tiup is checking updates for component cluster …
A new version of cluster is available:
The latest version: v1.15.0
Local installed version: v1.9.3
Update current component: tiup update cluster
Update all components: tiup update --all

Starting component cluster: /home/tidb/.tiup/components/cluster/v1.9.3/tiup-cluster /home/tidb/.tiup/components/cluster/v1.9.3/tiup-cluster scale-out tidb-test scale-out-tikv.yaml -uroot -p
Input SSH password:

  • Detect CPU Arch
    • Detecting node 172.16.1.204 … Done
      Please confirm your topology:
      Cluster type: tidb
      Cluster name: tidb-test
      Cluster version: v6.1.0
      Role Host Ports OS/Arch Directories

tikv 172.16.1.204 20160/20180 linux/x86_64 /tidb-deploy/tikv-20160,/tidb-data/tikv-20160
Attention:
1. If the topology is not what you expected, check your yaml file.
2. Please confirm there is no port/directory conflicts in same host.
Do you want to continue? [y/N]: (default=N) y

  • [ Serial ] - SSHKeySet: privateKey=/home/tidb/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa, publicKey=/home/tidb/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa.pub
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.202
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.202
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.203
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.203
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.201
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.201
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.201
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.201
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.201
  • [Parallel] - UserSSH: user=tidb, host=172.16.1.201
  • Download TiDB components
    • Download tikv:v6.1.0 (linux/amd64) … Done
    • Download node_exporter: (linux/amd64) … Done
    • Download blackbox_exporter: (linux/amd64) … Done
  • Initialize target host environments
    • Initialized host 172.16.1.204 … Done
  • Deploy TiDB instance
    • Deploy instance tikv → 172.16.1.204:20160 … Done
    • Deploy node_exporter → 172.16.1.204 … Done
    • Deploy blackbox_exporter → 172.16.1.204 … Done
  • Copy certificate to remote host
  • Generate scale-out config
    • Generate scale-out config tikv → 172.16.1.204:20160 … Done
  • Init monitor config
    • Generate config node_exporter → 172.16.1.204 … Done
    • Generate config blackbox_exporter → 172.16.1.204 … Done
  • Check status
    Enabling component tikv
    Enabling instance 172.16.1.204:20160
    Enable instance 172.16.1.204:20160 success
    Enabling component node_exporter
    Enabling instance 172.16.1.204
    Enable 172.16.1.204 success
    Enabling component blackbox_exporter
    Enabling instance 172.16.1.204
    Enable 172.16.1.204 success
  • [ Serial ] - Save meta
  • [ Serial ] - Start new instances
    Starting component tikv
    Starting instance 172.16.1.204:20160
    Start instance 172.16.1.204:20160 success
    Starting component node_exporter
    Starting instance 172.16.1.204
    Start 172.16.1.204 success
    Starting component blackbox_exporter
    Starting instance 172.16.1.204
    Start 172.16.1.204 success
  • Refresh components conifgs
    • Generate config pd → 172.16.1.201:2379 … Done
    • Generate config pd → 172.16.1.202:2379 … Done
    • Generate config pd → 172.16.1.203:2379 … Done
    • Generate config tikv → 172.16.1.201:20160 … Done
    • Generate config tikv → 172.16.1.202:20160 … Done
    • Generate config tikv → 172.16.1.203:20160 … Done
    • Generate config tikv → 172.16.1.204:20160 … Done
    • Generate config tidb → 172.16.1.201:4000 … Done
    • Generate config prometheus → 172.16.1.201:9090 … Done
    • Generate config grafana → 172.16.1.201:3000 … Done
    • Generate config alertmanager → 172.16.1.201:9093 … Done
  • Reload prometheus and grafana
    • Reload prometheus → 172.16.1.201:9090 … Done
    • Reload grafana → 172.16.1.201:3000 … Done
  • [ Serial ] - UpdateTopology: cluster=tidb-test
    Scaled cluster tidb-test out successfully

查看扩容后的服务器情况:
[tidb@node201 ~]$ tiup cluster display tidb-test
tiup is checking updates for component cluster …
A new version of cluster is available:
The latest version: v1.15.0
Local installed version: v1.9.3
Update current component: tiup update cluster
Update all components: tiup update --all

Starting component cluster: /home/tidb/.tiup/components/cluster/v1.9.3/tiup-cluster /home/tidb/.tiup/components/cluster/v1.9.3/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.16.1.203:2379/dashboard
ID Role Host Ports OS/Arch Status Data Dir Deploy Dir


172.16.1.201:9093 alertmanager 172.16.1.201 9093/9094 linux/x86_64 Up /tidb-data/alertmanager-9093 /tidb-deploy/alertmanager-9093
172.16.1.201:3000 grafana 172.16.1.201 3000 linux/x86_64 Up - /tidb-deploy/grafana-3000
172.16.1.201:2379 pd 172.16.1.201 2379/2380 linux/x86_64 Up /tidb-data/pd-2379 /tidb-deploy/pd-2379
172.16.1.202:2379 pd 172.16.1.202 2379/2380 linux/x86_64 Up|L /tidb-data/pd-2379 /tidb-deploy/pd-2379
172.16.1.203:2379 pd 172.16.1.203 2379/2380 linux/x86_64 Up|UI /tidb-data/pd-2379 /tidb-deploy/pd-2379
172.16.1.201:9090 prometheus 172.16.1.201 9090/12020 linux/x86_64 Up /tidb-data/prometheus-9090 /tidb-deploy/prometheus-9090
172.16.1.201:4000 tidb 172.16.1.201 4000/10080 linux/x86_64 Up - /tidb-deploy/tidb-4000
172.16.1.201:20160 tikv 172.16.1.201 20160/20180 linux/x86_64 Up /tidb-data/tikv-20160 /tidb-deploy/tikv-20160
172.16.1.202:20160 tikv 172.16.1.202 20160/20180 linux/x86_64 Up /tidb-data/tikv-20160 /tidb-deploy/tikv-20160
172.16.1.203:20160 tikv 172.16.1.203 20160/20180 linux/x86_64 Up /tidb-data/tikv-20160 /tidb-deploy/tikv-20160
172.16.1.204:20160 tikv 172.16.1.204 20160/20180 linux/x86_64 Up /tidb-data/tikv-20160 /tidb-deploy/tikv-20160
Total nodes: 11

1 个赞

你可以都放一个帖子里,分享学习测试笔记,代码可以用代码块包起来,这样比较好看,类似:

afasdfsafasdfasf
1 个赞

谢谢分享