TiDB集群运维之版本升级

智慧并不产生于学历,而是来自对于知识的终生不懈的追求。这篇文章主要讲述TiDB集群运维之版本升级相关的知识,希望能为你提供帮助。
1. 升级兼容性说明

  • TiDB 目前暂不支持版本降级或升级后回退。
  • 使用 TiDB Ansible 管理的 4.0 版本集群,需要先按照  ??4.0 版本文档的说明??将集群导入到 TiUP (tiup cluster) 管理后,再按本文档说明升级到 5.2 版本及后续修订版本。
  • 若要将 3.0 之前的版本升级至 5.2 版本:
  1. 首先??通过 TiDB Ansible 升级到 3.0 版本??。
  2. 然后按照  ??4.0 版本文档的说明??,使用 TiUP (tiup cluster) 将 TiDB Ansible 配置导入。
  3. 将集群升级至 4.0 版本。
  4. 按本文档说明将集群升级到 5.2 版本。
  • 支持 TiDB Binlog,TiCDC,TiFlash 等组件版本的升级。
  • 具体不同版本的兼容性说明,请查看各个版本的  ??Release Note??。请根据各个版本的 Release Note 的兼容性更改调整集群的配置。
2. 升级前准备本部分介绍实际开始升级前需要进行的更新 TiUP 和 TiUP Cluster 组件版本等准备工作。
2.1 升级 TiUP 或更新 TiUP 离线镜像
先升级 TiUP 版本(建议 tiup 版本不低于 1.5.0)
[root@tds01 ~]# tiup update --self
Updated successfully!
[root@tds01 ~]# tiup --version
1.5.2 tiup
Go Version: go1.16.5
Git Ref: v1.5.2
GitHash: 5f4e8abfe2ce2b3415b6a8161d8a4863d4e16ce0

【TiDB集群运维之版本升级】再升级 TiUP Cluster 版本(建议 tiup cluster 版本不低于 1.5.0)
[root@tds01 ~]# tiup update cluster
component cluster version v1.5.2 is already installed
Updated successfully!
[root@tds01 ~]# tiup cluster --version
Starting component `cluster`: /root/.tiup/components/cluster/v1.5.2/tiup-cluster --version
tiup version 1.5.2 tiup
Go Version: go1.16.5
Git Ref: v1.5.2
GitHash: 5f4e8abfe2ce2b3415b6a8161d8a4863d4e16ce0

更新 TiUP 离线镜像
[root@tds01 ~]# tar -xzf tidb-community-server-v5.2.1-linux-amd64.tar.gz
[root@tds01 ~]# cd tidb-community-server-v5.2.1-linux-amd64/
[root@tds01 tidb-community-server-v5.2.1-linux-amd64]# ./local_install.sh
Disable telemetry success
Successfully set mirror to /root/tidb-community-server-v5.2.1-linux-amd64
Detected shell: bash
Shell profile:/root/.bash_profile
Installed path: /root/.tiup/bin/tiup
===============================================
1. source /root/.bash_profile
2. Have a try:tiup playground
===============================================
[root@tds01 ~]# source .bash_profile

覆盖升级完成后,执行下列命令升级 Cluster 组件
[root@tds01 ~]# tiup update cluster
Updated successfully!

2.2 编辑 TiUP Cluster 拓扑配置文件
TiDB集群运维之版本升级

文章图片

这里不涉及,直接跳过。
2.3 检查当前集群的健康状况
[root@tds01 ~]# tiup cluster check tidbcluster --cluster
Starting component `cluster`: /root/.tiup/components/cluster/v1.5.6/tiup-cluster check tidbcluster --cluster
+ Download necessary tools
- Downloading check tools for linux/amd64 ... Done
+ Collect basic system information
- Getting system info of 192.168.120.113:22 ... ? CopyComponent: component=insight, version=, remote=192.168.120.113:/tmp/tiup os=linux, arch=amd64
+ Collect basic system information
+ Collect basic system information
- Getting system info of 192.168.120.113:22 ... Done
- Getting system info of 192.168.120.111:22 ... Done
- Getting system info of 192.168.120.114:22 ... Done
+ Check system requirements
+ Check system requirements
- Checking node 192.168.120.113 ... ? Shell: host=192.168.120.113, sudo=false, command=`ss -lnt`
+ Check system requirements
+ Check system requirements
- Checking node 192.168.120.113 ... ? Shell: host=192.168.120.113, sudo=false, command=`cat /etc/security/limits.conf`
+ Check system requirements
+ Check system requirements
+ Check system requirements
+ Check system requirements
- Checking node 192.168.120.113 ... Done
- Checking node 192.168.120.111 ... Done
- Checking node 192.168.120.111 ... Done
- Checking node 192.168.120.113 ... Done
- Checking node 192.168.120.114 ... Done
- Checking node 192.168.120.111 ... Done
- Checking node 192.168.120.114 ... Done
- Checking node 192.168.120.114 ... Done
+ Cleanup check files
- Cleanup check files on 192.168.120.113:22 ... Done
- Cleanup check files on 192.168.120.111:22 ... Done
- Cleanup check files on 192.168.120.111:22 ... Done
- Cleanup check files on 192.168.120.113:22 ... Done
- Cleanup check files on 192.168.120.114:22 ... Done
- Cleanup check files on 192.168.120.111:22 ... Done
- Cleanup check files on 192.168.120.114:22 ... Done
- Cleanup check files on 192.168.120.114:22 ... Done
......
Checking region status of the cluster tidbcluster...
All regions are healthy.

