有个客户有个需求:想把5.6版本的RDS for MySQL上周的数据呈现出来,和现在的数据进行比对,以进行其他业务操作。那么该怎么办呢?
1.使用RDS for MySQL自带的方便快捷的恢复方式(克隆实例),可以通过备份集和时间点进行恢复,只需要片刻的时间就完成了。
2.
把自动备份(物理备份)下载下来,然后在ECS自建MySQL的server端上读取这部分数据。 相对于方法1,方法2更加麻烦一些,但是可以节省一些支出。
针对这个客户的现状,当然首推方法1,难度很低,很快捷。但是客户选择方法2。那么问题来了:什么版本的MySQL的server才能读取RDS上物理备份的数据呢。
因为RDS是5.6的,所以客户选择了5.6.38这个版本的MySQL,安装完成登陆之后发现数据库上是有这些表的名称,但是select时总是处出现ERROR 1146 (42S02)的报错,百度之后网上给的解释是共享表空间ibdata1文件也要copy过去,但是RDS自然不用考虑这个问题。那么会是什么问题呢?
[root@172-16-10-204 /data/alisql/data] #mysql -uroot -h127.0.0.1 -P3308 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.6.38 MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. root@(none) 05:51:46>use ceshi; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A root@ceshi 05:51:51>show tables; root@ceshi 05:51:53>select * from c1; ERROR 1146 (42S02): Table 'ceshi.c1' doesn't exist MySQL5.6的版本可以正常启动,但是就是无法读取表的数据。用mysql_upgrade的时候会报错,显示mysql库内的许多表都不存在,一时很是疑惑。既然5.6的不行,索性就使用5.7的尝试一下吧:
[root@172-16-10-204 /root] #mysql -uroot -h127.0.0.1 -P3308 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 13 Server version: 5.7.20 MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. root@(none) 05:56:05>use ceshi; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A root@ceshi 05:56:12>select * from c1; +------+------+------+------+ +------+------+------+------+ +------+------+------+------+ 结果还是既是意料之外,又是情理之中的,因为RDS for MySQL虽然是5.6的版本,但是这不是原生纯正的MySQL,而是阿里巴巴修改过源码的alisql,里面加了许多5.7的功能,所以用5.6的版本再去读取这部分数据的时候可能不会那么完美的兼容。
总结:小版本更迭时,底层文件没有太大的差异,server层可能会继续使用这部分数据。大版本的更迭:1.如果是高版本server读取低版本的全量物理备份的时候,大概率是可以读取的(不是必然)。2.如果是低版本server读取高版本的全量物理备份的时候,大概率是不可以读取的(不是必然)。