天天看点

阿里云RDS恢复数据到自建数据库趟坑记录建议这里直接安装5.6.36+版本,可能需要通过源码,或者去mysql官方下载Ubuntu安装包,官方没有Ubuntu 16.04的包,可以选择Ubuntu 14的预编译包

首先应认真看下阿里云官方文档: RDS MySQL 物理备份文件恢复到自建数据库

本人实践的数据库版本是5.6,恢复数据的Ubuntu版本是14.04和16.04两个版本,这两个版本默认数据库都不是5.6,需要单独安装;

另外

Percona Xtrabackup

的版本也请按照阿里云的提示下载对应版本。我使用的是

2.3.7

apt-get install software-properties-common  
sudo add-apt-repository 'deb         http://archive.ubuntu.com/ubuntu                trusty universe'  
sudo apt-get update  
sudo apt install mysql-server-5.6           

建议这里直接安装5.6.36+版本,可能需要通过源码,或者去mysql官方下载Ubuntu安装包,官方没有Ubuntu 16.04的包,可以选择Ubuntu 14的预编译包

前面步骤如阿里云官方文档所示即可,但是在恢复数据库时遇到了问题

setenforce 0           
## vim /etc/apparmor.d/usr.sbin.mysqld
/root/mysql/data/ r,
/root/mysql/data/** rwk,           

增加数据目录权限即可,如果安装了5.6.36可能要调整配置文件目录权限,看错误提示操作即可

/etc/mysql/mysql.conf.d/ r, /etc/mysql/mysql.conf.d/* r,

在启动过程中,可能会遇到某些未知问题,可以通过添加

innodb_force_recovery = 6

参数来尝试修复,如果仍然出现下面错误,请升级mysql版本:
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338332 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.           

Thread pointer: 0x0 Attempting backtrace. You can use the following information to find out where mysqld died. If you see no messages after this, something went terribly wrong... stack_bottom = 0 thread_stack 0x40000

这个问题,在mysql后续版本中解决掉了,保证你的mysql版本在5.6.36+以上,我是升级到5.6.44解决的问题

之后启动后,即可导出相关数据即可!

云服务器ECS地址:阿里云·云小站