16.10 性能/可扩展性/容量选项

这些选项限制了备份进程使用的资源,以最大限度地减少繁忙或庞大数据库的备份开销,或者在遇到资源问题时指定进程的行为。

  • --number-of-buffers=num_buffers

    命令行格式 --number-of-buffers=NUMBER
    类型 数字
    默认值 14
    最小值 1

    指定在多线程选项期间使用的缓冲区数量,每个大小为 16MB。

    对 CPU 密集型处理(例如备份)使用较大的数字,尤其是在使用压缩时。使用较小的数字进行磁盘密集型处理,例如恢复备份。该值应至少与读取线程数或写入线程数一样高,具体取决于操作类型。

    默认值:当前为 14。

    对于压缩或增量备份操作,缓冲区大小略大于 16MB 以容纳标头。

    一个额外的缓冲区用于单文件增量备份和单文件压缩备份。

    压缩备份、压缩单文件备份和解压缩应用日志操作需要为每个进程线程提供一个额外的缓冲区。

    如果更改读取、写入和处理线程的数量,您可以尝试更改此值,使其略大于那些其他选项指定的线程总数。请参阅 第 11.1 节,“优化备份性能”第 11.2 节,“优化恢复性能”,以获取有关针对各种硬件配置(例如 RAID 或非 RAID 存储设备)的此选项和其他与性能相关的选项的推荐值组合的更多建议。

  • --read-threads=num_threads

    命令行格式 --read-threads=NUMBER
    类型 数字
    默认值 1
    最小值 1
    最大值 15

    指定用于从磁盘读取数据的线程数。此选项适用于这些类型的操作: copy-backcopy-back-and-apply-log(仅适用于目录备份) extract、、、 backupbackup-and-apply-log。如果您指定一个值 0,它会静默调整为 1。最大值为 15。如果您提供一个负值,它会静默调整为 15。对于以下操作,读取线程数始终为 1,而不管这个选项设置:

    请参阅第 11.1 节,“优化备份性能”第 11.2 节,“优化恢复性能”--read-threads ,以获取有关、 --process-threads--write-threads各种硬件配置(例如 RAID 或非 RAID 存储设备) 的推荐值组合的建议 。

    默认值:1。

  • --process-threads=num_threads

    命令行格式 --process-threads=NUMBER
    类型 数字
    默认值 6
    最小值 1
    最大值 15

    指定用于处理数据的线程数,包括压缩和解压缩、加密和解密、应用日志操作以及备份映像的打包和提取。对于 backup-and-apply-logcopy-back-and-apply-logapply-incremental-backup--process-threads为操作的应用日志阶段设置工作线程数。对于那些不涉及数据处理的操作 copy-back(除非涉及解密或解压缩)backup-dir-to-image ,或使用该 --incremental-with-redo-log-only 选项的备份操作,该选项将被忽略。

    默认值:6 适用于该选项适用的所有操作。

    如果您指定值 0,它会自动调整为 1。最大值为 15。如果您提供负值,它会自动调整为 15。请参阅 第 11.1 节,“优化备份性能”第 11.2 节,“优化还原” Performance”--read-threads以获得有关、 --process-threads--write-threads各种硬件配置(例如 RAID 或非 RAID 存储设备) 的推荐值组合的建议 。

  • --write-threads=num_threads

    命令行格式 --write-threads=NUMBER
    类型 数字
    默认值 1
    最小值 1
    最大值 15

    指定用于将数据写入磁盘的线程数。此选项适用于以下类型的操作: copy-backcopy-back-and-apply-logextractbackupbackup-and-apply-log(应用于目录备份时)。对于支持的操作,任何可搜索的写入目标都支持多个写入线程; --write-threads仅当写入目标不可查找时才强制为 1。对于其他操作,如单文件备份(始终使用 1 个写入线程)、 list-image(不使用写入线程)和validate(不使用写入线程),该选项将被忽略。

    如果指定值 0,它会自动调整为 1(对于使用写线程的操作)。最大值为 15。如果您提供负值,它会自动调整为 15。对于、 或 apply-log的操作和应用日志阶段 copy-back-and-apply-log, 无论此选项的设置如何,写入线程数始终为 0。有关建议的 、 和_ _ backup-and-apply-logapply-incremental-backup--read-threads--process-threads--write-threads用于各种硬件配置,例如 RAID 或非 RAID 存储设备。

    默认值:1。

  • --limit-memory=MB

    命令行格式 --limit-memory=MB
    类型 数字
    默认值 100 for apply-log (without uncompression), 400 for other operations
    最小值 0
    最大值 999999
    单元 兆字节

    指定mysqlbackup 可以使用的最大内存(以兆字节为 单位) 。以前只适用于 apply-log操作,但在 MySQL Enterprise Backup 3.8 及更高版本中它适用于所有操作。不要在选项值中 包含任何后缀,例如mb或 。kb

    默认值:100 表示apply-log不与 一起使用--uncompress,400 表示所有操作(以兆字节为单位)。

    此选项指定的内存限制还限制了可用于多线程处理的 16MB 缓冲区的数量。例如,对于 400 MB 的限制,最大缓冲区数为 25(云备份除外,需要额外的内存,最大缓冲区数为 18)。如果因为您增加了 、 、 和/或 的值而需要额外的缓冲区 --read-threads--process-threads--write-threads按 比例--number-of-buffers增加该--limit-memory值。

  • --sleep=MS

    命令行格式 --sleep=MS
    类型 数字
    默认值 0
    单元 毫秒

    Specify the number in milliseconds to sleep after copying a certain amount of data from InnoDB tables. Each block of data is 1024 InnoDB data pages, typically totalling 16MB. This is to limit the CPU and I/O overhead on the database server.

    Default: 0 (no voluntary sleeps).

  • --no-locking

    Disables locking during backup of non-InnoDB files, even if a connection is available. Can be used to copy non-InnoDB data with less disruption to normal database processing. There could be inconsistencies in non-InnoDB data if any changes are made while those files are being backed up.

  • --lock-wait-timeout

    Command-Line Format --lock-wait-timeout=S
    Type Numeric
    Default Value 60
    Minimum Value 1
    Unit second

    Specify the timeout in seconds for the FLUSH TABLES WITH READ LOCK statement, which mysqlbackup issues during the final stage of a backup to temporarily put the database into a read-only state. If the timeout is exceeded, the statement is failed and the lock on the tables is released, so that queries held up by the lock can then be executed. mysqlbackup then retries the statement and continues with the backup. The timeout prevents the case in which a long query running on the server prevents the FLUSH TABLES WITH READ LOCK statement from finishing, holding up further queries and eventually bringing down the server. Default is 60. Minimum value is 1.

  • --lock-wait-retry-count

    Command-Line Format --lock-wait-retry-count
    Introduced 4.1.4
    Type Integer
    Default Value 2147483647
    Minimum Value 0
    Maximum Value 2147483647

    Specify the maximum number of retries to be attempted by mysqlbackup after the FLUSH TABLES WITH READ LOCK statement, issued during the final stage of a backup to temporarily put the database into a read-only state, fails due to a timeout. The timeout is specified by the mysqlbackup option --lock-wait-timeout, or by the system variable --innodb_lock_wait_timeout on the server. This option prevents an excessive number of retries of the lock statement, during which all transactions are blocked on the server. Default and maximum value is 2147483647. Minimum value is 0 (no retry).

  • --page-reread-time=MS

    Command-Line Format --page-reread-time=MS
    Type Numeric
    Default Value 100
    Unit millisecond

    Interval in milliseconds that mysqlbackup waits before re-reading a page that fails a checksum test. A busy server could be writing a page at the same moment that mysqlbackup is reading it. Can be a floating-point number, such as 0.05 meaning 50 microseconds. Best possible resolution is 1 microsecond, but it could be worse on some platforms. Default is 100 milliseconds (0.1 second).

  • --page-reread-count=retry_limit

    Command-Line Format --page-reread-count=number
    Type Numeric
    Default Value 500

    Maximum number of re-read attempts, when a page fails a checksum test. A busy server could be writing a page at the same moment that mysqlbackup is reading it. If the same page fails this many checksum tests consecutively, with a pause based on the --page-reread-time option between each attempt, the backup fails. Default is 500.

  • --on-disk-full={abort|abort_and_remove|warn}

    Command-Line Format --on-disk-full=option
    Type Enumeration
    Default Value abort
    Valid Values

    abort

    warn

    abort_and_remove

    Specifies the behavior when a backup process encounters a disk-full condition. This option is only for backup operations (backup, backup-and-apply-log, and backup-to-image).

    • abort: Abort backup, without removing the backup directory. The disk remains full.

    • abort_and_remove: Abort backup and remove the backup directory.

    • warn: Write a warning message every 30 seconds and retry backup until disk space becomes available.

    Default: abort.

  • --skip-unused-pages

    Skip unused pages in tablespaces when backing up InnoDB tables. This option is applicable to the backup and backup-to-image operations, but not to incremental backups. The option is ignored by the backup-and-apply-log operation.

    Note that backups created with the --skip-unused-pages option cannot be restored using copy-back-and-apply-log.

    Unused pages are free pages often caused by bulk delete of data. By skipping the unused pages during backups, this option can reduce the backup sizes and thus the required disk space and I/O resources for the operations. However, subsequent apply-log operations on the backups will take more time to complete, as the unused pages are inserted back into the tables during the operations.

  • --skip-binlog

    Skip including the binary log files in the backup during a backup operation, or skip copying the binary log files onto a server during a restore operation.

    Binary log files, together with the binary log index file, are included by default for all kinds of online backups (full, incremental, compressed, partial, single-file, etc.). See Table 1.1, “Types of Files in a Backup”, for details. Use this option to skip backing up binary logs for the following situations:

    • If resource or performance issues arise.

    • If any binary log files are missing on the server you are backing up, in order to avoid mysqlbackup throwing an error for the missing files.

    • If you are making an incremental backup that is based on a backup (full or incremental) created using the --no-locking option, as binary log information will then be unavailable to mysqlbackup in that situation.

  • --skip-relaylog

    When working with a replica server, skip including the relay log files in the backup during a backup operation, or skip copying the relay log files onto a server during a restore operation.

    Relay log files, together with the relay log index file and the master.info and the slave.info files, are included by default for all kinds of online backups (full, incremental, compressed, partial, single-file, etc.) of a replica server. See Table 1.1, “Types of Files in a Backup”, for details. Use this option to skip backing up relay logs if resource, performance, or other issues arise.

    Note

    If a user runs a FLUSH LOGS statement while backup is in progress for a replica, the backup process will fail. Use the--skip-relaylog option if you expect a FLUSH LOGS statement will be run during the backup and it is not necessary to include the relay logs in the backup.

    The relay log files and the files backed up together with them, when included in a backup, are always copied into the restored server's data directory during a restore operation; if that is not the behavior you desire, use this option to skip the restoring of the relay log.

  • --skip-final-rescan

    Skip the final rescan for InnoDB tables that are modified by DDL operations after the database has been read-locked near the end of a backup operation. This potentially shortens the duration for the lock and reduces the backup's impact on the server's normal operation, especially when many tables are being backed up.

    Warning

    This option can cause an incomplete or inconsistent backup if, during the backup operation, DDL operations are executed on any InnoDB tables whose file-per-table tablespaces are outside the MySQL data directory (i.e., any InnoDB tables created using the DATA DIRECTORY table option).

    The option is ignored for backups using the --incremental-with-redo-log-only option and for non-backup operations.

  • --log-bin-index[=PATH]

    Command-Line Format --log-bin-index=FILENAME
    Type File name
    Default Value data_dir/host_name-bin.index

    For all offline backups: specify the absolute path (including file name and extension) of the index file on the MySQL server that lists all the used binary log files, if it is different from the default path given below, in order to include the binary log files in the backup.

    Default: data_dir/host_name-bin.index.

  • --relay-log-index[=PATH]

    Command-Line Format --relay-log-index=FILENAME
    Type File name
    Default Value data_dir/host_name-relay-bin.index

    For offline backups of replica servers only: specify the absolute path (including file name and extension) of the index file on the MySQL server that lists all the used relay log files, if it is different from the default path given below, in order to include the relay log files in the backup.

    Default: data_dir/host_name-relay-bin.index.

  • --master-info-file[=PATH]

    Command-Line Format --master-info-file=FILENAME
    Type File name
    Default Value data_dir/master.info

    For offline backups of replica servers only: specify the absolute path (including file name and extension) of the information file in which a replica records information about its source, if it is different from the default path given below, in order to include the information file in the backup.

    Default: data_dir/master.info.

  • --relaylog-info-file[=PATH]

    Command-Line Format --relaylog-info-file=FILENAME
    Type File name
    Default Value data_dir/relay-log.info

    For offline backups of replica servers only: specify the absolute path (including file name and extension) of the information file in which a replica records information about the relay logs, if it is different from the default path given below, in order to include the information file in the backup.

    Default: data_dir/relay-log.info.

  • --optimistic-time[=DATE-TIME]

    Command-Line Format --optimistic-time=DATE-TIME
    Type String
    Default Value now

    Perform an optimistic backup with the value specified with the option as the optimistic time—a time after which the tables that have not been modified are taken as inactive tables. The inactive tablesare believed to be unlikely to change during the backup process. The inactive tables are backed up in the optimistic phase of the backup, and all other tables are backed up in the normal phase. See Section 4.3.6, “Making an Optimistic Backup” for details on the concept, use cases, and command samples for an optimistic backup.

    Accepted formats for specifying the option include:

    • now: This includes all tables into the optimistic phase of the backup process. It is the default value for the option when no value is specified.

    • {Number}{Unit}: Indicates the optimistic time as a time at a certain duration into the past. {Unit} can be any one of years, months, hours, and minutes. Some examples for option strings in this format include: 5years, 2days,13months, 23hours, and 35minutes.

    • A date-time format in any of the following forms: YYMMDD, YYYYMMDD, YYMMDDHHMMSS, YYYYMMDDHHMMSS, YY-MM-DD, YYYY-MM-DD, YY-MM-DD HH.MM.SS, or YYYYMMDDTHHMMSS (where T is the character T).

    When both the optimistic-time and the optimistic-busy-tables options are used and they come into conflict on determining which tables are to be backed up in the optimistic phase, optimistic-busy-tables takes precedence over optimistic-time.

  • --optimistic-busy-tables=REGEXP

    Command-Line Format --optimistic-busy-tables=REGEXP
    Type String

    Perform an optimistic backup, using the regular expression specified with the option to select tables that will be skipped in the first phase of an optimistic backup, because they are likely to be modified during the backup process. Tables whose fully qualified names (in the form of database_name.table_name) are matched by the regular expression are taken as busy tables, which will be backed up in the second or the normal phase of the backup. Tables whose fully qualified names are NOT matched by the regular expression are taken as inactive tables, which will be backed up in the first or the optimistic phase of the backup. See Section 4.3.6, “Making an Optimistic Backup” for details on the concept, use cases, and command samples for an optimistic backup.

    MySQL Enterprise Backup will throw an error if the option is used but no regular expression is supplied with it.

    When both the optimistic-time and the optimistic-busy-tables options are used and they come into conflict on determining which tables are to be optimistic, optimistic-busy-tables takes precedence over optimistic-time.

  • --free-os-buffers

    通过将缓冲区缓存中的所有数据同步到硬盘,在备份操作结束时释放系统缓冲区缓存。对于存储设备较慢的系统和包含许多表的数据库,使用该选项可能会显着增加备份时间。

    默认值:禁用自动同步。