Chinaunix首页 | 论坛 | 博客
  • 博客访问: 23149
  • 博文数量: 4
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 40
  • 用 户 组: 普通用户
  • 注册时间: 2018-04-14 11:46
个人简介

专业打杂,挨踢

文章分类

全部博文(4)

文章存档

2018年(4)

我的朋友

分类: 系统运维

2018-04-28 14:54:19

mysql5.7.21存在安全漏洞,需要将mysql5.7.21升级到5.7.22,通过yum来完成升级。


操作系统版本centos6.5

当前mysql版本mysql5.7.21

 

注意:

由于项目生产系统为监控平台系统非运营业务系统,可以容忍业务暂时中断和丢失一部分数据,为防止升级出现意外。
在进行升级操作前关闭mysql服务通过cp命令对数据库文件进行物理冷备份。
如业务系统对数据库丢失和mysql业务关闭无法容忍,建议通过热备,本文暂不探讨。

关闭业务系统,停止当前mysql

service mysqld stop
项目数据库名为ocdb,备份数据库文件


cd /var/lib/mysql

cp -r ocdb /opt/ocdbbak


备份/etc/my.conf文件

cp /etc/my.cnf /etc/my.cnf20180428

备份/ect/init.d/mysqld文件

cp /etc/init.d/mysqld /etc/init.d/mysqld20180428


升级方式yum

mysql官方提供了mysql5.7.22最新版本的yum源,可以通过yum直接升级mysql5.7.22

https://dev.mysql.com/downloads/repo/yum/

我用的是mysql80-community-release-el6-1.noarch.rpm

备份/etc/yum.repos.d内之前的repo文件,然后安装mysql官方源。

yum install https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm

安装后查看安装会在/etc/yum.repos.d目录内生成repo文件

[root@monitor yum.repos.d]# pwd

/etc/yum.repos.d

[root@monitor yum.repos.d]# ls -rlt

total 8

-rw-r--r-- 1 root root 1885 Feb 22 00:36 mysql-community-source.repo

-rw-r--r-- 1 root root 1862 Apr 27 19:33 mysql-community.repo

 查看可用仓库

[root@monitor yum.repos.d]# yum repolist all | grep mysql               

mysql-cluster-7.5-community        MySQL Cluster 7.5 Community      disabled

mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So disabled

mysql-cluster-7.6-community        MySQL Cluster 7.6 Community      disabled

mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - So disabled

mysql-connectors-community         MySQL Connectors Community       enabled:  49

mysql-connectors-community-source  MySQL Connectors Community - Sou disabled

mysql-tools-community              MySQL Tools Community            enabled:  61

mysql-tools-community-source       MySQL Tools Community - Source   disabled

mysql-tools-preview                MySQL Tools Preview              disabled

mysql-tools-preview-source         MySQL Tools Preview - Source     disabled

mysql55-community                  MySQL 5.5 Community Server       disabled

mysql55-community-source           MySQL 5.5 Community Server - Sou disabled

mysql56-community                  MySQL 5.6 Community Server       disabled

mysql56-community-source           MySQL 5.6 Community Server - Sou disabled

mysql57-community                  MySQL 5.7 Community Server       enabled: 255

mysql57-community-source           MySQL 5.7 Community Server - Sou disabled

mysql80-community                  MySQL 8.0 Community Server       disabled

mysql80-community-source           MySQL 8.0 Community Server - Sou disabled

 
disable mysql80版本库,我们需要升级是mysql5.7.21至my5.7.22

yum-config-manager --disable mysql80-community


配置mysql57-community版本仓库

yum-config-manager --enable mysql57-community

[root@monitor yum.repos.d]#  yum repolist enabled | grep mysql

mysql-connectors-community           MySQL Connectors Community            49

mysql-tools-community                MySQL Tools Community                 61

mysql57-community                    MySQL 5.7 Community Server           255

 
升级mysql5.7.22最新版本

[root@monitor yum.repos.d]# yum upgrade mysql-community-server

Loaded plugins: product-id, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Upgrade Process

Resolving Dependencies

--> Running transaction check

---> Package mysql-community-server.x86_64 0:5.7.21-1.el6 will be updated

---> Package mysql-community-server.x86_64 0:5.7.22-1.el6 will be an update

--> Processing Dependency: mysql-community-common(x86-64) = 5.7.22-1.el6 for package: mysql-community-server-5.7.22-1.el6.x86_64

--> Running transaction check

---> Package mysql-community-common.x86_64 0:5.7.21-1.el6 will be updated

---> Package mysql-community-common.x86_64 0:5.7.22-1.el6 will be an update

 输入y,完成升级安装。


注意:

由于本文采用的是管方yum源,下载可能较慢,可在相同操作系统环境下的测试环境。通过yum下载对应的rpm包,或直接前往官网下载rpm包。
mysql-community-server-5.7.22-1.el6.x86_64
mysql-community-common-5.7.22-1.el6.x86_64

通过配置/etc/yum.conf里配置keepcache=1保留rpm包。

[root@monitor packages]# cat /etc/yum.conf

[main]

cachedir=/var/cache/yum/$basearch/$releasever

keepcache=1

[root@monitor packages]# pwd

/var/cache/yum/x86_64/6/mysql57-community/packages

 完成升级后启动数据库

[root@monitor packages]# service mysqld start

Starting MySQL... SUCCESS!


启动业务系统

检查mysql版本是否正常,查看业务系统登录是否正常。

mysql

mysql> select version();

+------------+

| version()  |

+------------+

| 5.7.22-log |

+------------+

1 row in set (0.00 sec)

阅读(1581) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~