系统:CentOS 6.5
数据库:MySQL5.7.18 & MySQL5.6.22
软件:xtrabackup-2.1.2
关于xtrabackup的安装和使用,可以参考该博主的,写的真的很详细,图文并茂,原理也很好理解,我等初学者受教了。
https://www.cnblogs.com/gomysql/p/3650645.html
以下是我在安装使用过程中出现的一些报错和解决方法:
一、xtrabackup-2.1.2暂时不支持MySQL5.7.18,有的说可以去percona官网查一下可支持的MySQL版本,但是找资料我实在不太行,没找到...所以就换成MySQL5.6.22
二、Can't locate Time/HiRes.pm
报错如下:
[root@backup ~]# innobackupex --user=backup --password=redhat --socket=/tmp/mysql.sock --defaults-file=/etc/my.cnf /data/backup/ Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/xtrabackup/bin/innobackupex line 23. BEGIN failed--compilation aborted at /usr/local/xtrabackup/bin/innobackupex line 23.
解决办法:
[root@backup ~]# yum install -y perl-Time-HiRes
三、Failed to connect to MySQL server as DBD
报错如下:
[root@backup lib64]# innobackupex --user=backup --password=redhat --socket=/tmp/mysql.sock --defaults-file=/etc/my.cnf /data/backup/ InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy and Percona Ireland Ltd 2009-2012. All Rights Reserved. This software is published under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991. 180110 17:33:48 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup;mysql_socket=/tmp/mysql.sock' as 'backup' (using password: YES). ERROR: Failed to connect to MySQL server as DBD::mysql module is not installed at /usr/local/xtrabackup/bin/innobackupex line 1397.
解决办法:
[root@backup lib64]# yum install -y perl-DBD-MySQL
四、Failed to connect to MySQL server: DBI connect(';mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup;mysql_socket=/tmp/mysql.sock','backup',...) failed: Access denied
[root@backup lib64]# innobackupex --user=backup --password=redhat --socket=/tmp/mysql.sock --defaults-file=/etc/my.cnf /data/backup/ InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy and Percona Ireland Ltd 2009-2012. All Rights Reserved. This software is published under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991. 180110 17:45:38 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup;mysql_socket=/tmp/mysql.sock' as 'backup' (using password: YES). ERROR: Failed to connect to MySQL server: DBI connect(';mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup;mysql_socket=/tmp/mysql.sock','backup',...) failed: Access denied for user 'backup'@'localhost' (using password: YES) at /usr/local/xtrabackup/bin/innobackupex line 1384
查阅相关资料说是将socke替换成host就可以,(原因是访问socket时没有权限)但是我的根本问题不是这个...
------------------- socket --> host ------------------------------- [xbackup@backup ~]$ innobackupex --user=backup --password=redhat --host=127.0.0.1 --defaults-file=/etc/my.cnf /data/backup/ InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy and Percona Ireland Ltd 2009-2012. All Rights Reserved. This software is published under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991. 180110 18:11:21 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup;host=127.0.0.1' as 'backup' (using password: YES). 180110 18:11:21 innobackupex: Connected to MySQL server IMPORTANT: Please check that the backup run completes successfully. At the end of a successful backup run innobackupex prints "completed OK!". innobackupex: Using mysql server version 5.6.22-log xtrabackup_56: error while loading shared libraries: libssl.so.6: cannot open shared object file: No such file or directory innobackupex: fatal error: no 'mysqld' group in MySQL options [xbackup@backup ~]$ DBD::mysql::db selectrow_array failed: MySQL server has gone away at /usr/local/xtrabackup/bin/innobackupex line 1325.
替换成host之后,发现了新的错误
xtrabackup_56: error while loading shared libraries: libssl.so.6: cannot open shared object file: No such file or directory
五、 libssl.so.6
最终解决办法来了:
[xbackup@backup ~]$ sudo yum install -y openssl-devel [xbackup@backup ~]$ su - Password: [root@backup ~]# ln -sf /usr/lib64/libssl.so.10 /usr/lib64/libssl.so.6 [root@backup ~]# ln -sf /usr/lib64/libcrypto.so.10 /usr/lib64/libcrypto.so.6
由于我用普通用户xbackup启动的时候还报了无法创建/data/backup/的权限错误,所以索性改成root来执行,终于成功了,也是不容易....
[root@backup ~]# innobackupex --user=backup --password=redhat --host=127.0.0.1 --defaults-file=/etc/my.cnf /data/backup/ InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy and Percona Ireland Ltd 2009-2012. All Rights Reserved. This software is published under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991. 180110 18:34:00 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup;host=127.0.0.1' as 'backup' (using password: YES). 180110 18:34:00 innobackupex: Connected to MySQL server IMPORTANT: Please check that the backup run completes successfully. At the end of a successful backup run innobackupex prints "completed OK!". innobackupex: Using mysql server version 5.6.22-log innobackupex: Created backup directory /data/backup/2018-01-10_18-34-00 180110 18:34:00 innobackupex: Starting ibbackup with command: xtrabackup_56 --defaults-file="/etc/my.cnf" --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/data/backup/2018-01-10_18-34-00 --tmpdir=/tmp innobackupex: Waiting for ibbackup (pid=1795) to suspend innobackupex: Suspend file '/data/backup/2018-01-10_18-34-00/xtrabackup_suspended_2' xtrabackup_56 version 2.1.2 for MySQL server 5.6.10 Linux (x86_64) (revision id: 611) xtrabackup: uses posix_fadvise(). xtrabackup: cd to xtrabackup: Target instance is assumed as followings. xtrabackup: innodb_data_home_dir = /data/mysql xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend xtrabackup: innodb_log_group_home_dir = /data/mysql xtrabackup: innodb_log_files_in_group = 3 xtrabackup: innodb_log_file_size = 67108864 >> log scanned up to (1650488) [01] Copying /data/mysql/ibdata1 to /data/backup/2018-01-10_18-34-00/ibdata1 [01] ...done >> log scanned up to (1650488) 180110 18:34:08 innobackupex: Continuing after ibbackup has suspended 180110 18:34:08 innobackupex: Starting to lock all tables... >> log scanned up to (1650488) 180110 18:34:08 innobackupex: All tables locked and flushed to disk 180110 18:34:08 innobackupex: Starting to backup non-InnoDB tables and files innobackupex: in subdirectories of '.' 180110 18:34:08 innobackupex: Finished backing up non-InnoDB tables and files 180110 18:34:08 innobackupex: Waiting for log copying to finish xtrabackup: The latest check point (for incremental): '1650488' xtrabackup: Stopping log copying thread. .>> log scanned up to (1650488) xtrabackup: Transaction log of lsn (1650488) to (1650488) was copied. 180110 18:34:09 innobackupex: All tables unlocked innobackupex: Backup created in directory '/data/backup/2018-01-10_18-34-00' innobackupex: MySQL binlog position: filename 'mysql-bin.000004', position 120 180110 18:34:09 innobackupex: Connection to database server closed 180110 18:34:09 innobackupex: completed OK!