Xtrabackup安装
1、确认服务器上已经安装MySQL
[root@PC ~]# rpm -qa mysql
mysql-5.1.73-5.el6_6.x86_64mysql Ver 14.14 Distrib 5.6.20, for Linux (i686)using EditLine wrapper
2:下载
进网站:
https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.3.2/binary/
选择适合自己的软件和硬件(这里选择64位x86_64)。
[root@pc download]# wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.3.2/binary/tarball/percona-xtrabackup-2.3.2-Linux-x86_64.tar.gz
3:安装xtrabackup
[root@pc download]# tar xvf percona-xtrabackup-2.3.2-Linux-x86_64.tar.gz
cd percona-xtrabackup-2.3.2-Linux-x86_64
cp bin/innobackupex /usr/bin
cp bin/xtrabackup* /usr/bin
4:安装相关插件
yum install perl-DBI -y
yum install perl-DBD-MySQL -y
yum install perl-Time-HiRes -y
yum install perl-IO-Socket-SSL –y
yum install perl-TermReadKey.x86_64 -y
wget https://www.percona.com/downloads/percona-toolkit/2.2.16/RPM/percona-toolkit-2.2.16-1.noarch.rpm
rpm -ivh percona-toolkit-2.2.16-1.noarch.rpm
Xtrabackup备份
测试Xtrabackup是否安装成功,这里做个简单的备份:
[root@pcbin]# innobackupex --user=root --password='beijing' /backup/mysql/xtrabackup/
备份时遇到的问题
1:innobackupex: fatal error: no 'mysqld' group in MySQL options
[root@pc /]# innobackupex --user=root --password='beijing' /backup/mysql/xtrabackup/
InnoDB Backup Utility v1.5.1-xtrabackup;Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2,June 1991.
151116 00:32:36 innobackupex: Starting mysql withoptions: --password=xxxxxxxx--user='root' --unbuffered --
151116 00:32:36 innobackupex: Connected to database withmysql child process (pid=4218)
151116 00:32:42 innobackupex: Connection to database serverclosed
IMPORTANT: Please check that the backup runcompletes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
innobackupex: Using mysql Ver 14.14 Distrib 5.6.20, for Linux (i686)using EditLine wrapper
Warning: Using a password on the commandline interface can be insecure.
innobackupex: Using mysql server versionCopyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
sh: /usr/bin/xtrabackup_56: cannot executebinary file
innobackupex: fatal error: no 'mysqld'group in MySQL options
解决办法:试试下载一个高版本的Xtrabackup。
2:-bash: /usr/bin/innobackupex: cannot executebinary file
[root@pc bin]# innobackupex --user=root --password='beijing' /backup/mysql/xtrabackup/
-bash: /usr/bin/innobackupex: cannotexecute binary file
出错原因是没有下载适合自己机器版本的软件(查看机器多少位命令:getconf LONG_BIT)该问题得到解决参考http://askubuntu.com/questions/184280/bash-filename-cannot-execute-binary-file
3:innobackupex: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file ordirectory
[root@PCdandan]# innobackupex --user=root --password='system@123' /backup/mysql/xtrabackup/
innobackupex:error while loading shared libraries: libaio.so.1: cannot open shared objectfile: No such file or directory
解决办法:
yum install libaio -y
4.version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;port=3306;mysql_socket=/tmp/mysql.sock' as 'orthdoctor' (using password: YES).
Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Failed to connect to MySQL server: DBI connect(';mysql_read_default_group=xtrabackup;port=3306;mysql_socket=/tmp/mysql.sock','orthdoctor',...) failed: Can't initialize character set utf8mb4 (path: /usr/share/mysql/charsets/) at - line 1314
161110 17:07:10 Connecting to MySQL server host: localhost, user: orthdoctor, password: set, port: 3306, socket: /tmp/mysql.sock
Using server version 5.5.13-log
Error: option 'datadir' has different values:
'.' in defaults file
'/data/mysqldata/' in SHOW VARIABLES
解决办法:这是因为在/etc/my.cnf中mysqld下没有datadir的设置,识别不出来mysql数据在哪。则需要修改my.cnf或者是innobackupex --defaults-file=/etc/my.cnf --datadir=/data/mysqldata --user=root --password='system@123' /backup/mysql/xtrabackup/
卸载Xtrabackup
[root@pc download]# cd /usr/bin
[root@pc bin]# rm -rf innobackupex
[root@pc bin]# rm -rf xtrabackup*
--本篇文章参考: http://www.cnblogs.com/ylqmf/archive/2011/10/27/2226958.html,
http://blog.youkuaiyun.com/yangzhawen/article/details/28864763,