MySQL 5.7 Transportable Tablespace

将5.7更新后的Transportable Tablespace 功能做一总结

一 普通表和分区表的传输(将db1的t1表传输到db2上。)


普通表创建 CREATE TABLE t1 (i int) ENGINE = InnoDB ;
分区表创建 CREATE TABLE t1 (i int) ENGINE = InnoDB PARTITION BY KEY (i) PARTITIONS 4;

db1上
1.flush table t1 for export;
2.将 t1 表的 .cfg 和 .idb 文件拷贝出来
3.unlock tables;


db2上
1.创建相同的表结构 CREATE TABLE t1...
2.alter table t1 discard tablespace ;
3.将 db1 的.cfg 和 .idb 文件拷贝到db2并修改权限
4.alter table t1 import  tablespace ;

 

二 分区表的若干分区传输(将db1的t1表的p2,p3分区传输到db2上。)


分区表创建 CREATE TABLE t1 (i int) ENGINE = InnoDB PARTITION BY KEY (i) PARTITIONS 4;
db1上
1.flush table t1 for export;
2.将 t1 表的对应分区的 .cfg 和 .idb 文件拷贝出来
3.unlock tables;

db2上
1.创建相同的表结构 CREATE TABLE t1...
2.alter table t1 discard PARTITION p2,p3 tablespace ;
3.将 db1 的对应分区的.cfg 和 .idb 文件拷贝到db2并修改权限
4.alter table t1 import PARTITION p2, p3 tablespace ;

Internals

The following information describes internals and error log messaging for the transportable tablespaces
copy procedure for a regular InnoDB table.
When ALTER TABLE ... DISCARD TABLESPACE is run on the destination instance:
• The table is locked in X mode.
• The tablespace is detached from the table.
When FLUSH TABLES ... FOR EXPORT is run on the source instance:
• The table being flushed for export is locked in shared mode.
• The purge coordinator thread is stopped.
• Dirty pages are synchronized to disk.
• Table metadata is written to the binary .cfg file.

When UNLOCK TABLES is run on the source instance:
• The binary .cfg file is deleted.
• The shared lock on the table or tables being imported is released and the purge coordinator thread is
restarted.
 
When ALTER TABLE ... IMPORT TABLESPACE is run on the destination instance, the import algorithm
performs the following operations for each tablespace being imported:
• Each tablespace page is checked for corruption.
Storing InnoDB Undo Logs in Separate Tablespaces
2384
• The space ID and log sequence numbers (LSNs) on each page are updated
• Flags are validated and LSN updated for the header page.
• Btree pages are updated.
• The page state is set to dirty so that it is written to disk.

转载于:https://my.oschina.net/xxj123go/blog/1786742

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
xtrabackup是一种备份工具,可用于对MySQL数据库进行全量或增量备份。在备份过程中,xtrabackup会创建一个完整的数据库备份,包括所有的表和数据。如果需要从xtrabackup备份中恢复单张表,可以使用可移动表空间(Transportable Tablespace)功能来实现。从MySQL 5.6版本开始,支持可移动表空间功能,该功能允许将单个表从一个数据库实例移动到另一个实例。 要从xtrabackup备份中恢复单张表,可以按照以下步骤进行操作: 1. 使用xtrabackup备份整个MySQL数据库。 2. 将备份文件解压到指定的目录,并确保解压后的备份文件包含了所有表的数据和结构。 3. 使用MySQL的物理备份工具innobackupex来恢复备份文件。这个工具可以将备份文件还原到指定的目录。 4. 在还原过程中,可以选择只恢复需要的表。可以将需要恢复的表复制到新的数据库实例中,或者使用可移动表空间(Transportable Tablespace)功能将表从备份中移动到现有的数据库实例中。 5. 如果备份后的数据中有插入操作,但在恢复过程中没有出现,请使用binlog进行恢复。binlog是MySQL的二进制日志,可以用于恢复备份后的插入操作。 请注意,以上步骤仅适用于使用xtrabackup进行备份的MySQL数据库,且需要使用MySQL 5.6版本或更高版本支持可移动表空间功能。有关更详细的步骤和示例,请参考中提供的链接。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [从xtrabackup备份恢复单表](https://blog.csdn.net/yimenglin/article/details/106902717)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值