mysql从5.5直接升级到5.7后,执行mysql_upgrade速度很慢且执行结束后数据目录大小增加一倍及 mysqlpump备份出现1577错误

mysql官网不支持夸大版本升级,比如跳过5.6直接升级到5.7,但由于一些客观原因,项目需要从5.5直接升级到5.7,以下是具体操作

1、备份之前mysql,(数据量少,可直接拷贝安装目录及data目录和配置文件,本例使用的为Percona XtraBackup工具进行的备份)

2、将data目录移出mysql5.5安装目录

3、解压mysql5.7版本

4、修改5.7需要配置文件my.cnf,添加datadir,指向5.5数据目录

5、初始化,该步骤可选,(新安装数据库,或者数据目录不存在,可执行如下命令初始化数据目录,本例中不需要执行如下操作)

bin/mysqld --initialize --user=mysql

6、执行ssl相关操作

bin/mysql_ssl_rsa_setup

7、启动mysql

8、此时数据目录还是5.5的,需要执行mysql_upgrade进行升级,在执行表修复前,需要确认一个参数innodb_file_per_table,mysql官网对该参数的解释如下

该参数在5.5版本默认为OFF,所有表和索引都导入一个共享文件中,名为ibdata1,但在5.6.7及以后版本,改参数被默认设置为ON,即每张表都有对应的表和索引存储文件,每个schema下,每个frm文件都有对应的ibd文件。

在执行mysql_upgrade时,会修复系统表,并且如果该参数在5.5和5.7版本均使用默认值,则会将之前共享表和索引的存储方式改为每张表单独存储表和索引的形式,故会出现拷贝复制的操作,如果数据量比较大,则用时就会很长,

使用nnodb_file_per_table=1,及表和索引单独存储的优缺点,可查看mysql官网介绍。

9、使用mysql_upgrade检测并修复表

使用方法与mysql命令登录命令行一样,mysql会自动检测当前表并自动修复

mysql_upgrade -uroot -p

10、修复完成后,若发现mysql启动有server-key.pem相关的ssl错误,则是server-key.pem文件权限问题

chmod 644 server-key.pem

11、但此时若执行mysqlpum备份数据,可能会出现异常

mysqlpump --user=root --password mytest > mytest.sql

错误信息:

mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.

解决方法:重启mysql服务 (本例中是这样解决的问题)

重新执行mysqlpump

Dump progress: 1/28 tables, 0/353 rows
Dump progress: 36/343 tables, 0/19746 rows
Dump progress: 180/343 tables, 6151/19746 rows
Dump completed in 3675 milliseconds

数据被正确备份下来,且备份速度很快,从备份文件可以看到,内容与mysqldump备份有很多不同

本次只是简单尝试mysqlpump,待后续再对mysqlpump做深入了解

 

posted @ 2019-01-09 13:30  大坑水滴  阅读(1850)  评论(0编辑  收藏  举报