编译安装 tokudb-xtrabackup 以支持tokudb的热备份

2019-09-18 15:06:33 浏览数 (1)

编译安装 tokudb-xtrabackup :

感谢知书堂吴老师

环境:centos6 x86_64

官方文档:

https://github.com/xelabs/tokudb-xtrabackup/wiki/How-to-build

先安装高版本的libev依赖包:

代码语言:javascript复制
wget https://fossies.org/linux/misc/libev-4.24.tar.gz
tar xvzf libev-4.22.tar.gz
cd libev-4.22
./configure
make && make install

开始编译安装xtrabackup:

代码语言:javascript复制
yum install cmake gcc gcc-c   libaio libaio-devel automake autoconf bison libtool ncurses-devel libgcrypt-devel libev-devel libcurl-devel vim-common

git clone  

cd tokudb-xtrabackup

cmake .
  -DBUILD_CONFIG=xtrabackup_release
  -DWITH_BOOST=extra/boost/boost_1_59_0.tar.gz
  -DWITH_MAN_PAGES=OFF
  -DCMAKE_INSTALL_PREFIX=/usr/local/xtrabackup_xelabs/
  
make -j8

make install

编译完成后, 在 /usr/local/xtrabackup_xelabs/bin/ 目录下就生成了我们需要的文件。

使用备份命令:

/usr/local/xtrabackup_xelabs/bin/innobackupex --user=root --password=123456 --no-timestamp  2>/tmp/bak.log /root/aaa   即可在生成全量的备份文件

整个备份流程如下(https://yq.aliyun.com/articles/213):

 1) SET TOKUDB_CHECKPOINT_LOCK=ON;

 2) FLUSH TABLES WITH READ LOCK;

 3) 记录binlog位置,拷贝最新的binlog和TokuDB的日志文件(*.tokulog)

 4) UNLOCK TABLES;

 5) 开始拷贝TokuDB的数据文件(不包含日志文件)  --移动到这里

 6) SET TOKUDB_CHECKPOINT_LOCK=OFF;

操作过程日志,部分内容如下:

180826 19:28:42 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!".

180826 19:28:43  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;port=3306;mysql_socket=/tmp/mysql.sock' as 'root'  (using password: YES).

180826 19:28:43  version_check Connected to MySQL server

180826 19:28:43  version_check Executing a version check against the server...

180826 19:28:43  version_check Done.

180826 19:28:43 Connecting to MySQL server host: localhost, user: root, password: set, port: 3306, socket: /tmp/mysql.sock

Using server version 5.7.18-15-log

/usr/local/xtrabackup_xelabs/bin/innobackupex version 2.4.7 based on MySQL server 5.7.13 Linux (x86_64) (revision id: )

xtrabackup: uses posix_fadvise().

xtrabackup: cd to /bdata/data/nowdb2

xtrabackup: open files limit requested 0, set to 65535

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

xtrabackup: using O_DIRECT

InnoDB: Number of pools: 1

180826 19:28:43 >> log scanned up to (1062788205)

xtrabackup: Generating a list of tablespaces

InnoDB: Allocated tablespace ID 21 for sys/sys_config, old maximum was 0

180826 19:28:43 [01] Copying ./ibdata1 to /root/aaa/ibdata1

180826 19:28:44 >> log scanned up to (1062788205)

180826 19:28:45 >> log scanned up to (1062788205)

180826 19:28:45 [01]        ...done

180826 19:28:45 [01] Copying ./sys/sys_config.ibd to /root/aaa/sys/sys_config.ibd

180826 19:28:45 [01]        ...done

180826 19:28:45 [01] Copying ./test/sbtest1_innodb.ibd to /root/aaa/test/sbtest1_innodb.ibd

180826 19:28:46 >> log scanned up to (1062788205)

180826 19:28:47 >> log scanned up to (1062788205)

180826 19:28:48 >> log scanned up to (1062788205)

180826 19:28:49 >> log scanned up to (1062788205)

180826 19:28:50 >> log scanned up to (1062788205)

180826 19:28:51 >> log scanned up to (1062788205)

180826 19:28:52 >> log scanned up to (1062788205)

180826 19:28:53 >> log scanned up to (1062788205)

180826 19:28:54 >> log scanned up to (1062788205)

180826 19:28:55 >> log scanned up to (1062788205)

180826 19:28:56 >> log scanned up to (1062788205)

180826 19:28:57 >> log scanned up to (1062788205)

180826 19:28:58 >> log scanned up to (1062788205)

180826 19:28:59 >> log scanned up to (1062788205)

180826 19:29:00 >> log scanned up to (1062788205)

180826 19:29:01 >> log scanned up to (1062788205)

180826 19:29:02 >> log scanned up to (1062788205)

180826 19:29:03 >> log scanned up to (1062788205)

180826 19:29:03 [01]        ...done

