innobackupex程序由perl编写,封装了xtrabackup工具。安装了percona-xtrabackup后,可以使用xtrabackup完成数据库的备份,包括全备、增量备等。innobackupex备份是启动的xtrabackup,但一直备不成功。报错如下:
1、不指定defaults-file参数
innobackupex --socket=/home/mysql/run/mysql.sock --user=root --password=123456 /tmp
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
150814 16:24:18 innobackupex: Starting mysql with options: --password=xxxxxxxx --user='root' --socket='/home/mysql/run/mysql.sock' --unbuffered --
150814 16:24:18 innobackupex: Connected to database with mysql child process (pid=38120)
150814 16:24:24 innobackupex: Connection to database server closed
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
innobackupex: Using mysql Ver 14.14 Distrib 5.6.21, for linux-glibc2.5 (x86_64) using EditLine wrapper
Warning: Using a password on the command line interface can be insecure.
innobackupex: Using mysql server version Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
innobackupex: fatal error: no 'mysqld' group in MySQL options
innobackupex: fatal error: OR no 'datadir' option in group 'mysqld' in MySQL options
2、指定--defaults-file参数(/etc/my.cnf中包含datadir参数)
./innobackupex --defaults-file=/etc/my.cnf --socket=/home/mysql/run/mysql.sock --user=root --password=123456 /tmp
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
150814 16:22:34 innobackupex: Starting mysql with options: --defaults-file='/etc/my.cnf' --password=xxxxxxxx --user='root' --socket='/home/mysql/run/mysql.sock' --unbuffered --
150814 16:22:34 innobackupex: Connected to database with mysql child process (pid=38093)
150814 16:22:40 innobackupex: Connection to database server closed
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
innobackupex: Using mysql Ver 14.14 Distrib 5.6.21, for linux-glibc2.5 (x86_64) using EditLine wrapper
Warning: Using a password on the command line interface can be insecure.
innobackupex: Using mysql server version Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
sh: --: invalid option
Usage: sh [GNU long option] [option] ...
sh [GNU long option] [option] script-file ...
GNU long options:
--debug
--debugger
--dump-po-strings
--dump-strings
--help
--init-file
--login
--noediting
--noprofile
--norc
--posix
--protected
--rcfile
--rpm-requires
--restricted
--verbose
--version
Shell options:
-irsD or -c command or -O shopt_option (invocation only)
-abefhkmnptuvxBCHP or -o option
innobackupex: fatal error: no 'mysqld' group in MySQL options
innobackupex: fatal error: OR no 'datadir' option in group 'mysqld' in MySQL options
两天都没搞定,查找网上说是没有datadir这个参数导致的,但明显不是。后来无意间发现,我的mysql版本是5.6,xtrabackup版本percona-xtrabackup-2.0.0.tar.gz,而2.1.7包含比2.0.0版本多两个程序:xbcrypt和xtrabackup_56。怀疑与此有关,于是下载安装(安装同http://www.voidcn.com/article/p-qfdjxmvs-bg.html),最终搞定。
ll /root/percona-xtrabackup-2.1.7-Linux-x86_64/bin
-rwxr-xr-x. 1 root root 169816 Jan 23 2014 innobackupex
lrwxrwxrwx. 1 root root 12 Aug 14 16:01 innobackupex-1.5.1 -> innobackupex
-rwxr-xr-x. 1 root root 2225863 Jan 23 2014 xbcrypt
-rwxr-xr-x. 1 root root 2295406 Jan 23 2014 xbstream
-rwxr-xr-x. 1 root root 13177384 Jan 23 2014 xtrabackup
-rwxr-xr-x. 1 root root 16598232 Jan 23 2014 xtrabackup_55
-rwxr-xr-x. 1 root root 82193336 Jan 23 2014 xtrabackup_56
ll /root/percona-xtrabackup-2.0.0/bin
-rwxr-xr-x. 1 root root 98808 Apr 4 2012 innobackupex
lrwxrwxrwx. 1 root root 12 Aug 13 15:20 innobackupex-1.5.1 -> innobackupex
-rwxr-xr-x. 1 root root 2261944 Apr 4 2012 xbstream
-rwxr-xr-x. 1 root root 12473482 Apr 4 2012 xtrabackup
-rwxr-xr-x. 1 root root 10586394 Apr 4 2012 xtrabackup_51
-rwxr-xr-x. 1 root root 15637452 Apr 4 2012 xtrabackup_55
innobackupex --socket=/home/mysql/run/mysql.sock --user=root --password=123456 /tmp
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/p
150814 16:39:56 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/home/mysql/run/mysql.sock' as 'root' (using password: YES).
150814 16:39:56 innobackupex: Connected to MySQL server
150814 16:39:56 innobackupex: Executing a version check against the server...
150814 16:39:56 innobackupex: Done.
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.21-log
innobackupex: Created backup directory /tmp/2015-08-14_16-39-57
150814 16:39:57 innobackupex: Starting ibbackup with command: xtrabackup_56 --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/tmp/2015-08-14_16-39-57 --tmpdir=/tmp
innobackupex: Waiting for ibbackup (pid=38180) to suspend
innobackupex: Suspend file '/tmp/2015-08-14_16-39-57/xtrabackup_suspended_2'
xtrabackup_56 version 2.1.7 for MySQL server 5.6.15 Linux (x86_64) (revision id: 721)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /home/mysql/data
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 1073741824
>> log scanned up to (12783975347)
InnoDB: Allocated tablespace 349, old maximum was 0
[01] Copying ./ibdata1 to /tmp/2015-08-14_16-39-57/ibdata1
>> log scanned up to (12783975347)
>> log scanned up to (12783975347)
... ...
innobackupex: Backup created in directory '/tmp/2015-08-14_16-39-57'
innobackupex: MySQL binlog position: filename 'mysql-bin.000002', position 120
150814 16:40:17 innobackupex: Connection to database server closed
150814 16:40:17 innobackupex: completed OK!备份文件
ll /tmp
drwxr-xr-x. 9 root root 4096 Aug 14 16:40 2015-08-14_16-39-57
-rw-r--r--. 1 root root 57 Aug 14 16:39 percona-version-check
ll /tmp/2015-08-14_16-39-57
-rw-r--r--. 1 root root 359 Aug 14 16:39 backup-my.cnf
drwx------. 2 root root 4096 Aug 14 16:40 bbp
-rw-r-----. 1 root root 146800640 Aug 14 16:40 ibdata1
drwx------. 2 root root 4096 Aug 14 16:40 lmis
drwx------. 2 root root 4096 Aug 14 16:40 mtms
drwxr-xr-x. 2 root root 4096 Aug 14 16:40 myisam
drwx------. 2 root root 4096 Aug 14 16:40 mysql
drwxr-xr-x. 2 root root 4096 Aug 14 16:40 performance_schema
drwx------. 2 root root 4096 Aug 14 16:40 test
-rw-r--r--. 1 root root 13 Aug 14 16:40 xtrabackup_binary
-rw-r--r--. 1 root root 23 Aug 14 16:40 xtrabackup_binlog_info
-rw-r-----. 1 root root 97 Aug 14 16:40 xtrabackup_checkpoints
-rw-r-----. 1 root root 2560 Aug 14 16:40 xtrabackup_logfile