首页 > 代码库 > RDS恢复数据到本地mysql(阿里云)
RDS恢复数据到本地mysql(阿里云)
一、准备mysql环境
1.1、安装mysql依赖软件
[root@shop src]# yum install -y gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libgcrypt* libtool* cmake bison bison-devel* [root@shop src]# wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz [root@shop src]# wget [root@shop src]# tar -zxvf cmake-2.8.8.tar.gz [root@shop src]# cd cmake-2.8.8 [root@shop cmake-2.8.8]# ./bootstrap [root@shop cmake-2.8.8]# gmake && gmake install [root@shop cmake-2.8.8]# cd ../ && tar -zxvf bison-2.5.tar.gz [root@shop bison-2.5]# cd bison-2.5 [root@shop bison-2.5]# ./configure [root@shop bison-2.5]# make && make install
1.2、安装mysql
[root@shop ~]# wget -O /usr/local/src [root@shop ~]# cd /usr/local/src/ [root@shop src]# tar –zxvf mysql-5.6.32.tar.gz [root@shop src]# cd mysql-5.6.32 [root@shop mysql-5.6.32]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql/ [root@shop mysql-5.6.32]# make && make install [root@shop mysql-5.6.32]# mkdir -p /data/mysql [root@shop mysql-5.6.32]# chown -R mysql.mysql /data/mysql [root@shop mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [root@shop mysql]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf [root@shop mysql]# chmod +x /etc/init.d/mysqld [root@shop mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql/
1.3、创建mysql用户及准备rds恢复数据
[root@shop mysql-5.6.32]# useradd -u 49 -M -s/sbin/nologin mysql [root@shop mysql-5.6.32]# wget -c ‘www.xxxxxxxx.com‘ -O /data/mysql-bak/mysqlbin.tar [root@shop mysql-5.6.32]# tar -zxvf mysqlbin.tar
二、安装perconna
[root@shop src]# wget http://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.2.10/binary/redhat/6/x86_64/Percona-XtraBackup-2.2.10-re623acb-el6-x86_64-bundle.tar [root@shop src]# tar -xvf Percona-XtraBackup-2.2.10-re623acb-el6-x86_64-bundle.tar [root@shop src]# yum -y install perlperl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL perl-ExtUtils-CBuilderperl-ExtU tils-MakeMaker libdigest-perl-md5-perl perl-Digest-MD5 [root@shop src]# rpm -ivh percona-xtrabackup-2.2.10-1.el6.x86_64.rpm
三、恢复数据
[root@shop src]# innobackupex --apply-log /data/mysql-bak/ [root@shop src]# innobackupex --copy-back /data/mysql-bak/
最后恢复的结尾出现ok表示恢复成功,最后再重新赋予mysql主目录的属主就可以启动了
[root@shop mysql-5.6.32]# chown -R mysql.mysql /data/mysql
本文出自 “初心、始终” 博客,请务必保留此出处http://gouyc.blog.51cto.com/1594451/1863561
RDS恢复数据到本地mysql(阿里云)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。