tidb的官方给出了单台机器的硬盘上限最多2T,量大的很快就会满,扩容就很重要。
1,扩容前的准备工作
参考:tidb 集群安装配置
因没有给tidb免密获取root权限导致以下错误
Error: Failed to initialize TiDB environment on remote host '10.0.54.6' (task.env_init.failed)
caused by: Failed to create '~/.ssh' directory for user 'tidb'
2,以扩容tikv为例
- $ cat add-tikv.yaml
- tikv_servers:
- - host: 10.0.54.6
3,查看集群信息
- # tiup cluster list //查看集群列表
- # tiup cluster display test_tidb //查看某一集群详细信息
4,扩容tikv
- [tidb@testjian conf]$ tiup cluster scale-out test_tidb add-tikv.yaml
- Found cluster newer version:
- The latest version: v1.5.6
- Local installed version: v1.5.3
- Update current component: tiup update cluster
- Update all components: tiup update --all
- Starting component `cluster`: /home/tidb/.tiup/components/cluster/v1.5.3/tiup-cluster scale-out test_tidb add-tikv.yaml
- Please confirm your topology:
- Cluster type: tidb
- Cluster name: test_tidb
- Cluster version: v4.0.8
- Role Host Ports OS/Arch Directories
- ---- ---- ----- ------- -----------
- tikv 10.0.54.6 20160/20180 linux/x86_64 /home/tidb/tidb-deploy/tikv-20160,/home/tidb/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/test_tidb/ssh/id_rsa, publicKey=/home/tidb/.tiup/storage/cluster/clusters/test_tidb/ssh/id_rsa.pub
- ==================================省略==============================
- + [ Serial ] - SystemCtl: host=10.0.10.23 action=reload prometheus-9090.service
- + [ Serial ] - UpdateTopology: cluster=test_tidb
- Scaled cluster `test_tidb` out successfully
- [tidb@testjian conf]$ tiup cluster display test_tidb //查看是否添加成功
新增的tikv,不会立马进行数据平衡,但是数据的增加会更加倾向于新增的机器。
5,缩容
- [tidb@testjian conf]$ tiup cluster scale-in test_tidb --node 10.0.54.17:4000 --force
- Found cluster newer version:
- The latest version: v1.5.6
- Local installed version: v1.5.3
- Update current component: tiup update cluster
- Update all components: tiup update --all
- Starting component `cluster`: /home/tidb/.tiup/components/cluster/v1.5.3/tiup-cluster scale-in test_tidb --node 10.0.54.17:4000 --force
- Forcing scale in is unsafe and may result in data loss for stateful components.
- The process is irreversible and could NOT be cancelled.
- Only use `--force` when some of the servers are already permanently offline.
- Are you sure to continue? [y/N]:(default=N) y
- This operation will delete the 10.0.54.17:4000 nodes in `test_tidb` and all their data.
- Do you want to continue? [y/N]:(default=N) y
- Scale-in nodes...
- + [ Serial ] - SSHKeySet: privateKey=/home/tidb/.tiup/storage/cluster/clusters/test_tidb/ssh/id_rsa, publicKey=/home/tidb/.tiup/storage/cluster/clusters/test_tidb/ssh/id_rsa.pub
- + [Parallel] - UserSSH: user=tidb, host=10.0.10.23
- + [Parallel] - UserSSH: user=tidb, host=10.0.55.16
- + [Parallel] - UserSSH: user=tidb, host=10.0.55.16
- + [Parallel] - UserSSH: user=tidb, host=10.0.10.23
- + [Parallel] - UserSSH: user=tidb, host=10.0.55.17
- ==================================省略==============================
--force慎用,特别是tikv,tiflash。
转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/tidb/2534.html