The feature I announced some time ago https://www.percona.com/blog/2009/06/08/impossible-possible-moving-innodb-tables-between-servers/ is now available in our latest releases of XtraBackup 0.8.1 and XtraDB-6.
Now I am going to show how to use it (the video will be also available on percona.tv).
Let’s take tpcc schema and running standard MySQL ® 5.0.83, and assume we want to copy order_line table to different server. Note I am going to do it online, no needs to lock or shutdown server.
To export table you need XtraBackup, and you can just specify table or table by mask:
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 |
xtrabackup --defaults-file=/etc/my.reg.cnf --backup --tables=tpcc.order_line* --target-dir=/data/vadim/mysql/export/ xtrabackup: tables regcomp(): Success xtrabackup Ver 0.8.1rc Rev 78 for 5.0.83 unknown-linux-gnu (x86_64) xtrabackup: uses posix_fadvise(). xtrabackup: cd to /bench/mysqldata xtrabackup: Target instance is assumed as followings. 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 = 3 xtrabackup: innodb_log_file_size = 536870912 xtrabackup: use O_DIRECT >> log scanned up to (3 767617628) Copying ./ibdata1 to /data/vadim/mysql/export//ibdata1 >> log scanned up to (3 769009554) ...done Copying ./mysql/ibbackup_binlog_marker.ibd is skipped. Copying ./tpcc/stock.ibd is skipped. Copying ./tpcc/warehouse.ibd is skipped. Copying ./tpcc/new_orders.ibd is skipped. Copying ./tpcc/order_line.ibd to /data/vadim/mysql/export//tpcc/order_line.ibd >> log scanned up to (3 770393658) ... >> log scanned up to (3 844882683) ...done Copying ./tpcc/district.ibd is skipped. Copying ./tpcc/orders.ibd is skipped. Copying ./tpcc/item.ibd is skipped. Copying ./tpcc/customer.ibd is skipped. Copying ./tpcc/history.ibd is skipped. xtrabackup: The latest check point (for incremental): '3:763362037' >> log scanned up to (3 845737724) xtrabackup: Stopping log copying thread. xtrabackup: Transaction log of lsn (3 763355707) to (3 845737724) was copied. |
Now in
1 |
/data/vadim/mysql/export |
we have backup but only with
1 |
ibdata1 |
and
1 |
order_line.ibd |
files
Second step is to prepare backup, but with special option “export”
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 |
xtrabackup --defaults-file=/etc/my.reg.cnf --prepare --export --use-memory=8G --target-dir=/data/vadim/mysql/export/ xtrabackup Ver 0.8.1rc Rev 78 for 5.0.83 unknown-linux-gnu (x86_64) xtrabackup: cd to /data/vadim/mysql/export/ xtrabackup: This target seems to be not prepared yet. xtrabackup: xtrabackup_logfile detected: size=92684288, start_lsn=(3 763355707) xtrabackup: Temporary instance for recovery is set as followings. 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 = 1 xtrabackup: innodb_log_file_size = 92684288 xtrabackup: Starting InnoDB instance for recovery. xtrabackup: Using 8589934592 bytes for buffer pool (set by --use-memory parameter) InnoDB: Log scan progressed past the checkpoint lsn 3 763355707 090730 23:22:43 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Doing recovery: scanned up to log sequence number 3 768598528 (6 %) .... InnoDB: Doing recovery: scanned up to log sequence number 3 845737724 (99 %) InnoDB: 12 transaction(s) which must be rolled back or cleaned up InnoDB: in total 107 row operations to undo InnoDB: Trx id counter is 0 1560320 .... id 0 1559932, 13 rows to undo InnoDB: Rolling back of trx id 0 1559932 completed 090730 23:23:35 InnoDB: Rolling back trx with id 0 1559890, 30 rows to undo InnoDB: Rolling back of trx id 0 1559890 completed 090730 23:23:35 InnoDB: Rollback of non-prepared transactions completed 090730 23:25:32 InnoDB: Shutdown completed; log sequence number 3 852825486 |
When it’s done we have two files
1 |
order_line.ibd |
and
1 |
order_line.exp |
in directory
1 |
/data/vadim/mysql/export/tpcc |
. ibd is regular InnoDB ® file, and exp is file with special export information. Both files should be copied to remote server.
Now on remote server you have to run MySQL server ® with XtraDB6 storage engine, you can take one of our binary builds with 5.1.36.
On new server we run