innobackupex遇到的坑

stream选择使用tar方式压缩到时slave_info信息不完整

版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[root@test1 backup]# innobackupex --version
innobackupex version 2.4.8 Linux (x86_64) (revision id: 97330f7)
[root@test1 backup]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@test1 backup]# gzip --version
gzip 1.3.12
Copyright (C) 2007 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by Jean-loup Gailly.
[root@test1 backup]# mysql -e"\s"
--------------
mysql Ver 14.14 Distrib 5.7.18, for linux-glibc2.5 (x86_64) using EditLine wrapper

Connection id: 11
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.18-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /data/mysqldata/3306/mysql.sock
Uptime: 15 min 52 sec

Threads: 3 Questions: 61 Slow queries: 0 Opens: 116 Flush tables: 5 Open tables: 0 Queries per second avg: 0.064
--------------

备份命令
1
innobackupex --user=backup --password='backup' --slave-info --stream=tar /tmp | gzip -> /data/mysqldata/backup/xtra_full.tar.gz

期望得到的完整信息
1
2
3
[root@test1 slave_info]# more xtrabackup_slave_info 
SET GLOBAL gtid_purged='5c351518-78ec-11e7-8e7a-005056a610c3:1-1164';
CHANGE MASTER TO MASTER_AUTO_POSITION=1;


实际得到的
1
2
[root@test1 backup]# more xtrabackup_slave_info 
SET GLOBAL gtid_purged='5c3

如果使用stream=xbstream同时指定了–slave-info,则根本不会按照期望的得到full.xbstream压缩文件,而是会直接将备份输出到timestamp文件夹,并产生一个empty的full.xbstream. 看下面例子
innobackupex –user=backup –password=’backup’ \
–stream=xbstream ./ > /data/mysqldata/backup/full.xbstream
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
170831 17:17:10 innobackupex: Starting the backup operation

IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".

170831 17:17:10 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/data/mysqldata/3306/mysql.sock' as 'backup' (using password: YES).
170831 17:17:10 version_check Connected to MySQL server
170831 17:17:10 version_check Executing a version check against the server...
170831 17:17:10 version_check Done.
170831 17:17:10 Connecting to MySQL server host: localhost, user: backup, password: set, port: not set, socket: /data/mysqldata/3306/mysql.sock
Using server version 5.7.18-log
innobackupex version 2.4.8 based on MySQL server 5.7.13 Linux (x86_64) (revision id: 97330f7)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysqldata/3306/data
xtrabackup: open files limit requested 65535, set to 65535
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = .
xtrabackup: innodb_data_file_path = ibdata1:1024M:autoextend
xtrabackup: innodb_log_group_home_dir = /data/mysqldata/3306/redolog
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 134217728
xtrabackup: using O_DIRECT
InnoDB: Number of pools: 1
170831 17:17:10 >> log scanned up to (2937521)
InnoDB: Opened 3 undo tablespaces
InnoDB: 0 undo tablespaces made active
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 27 for sms/SMS_DETAIL_INFO, old maximum was 3
170831 17:17:11 [01] Streaming ./ibdata1
170831 17:17:11 >> log scanned up to (2937521)
170831 17:17:12 >> log scanned up to (2937521)

...

170831 17:17:40 [00] ...done
170831 17:17:40 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '2937512'
xtrabackup: Stopping log copying thread.
.170831 17:17:40 >> log scanned up to (2937521)

170831 17:17:41 Executing UNLOCK TABLES
170831 17:17:41 All tables unlocked
170831 17:17:41 [00] Streaming ib_buffer_pool to <STDOUT>
170831 17:17:41 [00] ...done
170831 17:17:41 Backup created in directory '/data/mysqldata/backup/' --注意一会对比这里
MySQL binlog position: filename 'mysql-bin.000002', position '154', GTID of the last change '5c351518-78ec-11e7-8e7a-005056a610c3:1-1164'
170831 17:17:41 [00] Streaming <STDOUT>
170831 17:17:41 [00] ...done
170831 17:17:41 [00] Streaming <STDOUT>
170831 17:17:41 [00] ...done
xtrabackup: Transaction log of lsn (2937512) to (2937521) was copied.
170831 17:17:41 completed OK!

