各位路过的大哥可以帮我看看问题或者给条可行的可以远程备份的命令,我使用了2条官网给出的可以远程的命令,但是发现都不行,为了避免干扰,备份之前已经把iptables和selinux都关掉了,本地导出备份是正常的,但是一尝试备份到远程主机就出错。第一条命令:
innobackupex --user=root --password='145690' --stream=tar ./ | ssh [email protected]  "cat - > /data/backups/backup.tar"
控制台输出如下,这里都没提示让我输入远程主机的密码:[root@centos databackup]# innobackupex --user=root --password='145690' --stream=tar ./ | ssh [email protected]  "cat - > /data/backups/backup.tar"InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013.  All Rights Reserved.This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p150713 17:56:41  innobackupex: Executing a version check against the server...
150713 17:56:41  innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'root'  (using password: YES).
[email protected]'s password: 150713 17:56:41  innobackupex: Connected to MySQL server
150713 17:56:41  innobackupex: Done.
150713 17:56:41  innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'root'  (using password: YES).
150713 17:56:41  innobackupex: Connected to MySQL server
150713 17:56:41  innobackupex: Starting the backup operationIMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackupex
           prints "completed OK!".innobackupex:  Using server version 5.6.25innobackupex: Created backup directory /data/databackup150713 17:56:41  innobackupex: Starting ibbackup with command: xtrabackup  --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/tmp --innodb_log_file_size="50331648" --innodb_data_file_path="ibdata1:12M:autoextend" --tmpdir=/tmp --extra-lsndir='/tmp' --stream=tar
innobackupex: Waiting for ibbackup (pid=2078) to suspend
innobackupex: Suspend file '/tmp/xtrabackup_suspended_2'xtrabackup version 2.2.11 based on MySQL server 5.6.24 Linux (x86_64) (revision id: )
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = ./
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 50331648
>> log scanned up to (58238384)
xtrabackup: Generating a list of tablespaces
[01] Streaming ./ibdata1
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)
>> log scanned up to (58238384)发现会一直卡在 log scanned up to (58238384),我的测试数据库数据量很少, 在本地导出正常情况下是只有几行这个 log scanned up to 就完毕了,之后我又尝试了官网的第二条命令:
ssh [email protected] "( nc -l 9999 > /data/backups/backup.tar & )" && innobackupex --user=root --password='145690' --stream=tar ./  |  nc 192.168.0.129 9999
控制台输出如下:
[root@centos databackup]# ssh [email protected] "( nc -l 9999 > /data/backups/backup.tar & )" && innobackupex --user=root --password='145690' --stream=tar ./  |  nc 192.168.0.129 9999
[email protected]'s password: InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013.  All Rights Reserved.This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p150713 17:57:38  innobackupex: Executing a version check against the server...
150713 17:57:38  innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'root'  (using password: YES).
150713 17:57:38  innobackupex: Connected to MySQL server
150713 17:57:38  innobackupex: Done.
150713 17:57:38  innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'root'  (using password: YES).
150713 17:57:38  innobackupex: Connected to MySQL server
150713 17:57:38  innobackupex: Starting the backup operationIMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackupex
           prints "completed OK!".innobackupex:  Using server version 5.6.25innobackupex: Created backup directory /data/databackup
tar: -:无法 write: 断开的管道
tar: Error is not recoverable: exiting now
innobackupex: 'tar chf -' returned with exit code 2.
innobackupex: got a fatal error with the following stacktrace: at /usr/bin/innobackupex line 4921
main::backup_file_via_stream('/tmp', 'backup-my.cnf') called at /usr/bin/innobackupex line 4970
main::backup_file('/tmp', 'backup-my.cnf', '/tmp/backup-my.cnf') called at /usr/bin/innobackupex line 4994
main::write_to_backup_file('/tmp/backup-my.cnf', '# This MySQL options file was generated by innobackupex.\x{a}\x{a}# T...') called at /usr/bin/innobackupex line 3801
main::write_backup_config_file('/tmp/backup-my.cnf') called at /usr/bin/innobackupex line 3728
main::init() called at /usr/bin/innobackupex line 1574
innobackupex: Error: Failed to stream '/tmp/backup-my.cnf': 2 at /usr/bin/innobackupex line 4921.

解决方案 »

  1.   

    好吧我自己解决了。可参考这篇文章:
    http://m.blog.csdn.net/blog/zhu19774279/41284635具体解决方法是安装sshpass显示指定远程主机的密码,sshpass的安装如下:cd /etc/yum.repos.d/
    wget http://download.opensuse.org/repositories/home:Strahlex/CentOS_CentOS-6/home:Strahlex.repo
    yum install sshpass如下命令成功执行:
    innobackupex --user=root --password=root --stream=tar ./ | gzip | sshpass -p 'root123' ssh [email protected] "cat - > /usr/programs/xtraback/backup.tar.gz"