网站首页 > 博客文章 正文
原文链接:https://www.modb.co/db/24527 (复制链接至浏览器,即可查看)
摘要:MySQL 5.7 升级8.0的总结经验
为什么升级到MySQL8.0
1)基于安全考虑2)基于性能和 稳定性考虑:mgr复制 ,并行复制writeset 等功能,性能提升3)新的功能:Hash join ,窗口函数,DDL即时,joson 支持4)原始环境中版本太多,统一版本。8.0版本基本已到稳定期。可以大量投入生产环境中
升级之前需要了解
1)数据库字典升级schema,mysql,information_schema,performance_schema,sys比如:密码测试 mysql_native_password → caching_sha2_password2)关键词是不是兼容https://dev.mysql.com/doc/refman/8.0/en/keywords.html关键词 added in查询3)SQL是不是兼容Group by处理上的不兼容,触发器,存储过程5.6 可以跑select id,count(*)from group by name;5.7,8.0是不是允许的 sql_mode控制4)数据文件存储格式是不是可以直接升级Perconal 和 mysql 存储引擎一直,可以完全兼容5)现有应用的兼容性是否满足自定义函数,一些不规范的SQL语句等等6)密码策略
What Is New in MySQL 8.0
作为DBA需要基本了解8.0的一些功能https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.htmlAdded in 添加功能; Features Deprecated 弃用功能,Features Removed 移除功能
升级准备事项
已经了解8.0的特性,应对升级需要事先进行验证和准备工作
1)测试库升级,应用验证2)数据库升级,末知问题发生3)my.cnf配置信息调整4)不兼容的操作方法,影响复制5)一个平稳的过滤,列如先升级一个从库,到所有从库6)最少停机时间,同样生产数据恢复到环境,进行模拟升级,评估时间7)怎样进行数据验证:行数,表的数量 等等8)考虑回滚方案9)数据库备份
升级前检查Mysql8.0还是提供了很多方便,不像之前一样5.6升级5.7那样。现在可以通过mysql shell进行确认。https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-utilities-upgrade.html##下面2种方式
#mysqlsh root:123456@192.168.244.130:3410 -e 'util.checkForServerUpgrade({"targetVersion":"8.0.19","configPath":"/etc/my3410.cnf"})';
MySQL JS > util.checkForServerUpgrade('root@192.168.244.130:3410', {"password":"123456", "targetVersion":"8.0.11", "configPath":"/etc/my3410.cnf"})
按照提示的要求进行更改
虽然shell做的很好,但还是存在一些缺陷。比如以下内容都不会存在提示:1.basedir,2.sql_mode ,3.半同步配置,4.密码策略:default_authentication_plugin = mysql_native_password
开始升级
官网下载对应的tar包https://downloads.mysql.com/archives/community/下面是单机升级,高可用架构下 需要先升级从库,在逐步升级主库。
执行mysql_upgrade命令,会提示如下:
#/mysql8.0.19/bin/mysql_upgrade -uroot -p123456
在MySQL 8中mysql_upgrade客户端现已弃用。升级客户端执行的操作现在由服务器完成。要升级,请使用较旧的数据目录启动新的 MySQL 二进制文件。自动修复用户表。升级后不需要重新启动。所以必须在测试环境模拟准备对应SQL语句
***正确操作如下:
1)登录服务器进行正常关闭:innodb_fast_shutdown是默认是1,常常认为是安全关闭
##关闭innodb参数确认
mysql> show variables like 'innodb_fast_shutdown';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| innodb_fast_shutdown | 1 |
+----------------------+-------+
1 row in set (0.00 sec)
##确保数据都刷到硬盘上,更改成0
mysql> set global innodb_fast_shutdown=0;
Query OK, 0 rows affected (0.01 sec)
mysql> shutdown;
Query OK, 0 rows affected (0.00 sec)
*进行备份。
2)用mysql8.0.19客户端直接启动。启动mysql服务
[root@ss30 bin]# /opt/mysql8.0.19/bin/mysqld_safe --defaults-file=/etc/my3400.cnf --user=mysql &
[1] 15400
[root@ss30 bin]# 2020-04-25T13:07:16.591560Z mysqld_safe Logging to '/opt/data3400/logs/error.log'.
2020-04-25T13:07:16.636879Z mysqld_safe Starting mysqld daemon with databases from /opt/data3400/mysql
##打开另一个窗口查看error日志
[root@ss30 ~]# tail -f /opt/data3400/logs/mysql_error.log
##登录服务器确认
[root@ss30 ~]# mysql -uroot -p -S /opt/data3400/mysql/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.19 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.19 |
+-----------+
1 row in set (0.01 sec)
##无myisam引擎
mysql> SELECT table_schema,table_name,engine FROM information_schema.tables where engine!='InnoDB';
剩下的就是验证 和 业务确认否应用正常。
总结
整个从升级准备开始 到结束,中间包含很多细致的工作。比如版本确认,功能确认,测试,准备,备份,验证,高可用切换等等。前期需要投入很多精力进行准备,这样才能做到一步到位。升级完,下一步踏上8.0的使用旅程。
猜你喜欢
- 2024-09-10 解决Navicat连接 Mysql 8 出现1251- Client does not support错误
- 2024-09-10 win10安装mysql遇到的坑(win10安装mysql5.5)
- 2024-09-10 MySQL系列-二进制包安装(v8.0.24)
- 2024-09-10 Win10+docker+Laradock(下篇):Docker的基本操作与项目开发配置
- 2024-09-10 为Debezium配置MySQL单机版(mysqld 指定配置文件)
- 2024-09-10 Java 连接 MySQL 8.0 排错案例-爱可生
- 2024-09-10 MySQL数据库下载、安装、配置、卸载
- 2024-09-10 不要再原地踏步了,升级到 MySQL 8.x 的 6 大理由!
- 2024-09-10 Django + MySQL 8 开发环境用 Docker来部署
- 2024-09-10 【每日一学】数据库大揭秘:MySQL 事务学习手册,精通数据操作!
你 发表评论:
欢迎- 367℃用AI Agent治理微服务的复杂性问题|QCon
- 358℃初次使用IntelliJ IDEA新建Maven项目
- 358℃手把手教程「JavaWeb」优雅的SpringMvc+Mybatis整合之路
- 351℃Maven技术方案最全手册(mavena)
- 348℃安利Touch Bar 专属应用,让闲置的Touch Bar活跃起来!
- 346℃InfoQ 2024 年趋势报告:架构篇(infoq+2024+年趋势报告:架构篇分析)
- 345℃IntelliJ IDEA 2018版本和2022版本创建 Maven 项目对比
- 342℃从头搭建 IntelliJ IDEA 环境(intellij idea建包)
- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)