14.7.6 Copying File-Per-Table Tablespaces to Anoth

14.7.6.1 Transportable Tablespace Examples
14.7.6.2 Transportable Tablespace Internals
This section describes how to copy a file-per-table tablespace from one MySQL instance to another, otherwise known as the Transportable Tablespaces feature.
本節介紹如何將 file-per-table表空間 從一個MySQL實例複製到另一個MySQL實例,也稱爲傳輸表空間功能。
For information about other InnoDB table copying methods, see Section 14.8.1.3, “Moving or Copying InnoDB Tables”.
有關其他InnoDB表複製方法的信息,請參考Section 14.8.1.3, “Moving or Copying InnoDB Tables”.
There are many reasons why you might copy an InnoDB file-per-table tablespace to a different instance:
將InnoDB文件file-per-table表空間 複製到另一個實例的原因有很多:

  • To run reports without putting extra load on a production server.
  • 在不給生產服務器增加額外負載的情況下運行報表。
  • To set up identical data for a table on a new slave server.
  • 在新的slave server上爲一個表設置相同的數據。
  • To restore a backed-up version of a table or partition after a problem or mistake.
  • 在出現問題或錯誤後恢復已備份的表或分區。
  • As a faster way of moving data around than importing the results of a mysqldump command. The data is available immediately, rather than having to be re-inserted and the indexes rebuilt.
  • 作爲一種更快速的數據移動方式,比導入mysqldump命令的結果更快。 數據立即可用,而不必重新插入並重建索引。。
  • To move a file-per-table tablespace to a server with storage medium that better suits system requirements. For example, you may want to have busy tables on an SSD device, or large tables on a high-capacity HDD device.
  • 將 file-per-table表空間移動到具有更適合系統需求的存儲介質的服務器。例如,您可能希望在SSD設備上有繁忙的表,或者在高容量的HDD設備上有大型表。

Limitations and Usage Notes

限制和使用說明

  • The tablespace copy procedure is only possible when innodb_file_per_table is set to ON, which is the default setting. Tables residing in the shared system tablespace cannot be quiesced.
  • 只有當innodb_file_per_table設置爲ON時,innodb_file_per_table默認是開啓的,纔可能執行表空間複製過程。共享系統表空間中駐留的表不能被保存。
  • When a table is quiesced, only read-only transactions are allowed on the affected table.
  • 當一個表被暫停時,受影響的表上只允許只讀事務。
  • When importing a tablespace, the page size must match the page size of the importing instance.
  • 在導入表空間時,頁面大小必須與導入實例的頁面大小相匹配。
  • DISCARD TABLESPACE is not supported for tablespaces with a parent-child (primary key-foreign key) relationship when foreign_key_checks is set to 1. Before discarding a tablespace for parent-child tables, set foreign_key_checks=0. Partitioned InnoDB tables do not support foreign keys.
  • 當foreign_key_checks設置爲1時,具有parent-child(primary key-foreign key)關係的表空間不支持DISCARD TABLESPACE,在丟棄parent-child 表的表空間之前,請設置foreign_key_checks = 0。 分區的InnoDB表不支持外鍵。
  • ALTER TABLE ... IMPORT TABLESPACE does not enforce foreign key constraints on imported data. If there are foreign key constraints between tables, all tables should be exported at the same (logical) point in time. PartitionedInnoDB tables do not support foreign keys.
  • ALTER TABLE ... IMPORT TABLESPACE不強制導入數據的外鍵約束。如果表之間存在外鍵約束,則應該在相同(邏輯)時間點導出所有表。 分區的InnoDB表不支持外鍵。
  • ALTER TABLE ... IMPORT TABLESPACE and ALTER TABLE ... IMPORT PARTITION ... TABLESPACE do not require a .cfg metadata file to import a tablespace. However, metadata checks are not performed when importing without a .cfg file, and a warning similar to the following is issued:
  • ALTER TABLE ... IMPORT TABLESPACE和ALTER TABLE ... IMPORT PARTITION ... TABLESPACE不需要.cfg元數據文件來導入表空間。 但是,導入沒有.cfg文件時不會執行元數據檢查,並會發出類似於以下內容的警告:
    Message: InnoDB: IO Read error: (2, No such file or directory) Error opening '.\
    test\t.cfg', will attempt to import without schema verification
    1 row in set (0.00 sec)

