写点什么

【新手升级必看】从 TiDB v6.5 升级到 v7.5 的实践步骤

  • 2023-12-22
    北京
  • 本文字数:6036 字

    阅读完需:约 20 分钟

作者: 春风十里原文来源:https://tidb.net/blog/b0fea026


TiDB 7.5 已发布了 支持并行运行多个 ADD INDEX 语句 并且兼容MySQL 8.0.  是时候测试一下了,要测试必须先升级。那么下面就是按官方文档指示升级的过程。
复制代码


升级说明:本次升级测试为测试环境,单机部署。

操作系统版本 CentOS Linux release 7.8.2003 (Core)

原 tidb 版本 6.5.2

** 升级版本 7.5.0**


先看看官方的升级介绍:


12 月 1 日,期待已久的 TiDB v7.5.0 LTS 发版。 TiDB 7.5.0 Release Notes


作为 TiDB 7 系列的第二个长期支持版本 (LTS) ,TiDB 7.5 着眼于提升规模化场景下关键应用的稳定性。新版本中,TiDB 在可扩展性与性能、稳定性与高可用、SQL 以及可观测性等方面获得了持续的提升。TiDB 7.5 LTS 包含了已发布的 7.2.0-DMR、7.3.0-DMR 和 7.4.0-DMR 版本中的新功能、提升改进和错误修复,累计优化和修复功能 70 余项。

第一步 升级参考地址

使用 TiUP 升级 TiDB | PingCAP 文档中心

第二步 检查 tiup 版本

检查 tiup 版本

检查 tiup cluster 版本


确保 tiup 和 tiup cluster 版本不低于 1.11.3

第三步 编辑 TiUP Cluster 拓扑配置文件(可选)

注意,以下情况可跳过此步骤:


  • 原集群没有修改过配置参数,或通过 tiup cluster 修改过参数但不需要调整。

  • 升级后对未修改过的配置项希望使用 7.5.0 默认参数。


如果要保留就的参数配置,或者改变 7.5 新增的默认的参数,请修改 topology 配置文件。

第四步 检查当前集群的健康状况

测试环境有一些操作系统内核参数配置不符合推荐配置。




可以通过 –apply 先尝试自动修复


例如:tiup cluster check mytidb7 –cluster –apply


tiup 会尝试自动修复



如果不能自动修复,需要手工修复,部分操作可能需要重启。


例如:


numactl not usable, bash: numactl: command not foundnumactl 工具可用于查看当前服务器的 NUMA 节点配置、状态,可通过该工具将进程绑定到指定 CPU core,由指定 CPU core 来运行对应进程。FIX :yum -y install numactl.x86_64


THP is enabled, please disable it for best performanceTransparent Hugepages(THP,页面内存透明化), 透明大页面(THP)是一种 Linux 内存管理系统,通过使用更大的内存页面,可以减少具有大量内存的计算机上的 Translation Lookaside Buffer(TLB)查找的开销。但是,数据库工作负载通常在 THP 上表现不佳,因为它们往往具有稀疏而不是连续的内存访问模式。 您应该在 Linux 机器上禁用 THP 以确保使用 MongoDB 获得最佳性能。争对一些数据库,如 Oracle、MariaDB、MongoDB、VoltDB 在使用时,要求关闭此功能。FIX:vim /etc/rc.d/rc.local1: 新增:if test -f /sys/kernel/mm/transparent_hugepage/enabled; thenecho never > /sys/kernel/mm/transparent_hugepage/enabledfiif test -f /sys/kernel/mm/transparent_hugepage/defrag; thenecho never > /sys/kernel/mm/transparent_hugepage/defragfi2: 授权执行:chmod +x /etc/rc.d/rc.local3: 重启:reboot

第五步 检查当前集群的 DDL 和 Backup 情况



确保无正在执行的 ddl 语句、无备份任务或者还原任务。

第六步 升级 TiDB

tiup cluster upgrade mytidb v7.5.0


