一.基本資訊
主庫:10.24.65.30
(product)[email protected] [(none)]> select @@version;
+------------+
| @@version |
+------------+
| 5.6.24-log |
+------------+
從庫:10.24.65.33
(product)[email protected] [(none)]> select @@version;
+------------+
| @@version |
+------------+
| 5.6.24-log |
+------------+
二.确認主從是否同步,并關閉從庫
在從庫上檢視:
show slave status\G
Master_Log_File=Relay_Master_Log_File=mysql-bin.000003
Read_Master_Log_Pos=Exec_Master_Log_Pos=402
表示已同步正常。
主庫建個表:
use test;
create table zeng as select * from mysql.user;
從庫檢視:
use test;
show tables;
+----------------+
| Tables_in_test |
+----------------+
| zeng |
+----------------+
關閉從庫。
三.更新mysql到5.7版
1.修改配置檔案,去掉5.7不支援參數innodb_file_io_threads
2.将5.7包複制到/opt/mysql下
scp /data/software/mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz /opt/mysql/
3.對包解壓
cd /opt/mysql
tar -zxvf mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz
chown -R mysql:mysql mysql-5.7.14-linux-glibc2.5-x86_64
3.unlink mysql 5.6
cd /usr/local
unlink mysql
4.link mysql 5.7
cd /usr/local
ln -s /opt/mysql/mysql-5.7.14-linux-glibc2.5-x86_64 mysql
5.配置檔案修改
在/etc/my.cnf中加入skip-grant-tables
7.啟動mysql
mysqld_safe &
8.更新
/usr/local/mysql/bin/mysql_upgrade
9.關閉mysql
mysqladmin shutdown
10.配置檔案中移除skip-grant-tables
11.正常啟動mysql
mysqld_safe &
12.檢視版本
select @@version;
+------------+
| @@version |
+------------+
| 5.7.14-log |
+------------+
說明從庫更新成功。
四.檢查更新後主從同步是否正常
從庫啟動slave: start slave
主庫:
use test;
create table zeng1 as select * from mysql.user;
從庫:
use test;
show tables;
+----------------+
| Tables_in_test |
+----------------+
| zeng |
| zeng1 |
+----------------+
五.提升從庫為主庫,将業務切換到新主庫上運作
六.重新将原主庫配置為新從庫