The ability to import without a .cfg file may be more convenient when no schema mismatches are expected. Additionally, the ability to import without a .cfg file could be useful in crash recovery scenarios in which metadata cannot be collected from an .ibd file.

  • 如果預期沒有schema不匹配,則導入沒有.cfg文件的能力可能會更方便。此外,在無法從.ibd文件中收集元數據的崩潰恢復場景中,可以使用不帶.cfg文件的導入功能。
  • Due to a .cfg metadata file limitation, schema mismatches are not reported for partition type or partition definition differences when importing tablespace files for partitioned tables. Column differences are reported.
  • 由於.cfg元數據文件的限制,在爲分區表導入表空間文件時,不會報告分區類型或分區定義差異的schema不匹配。列差異被報告。
  • When running ALTER TABLE ... DISCARD PARTITION ... TABLESPACE and ALTER TABLE ... IMPORT PARTITION ... TABLESPACE on subpartitioned tables, both partition and subpartition table names are allowed. When a partition name is specified, subpartitions of that partition are included in the operation.
  • 當在子分區表上運行ALTER TABLE ... DISCARD PARTITION ... TABLESPACE和ALTER TABLE ... IMPORT PARTITION ... TABLESPACE時,可以同時使用分區和子分區表名。當指定分區名時,該分區的子分區包含在操作中。
  • Importing a tablespace file from another MySQL server instance works if both instances have GA (General Availability) status and their versions are within the same series. Otherwise, the file must have been created on the same server instance into which it is imported.
  • 如果兩個實例都具有GA(通用可用性)狀態並且它們的版本在同一個系列中,則從另一個MySQL服務器實例導入表空間文件將起作用。 否則,該文件必須已在與其導入的服務器實例相同的服務器實例上創建。
  • In replication scenarios, innodb_file_per_table must be set to ON on both the master and slave.
  • 在複製方案中,master和slave的innodb_file_per_table必須設置爲ON。
  • On Windows, InnoDB stores database, tablespace, and table names internally in lowercase. To avoid import problems on case-sensitive operating systems such as Linux and UNIX, create all databases, tablespaces, and tables using lowercase names. A convenient way to accomplish this is to add the following line to the [mysqld] section of your my.cnf or my.ini file before creating databases, tablespaces, or tables:
  • 在Windows上,InnoDB在內部以小寫形式存儲數據庫、表空間和表名。爲了避免在區分大小寫的操作系統(如Linux和UNIX)上出現導入問題,請使用小寫名稱創建所有數據庫、表空間和表。完成此操作的一種便捷方法是在創建數據庫,表空間或表之前,將以下行添加到my.cnf或my.ini文件的[mysqld]部分中:
    [mysqld]
    lower_case_table_names=1
  • ALTER TABLE ... DISCARD TABLESPACE and ALTER TABLE ...IMPORT TABLESPACE are not supported with tables that belong to an InnoDB general tablespace. For more information, see CREATE TABLESPACE.
  • ALTER TABLE ... DISCARD TABLESPACE和ALTER TABLE ... IMPORT TABLESPACE不支持屬於InnoDB常規表空間的表。 有關更多信息,請參閱CREATE TABLESPACE。
  • The default row format for InnoDB tables is configurable using the innodb_default_row_format configuration option. Attempting to import a table that does not explicitly define a row format (ROW_FORMAT), or that uses ROW_FORMAT=DEFAULT, could result in a schema mismatch error if the innodb_default_row_format setting on the source instance differs from the setting on the destination instance. For related information, see Section 14.11.2, “Specifying the Row Format for a Table”.
  • InnoDB表的默認行格式可以使用innodb_default_row_format配置選項進行配置。如果源實例上的innodb_default_row_format設置與目標實例上的設置不同,那麼嘗試導入不顯式定義行格式(ROW_FORMAT)或使用ROW_FORMAT=DEFAULT的表可能會導致schema不匹配錯誤,更多信息請看Section 14.11.2, “Specifying the Row Format for a Table”.
  • When exporting a tablespace that is encrypted using the InnoDB tablespace encryption feature, InnoDB generates a.cfp file in addition to a .cfg metadata file. The .cfp file must be copied to the destination instance together with the.cfg file and tablespace file before performing the ALTER TABLE ... IMPORT TABLESPACE operation on the destination instance. The .cfp file contains a transfer key and an encrypted tablespace key. On import, InnoDB uses the transfer key to decrypt the tablespace key. For related information, see Section 14.7.10, “InnoDB Tablespace Encryption”
  • 導出使用InnoDB表空間加密功能加密的表空間時,除了.cfg元數據文件之外,InnoDB還生成a.cfp文件.在對目標實例執行ALTER TABLE ... IMPORT TABLESPACE操作之前,必須將.cfp文件與the.cfg文件和表空間文件一起復制到目標實例。.cfp文件包含一個傳輸密鑰和一個加密的表空間密鑰。 在導入時,InnoDB使用傳輸密鑰來解密表空間密鑰。更多信息請看Section 14.7.10, “InnoDB Tablespace Encryption”
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章