3. 升级 TiDB 集群升级的方式有两种:不停机升级和停机升级。TiUP Cluster 默认的升级 TiDB 集群的方式是不停机升级,即升级过程中集群仍然可以对外提供服务。升级时会对各节点逐个迁移 leader 后再升级和重启,因此对于大规模集群需要较长时间才能完成整个升级操作。如果业务有维护窗口可供数据库停机维护,则可以使用停机升级的方式快速进行升级操作。
3.1 将集群升级到指定版本
[root@tds01 ~]# tiup cluster upgrade tidbcluster v5.2.1
Starting component `cluster`: /root/.tiup/components/cluster/v1.5.6/tiup-cluster upgrade tidbcluster v5.2.1
This operation will upgrade tidb v5.1.0 cluster tidbcluster to v5.2.1.
Do you want to continue? [y/N]:(default=N) y
......
Restart instance 192.168.120.114:20162 success
Upgrading component tidb
Restarting instance 192.168.120.111:4000
Restart instance 192.168.120.111:4000 success
Upgrading component prometheus
Restarting instance 192.168.120.114:9090
Restart instance 192.168.120.114:9090 success
Upgrading component grafana
Restarting instance 192.168.120.114:3000
Restart instance 192.168.120.114:3000 success
Upgraded cluster `tidbcluster` successfully

TiDB集群运维之版本升级

文章图片

3.2 升级后验证
[root@tds01 ~]# tiup cluster display tidbcluster
Starting component `cluster`: /root/.tiup/components/cluster/v1.5.6/tiup-cluster display tidbcluster
Cluster type:tidb
Cluster name:tidbcluster
Cluster version:v5.2.1
Deploy user:tidb
SSH type:builtin
Dashboard URL:http://192.168.120.111:2379/dashboard
IDRoleHostPortsOS/ArchStatusData DirDeploy Dir
----------------------------------------------
192.168.120.114:3000grafana192.168.120.1143000linux/x86_64Up-/data/tidb/tidb-deploy/grafana-3000
192.168.120.111:2379pd192.168.120.1112379/2380linux/x86_64Up|L|UI/data/tidb/tidb-data/pd-2379/data/tidb/tidb-deploy/pd-2379
192.168.120.114:9090prometheus192.168.120.1149090linux/x86_64Up/data/tidb/tidb-data/prometheus-9090/data/tidb/tidb-deploy/prometheus-9090
192.168.120.111:4000tidb192.168.120.1114000/10080linux/x86_64Up-/data/tidb/tidb-deploy/tidb-4000
192.168.120.113:9000tiflash192.168.120.1139000/8123/3930/20170/20292/8234linux/x86_64Up/data/tidb/tidb-data/tiflash-9000/data/tidb/tidb-deploy/tiflash-9000
192.168.120.111:20160tikv192.168.120.11120160/20180linux/x86_64Up/data/tidb/tidb-data/tikv-20160/data/tidb/tidb-deploy/tikv-20160
192.168.120.113:20161tikv192.168.120.11320161/20181linux/x86_64Up/data/tidb/tidb-data/tikv-20161/data/tidb/tidb-deploy/tikv-20161
192.168.120.114:20162tikv192.168.120.11420162/20182linux/x86_64Up/data/tidb/tidb-data/tikv-20162/data/tidb/tidb-deploy/tikv-20162
Total nodes: 8




    推荐阅读