因为网络限速,多次升级失败,建议 tidb 延长默认的下载文件时间


第七步 升级成功输出

[root\@zabbix_server ~]# tiup cluster upgrade mytidb v7.5.0tiup is checking updates for component cluster …A new version of cluster is available:The latest version: v1.14.0Local installed version: v1.12.1Update current component: tiup update clusterUpdate all components: tiup update –all


Starting component cluster: /root/.tiup/components/cluster/v1.12.1/tiup-cluster upgrade mytidb v7.5.0Before the upgrade, it is recommended to read the upgrade guide at https://docs.pingcap.com/tidb/stable/upgrade-tidb-using-tiup and finish the preparation steps.This operation will upgrade tidb v6.5.2 cluster mytidb to v7.5.0.Do you want to continue? [y/N]:(default=N) yUpgrading cluster…


  • [ Serial ] - SSHKeySet: privateKey=/root/.tiup/storage/cluster/clusters/mytidb/ssh/id_rsa, publicKey=/root/.tiup/storage/cluster/clusters/mytidb/ssh/id_rsa.pub

  • [Parallel] - UserSSH: user=tidb, host= 192.11.117.15

  • [Parallel] - UserSSH: user=tidb, host= 192.11.117.15

  • [Parallel] - UserSSH: user=tidb, host= 192.11.117.15

  • [Parallel] - UserSSH: user=tidb, host= 192.11.117.15

  • [Parallel] - UserSSH: user=tidb, host= 192.11.117.15

  • [Parallel] - UserSSH: user=tidb, host= 192.11.117.15

  • [Parallel] - UserSSH: user=tidb, host= 192.11.117.15

  • [Parallel] - UserSSH: user=tidb, host= 192.11.117.15

  • [ Serial ] - Download: component=tikv, version=v7.5.0, os=linux, arch=amd64

  • [ Serial ] - Download: component=prometheus, version=v7.5.0, os=linux, arch=amd64

  • [ Serial ] - Download: component=tiflash, version=v7.5.0, os=linux, arch=amd64

  • [ Serial ] - Download: component=pd, version=v7.5.0, os=linux, arch=amd64

  • [ Serial ] - Download: component=tidb, version=v7.5.0, os=linux, arch=amd64

  • [ Serial ] - Download: component=grafana, version=v7.5.0, os=linux, arch=amd64

  • [ Serial ] - Mkdir: host= 192.11.117.15, directories=‘/tidb-data/tikv-20162’

  • [ Serial ] - Mkdir: host= 192.11.117.15, directories=‘/tidb-data/tiflash-9000’

  • [ Serial ] - Mkdir: host= 192.11.117.15, directories=‘/tidb-data/pd-2379’

  • [ Serial ] - Mkdir: host= 192.11.117.15, directories=‘/tidb-data/tikv-20161’

  • [ Serial ] - Mkdir: host= 192.11.117.15, directories=‘/tidb-data/tikv-20160’

  • [ Serial ] - BackupComponent: component=tikv, currentVersion=v6.5.2, remote= 192.11.117.15:/tidb-deploy/tikv-20162

  • [ Serial ] - BackupComponent: component=tiflash, currentVersion=v6.5.2, remote= 192.11.117.15:/tidb-deploy/tiflash-9000

  • [ Serial ] - BackupComponent: component=pd, currentVersion=v6.5.2, remote= 192.11.117.15:/tidb-deploy/pd-2379

  • [ Serial ] - BackupComponent: component=tikv, currentVersion=v6.5.2, remote= 192.11.117.15:/tidb-deploy/tikv-20160

  • [ Serial ] - BackupComponent: component=tikv, currentVersion=v6.5.2, remote= 192.11.117.15:/tidb-deploy/tikv-20161

  • [ Serial ] - CopyComponent: component=tikv, version=v7.5.0, remote= 192.11.117.15:/tidb-deploy/tikv-20162 os=linux, arch=amd64

  • [ Serial ] - CopyComponent: component=pd, version=v7.5.0, remote= 192.11.117.15:/tidb-deploy/pd-2379 os=linux, arch=amd64

  • [ Serial ] - CopyComponent: component=tikv, version=v7.5.0, remote= 192.11.117.15:/tidb-deploy/tikv-20160 os=linux, arch=amd64

  • [ Serial ] - CopyComponent: component=tiflash, version=v7.5.0, remote= 192.11.117.15:/tidb-deploy/tiflash-9000 os=linux, arch=amd64

  • [ Serial ] - CopyComponent: component=tikv, version=v7.5.0, remote= 192.11.117.15:/tidb-deploy/tikv-20161 os=linux, arch=amd64

  • [ Serial ] - InitConfig: cluster=mytidb, user=tidb, host= 192.11.117.15, path=/root/.tiup/storage/cluster/clusters/mytidb/config-cache/tikv-20162.service, deploy_dir=/tidb-deploy/tikv-20162, data_dir=[/tidb-data/tikv-20162], log_dir=/tidb-deploy/tikv-20162/log, cache_dir=/root/.tiup/storage/cluster/clusters/mytidb/config-cache+ [ Serial ] - InitConfig: cluster=mytidb, user=tidb, host= 192.11.117.15, path=/root/.tiup/storage/cluster/clusters/mytidb/config-cache/pd-2379.service, deploy_dir=/tidb-deploy/pd-2379, data_dir=[/tidb-data/pd-2379], log_dir=/tidb-deploy/pd-2379/log, cache_dir=/root/.tiup/storage/cluster/clusters/mytidb/config-cache+ [ Serial ] - InitConfig: cluster=mytidb, user=tidb, host= 192.11.117.15, path=/root/.tiup/storage/cluster/clusters/mytidb/config-cache/tikv-20160.service, deploy_dir=/tidb-deploy/tikv-20160, data_dir=[/tidb-data/tikv-20160], log_dir=/tidb-deploy/tikv-20160/log, cache_dir=/root/.tiup/storage/cluster/clusters/mytidb/config-cache+ [ Serial ] - InitConfig: cluster=mytidb, user=tidb, host= 192.11.117.15, path=/root/.tiup/storage/cluster/clusters/mytidb/config-cache/tiflash-9000.service, deploy_dir=/tidb-deploy/tiflash-9000, data_dir=[/tidb-data/tiflash-9000], log_dir=/tidb-deploy/tiflash-9000/log, cache_dir=/root/.tiup/storage/cluster/clusters/mytidb/config-cache+ [ Serial ] - InitConfig: cluster=mytidb, user=tidb, host= 192.11.117.15, path=/root/.tiup/storage/cluster/clusters/mytidb/config-cache/tikv-20161.service, deploy_dir=/tidb-deploy/tikv-20161, data_dir=[/tidb-data/tikv-20161], log_dir=/tidb-deploy/tikv-20161/log, cache_dir=/root/.tiup/storage/cluster/clusters/mytidb/config-cache+ [ Serial ] - Mkdir: host= 192.11.117.15, directories=”

  • [ Serial ] - BackupComponent: component=tidb, currentVersion=v6.5.2, remote= 192.11.117.15:/tidb-deploy/tidb-4000

  • [ Serial ] - Mkdir: host= 192.11.117.15, directories=‘/tidb-data/prometheus-9090’

  • [ Serial ] - Mkdir: host= 192.11.117.15, directories=”

  • [ Serial ] - BackupComponent: component=grafana, currentVersion=v6.5.2, remote= 192.11.117.15:/tidb-deploy/grafana-3000

  • [ Serial ] - CopyComponent: component=grafana, version=v7.5.0, remote= 192.11.117.15:/tidb-deploy/grafana-3000 os=linux, arch=amd64

  • [ Serial ] - InitConfig: cluster=mytidb, user=tidb, host= 192.11.117.15, path=/root/.tiup/storage/cluster/clusters/mytidb/config-cache/grafana-3000.service, deploy_dir=/tidb-deploy/grafana-3000, data_dir=[], log_dir=/tidb-deploy/grafana-3000/log, cache_dir=/root/.tiup/storage/cluster/clusters/mytidb/config-cache+ [ Serial ] - CopyComponent: component=tidb, version=v7.5.0, remote= 192.11.117.15:/tidb-deploy/tidb-4000 os=linux, arch=amd64

  • [ Serial ] - BackupComponent: component=prometheus, currentVersion=v6.5.2, remote= 192.11.117.15:/tidb-deploy/prometheus-9090

  • [ Serial ] - CopyComponent: component=prometheus, version=v7.5.0, remote= 192.11.117.15:/tidb-deploy/prometheus-9090 os=linux, arch=amd64

  • [ Serial ] - InitConfig: cluster=mytidb, user=tidb, host= 192.11.117.15, path=/root/.tiup/storage/cluster/clusters/mytidb/config-cache/prometheus-9090.service, deploy_dir=/tidb-deploy/prometheus-9090, data_dir=[/tidb-data/prometheus-9090], log_dir=/tidb-deploy/prometheus-9090/log, cache_dir=/root/.tiup/storage/cluster/clusters/mytidb/config-cache+ [ Serial ] - InitConfig: cluster=mytidb, user=tidb, host= 192.11.117.15, path=/root/.tiup/storage/cluster/clusters/mytidb/config-cache/tidb-4000.service, deploy_dir=/tidb-deploy/tidb-4000,data_dir=[], log_dir=/tidb-deploy/tidb-4000/log, cache_dir=/root/.tiup/storage/cluster/clusters/mytidb/config-cache+ [ Serial ] - UpgradeClusterUpgrading component tiflashRestarting instance 192.11.117.15:9000Restart instance 192.11.117.15:9000 successUpgrading component pdRestarting instance 192.11.117.15:2379Restart instance 192.11.117.15:2379 successUpgrading component tikvRestarting instance 192.11.117.15:20160Restart instance 192.11.117.15:20160 successEvicting 1 leaders from store 192.11.117.15:20161…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Restarting instance 192.11.117.15:20161Restart instance 192.11.117.15:20161 successEvicting 1 leaders from store 192.11.117.15:20162…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Still waitting for 1 store leaders to transfer…Restarting instance 192.11.117.15:20162Restart instance 192.11.117.15:20162 successUpgrading component tidbRestarting instance 192.11.117.15:4000Restart instance 192.11.117.15:4000 successUpgrading component prometheusRestarting instance 192.11.117.15:9090Restart instance 192.11.117.15:9090 successUpgrading component grafanaRestarting instance 192.11.117.15:3000Restart instance 192.11.117.15:3000 successStopping component node_exporterStopping instance 192.11.117.15Stop 192.11.117.15 successStopping component blackbox_exporterStopping instance 192.11.117.15Stop 192.11.117.15 successStarting component node_exporterStarting instance 192.11.117.15Start 192.11.117.15 successStarting component blackbox_exporterStarting instance 192.11.117.15Start 192.11.117.15 successUpgraded cluster mytidb successfully


检查版本


结束语:

虽然是一个简单的升级,实际还是会遇到几个问题,实践大于查看。


这里把整个升级记录一下,以供参考。


发布于: 刚刚阅读数: 3
用户头像

TiDB 社区官网:https://tidb.net/ 2021-12-15 加入

TiDB 社区干货传送门是由 TiDB 社区中布道师组委会自发组织的 TiDB 社区优质内容对外宣布的栏目,旨在加深 TiDBer 之间的交流和学习。一起构建有爱、互助、共创共建的 TiDB 社区 https://tidb.net/

评论

发布
暂无评论
【新手升级必看】从 TiDB v6.5升级到 v7.5 的实践步骤_版本升级_TiDB 社区干货传送门_InfoQ写作社区