180826 19:29:03 [01] Copying ./test/t2.ibd to /root/aaa/test/t2.ibd

180826 19:29:03 [01]        ...done

180826 19:29:05 [01] Copying ./mysql/slave_worker_info.ibd to /root/aaa/mysql/slave_worker_info.ibd

180826 19:29:05 [01]        ...done

180826 19:29:05 >> log scanned up to (1062788205)

180826 19:29:05 Executing SET GLOBAL tokudb_checkpoint_lock=ON      # 注意这里参数 tokudb_checkpoint_lock=ON, 然后开始拷贝非innodb文件和tokudb文件(不包含日志文件) 

180826 19:29:05 tokudb_checkpoint_locked

180826 19:29:05 Executing LOCK TABLES FOR BACKUP...

180826 19:29:05 Starting to backup non-InnoDB tables and files

180826 19:29:05 [01] Copying ./sys/x@0024wait_classes_global_by_avg_latency.frm to /root/aaa/sys/x@0024wait_classes_global_by_avg_latency.frm

180826 19:29:05 [01]        ...done

180826 19:29:09 [01] Copying ./performance_schema/events_stages_summary_by_thread_by_event_name.frm to /root/aaa/performance_schema/events_stages_summary_by_thread_by_event_name.frm

180826 19:29:09 [01]        ...done

180826 19:29:09 [01] Copying ./performance_schema/events_transactions_summary_by_user_by_event_name.frm to /root/aaa/performance_schema/events_transactions_summary_by_user_by_event_name.frm

180826 19:29:09 [01]        ...done

180826 19:29:09 Finished backing up non-InnoDB tables and files

180826 19:29:09 Executing LOCK BINLOG FOR BACKUP...

180826 19:29:09 [00] Writing xtrabackup_binlog_info

180826 19:29:09 [00]        ...done

180826 19:29:09 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...

180826 19:29:09 Starting to backup tokudb.directory/tokudb.environment/tokudb.rollback...    # 开始备份TokuDB redo-log

180826 19:29:09 [01] Copying tokudb.directory to /root/aaa/tokudb.directory

180826 19:29:09 [01]        ...done

180826 19:29:09 [01] Copying tokudb.environment to /root/aaa/tokudb.environment

180826 19:29:09 [01]        ...done

180826 19:29:09 [01] Copying tokudb.rollback to /root/aaa/tokudb.rollback

180826 19:29:09 [01]        ...done

180826 19:29:09 Starting to backup TokuDB redo-log files

180826 19:29:09 [01] Copying ./log000000000067.tokulog29 to /root/aaa/log000000000067.tokulog29

180826 19:29:09 [01]        ...done

180826 19:29:09 Finished backing up TokuDB redo-log files

xtrabackup: The latest check point (for incremental): '1062788212'

xtrabackup: Stopping log copying thread.

.180826 19:29:09 >> log scanned up to (1062788221)

180826 19:29:09 Executing UNLOCK BINLOG         # 释放锁

180826 19:29:09 Executing UNLOCK TABLES 

180826 19:29:09 All tables unlocked

180826 19:29:09 Starting to backup TokuDB data files

180826 19:29:09 [01] Copying ./__tokudb_lock_dont_delete_me_data to /root/aaa/__tokudb_lock_dont_delete_me_data

180826 19:29:09 [01]        ...done

180826 19:29:09 [01] Copying ./test/tb123_main_1e3_2_1d.tokudb to /root/aaa/test/tb123_main_1e3_2_1d.tokudb

180826 19:29:09 [01]        ...done

180826 19:29:19 [01] Copying ./test/tb123_key_idx_1e5_3_1d_B_0.tokudb to /root/aaa/test/tb123_key_idx_1e5_3_1d_B_0.tokudb

180826 19:29:19 [01]        ...done

180826 19:29:19 [01] Copying ./test/tb123_status_1e3_1_1d.tokudb to /root/aaa/test/tb123_status_1e3_1_1d.tokudb

180826 19:29:19 [01]        ...done

180826 19:29:19 Finished backing up TokuDB data files

180826 19:29:19 Executing SET GLOBAL tokudb_checkpoint_lock=OFF           # 注意这里参数 tokudb_checkpoint_lock=OFF 

180826 19:29:19 tokudb_checkpoint_unlocked

180826 19:29:19 [00] Copying ib_buffer_pool to /root/aaa/ib_buffer_pool

180826 19:29:19 [00]        ...done

180826 19:29:19 Backup created in directory '/root/aaa/'

MySQL binlog position: filename 'mysql-bin.000053', position '154'

180826 19:29:19 [00] Writing backup-my.cnf

180826 19:29:19 [00]        ...done

180826 19:29:19 [00] Writing xtrabackup_info

180826 19:29:19 [00]        ...done

xtrabackup: Transaction log of lsn (1062788196) to (1062788221) was copied.

180826 19:29:19 completed OK!

0 人点赞