背景:
才安装部署了MySQL 8.0.15版本不几天,8.0.16版本于2019.04.25发布,考虑在线升级。
并且8.0.15版本的mysql实例作为MySQL5.7.25版本的从库。
1.配置好repo文件:
#wget https://repo.mysql.com//mysql80-community-release-el7-2.noarch.rpm
#rpm -ivh mysql80-community-release-el7-2.noarch.rpm
2.模拟安装指定版本:MySQL 8.0.15
# yum search mysql-community --show-duplicates
# yum search mysql-community --show-duplicates | grep -i 8.0.15
#yum -y install mysql-community-libs-compat-8.0.15 mysql-community-server-8.0.15 mysql-community-client-8.0.15 mysql-community-common-8.0.15 mysql-community-devel-8.0.15 mysql-community-libs-8.0.15 mysql-community-libs-compat-8.0.15
登录测试:
查询版本号:
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.15 |
+-----------+
1 row in set (0.00 sec)
--创建表:
create database wuhan;
create table wuhan.user(id bigint unsigned not null primary,username varchar(20),city_id int,city_name varchar(20));
--插入数据:
mysql> select * from wuhan.user;
+----+----------+---------+------------+
| id | username | city_id | city_name |
+----+----------+---------+------------+
| 1 | user001 | 100 | wuhan city |
+----+----------+---------+------------+
1 row in set (0.00 sec)
3.升级到MySQL8.0.16版本:
#yum -y update mysql-community-libs-compat mysql-community-server mysql-community-client mysql-community-common mysql-community-devel mysql-community-libs mysql-community-libs-compat
-- 版本复核:
# rpm -qa | grep -i mysql-community
mysql-community-common-8.0.16-1.el7.x86_64
mysql-community-devel-8.0.16-1.el7.x86_64
mysql-community-libs-8.0.16-1.el7.x86_64
mysql-community-server-8.0.16-1.el7.x86_64
mysql-community-libs-compat-8.0.16-1.el7.x86_64
mysql-community-client-8.0.16-1.el7.x86_64
4.升级之后的验证:
--MySQL状态验证:
# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2019-04-26 09:13:08 CST; 27min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 30257 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 30275 (mysqld)
Status: "SERVER_OPERATING"
CGroup: /system.slice/mysqld.service
└─30275 /usr/sbin/mysqld
-- 登录验证:
# mysql -h10.19.145.159 -uroot -poracle
--版本查询:
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.16 |
+-----------+
1 row in set (0.00 sec)
--数据查询:
mysql> select *from wuhan.user;
+----+----------+---------+------------+
| id | username | city_id | city_name |
+----+----------+---------+------------+
| 1 | user001 | 100 | wuhan city |
+----+----------+---------+------------+
1 row in set (0.00 sec)
-- 主从验证:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.19.162.134
Master_User: repl
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: mysql_bin.000001
Read_Master_Log_Pos: 857
Relay_Log_File: relay.000004
Relay_Log_Pos: 321
Relay_Master_Log_File: mysql_bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
...
总结:使用yum可在线升级,在升级的过程中不停机不重启,配置的主从可正常运行,对业务无感知。
升级过程中主从可正常运行,数据无丢失。