正常的备份,生成了.xbstream文件
1
2
3
4
5
6
[root@test1 backup]# ls
full.xbstream
[root@test1 backup]# file full.xbstream
full.xbstream: data
[root@test1 backup]# rm full.xbstream
rm: remove regular file `full.xbstream'? y

加上–slave-info的
innobackupex –user=backup –password=’backup’ –slave-info\
–stream=xbstream ./ > /data/mysqldata/backup/full.xbstream
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
170831 17:18:43 innobackupex: Starting the backup operation

IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".

170831 17:18:43 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/data/mysqldata/3306/mysql.sock' as 'backup' (using password: YES).
170831 17:18:43 version_check Connected to MySQL server
170831 17:18:43 version_check Executing a version check against the server...
170831 17:18:43 version_check Done.
170831 17:18:43 Connecting to MySQL server host: localhost, user: backup, password: set, port: not set, socket: /data/mysqldata/3306/mysql.sock
Using server version 5.7.18-log
innobackupex version 2.4.8 based on MySQL server 5.7.13 Linux (x86_64) (revision id: 97330f7)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysqldata/3306/data
xtrabackup: open files limit requested 65535, set to 65535
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = .
xtrabackup: innodb_data_file_path = ibdata1:1024M:autoextend
xtrabackup: innodb_log_group_home_dir = /data/mysqldata/3306/redolog
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 134217728
xtrabackup: using O_DIRECT
InnoDB: Number of pools: 1
170831 17:18:43 >> log scanned up to (2937521)
InnoDB: Opened 3 undo tablespaces
InnoDB: 0 undo tablespaces made active
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 27 for sms/SMS_DETAIL_INFO, old maximum was 3
170831 17:18:44 [01] Copying ./ibdata1 to /data/mysqldata/backup/2017-08-31_17-18-43/ibdata1 --注意
...

170831 17:19:05 Finished backing up non-InnoDB tables and files
170831 17:19:05 [00] Writing /data/mysqldata/backup/2017-08-31_17-18-43/xtrabackup_binlog_info --注意
170831 17:19:05 [00] ...done
170831 17:19:06 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '2937512'
xtrabackup: Stopping log copying thread.
.170831 17:19:06 >> log scanned up to (2937521)

170831 17:19:06 Executing UNLOCK TABLES
170831 17:19:06 All tables unlocked
170831 17:19:06 [00] Copying ib_buffer_pool to /data/mysqldata/backup/2017-08-31_17-18-43/ib_buffer_pool
170831 17:19:06 [00] ...done
170831 17:19:06 Backup created in directory '/data/mysqldata/backup/2017-08-31_17-18-43/'
MySQL binlog position: filename 'mysql-bin.000002', position '154', GTID of the last change '5c351518-78ec-11e7-8e7a-005056a610c3:1-1164'
170831 17:19:06 [00] Writing /data/mysqldata/backup/2017-08-31_17-18-43/backup-my.cnf
170831 17:19:06 [00] ...done
170831 17:19:06 [00] Writing /data/mysqldata/backup/2017-08-31_17-18-43/xtrabackup_info
170831 17:19:06 [00] ...done
xtrabackup: Transaction log of lsn (2937512) to (2937521) was copied.
170831 17:19:06 completed OK!

生成一个时间戳目录,和full.xbstream,full.xbstream是空的
1
2
3
4
[root@test1 backup]# ls
2017-08-31_17-18-43 full.xbstream
[root@test1 backup]# file full.xbstream
full.xbstream: empty

并且2017-08-31_17-18-43目录下也没有xtrabackup_slave_info
1
2
3
[root@test1 backup]# cd 2017-08-31_17-18-43
[root@test1 2017-08-31_17-18-43]# ls
backup-my.cnf fandb ib_buffer_pool ibdata1 mysql performance_schema sms sys undo001 undo002 undo003 xtrabackup_binlog_info xtrabackup_checkpoints xtrabackup_info xtrabackup_logfile yydb

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2022 Fan() All Rights Reserved.

访客数 : | 访问量 :