博客文章除注明转载外,均为原创。转载请注明出处。
本文链接地址:http://blog.chinaunix.net/uid-31396856-id-5761452.html
MySQL 5.7.17GA都已经出了,考虑到5.7的性能改进和很多新特性,笔者在进过前期的测试和试用后,也开始将生产环境从5.6.x升级到5.7.17了。
升级过程是将5.6.x升级到5.6.34 GA版本,再由5.6.34 GA升级到5.7.17 GA.
MySQL 升级方法通常以下两种:
1.Logical Upgrade:
利用mysqldump来直接导出sql文件,然后导入到新库中,这是最保险的方法,但是对于数据量较大的库的升级,mysqldump就会力不从心费时费力。
2.In-Place Upgrade:
直接替换掉mysql的base目录和my.cnf配置文件,利用mysql_upgrade脚本来完成系统表的升级。需要备份原有的文件,但属于物理拷贝,速度较快。
缺点的话,适合用于跨版本升级,比如mysql5.1升级到mysql5.6,mysql5.5升级到mysql5.7等。
将5.6.34升级到5.7.17以前测试的过程记录如下:
step1:必须先备份数据库xtrabackup(略)
step2:关闭5.6.34
mysql> set global innodb_fast_shutdown=0
mysql> select version();
+------------+
| version() |
+------------+
| 5.6.34-log |
+------------+
[root@dbwatcher-test-8816 ~]# /etc/init.d/mysql stop
Shutting down MySQL...[ OK ]
step3.卸载mysql 5.6.34base目录
[root@
dbwatcher-test-8816 local]# ls
bin etc games include lib lib64 libexec man mysql percona-toolkit sbin share src
[root@
dbwatcher-test-8816 local]# unlink mysql
[root@
dbwatcher-test-8816 local] # ls
bin etc games include lib lib64 libexec man percona-toolkit sbin share src
step4.创建5.7.14软连接,修改权限,设置启动
[root@
dbwatcher-test-8816 local]# ln -sv /opt/mysql/mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql
`/usr/local/mysql' -> `/opt/mysql/mysql-5.7.17-linux-glibc2.5-x86_64'
[root@dbwatcher-test-8816 local]#chown -R mysql.mysql /usr/local/mysql
[root@dbwatcher-test-8816 local]#chown -R mysql.mysql /opt/mysql/mysql-5.7.17-linux-glibc2.5-x86_64
[root@dbwatcher-test-8816 local]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
cp: overwrite `/etc/init.d/mysql'? y
step5 备份与替换my.cnf
注意注释掉
#innodb_file_io_threads=8 /必须去掉/
#innodb_file_format = Barracuda
#innodb_file_format_max = Barracuda
step 6
启动数据库
[root@
dbwatcher-test-8816 local]# /etc/init.d/mysql start
Starting
MySQL.....................................................................................................................................................
..........................................................................................................................................................
...................[ OK ]
注:打开error日志,观察操作过程是否有错误。
step 7 执行mysql_upgrade脚本升级
[root@dbwatcher-test-8816 local]# mysql_upgrade
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Upgrading the sys schema.
Checking databases.
dbtest1.sbtest1 OK
dbtest1.sbtest10 OK
dbtest1.sbtest2 OK
dbtest1.sbtest3 OK
dbtest1.sbtest4 OK
dbtest1.sbtest5 OK
dbtest1.sbtest6 OK
dbtest1.sbtest7 OK
dbtest1.sbtest8 OK
dbtest1.sbtest9 OK
dbtest2.sbtest1 OK
dbtest2.sbtest2 OK
dbtest2.sbtest3 OK
dbtest2.sbtest4 OK
dbtest2.sbtest5 OK
dbtest2.sbtest6 OK
dbtest2.sbtest7 OK
dbtest2.sbtest8 OK
sys.sys_config OK
test.sbtest1 OK
test.sbtest10 OK
test.sbtest2 OK
test.sbtest3 OK
test.sbtest4 OK
test.sbtest5 OK
test.sbtest6 OK
test.sbtest7 OK
test.sbtest8 OK
test.sbtest9 OK
Upgrade process completed successfully.
Checking if update is needed.
[root@dbwatcher-test-8816 local]#
注:这里也可以不升级数据文件,只升级系统表。
升级数据字典必须保证完全成功没有错误!!!
step 8重启数据库,检查
root@dbwatcher-test-8816 local]#
[root@dbwatcher-test-8816 local]# /etc/init.d/mysql restart
Shutting down MySQL...[ OK ]
Starting MySQL............[ OK ]
[root@dbwatcher-test-8816 local]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(mysql5.7)root@localhost [(none)]>
(mysql5.7)root@localhost [(none)]> select version();
+------------+
| version() |
+------------+
| 5.7.17-log |
+------------+
1 row in set (0.00 sec)
(mysql5.7)root@localhost [(none)]>
(mysql5.7)root@localhost [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| dbtest1 |
| dbtest2 |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
7 rows in set (0.00 sec)
进行相关验证和数据的校验!
完成后....
至此升级成功
---The end
阅读(6666) | 评论(0) | 转发(0) |