mysql 5.6 升級 mysql 5.7

mysql升級是個老生常談的話題,不多說,主要記錄mysql_update升級方式,以備給新手點借鑑

(一)注意點

1、磁盤空間是否充足,滿足本機主從搭建;

2、mysql5.6中my.cnf的部分參數不在適用於5.7;

3、升級方式的選擇

對於較小的庫,利用mysqldump來直接導出sql文件,然後導入到新庫中;

(二)升級步驟(mysql_update方式)

1、備份數據庫,且備份恢復驗證xtrabackup這裏不詳細記錄

2、關閉當前5.6數據庫實例

在關閉的時候刷新髒塊

SET GLOBAL innodb_fast_shutdown=0

    ./mysql_start_5.6.sh 3308 stop

3、base目錄修改爲5.7對應

修改my.cnf  /data/server/mysql5.7-17

4、mysql_upgrade執行

/data/server/mysql5.7-17/bin/mysql_upgrade--defaults-file=/data/dbdata/my.cnf5.7 -h127.0.0.1 -uroot -p -P3308

(三)操作記錄(10.88.100.15爲例)

1、登陸並執行

SETGLOBAL innodb_fast_shutdown=0

2、停庫 ./mysql_start.sh 3309 stop

3、下載5.7.17二進制包

下載  mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

 

tar–zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz 

mv mysql-5.7.17-linux-glibc2.5-x86_64mysql-5.7.17

4、備份

  備份數據文件、redolog、共享表空間等


5、修改my.cnf

Basedir修改爲/server/mysql-5.7.17

修改my.cnf中的innodb_use_sys_malloc=1 去掉

6、啓動

/data-2/server/mysql-5.7.17/bin/mysqld_safe--defaults-file=/data-2/dbdata/data_3309/my.cnf --port=3309 --user=mysql>/dev/null 2>&1 &

6、升級數據文件

/data-2/server/mysql-5.7.17/bin/mysql_upgrade--defaults-file=/data-2/dbdata/data_3309/my.cnf -h127.0.0.1 -uJRJ_YongChao -p-P3309

7、關閉數據庫

/data-2/server/mysql-5.7.17/bin/mysqladmin-h127.0.0.1 -P3309 -uJRJ_YongChao -p shutdown

8、修改mysql_start.sh 中mysqlbase基本目錄爲5.7.17 並啓動

字符串替換

:1,$s/mysql-5.6.22/mysql-5.7.17/g

啓動數據庫

./mysql_start_5.7.sh3309 start

升級完成

(四)參考文檔(官方文檔-升級部分)

1.      Review the changesdescribed in Section 2.11.1.1, “ChangesAffecting Upgrades to MySQL 5.7” for steps to be performed beforeupgrading.

2.      Configure MySQL toperform a slow shutdown by setting innodb_fast_shutdown to 0. For example:

Press CTRL+C tocopy

mysql -u root -p --execute="SET GLOBALinnodb_fast_shutdown=0"

With a slowshutdown, InnoDB performs a full purge and change buffer merge beforeshutting down, which ensures that data files are fully prepared in case of fileformat differences between releases.

3.      Shut down the oldMySQL server. For example:

Press CTRL+C tocopy

mysqladmin -u root -p shutdown

4.      Upgrade the MySQLbinaries or packages in place (replace the old binaries or packages with thenew ones).

Note

Forsupported Linux distributions, the preferred method for replacing the MySQLpackages is to use the MySQL software repositories; see Section 2.11.1.2, “UpgradingMySQL with the MySQL Yum Repository”, Section 2.11.1.3, “UpgradingMySQL with the MySQL APT Repository”, or UpgradingMySQL with the MySQL SLES Repository for instructions.

5.      Start the MySQL 5.7server, using the existing data directory. For example:

Press CTRL+C tocopy

mysqld_safe --user=mysql --datadir=/path/to/existing-datadir

6.      Run mysql_upgrade. For example:

Press CTRL+C tocopy

mysql_upgrade -u root -p

mysql_upgrade examines all tables in all databases forincompatibilities with the current version of MySQL. mysql_upgrade also upgrades the mysql system database so that you can takeadvantage of new privileges or capabilities.

Note

mysql_upgrade should not be used when the server is running with --gtid-mode=ON. See GTIDmode and mysql_upgrade for more information.

mysql_upgrade does not upgrade the contents of the help tables. Forupgrade instructions, see Section 5.1.10,“Server-Side Help”.

7.      Shut down andrestart the MySQL server to ensure that any changes made to the system tablestake effect. For example:

Press CTRL+C tocopy

mysqladmin -u root -p shutdown

mysqld_safe --user=mysql --datadir=/path/to/existing-datadir


 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章