|
如果用percona server的话有个方法可以在服务器之间移动ibd文件
- xtrabackup --defaults-file=/etc/my.cnf --backup --tables=test.t1 --target-dir=/data/tmp/
- xtrabackup: tables regcomp(test.t1): Success
- xtrabackup version 1.6.5 for Percona Server 5.1.59 unknown-linux-gnu (x86_64) (revision id: 328)
- xtrabackup: uses posix_fadvise().
- xtrabackup: cd to /var/lib/mysql
- 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 = 2
- xtrabackup: innodb_log_file_size = 5242880
- 120312 16:38:22 InnoDB: Warning: allocated tablespace 10, old maximum was 9
- >> log scanned up to (1601674)
- [01] Copying ./ibdata1
- to /data/tmp//ibdata1
- [01] ...done
- [01] Copying ./test/t1.ibd
- to /data/tmp//test/t1.ibd
- [01] ...done
- xtrabackup: The latest check point (for incremental): '1601674'
- >> log scanned up to (1601674)
- xtrabackup: Stopping log copying thread.
- xtrabackup: Transaction log of lsn (1601674) to (1601674) was copied.
- xtrabackup --defaults-file=/etc/my.cnf --prepare --export --target-dir=/data/tmp
- xtrabackup version 1.6.5 for Percona Server 5.1.59 unknown-linux-gnu (x86_64) (r evision id: 328)
- xtrabackup: cd to /data/tmp
- xtrabackup: This target seems to be not prepared yet.
- xtrabackup: xtrabackup_logfile detected: size=2097152, start_lsn=(1601674)
- 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 = 2097152
- xtrabackup: Starting InnoDB instance for recovery.
- xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter )
- InnoDB: The InnoDB memory heap is disabled
- InnoDB: Mutexes and rw_locks use GCC atomic builtins
- InnoDB: Compressed tables use zlib 1.2.3
- InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io _threads and innodb_write_io_threads instead
- 120312 16:41:17 InnoDB: Initializing buffer pool, size = 100.0M
- 120312 16:41:17 InnoDB: Completed initialization of buffer pool
- 120312 16:41:17 InnoDB: highest supported file format is Barracuda.
- InnoDB: The log sequence number in ibdata files does not match
- InnoDB: the log sequence number in the ib_logfiles!
- 120312 16:41:17 InnoDB: Database was not shut down normally!
- InnoDB: Starting crash recovery.
- InnoDB: Reading tablespace information from the .ibd files...
- 120312 16:41:17 Percona XtraDB (http://www.percona.com) 1.0.17-12.5 started; log sequence number 1601674
- xtrabackup: export option is specified.
- xtrabackup: export metadata of table 'test/t1' to file `./test/t1.exp` (1 indexe s)
- xtrabackup: name=GEN_CLUST_INDEX, id.low=16, page=3
- [notice (again)]
- If you use binary log and don't use any hack of group commit,
- the binary log position seems to be:
- xtrabackup: starting shutdown with innodb_fast_shutdown = 0
- 120312 16:41:17 InnoDB: Starting shutdown...
- 120312 16:41:17 InnoDB: Shutdown completed; log sequence number 1601674
复制代码 在需要导入数据的服务器
- mysql> set global innodb_import_table_from_xtrabackup=1;
复制代码 创建table
- mysql> create table t1 (id int)engine=innodb;
复制代码 删除表空间
- mysql> alter table t1 discard tablespace;
复制代码 拷贝ibd和exp文件到指定位置
cp t1.* /var/lib/mysql/test/
- mysql> alter table t1 import tablespace;
复制代码 另外数据可能需要重启mysql才能看到! |
|