8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

17.18.1 InnoDB 备份17.18.1 InnoDB Backup

安全数据库管理的关键是定期备份。根据您的数据量、MySQL 服务器数量和数据库工作负载,您可以单独或组合使用以下备份技术:使用 MySQL Enterprise Backup 的 热备份;在 MySQL 服务器关闭时复制文件的 冷备份;使用 mysqldump 的 逻辑备份,适用于较小的数据量或记录模式对象结构。热备份和冷备份是 物理备份,它们复制实际的数据文件,mysqld 服务器可以直接使用这些文件以加快恢复速度。The key to safe database management is making regular backups. Depending on your data volume, number of MySQL servers, and database workload, you can use these backup techniques, alone or in combination: hot backup with MySQL Enterprise Backup; cold backup by copying files while the MySQL server is shut down; logical backup with mysqldump for smaller data volumes or to record the structure of schema objects. Hot and cold backups are physical backups that copy actual data files, which can be used directly by the mysqld server for faster restore.

使用 MySQL 企业备份 是备份 InnoDB 数据的推荐方法。Using MySQL Enterprise Backup is the recommended method for backing up InnoDB data.

Note

InnoDB 不支持使用第三方备份工具恢复的数据库。InnoDB does not support databases that are restored using third-party backup tools.

热备份Hot Backups

mysqlbackup 命令是 MySQL 企业备份组件的一部分,它允许您在运行的 MySQL 实例上进行备份,包括 InnoDB 表,在尽量减少操作中断的同时生成数据库的一致快照。当 mysqlbackup 复制 InnoDB 表时,对 InnoDB 表的读写操作可以继续。MySQL 企业备份还可以创建压缩备份文件,并备份表和数据库的子集。结合 MySQL 二进制日志,用户可以执行时间点恢复。MySQL 企业备份是 MySQL 企业订阅的一部分。有关详细信息,请参见 第 32.1 节,“MySQL 企业备份概述”。The mysqlbackup command, part of the MySQL Enterprise Backup component, lets you back up a running MySQL instance, including InnoDB tables, with minimal disruption to operations while producing a consistent snapshot of the database. When mysqlbackup is copying InnoDB tables, reads and writes to InnoDB tables can continue. MySQL Enterprise Backup can also create compressed backup files, and back up subsets of tables and databases. In conjunction with the MySQL binary log, users can perform point-in-time recovery. MySQL Enterprise Backup is part of the MySQL Enterprise subscription. For more details, see Section 32.1, “MySQL Enterprise Backup Overview”.

冷备份Cold Backups

如果您可以关闭 MySQL 服务器,则可以进行物理备份,包括用于 InnoDB 管理其表的所有文件。使用以下步骤:If you can shut down the MySQL server, you can make a physical backup that consists of all files used by InnoDB to manage its tables. Use the following procedure:

  1. 对 MySQL 服务器执行慢速关闭,并确保其无错误停止。Perform a slow shutdown of the MySQL server and make sure that it stops without errors.

  2. 将所有 InnoDB 数据文件(ibdata 文件和 .ibd 文件)复制到安全的地方。Copy all InnoDB data files (ibdata files and .ibd files) into a safe place.

  3. 将所有 InnoDB 重做日志文件(#ib_redoN 文件)复制到安全的地方。Copy all InnoDB redo log files (#ib_redoN files) to a safe place.

  4. 将您的 my.cnf 配置文件复制到安全的地方。Copy your my.cnf configuration file or files to a safe place.

使用 mysqldump 进行逻辑备份Logical Backups Using mysqldump

除了物理备份外,建议您定期通过使用 mysqldump 导出表来创建逻辑备份。二进制文件可能会在您未注意到的情况下损坏。导出的表存储在可读的文本文件中,因此更容易发现表损坏。此外,由于格式更简单,严重数据损坏的可能性更小。mysqldump 还具有 --single-transaction 选项,可在不锁住其他客户端的情况下创建一致的快照。参见 第 9.3.1 节,“建立备份策略”。In addition to physical backups, it is recommended that you regularly create logical backups by dumping your tables using mysqldump. A binary file might be corrupted without you noticing it. Dumped tables are stored into text files that are human-readable, so spotting table corruption becomes easier. Also, because the format is simpler, the chance for serious data corruption is smaller. mysqldump also has a --single-transaction option for making a consistent snapshot without locking out other clients. See Section 9.3.1, “Establishing a Backup Policy”.

复制适用于InnoDB表,因此您可以使用 MySQL 的复制功能,在需要高可用性的数据库站点保留数据库副本。请参阅第 17.19 节,“InnoDB 与 MySQL 复制”。Replication works with InnoDB tables, so you can use MySQL replication capabilities to keep a copy of your database at database sites requiring high availability. See Section 17.19, “InnoDB and MySQL Replication”.