在 5.0 版本中,我们专注于帮助企业基于 TiDB 数据库快速构建应用程序,使企业在构建过程中无需担心数据库的性能、性能抖动、安全、高可用、容灾、SQL 语句的性能问题排查等问题。
在 TiDB 5.0 版本中,你可以获得以下关键特性:
EXPLAIN
功能、引入不可见索引等功能帮助提升 DBA 调试及 SQL 语句执行的效率。简单总结就是:从各方面对性能有了较大提升,目前版本已经升级到了****5.1.1。
版本下载地址:https://pingcap.com/zh/product-community/
选择最新的5.1.1下载
将下载好的安装文件上传到现在运行TiDB数据库的服务器上,解压。
tar xzvf tidb-community-server-${version}-linux-amd64.tar.gz
覆盖升级,分别执行以下两行命令:
sh tidb-community-server-${version}-linux-amd64/local_install.sh
source /home/tidb/.bash_profile
ubuntu@ubuntu:~/tidb$ sh tidb-community-server-v5.1.1-linux-amd64/local_install.sh
Successfully set mirror to /home/ubuntu/tidb/tidb-community-server-v5.1.1-linux-amd64
Detected shell: bash
Shell profile: /home/ubuntu/.bashrc
Installed path: /home/ubuntu/.tiup/bin/tiup
===============================================
1. source /home/ubuntu/.bashrc
2. Have a try: tiup playground
===============================================
ubuntu@ubuntu:~/tidb$
ubuntu@ubuntu:~/tidb$
ubuntu@ubuntu:~/tidb$
ubuntu@ubuntu:~/tidb$ source /home/ubuntu/.bashrc
ubuntu@ubuntu:~/tidb$ tiup update cluster
Updated successfully!
为避免升级过程中出现未定义行为或其他故障,建议在升级前对集群当前的 region 健康状态进行检查,此操作可通过 check
子命令完成。
tiup cluster check <cluster-name> --cluster
执行结束后,最后会输出 region status 检查结果。如果结果为 "All regions are healthy",则说明当前集群中所有 region 均为健康状态,可以继续执行升级;如果结果为 "Regions are not fully healthy: m miss-peer, n pending-peer" 并提示 "Please fix unhealthy regions before other operations.",则说明当前集群中有 region 处在异常状态,应先排除相应异常状态,并再次检查结果为 "All regions are healthy" 后再继续升级。
升级的方式有两种:不停机升级和停机升级。TiUP Cluster 默认的升级 TiDB 集群的方式是不停机升级,即升级过程中集群仍然可以对外提供服务。升级时会对各节点逐个迁移 leader 后再升级和重启,因此对于大规模集群需要较长时间才能完成整个升级操作。如果业务有维护窗口可供数据库停机维护,则可以使用停机升级的方式快速进行升级操作。
以升级到 5.1.1 版本为例:
tiup cluster upgrade <cluster-name> v5.1.1
注意:
--force
,该方式会造成性能抖动,不会造成数据损失。--transfer-timeout
为一个更大的值,如--transfer-timeout 3600
,单位为秒。在停机升级前,首先需要将整个集群关停。
tiup cluster stop <cluster-name>
之后通过 upgrade
命令添加 --offline
参数来进行停机升级。
tiup cluster upgrade <cluster-name> <version> --offline
升级完成后集群不会自动启动,需要使用 start
命令来启动集群。
tiup cluster start <cluster-name>
执行 display
命令来查看最新的集群版本 TiDB Version
:
tiup cluster display <cluster-name>
Cluster type: tidb
Cluster name: <cluster-name>
Cluster version: v5.1.0
我是采用的不停机升级方式,下面我升级后的结果信息,整个过程非常优雅:
重新执行 tiup cluster upgrade
命令进行升级,升级操作会重启之前已经升级完成的节点。如果不希望重启已经升级过的节点,可以使用 replay
子命令来重试操作,具体方法如下:
tiup cluster audit
命令查看操作记录:tiup cluster audit
在其中找到失败的升级操作记录,并记下该操作记录的 ID,下一步中将使用 <audit-id>
表示操作记录 ID 的值。
2.使用 tiup cluster replay <audit-id>
命令重试对应操作:
tiup cluster replay <audit-id>
可以指定 --force
,升级时会跳过 PD transfer leader
和 TiKV evict leader
过程,直接重启并升级版本,对线上运行的集群性能影响较大。命令如下:
tiup cluster upgrade <cluster-name> <version> --force
可通过 TiUP 安装对应版本的 ctl
组件来更新相关工具版本:
tiup install ctl:v5.1.0