雲計算

阿里雲RDS恢復數據到自建數據庫趟坑記錄

首先應認真看下阿里雲官方文檔: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地址:阿里雲·雲小站

Leave a Reply

Your email address will not be published. Required fields are marked *