当前位置:   article > 正文

rpm小版本升级mysql5.7(keepalived+mysql环境)_mysql5.7小版本推荐

mysql5.7小版本推荐

因漏洞扫描出以下结果(展示部分),推荐升级到5.7.38以上,索性直接升到头(小版本)。

Oracle MySQL 输入验证错误漏洞(CVE-2022-21454)

Oracle MySQL 输入验证错误漏洞(CVE-2022-21427)

因当时部署时用的rpm方式,所以这次也用rpm升级,官网看到5.7最高为40版本。

下载地址: https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.40-1.el7.x86_64.rpm-bundle.tar

1、准备工作

下载完包后,开始备份文件(很重要!)

1.1、备份配置文件

[root@db01 ~]# cp /etc/my.cnf /etc/my.cnf.bak

1.2、用dump把库导出为sql文件。 

[root@db01 ~]# mysqldump -u root  -p --set-gtid-purged=off --all-databases --single-transaction  > /data01/backup/database20230308.sql

1.3、主从关闭keepalived

[root@db01 ~]# systemctl stop keepalived

 1.4、关闭slave

登录mysql(从执行)

  1. mysql> stop slave;
  2. Query OK, 0 rows affected (0.01 sec)

 

1.5、关闭数据库(主从)

[root@db01 ~]# systemctl stop mysqld

2、开始部署 

2.1、检查当前版本

  1. [root@db01 ~]# rpm -qa|grep mysql
  2. mysql-community-common-5.7.38-1.el7.x86_64
  3. mysql-community-server-5.7.38-1.el7.x86_64
  4. mysql-community-libs-5.7.38-1.el7.x86_64
  5. mysql-community-client-5.7.38-1.el7.x86_64

 2.2、rpm -Uvh直接升级

这样不用先卸载再安装,数据库密码等配置也不会变,升级完后直接可以用原密码登录,否则还要用初始密码登录再改,slave等其他配置也得重新配。

  1. [root@db01 mysql]# rpm -Uvh mysql-community-server-5.7.40-1.el7.x86_64.rpm --force --nodeps
  2. warning: mysql-community-server-5.7.40-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
  3. Preparing... ################################# [100%]
  4. Updating / installing...
  5. 1:mysql-community-server-5.7.40-1.e################################# [ 50%]
  6. Cleaning up / removing...
  7. 2:mysql-community-server-5.7.38-1.e################################# [100%]
  8. [root@db01 mysql]# rpm -Uvh mysql-community-libs-5.7.40-1.el7.x86_64.rpm --force --nodeps
  9. warning: mysql-community-libs-5.7.40-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
  10. Preparing... ################################# [100%]
  11. Updating / installing...
  12. 1:mysql-community-libs-5.7.40-1.el7################################# [ 50%]
  13. Cleaning up / removing...
  14. 2:mysql-community-libs-5.7.38-1.el7################################# [100%]
  15. [root@db01 mysql]# rpm -Uvh mysql-community-common-5.7.40-1.el7.x86_64.rpm --force --nodeps
  16. warning: mysql-community-common-5.7.40-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
  17. Preparing... ################################# [100%]
  18. Updating / installing...
  19. 1:mysql-community-common-5.7.40-1.e################################# [ 50%]
  20. Cleaning up / removing...
  21. 2:mysql-community-common-5.7.38-1.e################################# [100%]
  22. [root@db01 mysql]# rpm -Uvh mysql-community-client-5.7.40-1.el7.x86_64.rpm --force --nodeps
  23. warning: mysql-community-client-5.7.40-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
  24. Preparing... ################################# [100%]
  25. Updating / installing...
  26. 1:mysql-community-client-5.7.40-1.e################################# [ 50%]
  27. Cleaning up / removing...
  28. 2:mysql-community-client-5.7.38-1.e################################# [100%]

 2.3、启动数据库

升级完毕后确认下my.cnf文件,并且启动数据库。

[root@db01 mysql]# systemctl start mysqld.service

2.4、原密码登录 

启动后登录数据库还用原来的密码。

  1. [root@db01 mysql]# mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 6
  5. Server version: 5.7.40 MySQL Community Server (GPL)
  6. Copyright (c) 2000, 2022, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql>

2.5、执行mysql的升级检查命令

  1. [root@db01 mysql]# mysql_upgrade -uroot -p
  2. Enter password:
  3. Checking if update is needed.
  4. Checking server version.
  5. Running queries to upgrade MySQL server.
  6. Checking system database.
  7. mysql.columns_priv OK
  8. mysql.db OK
  9. mysql.engine_cost OK
  10. mysql.event OK
  11. mysql.func OK
  12. mysql.general_log OK
  13. mysql.gtid_executed OK
  14. mysql.help_category OK
  15. mysql.help_keyword OK
  16. mysql.help_relation OK
  17. mysql.help_topic OK
  18. mysql.innodb_index_stats OK
  19. mysql.innodb_table_stats OK
  20. mysql.ndb_binlog_index OK
  21. mysql.plugin OK
  22. mysql.proc OK
  23. mysql.procs_priv OK
  24. mysql.proxies_priv OK
  25. mysql.server_cost OK
  26. mysql.servers OK
  27. mysql.slave_master_info OK
  28. mysql.slave_relay_log_info OK
  29. mysql.slave_worker_info OK
  30. mysql.slow_log OK
  31. mysql.tables_priv OK
  32. mysql.time_zone OK
  33. mysql.time_zone_leap_second OK
  34. mysql.time_zone_name OK
  35. mysql.time_zone_transition OK
  36. mysql.time_zone_transition_type OK
  37. mysql.user OK
  38. The sys schema is already up to date (version 1.5.2).
  39. Found 0 sys functions, but expected 22. Re-installing the sys schema.
  40. Upgrading the sys schema.
  41. Checking databases.
  42. sys.sys_config OK
  43. Upgrade process completed successfully.
  44. Checking if update is needed.

2.6、查看版本 

  1. [root@db01 mysql]# mysql -V
  2. mysql Ver 14.14 Distrib 5.7.40, for Linux (x86_64) using EditLine wrapper

2.7、开启slave(从节点执行) 

  1. mysql> start slave;
  2. Query OK, 0 rows affected (0.01 sec)

2.8、查看slave (红框内必须恢复yes)

mysql> show slave status \G

 

 2.9、验证主从功能

主创建一个test,验证在从上是否能看到。

  1. mysql> create database test;
  2. Query OK, 1 row affected (0.00 sec)
  3. mysql> show databases;
  4. +--------------------+
  5. | Database |
  6. +--------------------+
  7. | information_schema |
  8. | mysql |
  9. | performance_schema |
  10. | sys |
  11. | test |
  12. +--------------------+
  13. 5 rows in set (0.00 sec)

 2.10、开启keepalived(主从)

[root@db01 mysql]# systemctl start keepalived

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/967147
推荐阅读
相关标签
  

闽ICP备14008679号