可以在服务器启动时启用或禁用布尔类型的系统变量,启用时直接命名变量,禁用时使用
--skip-前缀。例如,要启用或禁用InnoDB自适应哈希索引,可以在命令行中使用--innodb-adaptive-hash-index或--skip-innodb-adaptive-hash-index,或者在选项文件中使用innodb_adaptive_hash_index或skip_innodb_adaptive_hash_index。System variables that are true or false can be enabled at server startup by naming them, or disabled by using a--skip-prefix. For example, to enable or disable theInnoDBadaptive hash index, you can use--innodb-adaptive-hash-indexor--skip-innodb-adaptive-hash-indexon the command line, orinnodb_adaptive_hash_indexorskip_innodb_adaptive_hash_indexin an option file.一些变量描述提到“启用”或“禁用”某个变量。这些变量可以通过
SET语句设置为ON或1来启用,或设置为OFF或0来禁用。布尔变量可以在启动时设置为ON、TRUE、OFF和FALSE(不区分大小写),也可以设置为1和0。参见第 6.2.2.4 节,“程序选项修改符”。Some variable descriptions refer to “enabling” or “disabling” a variable. These variables can be enabled with theSETstatement by setting them toONor1, or disabled by setting them toOFFor0. Boolean variables can be set at startup to the valuesON,TRUE,OFF, andFALSE(not case-sensitive), as well as1and0. See Section 6.2.2.4, “Program Option Modifiers”.取数值的系统变量可以在命令行上指定为
--,或在选项文件中指定为var_name=value。System variables that take a numeric value can be specified asvar_name=value--on the command line or asvar_name=valuein option files.var_name=value许多系统变量可以在运行时更改(参见第 7.1.9.2 节,“动态系统变量”)。Many system variables can be changed at runtime (see Section 7.1.9.2, “Dynamic System Variables”).
有关
GLOBAL和SESSION变量作用域修饰符的信息,请参阅SET语句文档。For information aboutGLOBALandSESSIONvariable scope modifiers, refer to theSETstatement documentation.某些选项控制
InnoDB数据文件的位置和布局。第 17.8.1 节,“InnoDB 启动配置” 说明了如何使用这些选项。Certain options control the locations and layout of theInnoDBdata files. Section 17.8.1, “InnoDB Startup Configuration” explains how to use these options.一些选项可能初期不会使用,它们可以根据机器容量和数据库 工作负载 调整
InnoDB的性能特性。Some options, which you might not use initially, help tuneInnoDBperformance characteristics based on machine capacity and database workload.有关指定选项和系统变量的更多信息,请参见 第 6.2.2 节,“指定程序选项”。For more information on specifying options and system variables, see Section 6.2.2, “Specifying Program Options”.
表 17.23 InnoDB 选项和变量参考Table 17.23 InnoDB Option and Variable Reference
InnoDB 启动选项InnoDB Startup Options
命令行格式Command-Line Format --innodb-dedicated-server[={OFF|ON}]系统变量System Variable innodb_dedicated_server范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF当通过命令行或
my.cnf文件使用--innodb-dedicated-server或--innodb-dedicated-server=ON启动服务器时,InnoDB会自动计算并设置以下变量的值:When this option is set by starting the server with--innodb-dedicated-serveror--innodb-dedicated-server=ON, either on the command line or in amy.cnffile,InnoDBautomatically calculates and sets the values of the following variables:Note在较早版本的 MySQL 8.0 中,
innodb_log_file_size和innodb_log_files_in_group也可以通过--innodb-dedicated-server设置。innodb_log_file_size和innodb_log_files_in_group后来已被弃用,被innodb_redo_log_capacity取代。请参阅 第 17.6.5 节,“重做日志”。In older versions of MySQL 8.0,innodb_log_file_sizeandinnodb_log_files_in_groupwere also set by--innodb-dedicated-server.innodb_log_file_sizeandinnodb_log_files_in_grouphave since been deprecated, and superseded byinnodb_redo_log_capacity. See Section 17.6.5, “Redo Log”.在 MySQL 8.0 中,
innodb_flush_method也会由此选项自动设置,但在 MySQL 8.4 中,这种情况已不再适用。In MySQL 8.0,innodb_flush_methodwas also set automatically by this option, but in MySQL 8.4, this is no longer the case.您应当仅在 MySQL 实例运行在可以使用所有可用系统资源的专用服务器上时考虑使用
--innodb-dedicated-server。如果 MySQL 实例与其他应用程序共享系统资源,则不建议使用此选项。You should consider using--innodb-dedicated-serveronly if the MySQL instance resides on a dedicated server where it can use all available system resources. Using this option is not recommended if the MySQL instance shares system resources with other applications.强烈建议您在生产环境中使用此选项之前,先阅读 第 17.8.12 节,“为专用 MySQL 服务器启用自动 InnoDB 配置”。It is strongly recommended that you read Section 17.8.12, “Enabling Automatic InnoDB Configuration for a Dedicated MySQL Server”, before using this option in production.
命令行格式Command-Line Format --innodb-status-file[={OFF|ON}]类型Type 布尔Boolean 默认值Default Value OFFOFF--innodb-status-file启动选项控制InnoDB是否在数据目录中创建一个名为innodb_status.的文件,并大约每 15 秒将pidSHOW ENGINE INNODB STATUS输出写入该文件。The--innodb-status-filestartup option controls whetherInnoDBcreates a file namedinnodb_status.in the data directory and writespidSHOW ENGINE INNODB STATUSoutput to it every 15 seconds, approximately.默认情况下不创建
innodb_status.文件。要创建它,请使用pid--innodb-status-file选项启动 mysqld。当服务器正常关闭时,InnoDB会删除该文件。如果发生异常关闭,则可能需要手动删除状态文件。Theinnodb_status.file is not created by default. To create it, start mysqld with thepid--innodb-status-fileoption.InnoDBremoves the file when the server is shut down normally. If an abnormal shutdown occurs, the status file may have to be removed manually.--innodb-status-file选项用于临时用途,因为生成SHOW ENGINE INNODB STATUS输出可能会影响性能,并且innodb_status.文件随时间可能会变得非常大。Thepid--innodb-status-fileoption is intended for temporary use, asSHOW ENGINE INNODB STATUSoutput generation can affect performance, and theinnodb_status.file can become quite large over time.pid有关相关信息,请参阅 第 17.17.2 节,“启用 InnoDB 监视器”。For related information, see Section 17.17.2, “Enabling InnoDB Monitors”.
InnoDB 系统变量InnoDB System Variables
命令行格式Command-Line Format --innodb-adaptive-flushing[={OFF|ON}]系统变量System Variable innodb_adaptive_flushing范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONONSpecifies whether to dynamically adjust the rate of flushing dirty pages in the
InnoDB缓冲池 based on the workload. Adjusting the flush rate dynamically is intended to avoid bursts of I/O activity. This setting is enabled by default. See Section 17.8.3.5, “Configuring Buffer Pool Flushing” for more information. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.Specifies whether to dynamically adjust the rate of flushing dirty pages in theInnoDBbuffer pool based on the workload. Adjusting the flush rate dynamically is intended to avoid bursts of I/O activity. This setting is enabled by default. See Section 17.8.3.5, “Configuring Buffer Pool Flushing” for more information. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.命令行格式Command-Line Format --innodb-adaptive-flushing-lwm=#系统变量System Variable innodb_adaptive_flushing_lwm范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 10最小值Minimum Value 0最大值Maximum Value 70定义低水位标志,表示启用自适应刷新时重做日志容量的百分比。有关更多信息,请参见第 17.8.3.5 节,“配置缓冲池刷新”。Defines the low water mark representing percentage of redo log capacity at which adaptive flushing is enabled. For more information, see Section 17.8.3.5, “Configuring Buffer Pool Flushing”.
命令行格式Command-Line Format --innodb-adaptive-hash-index[={OFF|ON}]系统变量System Variable innodb_adaptive_hash_index范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF是否启用
InnoDB自适应哈希索引。根据您的工作负载,动态启用或禁用自适应哈希索引可能有助于提高查询性能。由于自适应哈希索引并非对所有工作负载都有效,应在启用和禁用的情况下使用真实工作负载进行基准测试。有关详细信息,请参见第 17.5.3 节,“自适应哈希索引”。Whether theInnoDBadaptive hash index is enabled or disabled. It may be desirable, depending on your workload, to dynamically enable or disable adaptive hash indexing to improve query performance. Because the adaptive hash index may not be useful for all workloads, conduct benchmarks with it both enabled and disabled, using realistic workloads. See Section 17.5.3, “Adaptive Hash Index” for details.此变量默认情况下是禁用的。您可以使用
SET GLOBAL语句修改此参数,而无需重启服务器。在运行时更改此设置需要具有足够权限来设置全局系统变量。请参见第 7.1.9.1 节,“系统变量权限”。您还可以在服务器启动时使用--innodb-adaptive-hash-index来启用它。This variable is disabled by default. You can modify this parameter using theSET GLOBALstatement, without restarting the server. Changing the setting at runtime requires privileges sufficient to set global system variables. See Section 7.1.9.1, “System Variable Privileges”. You can also use--innodb-adaptive-hash-indexat server startup to enable it.禁用自适应哈希索引会立即清空哈希表。哈希表清空的同时,正常操作可以继续进行,并且执行使用哈希表的查询将直接访问索引 B 树。当重新启用自适应哈希索引时,哈希表会在正常操作中重新填充。Disabling the adaptive hash index empties the hash table immediately. Normal operations can continue while the hash table is emptied, and executing queries that were using the hash table access the index B-trees directly instead. When the adaptive hash index is re-enabled, the hash table is populated again during normal operation.
在 MySQL 8.4 之前,此选项默认启用。Before MySQL 8.4, this option was enabled by default.
innodb_adaptive_hash_index_parts命令行格式Command-Line Format --innodb-adaptive-hash-index-parts=#系统变量System Variable innodb_adaptive_hash_index_parts范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 数字Numeric 默认值Default Value 8最小值Minimum Value 1最大值Maximum Value 512对自适应哈希索引搜索系统进行分区。每个索引绑定到特定分区,每个分区由单独的闩保护。Partitions the adaptive hash index search system. Each index is bound to a specific partition, with each partition protected by a separate latch.
自适应哈希索引搜索系统默认分为 8 个部分。最大设置为 512。The adaptive hash index search system is partitioned into 8 parts by default. The maximum setting is 512.
有关相关信息,请参见 第 17.5.3 节,“自适应哈希索引”。For related information, see Section 17.5.3, “Adaptive Hash Index”.
innodb_adaptive_max_sleep_delay命令行格式Command-Line Format --innodb-adaptive-max-sleep-delay=#系统变量System Variable innodb_adaptive_max_sleep_delay范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 150000最小值Minimum Value 0最大值Maximum Value 1000000单位Unit 微秒microseconds 允许
InnoDB根据当前工作负载自动调整innodb_thread_sleep_delay的值向上或向下。任何非零值都启用自动、动态调整innodb_thread_sleep_delay的功能,最大可达innodb_adaptive_max_sleep_delay参数中指定的值。该值表示微秒数。此选项在繁忙系统中非常有用,尤其是InnoDB线程超过 16 个的情况下。(实际上,它对拥有数百或数千个同时连接的 MySQL 系统最有价值。)PermitsInnoDBto automatically adjust the value ofinnodb_thread_sleep_delayup or down according to the current workload. Any nonzero value enables automated, dynamic adjustment of theinnodb_thread_sleep_delayvalue, up to the maximum value specified in theinnodb_adaptive_max_sleep_delayoption. The value represents the number of microseconds. This option can be useful in busy systems, with greater than 16InnoDBthreads. (In practice, it is most valuable for MySQL systems with hundreds or thousands of simultaneous connections.)欲了解更多信息,请参见第 17.8.4 节,“配置 InnoDB 的线程并发”。For more information, see Section 17.8.4, “Configuring Thread Concurrency for InnoDB”.
命令行格式Command-Line Format --innodb-autoextend-increment=#系统变量System Variable innodb_autoextend_increment范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 64最小值Minimum Value 1最大值Maximum Value 1000单位Unit 兆字节megabytes 当自动扩展的
InnoDB系统表空间 文件满时,用于扩展大小的增量(以兆字节为单位)。默认值为 64。有关相关信息,请参见 系统表空间数据文件配置 和 调整系统表空间大小。The increment size (in megabytes) for extending the size of an auto-extendingInnoDBsystem tablespace file when it becomes full. The default value is 64. For related information, see System Tablespace Data File Configuration, and Resizing the System Tablespace.innodb_autoextend_increment设置不影响 每表文件表空间 或 通用表空间 文件。这些文件无论innodb_autoextend_increment设置如何,都会自动扩展。初始扩展为小幅度,之后的扩展以 4MB 增量进行。Theinnodb_autoextend_incrementsetting does not affect file-per-table tablespace files or general tablespace files. These files are auto-extending regardless of theinnodb_autoextend_incrementsetting. The initial extensions are by small amounts, after which extensions occur in increments of 4MB.命令行格式Command-Line Format --innodb-autoinc-lock-mode=#系统变量System Variable innodb_autoinc_lock_mode范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2有效值Valid Values 012用于生成自增值的锁模式。允许的值为 0、1 或 2,分别对应传统、连续或交错模式。The lock mode to use for generating auto-increment values. Permissible values are 0, 1, or 2, for traditional, consecutive, or interleaved, respectively.
默认设置为 2(交错),以兼容基于行的复制。The default setting is 2 (interleaved), for compatibility with row-based replication.
有关每种锁模式的特性,请参见InnoDB AUTO_INCREMENT 锁模式。For the characteristics of each lock mode, see InnoDB AUTO_INCREMENT Lock Modes.
innodb_background_drop_list_empty命令行格式Command-Line Format --innodb-background-drop-list-empty[={OFF|ON}]系统变量System Variable innodb_background_drop_list_empty范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用
innodb_background_drop_list_empty调试选项可以通过延迟表创建直到后台删除列表为空来避免测试用例失败。例如,如果测试用例 A 将表t1放入后台删除列表中,则测试用例 B 将在后台删除列表为空之前等待,然后再创建表t1。Enabling theinnodb_background_drop_list_emptydebug option helps avoid test case failures by delaying table creation until the background drop list is empty. For example, if test case A places tablet1on the background drop list, test case B waits until the background drop list is empty before creating tablet1.命令行格式Command-Line Format --innodb-buffer-pool-chunk-size=#系统变量System Variable innodb_buffer_pool_chunk_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 134217728最小值Minimum Value 1048576最大值Maximum Value innodb_buffer_pool_size / innodb_buffer_pool_instances单位Unit 字节bytes innodb_buffer_pool_chunk_size定义了InnoDB缓冲池调整大小操作的块大小。innodb_buffer_pool_chunk_sizedefines the chunk size forInnoDBbuffer pool resizing operations.为了在调整大小操作期间避免复制所有缓冲池页面,操作是以 “块” 的方式执行的。默认情况下,
innodb_buffer_pool_chunk_size为 128MB(134217728 字节)。块中包含的页面数量取决于innodb_page_size的值。innodb_buffer_pool_chunk_size可以以 1MB(1048576 字节)为单位增加或减少。To avoid copying all buffer pool pages during resizing operations, the operation is performed in “chunks”. By default,innodb_buffer_pool_chunk_sizeis 128MB (134217728 bytes). The number of pages contained in a chunk depends on the value ofinnodb_page_size.innodb_buffer_pool_chunk_sizecan be increased or decreased in units of 1MB (1048576 bytes).更改
innodb_buffer_pool_chunk_size值时,适用以下条件:The following conditions apply when altering theinnodb_buffer_pool_chunk_sizevalue:如果
innodb_buffer_pool_chunk_size*innodb_buffer_pool_instances大于初始化缓冲池时的当前缓冲池大小,innodb_buffer_pool_chunk_size将被截断为innodb_buffer_pool_size/innodb_buffer_pool_instances。Ifinnodb_buffer_pool_chunk_size*innodb_buffer_pool_instancesis larger than the current buffer pool size when the buffer pool is initialized,innodb_buffer_pool_chunk_sizeis truncated toinnodb_buffer_pool_size/innodb_buffer_pool_instances.缓冲池大小必须始终等于或为
innodb_buffer_pool_chunk_size*innodb_buffer_pool_instances的倍数。如果您更改innodb_buffer_pool_chunk_size,innodb_buffer_pool_size会自动四舍五入为等于或为innodb_buffer_pool_chunk_size*innodb_buffer_pool_instances的倍数的值。此调整在缓冲池初始化时发生。Buffer pool size must always be equal to or a multiple ofinnodb_buffer_pool_chunk_size*innodb_buffer_pool_instances. If you alterinnodb_buffer_pool_chunk_size,innodb_buffer_pool_sizeis automatically rounded to a value that is equal to or a multiple ofinnodb_buffer_pool_chunk_size*innodb_buffer_pool_instances. The adjustment occurs when the buffer pool is initialized.
Important在更改
innodb_buffer_pool_chunk_size时应谨慎,因为更改此值可能会自动增加缓冲池的大小。在更改innodb_buffer_pool_chunk_size之前,请计算其对innodb_buffer_pool_size的影响,以确保最终的缓冲池大小是可接受的。Care should be taken when changinginnodb_buffer_pool_chunk_size, as changing this value can automatically increase the size of the buffer pool. Before changinginnodb_buffer_pool_chunk_size, calculate its effect oninnodb_buffer_pool_sizeto ensure that the resulting buffer pool size is acceptable.为了避免潜在的性能问题,chunk 的数量(
innodb_buffer_pool_size/innodb_buffer_pool_chunk_size)不应超过 1000。To avoid potential performance issues, the number of chunks (innodb_buffer_pool_size/innodb_buffer_pool_chunk_size) should not exceed 1000.innodb_buffer_pool_size变量是动态的,可以在服务器在线时调整缓冲池大小。然而,缓冲池大小必须等于或是innodb_buffer_pool_chunk_size*innodb_buffer_pool_instances的倍数,更改任意一个变量设置都需要重启服务器。Theinnodb_buffer_pool_sizevariable is dynamic, which permits resizing the buffer pool while the server is online. However, the buffer pool size must be equal to or a multiple ofinnodb_buffer_pool_chunk_size*innodb_buffer_pool_instances, and changing either of those variable settings requires restarting the server.有关更多信息,请参阅 第 17.8.3.1 节,“配置 InnoDB 缓冲池大小”。See Section 17.8.3.1, “Configuring InnoDB Buffer Pool Size” for more information.
命令行格式Command-Line Format --innodb-buffer-pool-debug[={OFF|ON}]系统变量System Variable innodb_buffer_pool_debug范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用此选项允许在缓冲池小于 1GB 时使用多个缓冲池实例,忽略在
innodb_buffer_pool_instances上施加的 1GB 最小缓冲池大小限制。只有在使用WITH_DEBUGCMake 选项编译了调试支持时,才提供innodb_buffer_pool_debug选项。Enabling this option permits multiple buffer pool instances when the buffer pool is less than 1GB in size, ignoring the 1GB minimum buffer pool size constraint imposed oninnodb_buffer_pool_instances. Theinnodb_buffer_pool_debugoption is only available if debugging support is compiled in using theWITH_DEBUGCMake option.innodb_buffer_pool_dump_at_shutdown命令行格式Command-Line Format --innodb-buffer-pool-dump-at-shutdown[={OFF|ON}]系统变量System Variable innodb_buffer_pool_dump_at_shutdown范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON指定在 MySQL 服务器关闭时是否记录缓存于
InnoDB缓冲池 的页面,以缩短下一次重启时的 预热 过程。通常与innodb_buffer_pool_load_at_startup配合使用。innodb_buffer_pool_dump_pct选项定义要转储的最近最常使用缓冲池页面的百分比。Specifies whether to record the pages cached in theInnoDBbuffer pool when the MySQL server is shut down, to shorten the warmup process at the next restart. Typically used in combination withinnodb_buffer_pool_load_at_startup. Theinnodb_buffer_pool_dump_pctoption defines the percentage of most recently used buffer pool pages to dump.innodb_buffer_pool_dump_at_shutdown和innodb_buffer_pool_load_at_startup默认均为启用。Bothinnodb_buffer_pool_dump_at_shutdownandinnodb_buffer_pool_load_at_startupare enabled by default.更多信息,请参阅 章节 17.8.3.6,“保存和恢复缓冲池状态”。For more information, see Section 17.8.3.6, “Saving and Restoring the Buffer Pool State”.
命令行格式Command-Line Format --innodb-buffer-pool-dump-now[={OFF|ON}]系统变量System Variable innodb_buffer_pool_dump_now范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF立即记录缓存于
InnoDB缓冲池 中的页。通常与innodb_buffer_pool_load_now结合使用。Immediately makes a record of pages cached in theInnoDBbuffer pool. Typically used in combination withinnodb_buffer_pool_load_now.启用
innodb_buffer_pool_dump_now会触发记录操作,但不会更改变量设置,该变量始终保持OFF或0。触发转储后,要查看缓冲池转储状态,请查询Innodb_buffer_pool_dump_status变量。Enablinginnodb_buffer_pool_dump_nowtriggers the recording action but does not alter the variable setting, which always remainsOFFor0. To view buffer pool dump status after triggering a dump, query theInnodb_buffer_pool_dump_statusvariable.启用
innodb_buffer_pool_dump_now会触发转储操作,但不会更改变量设置,该变量始终保持OFF或0。触发转储后,要查看缓冲池转储状态,请查询Innodb_buffer_pool_dump_status变量。Enablinginnodb_buffer_pool_dump_nowtriggers the dump action but does not alter the variable setting, which always remainsOFFor0. To view buffer pool dump status after triggering a dump, query theInnodb_buffer_pool_dump_statusvariable.更多信息,请参阅 章节 17.8.3.6,“保存和恢复缓冲池状态”。For more information, see Section 17.8.3.6, “Saving and Restoring the Buffer Pool State”.
命令行格式Command-Line Format --innodb-buffer-pool-dump-pct=#系统变量System Variable innodb_buffer_pool_dump_pct范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 25最小值Minimum Value 1最大值Maximum Value 100指定每个缓冲池中最近使用的页面所占的百分比,以便读取和转储。范围是 1 到 100。默认值为 25。例如,如果有 4 个缓冲池,每个缓冲池有 100 个页面,并且
innodb_buffer_pool_dump_pct设置为 25,则每个缓冲池最近使用的 25 个页面将被转储。Specifies the percentage of the most recently used pages for each buffer pool to read out and dump. The range is 1 to 100. The default value is 25. For example, if there are 4 buffer pools with 100 pages each, andinnodb_buffer_pool_dump_pctis set to 25, the 25 most recently used pages from each buffer pool are dumped.命令行格式Command-Line Format --innodb-buffer-pool-filename=file_name系统变量System Variable innodb_buffer_pool_filename范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 文件名File name 默认值Default Value ib_buffer_pool指定保存由
innodb_buffer_pool_dump_at_shutdown或innodb_buffer_pool_dump_now生成的表空间 ID 和页面 ID 列表的文件名称。表空间 ID 和页面 ID 的保存格式如下:space, page_id。默认情况下,该文件名为ib_buffer_pool,位于InnoDB数据目录中。非默认位置必须相对于数据目录指定。Specifies the name of the file that holds the list of tablespace IDs and page IDs produced byinnodb_buffer_pool_dump_at_shutdownorinnodb_buffer_pool_dump_now. Tablespace IDs and page IDs are saved in the following format:space, page_id. By default, the file is namedib_buffer_pooland is located in theInnoDBdata directory. A non-default location must be specified relative to the data directory.可以在运行时使用
SET语句指定文件名:A file name can be specified at runtime, using aSETstatement:SET GLOBAL innodb_buffer_pool_filename=
'file_name';您也可以在启动时、在启动字符串中或在 MySQL 配置文件中指定文件名。启动时指定文件名时,该文件必须存在,否则
InnoDB会返回启动错误,指示没有此类文件或目录。You can also specify a file name at startup, in a startup string or MySQL configuration file. When specifying a file name at startup, the file must exist orInnoDBreturns a startup error indicating that there is no such file or directory.更多信息,请参阅 章节 17.8.3.6,“保存和恢复缓冲池状态”。For more information, see Section 17.8.3.6, “Saving and Restoring the Buffer Pool State”.
innodb_buffer_pool_in_core_file命令行格式Command-Line Format --innodb-buffer-pool-in-core-file[={OFF|ON}]系统变量System Variable innodb_buffer_pool_in_core_file范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF禁用(默认)
innodb_buffer_pool_in_core_file变量可以通过排除InnoDB缓冲池页来减小核心文件的大小。Disabling (default) theinnodb_buffer_pool_in_core_filevariable reduces the size of core files by excludingInnoDBbuffer pool pages.要使用此变量,必须启用
core_file变量,要禁用此选项,操作系统必须支持MADV_DONTDUMP对madvise()的非 POSIX 扩展,该功能在 Linux 3.4 及更高版本中受支持。有关更多信息,请参阅 第 17.8.3.7 节,“从核心文件中排除或包含缓冲池页”。To use this variable, thecore_filevariable must be enabled, and to disable this option the operating system must support theMADV_DONTDUMPnon-POSIX extension tomadvise(), which is supported in Linux 3.4 and later. For more information, see Section 17.8.3.7, “Excluding or Including Buffer Pool Pages from Core Files”.在支持
MADV_DONTDUMP的系统上默认禁用,通常仅限于 Linux,而不包括 macOS 或 Windows。This is disabled by default on systems that supportMADV_DONTDUMP, which is typically only Linux and not macOS or Windows.在 MySQL 8.4 之前,此选项默认启用。Before MySQL 8.4, this option was enabled by default.
命令行格式Command-Line Format --innodb-buffer-pool-instances=#系统变量System Variable innodb_buffer_pool_instances范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value see descriptionsee description最小值Minimum Value 1最大值Maximum Value 64InnoDB缓冲池被划分的区域数量。对于拥有多 GB 范围缓冲池的系统,将缓冲池划分为独立实例可以提高并发性,因为不同线程在读写缓存页面时的争用会减少。存储在缓冲池中或从缓冲池读取的每个页面会随机分配给其中一个缓冲池实例,使用哈希函数。每个缓冲池实例管理其自己的空闲列表、刷新列表、LRU以及与缓冲池相关的所有其他数据结构,并由其自己的缓冲池互斥锁保护。The number of regions that theInnoDBbuffer pool is divided into. For systems with buffer pools in the multi-gigabyte range, dividing the buffer pool into separate instances can improve concurrency, by reducing contention as different threads read and write to cached pages. Each page that is stored in or read from the buffer pool is assigned to one of the buffer pool instances randomly, using a hashing function. Each buffer pool instance manages its own free lists, flush lists, LRUs, and all other data structures connected to a buffer pool, and is protected by its own buffer pool mutex.总缓冲池大小在所有缓冲池实例之间分配。为了获得最佳效率,请指定
innodb_buffer_pool_instances和innodb_buffer_pool_size的组合,以使每个缓冲池实例至少为 1GB。The total buffer pool size is divided among all the buffer pools. For best efficiency, specify a combination ofinnodb_buffer_pool_instancesandinnodb_buffer_pool_sizeso that each buffer pool instance is at least 1GB.如果
innodb_buffer_pool_size<= 1 GiB,则默认的innodb_buffer_pool_instances值为 1。Ifinnodb_buffer_pool_size<= 1 GiB, then the defaultinnodb_buffer_pool_instancesvalue is 1.如果
innodb_buffer_pool_size> 1 GiB,则默认的innodb_buffer_pool_instances值是在以下两个计算提示中取最小值,范围为 1-64:Ifinnodb_buffer_pool_size> 1 GiB, then the defaultinnodb_buffer_pool_instancesvalue is the minimum value from the following two calculated hints, within a range of 1-64:缓冲池提示:计算为 (
innodb_buffer_pool_size/innodb_buffer_pool_chunk_size) 的一半Buffer pool hint: calculated as 1/2 of (innodb_buffer_pool_size/innodb_buffer_pool_chunk_size)CPU 提示:计算为可用逻辑处理器数量的四分之一CPU hint: calculated as 1/4 of available logical processors
有关信息,请参阅 第 17.8.3.1 节,“配置 InnoDB 缓冲池大小”。For related information, see Section 17.8.3.1, “Configuring InnoDB Buffer Pool Size”.
命令行格式Command-Line Format --innodb-buffer-pool-load-abort[={OFF|ON}]系统变量System Variable innodb_buffer_pool_load_abort范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF中断恢复
InnoDBbuffer pool 内容的过程,该过程由innodb_buffer_pool_load_at_startup或innodb_buffer_pool_load_now触发。Interrupts the process of restoringInnoDBbuffer pool contents triggered byinnodb_buffer_pool_load_at_startuporinnodb_buffer_pool_load_now.启用
innodb_buffer_pool_load_abort会触发中止操作,但不会更改变量设置,该变量始终保持OFF或0。要在触发中止操作后查看缓冲池加载状态,请查询Innodb_buffer_pool_load_status变量。Enablinginnodb_buffer_pool_load_aborttriggers the abort action but does not alter the variable setting, which always remainsOFFor0. To view buffer pool load status after triggering an abort action, query theInnodb_buffer_pool_load_statusvariable.更多信息,请参阅 章节 17.8.3.6,“保存和恢复缓冲池状态”。For more information, see Section 17.8.3.6, “Saving and Restoring the Buffer Pool State”.
innodb_buffer_pool_load_at_startup命令行格式Command-Line Format --innodb-buffer-pool-load-at-startup[={OFF|ON}]系统变量System Variable innodb_buffer_pool_load_at_startup范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON指定在 MySQL 服务器启动时,
InnoDB缓冲池 会自动通过加载之前持有的相同页面来完成 热身。通常与innodb_buffer_pool_dump_at_shutdown配合使用。Specifies that, on MySQL server startup, theInnoDBbuffer pool is automatically warmed up by loading the same pages it held at an earlier time. Typically used in combination withinnodb_buffer_pool_dump_at_shutdown.innodb_buffer_pool_dump_at_shutdown和innodb_buffer_pool_load_at_startup默认均为启用。Bothinnodb_buffer_pool_dump_at_shutdownandinnodb_buffer_pool_load_at_startupare enabled by default.更多信息,请参阅 章节 17.8.3.6,“保存和恢复缓冲池状态”。For more information, see Section 17.8.3.6, “Saving and Restoring the Buffer Pool State”.
命令行格式Command-Line Format --innodb-buffer-pool-load-now[={OFF|ON}]系统变量System Variable innodb_buffer_pool_load_now范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF立即通过加载数据页而无需等待服务器重启来预热
InnoDB缓冲池。这在基准测试期间将缓存内存恢复到已知状态或在运行报表或维护查询后让 MySQL 服务器准备恢复其正常工作负载时可能非常有用。Immediately warms up theInnoDBbuffer pool by loading data pages without waiting for a server restart. Can be useful to bring cache memory back to a known state during benchmarking or to ready the MySQL server to resume its normal workload after running queries for reports or maintenance.启用
innodb_buffer_pool_load_now会触发加载操作,但不会更改变量设置,该变量始终保持OFF或0。要在触发加载后查看缓冲池加载进度,请查询Innodb_buffer_pool_load_status变量。Enablinginnodb_buffer_pool_load_nowtriggers the load action but does not alter the variable setting, which always remainsOFFor0. To view buffer pool load progress after triggering a load, query theInnodb_buffer_pool_load_statusvariable.更多信息,请参阅 章节 17.8.3.6,“保存和恢复缓冲池状态”。For more information, see Section 17.8.3.6, “Saving and Restoring the Buffer Pool State”.
命令行格式Command-Line Format --innodb-buffer-pool-size=#系统变量System Variable innodb_buffer_pool_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 134217728最小值Minimum Value 5242880最大值(64 位平台)Maximum Value (64-bit platforms) 2**64-1最大值(32 位平台)Maximum Value (32-bit platforms) 2**32-1单位Unit 字节bytes 缓冲池的字节大小,即
InnoDB缓存表和索引数据的内存区域。默认值为 134217728 字节(128MB)。最大值取决于 CPU 架构;在 32 位系统上最大值为 4294967295(232-1),在 64 位系统上最大值为 18446744073709551615(264-1)。在 32 位系统上,CPU 架构和操作系统可能会限制比标称最大值更低的实际最大值。当缓冲池的大小大于 1GB 时,将innodb_buffer_pool_instances设置为大于 1 的值可以提高繁忙服务器的可扩展性。The size in bytes of the buffer pool, the memory area whereInnoDBcaches table and index data. The default value is 134217728 bytes (128MB). The maximum value depends on the CPU architecture; the maximum is 4294967295 (232-1) on 32-bit systems and 18446744073709551615 (264-1) on 64-bit systems. On 32-bit systems, the CPU architecture and operating system may impose a lower practical maximum size than the stated maximum. When the size of the buffer pool is greater than 1GB, settinginnodb_buffer_pool_instancesto a value greater than 1 can improve the scalability on a busy server.更大的缓冲池可以减少访问同一表数据多次时的磁盘 I/O。在专用数据库服务器上,你可以将缓冲池大小设置为机器物理内存的 80%。在配置缓冲池大小时,请注意以下潜在问题,并准备在必要时缩减缓冲池的大小。A larger buffer pool requires less disk I/O to access the same table data more than once. On a dedicated database server, you might set the buffer pool size to 80% of the machine's physical memory size. Be aware of the following potential issues when configuring buffer pool size, and be prepared to scale back the size of the buffer pool if necessary.
争夺物理内存可能导致操作系统发生分页。Competition for physical memory can cause paging in the operating system.
InnoDB为缓冲区和控制结构保留额外的内存,因此分配的总空间大约比指定的缓冲池大小多 10%。InnoDBreserves additional memory for buffers and control structures, so that the total allocated space is approximately 10% greater than the specified buffer pool size.缓冲池的地址空间必须是连续的,这在 Windows 系统上可能是一个问题,因为 DLL 会在特定地址加载。Address space for the buffer pool must be contiguous, which can be an issue on Windows systems with DLLs that load at specific addresses.
初始化缓冲池的时间大致与其大小成正比。在缓冲池较大的实例上,初始化时间可能会很长。为了减少初始化时间,你可以在服务器关闭时保存缓冲池状态,并在服务器启动时恢复它。请参见 第 17.8.3.6 节,“保存和恢复缓冲池状态”。The time to initialize the buffer pool is roughly proportional to its size. On instances with large buffer pools, initialization time might be significant. To reduce the initialization period, you can save the buffer pool state at server shutdown and restore it at server startup. See Section 17.8.3.6, “Saving and Restoring the Buffer Pool State”.
当你增加或减少缓冲池大小时,该操作会分块执行。块大小由
innodb_buffer_pool_chunk_size变量定义,默认值为 128 MB。When you increase or decrease buffer pool size, the operation is performed in chunks. Chunk size is defined by theinnodb_buffer_pool_chunk_sizevariable, which has a default of 128 MB.缓冲池大小必须始终等于或是
innodb_buffer_pool_chunk_size*innodb_buffer_pool_instances的整数倍。如果你将缓冲池大小更改为不等于或不是innodb_buffer_pool_chunk_size*innodb_buffer_pool_instances的整数倍的值,缓冲池大小会自动调整为等于或是innodb_buffer_pool_chunk_size*innodb_buffer_pool_instances的整数倍的值。Buffer pool size must always be equal to or a multiple ofinnodb_buffer_pool_chunk_size*innodb_buffer_pool_instances. If you alter the buffer pool size to a value that is not equal to or a multiple ofinnodb_buffer_pool_chunk_size*innodb_buffer_pool_instances, buffer pool size is automatically adjusted to a value that is equal to or a multiple ofinnodb_buffer_pool_chunk_size*innodb_buffer_pool_instances.innodb_buffer_pool_size可以动态设置,这允许您在不重启服务器的情况下调整缓冲池大小。Innodb_buffer_pool_resize_status状态变量报告在线缓冲池调整操作的状态。更多信息请参见 第 17.8.3.1 节,“配置 InnoDB 缓冲池大小”。innodb_buffer_pool_sizecan be set dynamically, which allows you to resize the buffer pool without restarting the server. TheInnodb_buffer_pool_resize_statusstatus variable reports the status of online buffer pool resizing operations. See Section 17.8.3.1, “Configuring InnoDB Buffer Pool Size” for more information.如果服务器使用
--innodb-dedicated-server启动,那么innodb_buffer_pool_size的值会在未显式定义时自动设置。更多信息请参见 第 17.8.12 节,“为专用 MySQL 服务器启用自动 InnoDB 配置”。If the server is started with--innodb-dedicated-server, the value ofinnodb_buffer_pool_sizeis set automatically if it is not explicitly defined. For more information, see Section 17.8.12, “Enabling Automatic InnoDB Configuration for a Dedicated MySQL Server”.命令行格式Command-Line Format --innodb-change-buffer-max-size=#系统变量System Variable innodb_change_buffer_max_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 25最小值Minimum Value 0最大值Maximum Value 50InnoDB变更缓冲区的最大大小,占 缓冲池 总大小的百分比。对于具有大量插入、更新和删除活动的 MySQL 服务器,你可能会增加该值;对于用于报告且数据不变的 MySQL 服务器,你可能会减少该值。更多信息请参见 第 17.5.2 节,“变更缓冲区”。有关一般 I/O 调优建议,请参见 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。Maximum size for theInnoDBchange buffer, as a percentage of the total size of the buffer pool. You might increase this value for a MySQL server with heavy insert, update, and delete activity, or decrease it for a MySQL server with unchanging data used for reporting. For more information, see Section 17.5.2, “Change Buffer”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.命令行格式Command-Line Format --innodb-change-buffering=value系统变量System Variable innodb_change_buffering范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value nonenone有效值Valid Values nonenoneinsertsdeleteschangespurgesallall是否启用
InnoDB的 变更缓冲,这是一种优化方法,将写入操作延迟到辅助索引,以便 I/O 操作可以顺序执行。允许的值在下表中描述,也可以用数字指定值。WhetherInnoDBperforms change buffering, an optimization that delays write operations to secondary indexes so that the I/O operations can be performed sequentially. Permitted values are described in the following table. Values may also be specified numerically.表 17.24 innodb_change_buffering 的允许值Table 17.24 Permitted Values for innodb_change_buffering
价值Value 数值Numeric Value 说明Description nonenone0默认值。不缓冲任何操作。Default. Do not buffer any operations. inserts1缓冲插入操作。Buffer insert operations. deletes2缓冲区删除标记操作;严格来说,是在清理操作期间为稍后删除而标记索引记录的写入。Buffer delete marking operations; strictly speaking, the writes that mark index records for later deletion during a purge operation. changes3缓冲区插入和删除标记操作。Buffer inserts and delete-marking operations. purges4缓冲区在后台进行的物理删除操作。Buffer the physical deletion operations that happen in the background. allall5缓冲区插入、删除标记操作和清理操作。Buffer inserts, delete-marking operations, and purges. 在 MySQL 8.4 之前,默认值是
all。Before MySQL 8.4, the default value wasall.更多信息,请参见 第 17.5.2 节,“变更缓冲”。有关一般 I/O 调优建议,请参见 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。For more information, see Section 17.5.2, “Change Buffer”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.
命令行格式Command-Line Format --innodb-change-buffering-debug=#系统变量System Variable innodb_change_buffering_debug范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 2设置
InnoDB变更缓冲的调试标志。值为 1 强制所有更改进入变更缓冲。值为 2 在合并时会导致意外退出。默认值 0 表示未设置变更缓冲调试标志。此选项仅在使用WITH_DEBUGCMake 选项编译的调试支持中可用。Sets a debug flag forInnoDBchange buffering. A value of 1 forces all changes to the change buffer. A value of 2 causes an unexpected exit at merge. A default value of 0 indicates that the change buffering debug flag is not set. This option is only available when debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-checkpoint-disabled[={OFF|ON}]系统变量System Variable innodb_checkpoint_disabled范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF这是一个调试选项,只用于专家调试。它会禁用检查点,以便每次有意的服务器退出都会触发
InnoDB恢复。它只应在短时间内启用,通常是在执行写入 redo 日志条目的 DML 操作之前,以便在服务器退出后需要恢复。仅当使用WITH_DEBUGCMake 选项编译了调试支持时,此选项才可用。This is a debug option that is only intended for expert debugging use. It disables checkpoints so that a deliberate server exit always initiatesInnoDBrecovery. It should only be enabled for a short interval, typically before running DML operations that write redo log entries that would require recovery following a server exit. This option is only available if debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-checksum-algorithm=value系统变量System Variable innodb_checksum_algorithm范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value crc32有效值Valid Values crc32strict_crc32innodbstrict_innodbnonenonestrict_none指定如何生成和验证存储在
InnoDB表空间 磁盘块中的 校验和。innodb_checksum_algorithm的默认值为crc32。Specifies how to generate and verify the checksum stored in the disk blocks ofInnoDBtablespaces. The default value forinnodb_checksum_algorithmiscrc32.值
innodb与早期版本的 MySQL 向后兼容。值crc32使用一种算法,可以更快地计算每个修改块的校验和,并检查每次磁盘读取的校验和。它一次扫描 64 位的块,比innodb校验和算法扫描 8 位块的速度更快。值none在校验和字段中写入一个常量值,而不是基于块数据计算值。表空间中的块可以使用旧的、新的和无校验和的混合值,并随着数据的修改逐步更新;一旦表空间中的块被修改为使用crc32算法,则关联的表将无法被早期版本的 MySQL 读取。The valueinnodbis backward-compatible with earlier versions of MySQL. The valuecrc32uses an algorithm that is faster to compute the checksum for every modified block, and to check the checksums for each disk read. It scans blocks 64 bits at a time, which is faster than theinnodbchecksum algorithm, which scans blocks 8 bits at a time. The valuenonewrites a constant value in the checksum field rather than computing a value based on the block data. The blocks in a tablespace can use a mix of old, new, and no checksum values, being updated gradually as the data is modified; once blocks in a tablespace are modified to use thecrc32algorithm, the associated tables cannot be read by earlier versions of MySQL.校验和算法的严格形式会在表空间中遇到有效但不匹配的校验和值时报告错误。建议仅在新实例中使用严格设置,以首次设置表空间。严格设置速度稍快一些,因为它们在磁盘读取期间无需计算所有校验和值。The strict form of a checksum algorithm reports an error if it encounters a valid but non-matching checksum value in a tablespace. It is recommended that you only use strict settings in a new instance, to set up tablespaces for the first time. Strict settings are somewhat faster, because they do not need to compute all checksum values during disk reads.
下表显示了
none、innodb和crc32选项值及其严格对应值之间的差异。none、innodb和crc32会将指定类型的校验和值写入每个数据块,但为了兼容性,在读取操作时验证数据块时也接受其他校验值。严格设置也接受有效的校验值,但在遇到有效但不匹配的校验值时会打印错误消息。如果实例中所有InnoDB数据文件都是在相同的innodb_checksum_algorithm值下创建的,使用严格形式可以加快验证速度。The following table shows the difference between thenone,innodb, andcrc32option values, and their strict counterparts.none,innodb, andcrc32write the specified type of checksum value into each data block, but for compatibility accept other checksum values when verifying a block during a read operation. Strict settings also accept valid checksum values but print an error message when a valid non-matching checksum value is encountered. Using the strict form can make verification faster if allInnoDBdata files in an instance are created under an identicalinnodb_checksum_algorithmvalue.表 17.25 允许的 innodb_checksum_algorithm 值Table 17.25 Permitted innodb_checksum_algorithm Values
价值Value 生成的校验值(写入时)Generated checksum (when writing) 允许的校验值(读取时)Permitted checksums (when reading) 无none 一个常数值。A constant number. none、innodb或crc32生成的任何校验值。Any of the checksums generated bynone,innodb, orcrc32.innodb 使用 InnoDB的原始算法通过软件计算的校验值。A checksum calculated in software, using the original algorithm fromInnoDB.none、innodb或crc32生成的任何校验值。Any of the checksums generated bynone,innodb, orcrc32.crc32 使用 crc32算法计算的校验值,可能使用硬件加速。A checksum calculated using thecrc32algorithm, possibly done with a hardware assist.none、innodb或crc32生成的任何校验值。Any of the checksums generated bynone,innodb, orcrc32.strict_none 一个常数值A constant number none、innodb或crc32生成的任何校验值。如果遇到有效但不匹配的校验值,InnoDB会打印错误消息。Any of the checksums generated bynone,innodb, orcrc32.InnoDBprints an error message if a valid but non-matching checksum is encountered.strict_innodb 使用 InnoDB的原始算法通过软件计算的校验值。A checksum calculated in software, using the original algorithm fromInnoDB.none、innodb或crc32生成的任何校验值。如果遇到有效但不匹配的校验值,InnoDB会打印错误消息。Any of the checksums generated bynone,innodb, orcrc32.InnoDBprints an error message if a valid but non-matching checksum is encountered.strict_crc32 使用 crc32算法计算的校验值,可能使用硬件加速。A checksum calculated using thecrc32algorithm, possibly done with a hardware assist.none、innodb或crc32生成的任何校验值。如果遇到有效但不匹配的校验值,InnoDB会打印错误消息。Any of the checksums generated bynone,innodb, orcrc32.InnoDBprints an error message if a valid but non-matching checksum is encountered.命令行格式Command-Line Format --innodb-cmp-per-index-enabled[={OFF|ON}]系统变量System Variable innodb_cmp_per_index_enabled范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF在信息模式的
INNODB_CMP_PER_INDEX表中启用每个索引的压缩相关统计信息。由于收集这些统计信息可能开销较大,仅在开发、测试或复制实例上进行与InnoDB压缩 表相关的性能调优时启用此选项。Enables per-index compression-related statistics in the Information SchemaINNODB_CMP_PER_INDEXtable. Because these statistics can be expensive to gather, only enable this option on development, test, or replica instances during performance tuning related toInnoDBcompressed tables.更多信息,请参阅 第 28.4.8 节,“INFORMATION_SCHEMA INNODB_CMP_PER_INDEX 和 INNODB_CMP_PER_INDEX_RESET 表” 和 第 17.9.1.4 节,“运行时监控 InnoDB 表压缩”。For more information, see Section 28.4.8, “The INFORMATION_SCHEMA INNODB_CMP_PER_INDEX and INNODB_CMP_PER_INDEX_RESET Tables”, and Section 17.9.1.4, “Monitoring InnoDB Table Compression at Runtime”.
命令行格式Command-Line Format --innodb-commit-concurrency=#系统变量System Variable innodb_commit_concurrency范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 1000可以同时 提交 的 线程数。值为 0(默认值)允许任意数量的 事务 同时提交。The number of threads that can commit at the same time. A value of 0 (the default) permits any number of transactions to commit simultaneously.
innodb_commit_concurrency的值不能在运行时从零更改为非零,或从非零更改为零。值可以从一个非零值更改为另一个非零值。The value ofinnodb_commit_concurrencycannot be changed at runtime from zero to nonzero or vice versa. The value can be changed from one nonzero value to another.命令行格式Command-Line Format --innodb-compress-debug=value--innodb-compress-debug=value系统变量System Variable innodb_compress_debug范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value nonenone有效值Valid Values nonenonezliblz4lz4hc使用指定的压缩算法压缩所有表,而无需为每个表定义
COMPRESSION属性。仅当使用WITH_DEBUGCMake 选项编译了调试支持时,此选项才可用。Compresses all tables using a specified compression algorithm without having to define aCOMPRESSIONattribute for each table. This option is only available if debugging support is compiled in using theWITH_DEBUGCMake option.有关相关信息,请参阅 第 17.9.2 节,“InnoDB 页压缩”。For related information, see Section 17.9.2, “InnoDB Page Compression”.
innodb_compression_failure_threshold_pct命令行格式Command-Line Format --innodb-compression-failure-threshold-pct=#系统变量System Variable innodb_compression_failure_threshold_pct范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 5最小值Minimum Value 0最大值Maximum Value 100定义表的压缩失败率阈值,以百分比表示,当达到该阈值时,MySQL 开始在压缩的页面中添加填充,以避免昂贵的压缩失败。当超过此阈值时,MySQL 开始在每个新压缩页面中留出额外的空闲空间,并动态调整空闲空间的数量,直到达到
innodb_compression_pad_pct_max指定的页面大小百分比。值为零会禁用监控压缩效率并动态调整填充量的机制。Defines the compression failure rate threshold for a table, as a percentage, at which point MySQL begins adding padding within compressed pages to avoid expensive compression failures. When this threshold is passed, MySQL begins to leave additional free space within each new compressed page, dynamically adjusting the amount of free space up to the percentage of page size specified byinnodb_compression_pad_pct_max. A value of zero disables the mechanism that monitors compression efficiency and dynamically adjusts the padding amount.有关更多信息,请参阅 第 17.9.1.6 节,“用于 OLTP 工作负载的压缩”。For more information, see Section 17.9.1.6, “Compression for OLTP Workloads”.
命令行格式Command-Line Format --innodb-compression-level=#系统变量System Variable innodb_compression_level范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 6最小值Minimum Value 0最大值Maximum Value 9指定用于
InnoDB压缩 表和索引的 zlib 压缩级别。较高的值可以让你在存储设备上存入更多数据,但会增加压缩时的 CPU 开销。较低的值可以在存储空间不紧张或者预期数据不容易压缩时减少 CPU 开销。Specifies the level of zlib compression to use forInnoDBcompressed tables and indexes. A higher value lets you fit more data onto a storage device, at the expense of more CPU overhead during compression. A lower value lets you reduce CPU overhead when storage space is not critical, or you expect the data is not especially compressible.有关更多信息,请参阅 第 17.9.1.6 节,“用于 OLTP 工作负载的压缩”。For more information, see Section 17.9.1.6, “Compression for OLTP Workloads”.
innodb_compression_pad_pct_max命令行格式Command-Line Format --innodb-compression-pad-pct-max=#系统变量System Variable innodb_compression_pad_pct_max范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 50最小值Minimum Value 0最大值Maximum Value 75指定每个压缩页面中可以保留为空闲空间的最大百分比,以便在更新压缩表或索引并可能重新压缩数据时,为重新组织页面内的数据和修改日志留出空间。仅当
innodb_compression_failure_threshold_pct设置为非零值,并且压缩失败的比率超过临界点时才适用。Specifies the maximum percentage that can be reserved as free space within each compressed page, allowing room to reorganize the data and modification log within the page when a compressed table or index is updated and the data might be recompressed. Only applies wheninnodb_compression_failure_threshold_pctis set to a nonzero value, and the rate of compression failures passes the cutoff point.有关更多信息,请参阅 第 17.9.1.6 节,“用于 OLTP 工作负载的压缩”。For more information, see Section 17.9.1.6, “Compression for OLTP Workloads”.
命令行格式Command-Line Format --innodb-concurrency-tickets=#系统变量System Variable innodb_concurrency_tickets范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 5000最小值Minimum Value 1最大值Maximum Value 4294967295确定可以同时进入
InnoDB的线程数量。如果线程数已经达到并发限制,当线程尝试进入InnoDB时,它会被放入队列中。当线程被允许进入InnoDB时,它会获得与innodb_concurrency_tickets值相等的“票”数量,线程可以在使用完票之前自由地进入和离开InnoDB。在此之后,下次线程尝试进入InnoDB时,它将再次受到并发检查(以及可能的排队)限制。默认值为 5000。Determines the number of threads that can enterInnoDBconcurrently. A thread is placed in a queue when it tries to enterInnoDBif the number of threads has already reached the concurrency limit. When a thread is permitted to enterInnoDB, it is given a number of “ tickets” equal to the value ofinnodb_concurrency_tickets, and the thread can enter and leaveInnoDBfreely until it has used up its tickets. After that point, the thread again becomes subject to the concurrency check (and possible queuing) the next time it tries to enterInnoDB. The default value is 5000.当
innodb_concurrency_tickets的值较小时,只需要处理少量行的小事务可以与处理大量行的大事务公平竞争。较小的innodb_concurrency_tickets值的缺点是,大事务必须多次循环队列才能完成其操作,这会延长完成任务所需的时间。With a smallinnodb_concurrency_ticketsvalue, small transactions that only need to process a few rows compete fairly with larger transactions that process many rows. The disadvantage of a smallinnodb_concurrency_ticketsvalue is that large transactions must loop through the queue many times before they can complete, which extends the amount of time required to complete their task.当
innodb_concurrency_tickets值较大时,大型事务花在等待队列末端位置的时间较少(由innodb_thread_concurrency控制),花在检索行的时间更多。大型事务完成其任务所需通过队列的次数也较少。innodb_concurrency_tickets值过大的缺点是,当许多大型事务同时运行时,可能会导致较小的事务被饿死,因为它们在执行前需要等待更长时间。With a largeinnodb_concurrency_ticketsvalue, large transactions spend less time waiting for a position at the end of the queue (controlled byinnodb_thread_concurrency) and more time retrieving rows. Large transactions also require fewer trips through the queue to complete their task. The disadvantage of a largeinnodb_concurrency_ticketsvalue is that too many large transactions running at the same time can starve smaller transactions by making them wait a longer time before executing.当
innodb_thread_concurrency值非零时,你可能需要调高或调低innodb_concurrency_tickets的值,以找到大事务和小事务之间的最佳平衡。SHOW ENGINE INNODB STATUS报告显示在队列当前轮次中,一个执行中的事务剩余的票数。也可以从信息模式INNODB_TRX表的TRX_CONCURRENCY_TICKETS列获得此数据。With a nonzeroinnodb_thread_concurrencyvalue, you may need to adjust theinnodb_concurrency_ticketsvalue up or down to find the optimal balance between larger and smaller transactions. TheSHOW ENGINE INNODB STATUSreport shows the number of tickets remaining for an executing transaction in its current pass through the queue. This data may also be obtained from theTRX_CONCURRENCY_TICKETScolumn of the Information SchemaINNODB_TRXtable.欲了解更多信息,请参见第 17.8.4 节,“配置 InnoDB 的线程并发”。For more information, see Section 17.8.4, “Configuring Thread Concurrency for InnoDB”.
命令行格式Command-Line Format --innodb-data-file-path=file_name系统变量System Variable innodb_data_file_path范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value ibdata1:12M:autoextend定义
InnoDB系统表空间数据文件的名称、大小和属性。如果未为innodb_data_file_path指定值,默认行为是创建一个自动扩展的数据文件,略大于 12MB,名为ibdata1。Defines the name, size, and attributes ofInnoDBsystem tablespace data files. If you do not specify a value forinnodb_data_file_path, the default behavior is to create a single auto-extending data file, slightly larger than 12MB, namedibdata1.数据文件规范的完整语法包括文件名、文件大小、
autoextend属性和max属性:The full syntax for a data file specification includes the file name, file size,autoextendattribute, andmaxattribute:file_name:file_size[:autoextend[:max:max_file_size]]文件大小通过在数值后添加
K、M或G来指定千字节、兆字节或千兆字节。如果以千字节指定数据文件大小,请使用 1024 的倍数。否则,KB 值将四舍五入到最接近的兆字节 (MB) 边界。文件大小之和至少必须略大于 12MB。File sizes are specified in kilobytes, megabytes, or gigabytes by appendingK,MorGto the size value. If specifying the data file size in kilobytes, do so in multiples of 1024. Otherwise, KB values are rounded to nearest megabyte (MB) boundary. The sum of file sizes must be, at a minimum, slightly larger than 12MB.有关其他配置信息,请参见 系统表空间数据文件配置。有关调整大小的说明,请参见 调整系统表空间大小。For additional configuration information, see System Tablespace Data File Configuration. For resizing instructions, see Resizing the System Tablespace.
命令行格式Command-Line Format --innodb-data-home-dir=dir_name--innodb-data-home-dir=dir_name系统变量System Variable innodb_data_home_dir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name 目录路径的公共部分,用于
InnoDB系统表空间 数据文件。默认值是 MySQL 的data目录。除非该设置被定义为绝对路径,否则该设置会与innodb_data_file_path设置拼接。The common part of the directory path forInnoDBsystem tablespace data files. The default value is the MySQLdatadirectory. The setting is concatenated with theinnodb_data_file_pathsetting, unless that setting is defined with an absolute path.在为
innodb_data_home_dir指定值时,需要在末尾加斜杠。例如:A trailing slash is required when specifying a value forinnodb_data_home_dir. For example:[mysqld] innodb_data_home_dir = /path/to/myibdata/
此设置不会影响 file-per-table 表空间的位置。This setting does not affect the location of file-per-table tablespaces.
有关相关信息,请参见 第 17.8.1 节,“InnoDB 启动配置”。For related information, see Section 17.8.1, “InnoDB Startup Configuration”.
命令行格式Command-Line Format --innodb-ddl-buffer-size=#系统变量System Variable innodb_ddl_buffer_size范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 1048576最小值Minimum Value 65536最大值Maximum Value 4294967295单位Unit 字节bytes 定义了 DDL 操作的最大缓冲区大小。默认设置为 1048576 字节(约 1 MB)。适用于创建或重建辅助索引的在线 DDL 操作。请参见 第 17.12.4 节,“在线 DDL 内存管理”。每个 DDL 线程的最大缓冲区大小为最大缓冲区大小除以 DDL 线程数 (
innodb_ddl_buffer_size/innodb_ddl_threads)。Defines the maximum buffer size for DDL operations. The default setting is 1048576 bytes (approximately 1 MB). Applies to online DDL operations that create or rebuild secondary indexes. See Section 17.12.4, “Online DDL Memory Management”. The maximum buffer size per DDL thread is the maximum buffer size divided by the number of DDL threads (innodb_ddl_buffer_size/innodb_ddl_threads).innodb_ddl_log_crash_reset_debug命令行格式Command-Line Format --innodb-ddl-log-crash-reset-debug[={OFF|ON}]系统变量System Variable innodb_ddl_log_crash_reset_debug范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用此调试选项以将 DDL 日志崩溃注入计数器重置为 1。此选项仅在使用
WITH_DEBUGCMake 选项编译了调试支持时才可用。Enable this debug option to reset DDL log crash injection counters to 1. This option is only available when debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-ddl-threads=#系统变量System Variable innodb_ddl_threads范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 4最小值Minimum Value 1最大值Maximum Value 64定义索引创建的排序和构建阶段的最大并行线程数。适用于创建或重建二级索引的在线 DDL 操作。有关相关信息,请参见 第 17.12.5 节,“配置在线 DDL 操作的并行线程” 和 第 17.12.4 节,“在线 DDL 内存管理”。Defines the maximum number of parallel threads for the sort and build phases of index creation. Applies to online DDL operations that create or rebuild secondary indexes. For related information, see Section 17.12.5, “Configuring Parallel Threads for Online DDL Operations”, and Section 17.12.4, “Online DDL Memory Management”.
命令行格式Command-Line Format --innodb-deadlock-detect[={OFF|ON}]系统变量System Variable innodb_deadlock_detect范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON此选项用于禁用死锁检测。在高并发系统中,当多个线程等待同一个锁时,死锁检测可能导致速度变慢。有时,禁用死锁检测并依赖于
innodb_lock_wait_timeout设置在发生死锁时回滚事务可能更高效。This option is used to disable deadlock detection. On high concurrency systems, deadlock detection can cause a slowdown when numerous threads wait for the same lock. At times, it may be more efficient to disable deadlock detection and rely on theinnodb_lock_wait_timeoutsetting for transaction rollback when a deadlock occurs.有关相关信息,请参见 第 17.7.5.2 节,“死锁检测”。For related information, see Section 17.7.5.2, “Deadlock Detection”.
命令行格式Command-Line Format --innodb-default-row-format=value系统变量System Variable innodb_default_row_format范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value DYNAMICDYNAMIC有效值Valid Values REDUNDANTREDUNDANTCOMPACTCOMPACTDYNAMICDYNAMICinnodb_default_row_format选项定义了InnoDB表和用户创建的临时表的默认行格式。默认设置为DYNAMIC。其他允许的值为COMPACT和REDUNDANT。COMPRESSED行格式不支持在 系统表空间 中使用,因此不能定义为默认格式。Theinnodb_default_row_formatoption defines the default row format forInnoDBtables and user-created temporary tables. The default setting isDYNAMIC. Other permitted values areCOMPACTandREDUNDANT. TheCOMPRESSEDrow format, which is not supported for use in the system tablespace, cannot be defined as the default.新创建的表在未显式指定
ROW_FORMAT选项或使用ROW_FORMAT=DEFAULT时,会使用innodb_default_row_format定义的行格式。Newly created tables use the row format defined byinnodb_default_row_formatwhen aROW_FORMAToption is not specified explicitly or whenROW_FORMAT=DEFAULTis used.当未显式指定
ROW_FORMAT选项或使用ROW_FORMAT=DEFAULT时,任何重建表的操作也会默默地将表的行格式更改为innodb_default_row_format定义的格式。有关更多信息,请参见定义表的行格式。When aROW_FORMAToption is not specified explicitly or whenROW_FORMAT=DEFAULTis used, any operation that rebuilds a table also silently changes the row format of the table to the format defined byinnodb_default_row_format. For more information, see Defining the Row Format of a Table.服务器为处理查询而创建的内部
InnoDB临时表使用DYNAMIC行格式,无论innodb_default_row_format设置为何。InternalInnoDBtemporary tables created by the server to process queries use theDYNAMICrow format, regardless of theinnodb_default_row_formatsetting.命令行格式Command-Line Format --innodb-directories=dir_name系统变量System Variable innodb_directories范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name 默认值Default Value NULL定义启动时扫描表空间文件的目录。当在服务器离线时移动或恢复表空间文件到新位置时使用此选项。它还用于指定使用绝对路径创建的表空间文件或位于数据目录之外的目录。Defines directories to scan at startup for tablespace files. This option is used when moving or restoring tablespace files to a new location while the server is offline. It is also used to specify directories of tablespace files created using an absolute path or that reside outside of the data directory.
崩溃恢复期间的表空间发现依赖于
innodb_directories设置来识别重做日志中引用的表空间。更多信息,请参见 崩溃恢复期间的表空间发现。Tablespace discovery during crash recovery relies on theinnodb_directoriessetting to identify tablespaces referenced in the redo logs. For more information, see Tablespace Discovery During Crash Recovery.默认值为 NULL,但由
innodb_data_home_dir、innodb_undo_directory和datadir定义的目录总会被附加到innodb_directories参数值中,当InnoDB在启动时构建要扫描的目录列表时。这些目录会被附加,不管是否显式指定了innodb_directories设置。The default value is NULL, but directories defined byinnodb_data_home_dir,innodb_undo_directory, anddatadirare always appended to theinnodb_directoriesargument value whenInnoDBbuilds a list of directories to scan at startup. These directories are appended regardless of whether aninnodb_directoriessetting is specified explicitly.innodb_directories可以作为启动命令或 MySQL 配置文件中的选项来指定。参数值需要用引号括起来,因为否则某些命令解释器会将分号 (;) 解释为特殊字符。(例如,Unix shell 会将其视为命令终止符。)innodb_directoriesmay be specified as an option in a startup command or in a MySQL option file. Quotes surround the argument value because otherwise some command interpreters interpret semicolon (;) as a special character. (For example, Unix shells treat it as a command terminator.)启动命令:Startup command:
mysqld --innodb-directories="
directory_path_1;directory_path_2"MySQL 配置文件:MySQL option file:
[mysqld] innodb_directories="
directory_path_1;directory_path_2"不能使用通配符表达式来指定目录。Wildcard expressions cannot be used to specify directories.
innodb_directories扫描也会遍历指定目录的子目录。重复的目录和子目录会从要扫描的目录列表中删除。Theinnodb_directoriesscan also traverses the subdirectories of specified directories. Duplicate directories and subdirectories are discarded from the list of directories to be scanned.有关更多信息,请参见 第 17.6.3.6 节,“在服务器离线时移动表空间文件”。For more information, see Section 17.6.3.6, “Moving Tablespace Files While the Server is Offline”.
innodb_disable_sort_file_cache命令行格式Command-Line Format --innodb-disable-sort-file-cache[={OFF|ON}]系统变量System Variable innodb_disable_sort_file_cache范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF禁用用于归并排序临时文件的操作系统文件系统缓存。其效果是以类似
O_DIRECT的方式打开此类文件。Disables the operating system file system cache for merge-sort temporary files. The effect is to open such files with the equivalent ofO_DIRECT.命令行格式Command-Line Format --innodb-doublewrite=value系统变量System Variable innodb_doublewrite范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value ONON有效值Valid Values ONONOFFOFFDETECT_AND_RECOVERDETECT_ONLYinnodb_doublewrite变量控制双写缓冲。双写缓冲在大多数情况下默认启用。Theinnodb_doublewritevariable controls doublewrite buffering. Doublewrite buffering is enabled by default in most cases.您可以在启动服务器时将
innodb_doublewrite设置为ON或OFF,分别用于启用或禁用双写缓冲。DETECT_AND_RECOVER与ON相同。在此设置下,除了双写缓冲被完全启用之外,数据库页内容会被写入双写缓冲区,在恢复时访问这些内容以修复未完成的页面写入。使用DETECT_ONLY时,仅元数据被写入双写缓冲区。数据库页内容不会写入双写缓冲区,并且恢复过程中不会使用双写缓冲区来修复未完成的页面写入。此轻量级设置仅用于检测未完成的页面写入。You can setinnodb_doublewritetoONorOFFwhen starting the server to enable or disable doublewrite buffering, respectively.DETECT_AND_RECOVERis the same asON. With this setting, except that the doublewrite buffer is fully enabled, with database page content written to the doublewrite buffer where it is accessed during recovery to fix incomplete page writes. WithDETECT_ONLY, only metadata is written to the doublewrite buffer. Database page content is not written to the doublewrite buffer, and recovery does not use the doublewrite buffer to fix incomplete page writes. This lightweight setting is intended for detecting incomplete page writes only.MySQL 支持对
innodb_doublewrite设置进行动态更改,用于启用双写缓冲区,可在ON、DETECT_AND_RECOVER和DETECT_ONLY之间切换。MySQL 不支持在启用双写缓冲区的设置与OFF之间或反之进行动态更改。MySQL supports dynamic changes to theinnodb_doublewritesetting that enables the doublewrite buffer, betweenON,DETECT_AND_RECOVER, andDETECT_ONLY. MySQL does not support dynamic changes between a setting that enables the doublewrite buffer andOFFor vice versa.如果双写缓冲区位于支持原子写入的 Fusion-io 设备上,双写缓冲区将自动禁用,并且数据文件写入将改为使用 Fusion-io 的原子写入。然而,请注意
innodb_doublewrite设置是全局的。当双写缓冲区被禁用时,它对于所有数据文件都是禁用的,包括那些不在 Fusion-io 硬件上的文件。此功能仅在 Fusion-io 硬件上受支持,并且仅在 Linux 上的 Fusion-io NVMFS 上启用。为了充分利用此功能,建议将innodb_flush_method设置为O_DIRECT。If the doublewrite buffer is located on a Fusion-io device that supports atomic writes, the doublewrite buffer is automatically disabled and data file writes are performed using Fusion-io atomic writes instead. However, be aware that theinnodb_doublewritesetting is global. When the doublewrite buffer is disabled, it is disabled for all data files including those that do not reside on Fusion-io hardware. This feature is only supported on Fusion-io hardware and is only enabled for Fusion-io NVMFS on Linux. To take full advantage of this feature, aninnodb_flush_methodsetting ofO_DIRECTis recommended.有关相关信息,请参见 第 17.6.4 节,“双写缓冲区”。For related information, see Section 17.6.4, “Doublewrite Buffer”.
命令行格式Command-Line Format --innodb-doublewrite-batch-size=#系统变量System Variable innodb_doublewrite_batch_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 256该变量用于表示要批量写入的双写页数。此功能已被
innodb_doublewrite_pages所取代。This variable was intended to represent the number of doublewrite pages to write in a batch. This functionality was replaced byinnodb_doublewrite_pages.更多信息,请参见 第 17.6.4 节,“双写缓冲区”。For more information, see Section 17.6.4, “Doublewrite Buffer”.
命令行格式Command-Line Format --innodb-doublewrite-dir=dir_name系统变量System Variable innodb_doublewrite_dir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name 定义双写文件的目录。如果未指定目录,则双写文件将创建在
innodb_data_home_dir目录中,如果未指定,该目录默认为数据目录。Defines the directory for doublewrite files. If no directory is specified, doublewrite files are created in theinnodb_data_home_dirdirectory, which defaults to the data directory if unspecified.更多信息,请参见 第 17.6.4 节,“双写缓冲区”。For more information, see Section 17.6.4, “Doublewrite Buffer”.
命令行格式Command-Line Format --innodb-doublewrite-files=#系统变量System Variable innodb_doublewrite_files范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2最小值Minimum Value 1最大值Maximum Value 256定义双写文件的数量。默认情况下,每个缓冲池实例创建两个双写文件。Defines the number of doublewrite files. By default, two doublewrite files are created for each buffer pool instance.
至少有两个双写文件。双写文件的最大数量是缓冲池实例数量的两倍。(缓冲池实例的数量由
innodb_buffer_pool_instances变量控制。)At a minimum, there are two doublewrite files. The maximum number of doublewrite files is two times the number of buffer pool instances. (The number of buffer pool instances is controlled by theinnodb_buffer_pool_instancesvariable.)更多信息,请参见 第 17.6.4 节,“双写缓冲区”。For more information, see Section 17.6.4, “Doublewrite Buffer”.
命令行格式Command-Line Format --innodb-doublewrite-pages=#系统变量System Variable innodb_doublewrite_pages范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 128最小值Minimum Value 1最大值Maximum Value 512定义每个线程在批量写入过程中双写页的最大数量。如果没有指定值,
innodb_doublewrite_pages默认为 128。Defines the maximum number of doublewrite pages per thread for a batch write. If no value is specified,innodb_doublewrite_pagesdefaults to 128.在 MySQL 8.4 之前,默认值是
innodb_write_io_threads的值,默认是 4。Before MySQL 8.4, the default value was theinnodb_write_io_threadsvalue, which is 4 by default.更多信息,请参见 第 17.6.4 节,“双写缓冲区”。For more information, see Section 17.6.4, “Doublewrite Buffer”.
命令行格式Command-Line Format --innodb=extend-and-initialize[={OFF|ON}]系统变量System Variable innodb_extend_and_initialize范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON控制在 Linux 系统上如何为每表表空间和通用表空间分配空间。Controls how space is allocated to file-per-table and general tablespaces on Linux systems.
启用时,
InnoDB会向新分配的页面写入 NULL。禁用时,空间分配使用posix_fallocate()调用,该调用在不实际写入 NULL 的情况下预留空间。When enabled,InnoDBwrites NULLs to newly allocated pages. When disabled, space is allocated usingposix_fallocate()calls, which reserve space without physically writing NULLs.有关更多信息,请参见 第 17.6.3.8 节,“在 Linux 上优化表空间的空间分配”。For more information, see Section 17.6.3.8, “Optimizing Tablespace Space Allocation on Linux”.
命令行格式Command-Line Format --innodb-fast-shutdown=#系统变量System Variable innodb_fast_shutdown范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 1有效值Valid Values 012InnoDB关闭模式。如果值为 0,InnoDB会执行慢关闭,在关闭前进行完整的清理和缓冲区更改合并。如果值为 1(默认值),InnoDB在关闭时会跳过这些操作,这种过程称为快速关闭。如果值为 2,InnoDB会刷新日志并进行冷关闭,就像 MySQL 崩溃一样;已提交的事务不会丢失,但崩溃恢复操作会使下一次启动花费更长时间。TheInnoDBshutdown mode. If the value is 0,InnoDBdoes a slow shutdown, a full purge and a change buffer merge before shutting down. If the value is 1 (the default),InnoDBskips these operations at shutdown, a process known as a fast shutdown. If the value is 2,InnoDBflushes its logs and shuts down cold, as if MySQL had crashed; no committed transactions are lost, but the crash recovery operation makes the next startup take longer.慢速关闭可能需要几分钟,甚至在极端情况下,如果仍有大量数据在缓冲中,可能需要几个小时。在升级或降级 MySQL 主要版本之前使用慢速关闭技术,以确保在升级过程更新文件格式时,所有数据文件都已完全准备就绪。The slow shutdown can take minutes, or even hours in extreme cases where substantial amounts of data are still buffered. Use the slow shutdown technique before upgrading or downgrading between MySQL major releases, so that all data files are fully prepared in case the upgrade process updates the file format.
在紧急或故障排除情况下使用
innodb_fast_shutdown=2,以在数据有损坏风险时实现最快的关闭。Useinnodb_fast_shutdown=2in emergency or troubleshooting situations, to get the absolute fastest shutdown if data is at risk of corruption.innodb_fil_make_page_dirty_debug命令行格式Command-Line Format --innodb-fil-make-page-dirty-debug=#系统变量System Variable innodb_fil_make_page_dirty_debug范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 2**32-1默认情况下,将
innodb_fil_make_page_dirty_debug设置为表空间的 ID 会立即使表空间的第一页变脏。如果innodb_saved_page_number_debug设置为非默认值,则设置innodb_fil_make_page_dirty_debug会使指定的页面变脏。innodb_fil_make_page_dirty_debug选项仅在使用WITH_DEBUGCMake 选项编译了调试支持时可用。By default, settinginnodb_fil_make_page_dirty_debugto the ID of a tablespace immediately dirties the first page of the tablespace. Ifinnodb_saved_page_number_debugis set to a non-default value, settinginnodb_fil_make_page_dirty_debugdirties the specified page. Theinnodb_fil_make_page_dirty_debugoption is only available if debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-file-per-table[={OFF|ON}]系统变量System Variable innodb_file_per_table范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON当
innodb_file_per_table被启用时,表默认创建在每表单独表空间中。当禁用时,表默认创建在系统表空间中。有关每表单独表空间的信息,请参见第 17.6.3.2 节,“文件-每表表空间”。有关InnoDB系统表空间的信息,请参见第 17.6.3.1 节,“系统表空间”。Wheninnodb_file_per_tableis enabled, tables are created in file-per-table tablespaces by default. When disabled, tables are created in the system tablespace by default. For information about file-per-table tablespaces, see Section 17.6.3.2, “File-Per-Table Tablespaces”. For information about theInnoDBsystem tablespace, see Section 17.6.3.1, “The System Tablespace”.innodb_file_per_table变量可以通过SET GLOBAL语句在运行时配置,也可以在启动时通过命令行指定,或在选项文件中指定。在运行时进行配置需要有足够的权限来设置全局系统变量(参见 第 7.1.9.1 节,“系统变量权限”)并会立即影响所有连接的操作。Theinnodb_file_per_tablevariable can be configured at runtime using aSET GLOBALstatement, specified on the command line at startup, or specified in an option file. Configuration at runtime requires privileges sufficient to set global system variables (see Section 7.1.9.1, “System Variable Privileges”) and immediately affects the operation of all connections.当位于每表文件表空间中的表被截断或删除时,释放的空间会返回操作系统。截断或删除位于系统表空间中的表只会释放系统表空间中的空间。系统表空间中释放的空间可以再次用于
InnoDB数据,但不会返回操作系统,因为系统表空间的数据文件从不缩小。When a table that resides in a file-per-table tablespace is truncated or dropped, the freed space is returned to the operating system. Truncating or dropping a table that resides in the system tablespace only frees space in the system tablespace. Freed space in the system tablespace can be used again forInnoDBdata but is not returned to the operating system, as system tablespace data files never shrink.innodb_file_per-table设置不影响临时表的创建;临时表是在会话临时表空间中创建的。参见 第 17.6.3.5 节,“临时表空间”。Theinnodb_file_per-tablesetting does not affect the creation of temporary tables; temporary tables are created in session temporary tablespaces. See Section 17.6.3.5, “Temporary Tablespaces”.命令行格式Command-Line Format --innodb-fill-factor=#系统变量System Variable innodb_fill_factor范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 100最小值Minimum Value 10最大值Maximum Value 100InnoDB在创建或重建索引时执行批量加载。这种索引创建方法被称为 “排序索引构建”。InnoDBperforms a bulk load when creating or rebuilding indexes. This method of index creation is known as a “sorted index build”.innodb_fill_factor定义在构建排序索引时,每个 B 树页面填充的空间百分比,剩余空间为未来索引增长保留。例如,将innodb_fill_factor设置为 80,会在每个 B 树页面上保留 20% 的空间以便未来索引增长。实际百分比可能有所不同。innodb_fill_factor设置被解释为提示而非硬性限制。innodb_fill_factordefines the percentage of space on each B-tree page that is filled during a sorted index build, with the remaining space reserved for future index growth. For example, settinginnodb_fill_factorto 80 reserves 20 percent of the space on each B-tree page for future index growth. Actual percentages may vary. Theinnodb_fill_factorsetting is interpreted as a hint rather than a hard limit.将
innodb_fill_factor设置为 100,会在聚簇索引页面中保留 1/16 的空间用于未来索引增长。Aninnodb_fill_factorsetting of 100 leaves 1/16 of the space in clustered index pages free for future index growth.innodb_fill_factor适用于 B 树的叶子页和非叶子页。它不适用于用于TEXT或BLOB条目的外部页。innodb_fill_factorapplies to both B-tree leaf and non-leaf pages. It does not apply to external pages used forTEXTorBLOBentries.有关更多信息,请参阅 第 17.6.2.3 节,“排序索引构建”。For more information, see Section 17.6.2.3, “Sorted Index Builds”.
命令行格式Command-Line Format --innodb-flush-log-at-timeout=#系统变量System Variable innodb_flush_log_at_timeout范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 1最小值Minimum Value 1最大值Maximum Value 2700单位Unit 秒seconds 每
N秒写入并刷新日志。innodb_flush_log_at_timeout允许增加刷新之间的超时时间,以减少刷新操作并避免影响二进制日志组提交的性能。innodb_flush_log_at_timeout的默认设置是每秒一次。Write and flush the logs everyNseconds.innodb_flush_log_at_timeoutallows the timeout period between flushes to be increased in order to reduce flushing and avoid impacting performance of binary log group commit. The default setting forinnodb_flush_log_at_timeoutis once per second.innodb_flush_log_at_trx_commit命令行格式Command-Line Format --innodb-flush-log-at-trx-commit=#系统变量System Variable innodb_flush_log_at_trx_commit范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value 1有效值Valid Values 012失败。但允许同一表中两列之间存在外键约束。符合 compliance for 相关 I/O 操作重新排列并批量执行时可能实现的更高性能之间的平衡。通过更改默认值可以获得更好的性能,但那样可能会在崩溃时丢失事务。定义一个低水位标记,表示Controls the balance between strict ACID compliance for commit operations and higher performance that is possible when commit-related I/O operations are rearranged and done in batches. You can achieve better performance by changing the default value but then you can lose transactions in a crash.
默认设置为 1,以确保完全符合 ACID。日志在每次事务提交时都会写入并刷新到磁盘。The default setting of 1 is required for full ACID compliance. Logs are written and flushed to disk at each transaction commit.
设置为 0 时,日志每秒写入并刷新一次。尚未刷新日志的事务在崩溃时可能会丢失。With a setting of 0, logs are written and flushed to disk once per second. Transactions for which logs have not been flushed can be lost in a crash.
在设置为 2 时,日志会在每次事务提交后写入,并每秒刷新到磁盘一次。那些日志尚未刷新的事务在系统崩溃时可能会丢失。With a setting of 2, logs are written after each transaction commit and flushed to disk once per second. Transactions for which logs have not been flushed can be lost in a crash.
对于设置 0 和 2,每秒刷新一次并不是 100% 保证。由于 DDL 变更和其他内部
InnoDB活动可能独立于innodb_flush_log_at_trx_commit设置而导致日志刷新,刷新的频率可能更高,有时因为调度问题而频率更低。如果日志每秒刷新一次,系统崩溃时最多可能丢失一秒的事务。如果日志刷新的频率高于或低于每秒一次,可能丢失的事务量也会相应变化。For settings 0 and 2, once-per-second flushing is not 100% guaranteed. Flushing may occur more frequently due to DDL changes and other internalInnoDBactivities that cause logs to be flushed independently of theinnodb_flush_log_at_trx_commitsetting, and sometimes less frequently due to scheduling issues. If logs are flushed once per second, up to one second of transactions can be lost in a crash. If logs are flushed more or less frequently than once per second, the amount of transactions that can be lost varies accordingly.日志刷新频率由
innodb_flush_log_at_timeout控制,它允许您将日志刷新频率设置为N秒(其中N为1 ... 2700,默认值为 1)。然而,任何意外的 mysqld 进程退出都可能会丢失最多N秒的事务。Log flushing frequency is controlled byinnodb_flush_log_at_timeout, which allows you to set log flushing frequency toNseconds (whereNis1 ... 2700, with a default value of 1). However, any unexpected mysqld process exit can erase up toNseconds of transactions.DDL 更改和其他内部
InnoDB活动会独立于innodb_flush_log_at_trx_commit设置刷新日志。DDL changes and other internalInnoDBactivities flush the log independently of theinnodb_flush_log_at_trx_commitsetting.InnoDB崩溃恢复 不受innodb_flush_log_at_trx_commit设置的影响。事务要么完全应用,要么完全撤销。InnoDBcrash recovery works regardless of theinnodb_flush_log_at_trx_commitsetting. Transactions are either applied entirely or erased entirely.
对于在使用事务的
InnoDB的复制环境中的持久性和一致性:For durability and consistency in a replication setup that usesInnoDBwith transactions:如果启用了二进制日志,请设置
sync_binlog=1。If binary logging is enabled, setsync_binlog=1.始终设置
innodb_flush_log_at_trx_commit=1。Always setinnodb_flush_log_at_trx_commit=1.
有关最能应对意外停止的副本设置组合的信息,请参见 第 19.4.2 节,“处理副本的意外停止”。For information on the combination of settings on a replica that is most resilient to unexpected halts, see Section 19.4.2, “Handling an Unexpected Halt of a Replica”.
Caution许多操作系统和一些磁盘硬件会误导“刷新到磁盘”操作。它们可能会告诉 mysqld 刷新已经完成,即使实际上没有完成。在这种情况下,即使使用推荐的设置,事务的持久性也不能得到保证,在最坏的情况下,断电可能会损坏
InnoDB数据。使用 SCSI 磁盘控制器或磁盘本身中的电池备份磁盘缓存可以加快文件刷新速度,并使操作更安全。你也可以尝试在硬件缓存中禁用磁盘写入缓存。Many operating systems and some disk hardware fool the flush-to-disk operation. They may tell mysqld that the flush has taken place, even though it has not. In this case, the durability of transactions is not guaranteed even with the recommended settings, and in the worst case, a power outage can corruptInnoDBdata. Using a battery-backed disk cache in the SCSI disk controller or in the disk itself speeds up file flushes, and makes the operation safer. You can also try to disable the caching of disk writes in hardware caches.命令行格式Command-Line Format --innodb-flush-method=value系统变量System Variable innodb_flush_method范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值(Unix)Default Value (Unix) O_DIRECT if supported, otherwise fsyncO_DIRECT if supported, otherwise fsync默认值(Windows)Default Value (Windows) unbufferedunbuffered有效值(Unix)Valid Values (Unix) fsyncO_DSYNClittlesyncnosyncO_DIRECTO_DIRECT_NO_FSYNC有效值(Windows)Valid Values (Windows) unbufferedunbufferednormalnormal定义用于将数据 刷写 到
InnoDB数据文件 和 日志文件 的方法,这会影响 I/O 吞吐量。Defines the method used to flush data toInnoDBdata files and log files, which can affect I/O throughput.在类 Unix 系统中,如果支持,默认值是
O_DIRECT,否则默认为fsync。在 Windows 上,默认值是unbuffered。On Unix-like systems, the default value isO_DIRECTif supported otherwise defaults tofsync. On Windows, the default value isunbuffered.类 Unix 系统的
innodb_flush_method选项包括:Theinnodb_flush_methodoptions for Unix-like systems include:fsync或0:InnoDB使用fsync()系统调用刷新数据文件和日志文件。fsyncor0:InnoDBuses thefsync()system call to flush both the data and log files.O_DSYNC或1:InnoDB使用O_SYNC来打开并刷新日志文件,并使用fsync()来刷新数据文件。InnoDB不直接使用O_DSYNC,因为在许多类型的 Unix 系统上它存在问题。O_DSYNCor1:InnoDBusesO_SYNCto open and flush the log files, andfsync()to flush the data files.InnoDBdoes not useO_DSYNCdirectly because there have been problems with it on many varieties of Unix.littlesync或2:此选项用于内部性能测试,目前不受支持。使用风险自负。littlesyncor2: This option is used for internal performance testing and is currently unsupported. Use at your own risk.nosync或3:此选项用于内部性能测试,目前不受支持。使用风险自负。nosyncor3: This option is used for internal performance testing and is currently unsupported. Use at your own risk.O_DIRECT或4:InnoDB使用O_DIRECT(在 Solaris 上使用directio())打开数据文件,并使用fsync()刷新数据文件和日志文件。此选项在某些 GNU/Linux 版本、FreeBSD 和 Solaris 上可用。O_DIRECTor4:InnoDBusesO_DIRECT(ordirectio()on Solaris) to open the data files, and usesfsync()to flush both the data and log files. This option is available on some GNU/Linux versions, FreeBSD, and Solaris.O_DIRECT_NO_FSYNC:InnoDB在刷新 I/O 时使用O_DIRECT,但在每次写操作后跳过fsync()系统调用。O_DIRECT_NO_FSYNC:InnoDBusesO_DIRECTduring flushing I/O, but skips thefsync()system call after each write operation.MySQL 在创建新文件、增加文件大小以及关闭文件后会调用
fsync(),以确保文件系统元数据更改被同步。在每次写操作后fsync()系统调用仍然被跳过。MySQL callsfsync()after creating a new file, after increasing file size, and after closing a file, to ensure that file system metadata changes are synchronized. Thefsync()system call is still skipped after each write operation.如果重做日志文件和数据文件位于不同的存储设备上,并且在数据文件写入尚未从非电池备份的设备缓存刷新之前发生意外退出,可能会导致数据丢失。如果您使用或打算使用不同的存储设备来存放重做日志文件和数据文件,并且您的数据文件位于具有非电池备份缓存的设备上,请改用
O_DIRECT。Data loss is possible if redo log files and data files reside on different storage devices, and an unexpected exit occurs before data file writes are flushed from a device cache that is not battery-backed. If you use or intend to use different storage devices for redo log files and data files, and your data files reside on a device with a cache that is not battery-backed, useO_DIRECTinstead.
在支持
fdatasync()系统调用的平台上,innodb_use_fdatasync变量允许使用fsync()的innodb_flush_method选项改用fdatasync()。fdatasync()系统调用不会刷新文件元数据的更改,除非为后续数据检索所需,这提供了潜在的性能优势。On platforms that supportfdatasync()system calls, theinnodb_use_fdatasyncvariable permitsinnodb_flush_methodoptions that usefsync()to usefdatasync()instead. Anfdatasync()system call does not flush changes to file metadata unless required for subsequent data retrieval, providing a potential performance benefit.Windows 系统的
innodb_flush_method选项包括:Theinnodb_flush_methodoptions for Windows systems include:unbuffered或0:InnoDB使用非缓冲 I/O。unbufferedor0:InnoDBuses non-buffered I/O.Note在 Windows 上的 4K 扇区硬盘上运行 MySQL 服务器时,不支持
unbuffered。解决方法是使用innodb_flush_method=normal。Running MySQL server on a 4K sector hard drive on Windows is not supported withunbuffered. The workaround is to useinnodb_flush_method=normal.normal或1:InnoDB使用缓冲 I/O。normalor1:InnoDBuses buffered I/O.
每个设置对性能的影响取决于硬件配置和工作负载。应对特定配置进行基准测试,以决定使用哪个设置,或是否保持默认设置。检查
Innodb_data_fsyncs状态变量,以查看每个设置下fsync()调用(如果启用了innodb_use_fdatasync则为fdatasync()调用)的总次数。工作负载中读写操作的比例会影响设置的性能。例如,在具有硬件 RAID 控制器和电池备份写缓存的系统上,O_DIRECT可以帮助避免InnoDB缓冲池与操作系统文件系统缓存之间的双重缓存。在某些InnoDB数据和日志文件位于 SAN 的系统上,对于以SELECT语句为主的读密集型工作负载,默认值或O_DSYNC可能更快。始终在反映生产环境的硬件和工作负载下测试此参数。有关一般 I/O 调优建议,请参阅 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。How each setting affects performance depends on hardware configuration and workload. Benchmark your particular configuration to decide which setting to use, or whether to keep the default setting. Examine theInnodb_data_fsyncsstatus variable to see the overall number offsync()calls (orfdatasync()calls ifinnodb_use_fdatasyncis enabled) for each setting. The mix of read and write operations in your workload can affect how a setting performs. For example, on a system with a hardware RAID controller and battery-backed write cache,O_DIRECTcan help to avoid double buffering between theInnoDBbuffer pool and the operating system file system cache. On some systems whereInnoDBdata and log files are located on a SAN, the default value orO_DSYNCmight be faster for a read-heavy workload with mostlySELECTstatements. Always test this parameter with hardware and workload that reflect your production environment. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.命令行格式Command-Line Format --innodb-flush-neighbors=#系统变量System Variable innodb_flush_neighbors范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value 0有效值Valid Values 012Specifies whether flushing a page from the
InnoDB缓冲池 also flushes other dirty pages in the same extent.Specifies whether flushing a page from theInnoDBbuffer pool also flushes other dirty pages in the same extent.设置为 0 会禁用
innodb_flush_neighbors。同一区段中的脏页不会被刷新。A setting of 0 disablesinnodb_flush_neighbors. Dirty pages in the same extent are not flushed.设置为 1 会刷新同一区段中连续的脏页。A setting of 1 flushes contiguous dirty pages in the same extent.
设置为 2 会刷新同一区段中的脏页。A setting of 2 flushes dirty pages in the same extent.
当表数据存储在传统的HDD存储设备上时,一次性刷新这些相邻页面相比于在不同时间刷新各个页面,可以减少 I/O 开销(主要针对磁盘寻道操作)。对于存储在SSD上的表数据,寻道时间不是关键因素,你可以将此选项设置为 0 以分散写操作。有关相关信息,请参阅第 17.8.3.5 节,“配置缓冲池刷新”。When the table data is stored on a traditional HDD storage device, flushing such neighbor pages in one operation reduces I/O overhead (primarily for disk seek operations) compared to flushing individual pages at different times. For table data stored on SSD, seek time is not a significant factor and you can set this option to 0 to spread out write operations. For related information, see Section 17.8.3.5, “Configuring Buffer Pool Flushing”.
命令行格式Command-Line Format --innodb-flush-sync[={OFF|ON}]系统变量System Variable innodb_flush_sync范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONONinnodb_flush_sync变量默认启用,它会导致在 检查点 发生的一些 I/O 活动高峰期间,innodb_io_capacity和innodb_io_capacity_max设置被忽略。若要遵循由innodb_io_capacity和innodb_io_capacity_max定义的 I/O 速率,请禁用innodb_flush_sync。Theinnodb_flush_syncvariable, which is enabled by default, causes theinnodb_io_capacityandinnodb_io_capacity_maxsettings to be ignored during bursts of I/O activity that occur at checkpoints. To adhere to the I/O rate defined byinnodb_io_capacityandinnodb_io_capacity_max, disableinnodb_flush_sync.有关配置
innodb_flush_sync变量的信息,请参见 第 17.8.7 节,“配置 InnoDB I/O 容量”。For information about configuring theinnodb_flush_syncvariable, see Section 17.8.7, “Configuring InnoDB I/O Capacity”.命令行格式Command-Line Format --innodb-flushing-avg-loops=#系统变量System Variable innodb_flushing_avg_loops范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 30最小值Minimum Value 1最大值Maximum Value 1000Number of iterations for which
InnoDBkeeps the previously calculated snapshot of the flushing state, controlling how quickly adaptive flushing responds to changing workloads. Increasing the value makes the rate of 刷新 operations change smoothly and gradually as the workload changes. Decreasing the value makes adaptive flushing adjust quickly to workload changes, which can cause spikes in flushing activity if the workload increases and decreases suddenly.Number of iterations for whichInnoDBkeeps the previously calculated snapshot of the flushing state, controlling how quickly adaptive flushing responds to changing workloads. Increasing the value makes the rate of flush operations change smoothly and gradually as the workload changes. Decreasing the value makes adaptive flushing adjust quickly to workload changes, which can cause spikes in flushing activity if the workload increases and decreases suddenly.有关相关信息,请参见 第 17.8.3.5 节,“配置缓冲池刷新”。For related information, see Section 17.8.3.5, “Configuring Buffer Pool Flushing”.
命令行格式Command-Line Format --innodb-force-load-corrupted[={OFF|ON}]系统变量System Variable innodb_force_load_corrupted范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF允许
InnoDB在启动时加载被标记为损坏的表。仅在故障排除期间使用,以恢复无法访问的数据。故障排除完成后,请禁用此设置并重启服务器。PermitsInnoDBto load tables at startup that are marked as corrupted. Use only during troubleshooting, to recover data that is otherwise inaccessible. When troubleshooting is complete, disable this setting and restart the server.命令行格式Command-Line Format --innodb-force-recovery=#系统变量System Variable innodb_force_recovery范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 6崩溃恢复 模式,通常仅在严重故障排除情况下更改。可能的值从 0 到 6。有关这些值的含义以及
innodb_force_recovery的重要信息,请参见 第 17.20.3 节,“强制 InnoDB 恢复”。The crash recovery mode, typically only changed in serious troubleshooting situations. Possible values are from 0 to 6. For the meanings of these values and important information aboutinnodb_force_recovery, see Section 17.20.3, “Forcing InnoDB Recovery”.Warning仅在紧急情况下将此变量设置为大于 0 的值,以便您可以启动
InnoDB并导出您的表。作为安全措施,当innodb_force_recovery大于 0 时,InnoDB会阻止INSERT、UPDATE或DELETE操作。将innodb_force_recovery设置为 4 或更高会将InnoDB置于只读模式。Only set this variable to a value greater than 0 in an emergency situation so that you can startInnoDBand dump your tables. As a safety measure,InnoDBpreventsINSERT,UPDATE, orDELETEoperations wheninnodb_force_recoveryis greater than 0. Aninnodb_force_recoverysetting of 4 or greater placesInnoDBinto read-only mode.这些限制可能会导致复制管理命令失败并显示错误,因为复制会将副本状态日志存储在
InnoDB表中。These restrictions may cause replication administration commands to fail with an error, as replication stores the replica status logs inInnoDBtables.命令行格式Command-Line Format --innodb-fsync-threshold=#系统变量System Variable innodb_fsync_threshold范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 2**64-1默认情况下,当
InnoDB创建一个新的数据文件,例如新的日志文件或表空间文件时,文件会先完全写入操作系统缓存,然后才刷新到磁盘,这可能会导致大量磁盘写入活动同时发生。为了强制从操作系统缓存进行更小、周期性的数据刷新,您可以使用innodb_fsync_threshold变量来定义一个阈值,以字节为单位。当达到字节阈值时,操作系统缓存的内容会刷新到磁盘。默认值 0 会强制使用默认行为,即只有在文件完全写入缓存后才将数据刷新到磁盘。By default, whenInnoDBcreates a new data file, such as a new log file or tablespace file, the file is fully written to the operating system cache before it is flushed to disk, which can cause a large amount of disk write activity to occur at once. To force smaller, periodic flushes of data from the operating system cache, you can use theinnodb_fsync_thresholdvariable to define a threshold value, in bytes. When the byte threshold is reached, the contents of the operating system cache are flushed to disk. The default value of 0 forces the default behavior, which is to flush data to disk only after a file is fully written to the cache.在多个 MySQL 实例使用相同存储设备的情况下,指定阈值来强制进行较小的定期刷新可能会很有用。例如,创建新的 MySQL 实例及其关联的数据文件可能会导致磁盘写入活动大幅激增,从而影响使用相同存储设备的其他 MySQL 实例的性能。配置阈值有助于避免写入活动激增。Specifying a threshold to force smaller, periodic flushes may be beneficial in cases where multiple MySQL instances use the same storage devices. For example, creating a new MySQL instance and its associated data files could cause large surges of disk write activity, impeding the performance of other MySQL instances that use the same storage devices. Configuring a threshold helps avoid such surges in write activity.
系统变量System Variable innodb_ft_aux_table范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 指定包含
FULLTEXT索引的InnoDB表的限定名称。此变量用于诊断目的,并且只能在运行时设置。例如:Specifies the qualified name of anInnoDBtable containing aFULLTEXTindex. This variable is intended for diagnostic purposes and can only be set at runtime. For example:SET GLOBAL innodb_ft_aux_table = 'test/t1';
在您将此变量设置为格式为
的名称后,db_name/table_nameINFORMATION_SCHEMA表INNODB_FT_INDEX_TABLE、INNODB_FT_INDEX_CACHE、INNODB_FT_CONFIG、INNODB_FT_DELETED和INNODB_FT_BEING_DELETED将显示指定表的搜索索引信息。After you set this variable to a name in the format, thedb_name/table_nameINFORMATION_SCHEMAtablesINNODB_FT_INDEX_TABLE,INNODB_FT_INDEX_CACHE,INNODB_FT_CONFIG,INNODB_FT_DELETED, andINNODB_FT_BEING_DELETEDshow information about the search index for the specified table.欲了解更多信息,请参见 第 17.15.4 节,“InnoDB INFORMATION_SCHEMA 全文索引表”。For more information, see Section 17.15.4, “InnoDB INFORMATION_SCHEMA FULLTEXT Index Tables”.
命令行格式Command-Line Format --innodb-ft-cache-size=#系统变量System Variable innodb_ft_cache_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 8000000最小值Minimum Value 1600000最大值Maximum Value 80000000单位Unit 字节bytes 分配给
InnoDBFULLTEXT搜索索引缓存的内存(以字节为单位),在创建InnoDBFULLTEXT索引时用于在内存中保存解析后的文档。索引的插入和更新只有在达到innodb_ft_cache_size大小限制时才会提交到磁盘。innodb_ft_cache_size定义了每个表的缓存大小。要为所有表设置全局限制,请参见innodb_ft_total_cache_size。The memory allocated, in bytes, for theInnoDBFULLTEXTsearch index cache, which holds a parsed document in memory while creating anInnoDBFULLTEXTindex. Index inserts and updates are only committed to disk when theinnodb_ft_cache_sizesize limit is reached.innodb_ft_cache_sizedefines the cache size on a per table basis. To set a global limit for all tables, seeinnodb_ft_total_cache_size.欲了解更多信息,请参见 InnoDB 全文索引缓存。For more information, see InnoDB Full-Text Index Cache.
命令行格式Command-Line Format --innodb-ft-enable-diag-print[={OFF|ON}]系统变量System Variable innodb_ft_enable_diag_print范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF是否启用额外的全文搜索 (FTS) 诊断输出。此选项主要用于高级 FTS 调试,对于大多数用户来说并不相关。输出将打印到错误日志中,并包括以下信息:Whether to enable additional full-text search (FTS) diagnostic output. This option is primarily intended for advanced FTS debugging and is not of interest to most users. Output is printed to the error log and includes information such as:
FTS 索引同步进度(当达到 FTS 缓存限制时)。例如:FTS index sync progress (when the FTS cache limit is reached). For example:
FTS SYNC for table test, deleted count: 100 size: 10000 bytes SYNC words: 100
FTS 优化进度。例如:FTS optimize progress. For example:
FTS start optimize test FTS_OPTIMIZE: optimize "mysql" FTS_OPTIMIZE: processed "mysql"
FTS 索引构建进度。例如:FTS index build progress. For example:
Number of doc processed: 1000
对于 FTS 查询,会打印查询解析树、词权重、查询处理时间和内存使用。例如:For FTS queries, the query parsing tree, word weight, query processing time, and memory usage are printed. For example:
FTS Search Processing time: 1 secs: 100 millisec: row(s) 10000 Full Search Memory: 245666 (bytes), Row: 10000
命令行格式Command-Line Format --innodb-ft-enable-stopword[={OFF|ON}]系统变量System Variable innodb_ft_enable_stopword范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON指定在创建
InnoDBFULLTEXT索引时,与索引关联的一组 停用词。如果设置了innodb_ft_user_stopword_table选项,则停用词从该表中获取。否则,如果设置了innodb_ft_server_stopword_table选项,则停用词从该表中获取。否则,将使用内置的默认停用词集。Specifies that a set of stopwords is associated with anInnoDBFULLTEXTindex at the time the index is created. If theinnodb_ft_user_stopword_tableoption is set, the stopwords are taken from that table. Else, if theinnodb_ft_server_stopword_tableoption is set, the stopwords are taken from that table. Otherwise, a built-in set of default stopwords is used.更多信息,请参见 第 14.9.4 节,“全文停用词”。For more information, see Section 14.9.4, “Full-Text Stopwords”.
命令行格式Command-Line Format --innodb-ft-max-token-size=#系统变量System Variable innodb_ft_max_token_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 84最小值Minimum Value 10最大值Maximum Value 84存储在
InnoDBFULLTEXT索引中的单词的最大字符长度。对该值设置限制可以减少索引的大小,从而通过省略长关键词或不是实际单词且不太可能成为搜索词的任意字母组合来加快查询速度。Maximum character length of words that are stored in anInnoDBFULLTEXTindex. Setting a limit on this value reduces the size of the index, thus speeding up queries, by omitting long keywords or arbitrary collections of letters that are not real words and are not likely to be search terms.更多信息,请参见 第 14.9.6 节,“微调 MySQL 全文搜索”。For more information, see Section 14.9.6, “Fine-Tuning MySQL Full-Text Search”.
命令行格式Command-Line Format --innodb-ft-min-token-size=#系统变量System Variable innodb_ft_min_token_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 3最小值Minimum Value 0最大值Maximum Value 16存储在
InnoDBFULLTEXT索引中的单词的最小长度。增大该值可以通过省略在搜索环境中不太可能有意义的常见单词(例如英文单词 “a” 和 “to”)来减少索引的大小,从而加快查询速度。对于使用中、日、韩 (CJK) 字符集的内容,请指定值为 1。Minimum length of words that are stored in anInnoDBFULLTEXTindex. Increasing this value reduces the size of the index, thus speeding up queries, by omitting common words that are unlikely to be significant in a search context, such as the English words “a” and “to”. For content using a CJK (Chinese, Japanese, Korean) character set, specify a value of 1.更多信息,请参见 第 14.9.6 节,“微调 MySQL 全文搜索”。For more information, see Section 14.9.6, “Fine-Tuning MySQL Full-Text Search”.
命令行格式Command-Line Format --innodb-ft-num-word-optimize=#系统变量System Variable innodb_ft_num_word_optimize范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2000最小值Minimum Value 1000最大值Maximum Value 10000在每次针对
InnoDBFULLTEXT索引进行OPTIMIZE TABLE操作时要处理的单词数量。由于对包含全文索引的表进行批量插入或更新操作可能需要大量索引维护以合并所有更改,因此你可能需要执行一系列OPTIMIZE TABLE语句,每次从上一次操作结束的地方继续。Number of words to process during eachOPTIMIZE TABLEoperation on anInnoDBFULLTEXTindex. Because a bulk insert or update operation to a table containing a full-text search index could require substantial index maintenance to incorporate all changes, you might do a series ofOPTIMIZE TABLEstatements, each picking up where the last left off.更多信息,请参见 第 14.9.6 节,“微调 MySQL 全文搜索”。For more information, see Section 14.9.6, “Fine-Tuning MySQL Full-Text Search”.
命令行格式Command-Line Format --innodb-ft-result-cache-limit=#系统变量System Variable innodb_ft_result_cache_limit范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2000000000最小值Minimum Value 1000000最大值Maximum Value 2**32-1单位Unit 字节bytes InnoDB全文搜索查询结果缓存限制(以字节为单位),适用于每个全文搜索查询或每个线程。中间和最终的InnoDB全文搜索查询结果在内存中处理。使用innodb_ft_result_cache_limit对全文搜索查询结果缓存设置大小限制,以避免在InnoDB全文搜索查询结果非常大(例如数百万或数亿行)时占用过多内存。处理全文搜索查询时,会按需分配内存。如果达到结果缓存大小限制,将返回错误,提示查询超过允许的最大内存。TheInnoDBfull-text search query result cache limit (defined in bytes) per full-text search query or per thread. Intermediate and finalInnoDBfull-text search query results are handled in memory. Useinnodb_ft_result_cache_limitto place a size limit on the full-text search query result cache to avoid excessive memory consumption in case of very largeInnoDBfull-text search query results (millions or hundreds of millions of rows, for example). Memory is allocated as required when a full-text search query is processed. If the result cache size limit is reached, an error is returned indicating that the query exceeds the maximum allowed memory.对于所有平台类型和位数,
innodb_ft_result_cache_limit的最大值是 2**32-1。The maximum value ofinnodb_ft_result_cache_limitfor all platform types and bit sizes is 2**32-1.innodb_ft_server_stopword_table命令行格式Command-Line Format --innodb-ft-server-stopword-table=db_name/table_name系统变量System Variable innodb_ft_server_stopword_table范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value NULL此选项用于为所有
InnoDB表指定您自己的InnoDBFULLTEXT索引停用词列表。要为特定InnoDB表配置自己的停用词列表,请使用innodb_ft_user_stopword_table。This option is used to specify your ownInnoDBFULLTEXTindex stopword list for allInnoDBtables. To configure your own stopword list for a specificInnoDBtable, useinnodb_ft_user_stopword_table.将
innodb_ft_server_stopword_table设置为包含停用词列表的表名,格式为。Setdb_name/table_nameinnodb_ft_server_stopword_tableto the name of the table containing a list of stopwords, in the format.db_name/table_name在配置
innodb_ft_server_stopword_table之前,必须先存在停用词表。必须启用innodb_ft_enable_stopword,并且必须配置innodb_ft_server_stopword_table选项,然后才能创建FULLTEXT索引。The stopword table must exist before you configureinnodb_ft_server_stopword_table.innodb_ft_enable_stopwordmust be enabled andinnodb_ft_server_stopword_tableoption must be configured before you create theFULLTEXTindex.停用词表必须是一个
InnoDB表,包含一个名为value的单列VARCHAR列。The stopword table must be anInnoDBtable, containing a singleVARCHARcolumn namedvalue.更多信息,请参见 第 14.9.4 节,“全文停用词”。For more information, see Section 14.9.4, “Full-Text Stopwords”.
命令行格式Command-Line Format --innodb-ft-sort-pll-degree=#系统变量System Variable innodb_ft_sort_pll_degree范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2最小值Minimum Value 1最大值Maximum Value 16在构建搜索索引时,用于在
InnoDBFULLTEXT索引中并行索引和分词的线程数。Number of threads used in parallel to index and tokenize text in anInnoDBFULLTEXTindex when building a search index.有关相关信息,请参阅 第 17.6.2.4 节,“InnoDB 全文索引”,以及
innodb_sort_buffer_size。For related information, see Section 17.6.2.4, “InnoDB Full-Text Indexes”, andinnodb_sort_buffer_size.命令行格式Command-Line Format --innodb-ft-total-cache-size=#系统变量System Variable innodb_ft_total_cache_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 640000000最小值Minimum Value 32000000最大值Maximum Value 1600000000单位Unit 字节bytes 为所有表的
InnoDB全文搜索索引缓存分配的总内存(以字节为单位)。创建大量表,每个表都有一个FULLTEXT搜索索引,可能会消耗大量可用内存。innodb_ft_total_cache_size定义了所有全文搜索索引的全局内存限制,以帮助避免过度的内存消耗。如果索引操作达到全局限制,将触发强制同步。The total memory allocated, in bytes, for theInnoDBfull-text search index cache for all tables. Creating numerous tables, each with aFULLTEXTsearch index, could consume a significant portion of available memory.innodb_ft_total_cache_sizedefines a global memory limit for all full-text search indexes to help avoid excessive memory consumption. If the global limit is reached by an index operation, a forced sync is triggered.欲了解更多信息,请参见 InnoDB 全文索引缓存。For more information, see InnoDB Full-Text Index Cache.
命令行格式Command-Line Format --innodb-ft-user-stopword-table=db_name/table_name系统变量System Variable innodb_ft_user_stopword_table范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value NULL此选项用于指定您在特定表上使用自己的
InnoDBFULLTEXT索引停用词列表。要为所有InnoDB表配置自己的停用词列表,请使用innodb_ft_server_stopword_table。This option is used to specify your ownInnoDBFULLTEXTindex stopword list on a specific table. To configure your own stopword list for allInnoDBtables, useinnodb_ft_server_stopword_table.将
innodb_ft_user_stopword_table设置为包含停用词列表的表的名称,格式为。Setdb_name/table_nameinnodb_ft_user_stopword_tableto the name of the table containing a list of stopwords, in the format.db_name/table_name在配置
innodb_ft_user_stopword_table之前,停用词表必须存在。innodb_ft_enable_stopword必须启用,并且innodb_ft_user_stopword_table必须配置好,然后才能创建FULLTEXT索引。The stopword table must exist before you configureinnodb_ft_user_stopword_table.innodb_ft_enable_stopwordmust be enabled andinnodb_ft_user_stopword_tablemust be configured before you create theFULLTEXTindex.停用词表必须是一个
InnoDB表,包含一个名为value的单列VARCHAR列。The stopword table must be anInnoDBtable, containing a singleVARCHARcolumn namedvalue.更多信息,请参见 第 14.9.4 节,“全文停用词”。For more information, see Section 14.9.4, “Full-Text Stopwords”.
命令行格式Command-Line Format --innodb-idle-flush-pct=#系统变量System Variable innodb_idle_flush_pct范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 100最小值Minimum Value 0最大值Maximum Value 100在
InnoDB空闲时限制页面刷新。innodb_idle_flush_pct的值是innodb_io_capacity设置的百分比,该设置定义了InnoDB每秒可用的 I/O 操作次数。更多信息,请参阅空闲期间限制缓冲刷新。Limits page flushing whenInnoDBis idle. Theinnodb_idle_flush_pctvalue is a percentage of theinnodb_io_capacitysetting, which defines the number of I/O operations per second available toInnoDB. For more information, see Limiting Buffer Flushing During Idle Periods.命令行格式Command-Line Format --innodb-io-capacity=#系统变量System Variable innodb_io_capacity范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 10000最小值Minimum Value 100最大值Maximum Value 2**32-1该
innodb_io_capacityvariable defines the number of I/O operations per second (IOPS) available toInnoDBbackground tasks, such as flushing pages from the 缓冲池 and merging data from the change buffer.Theinnodb_io_capacityvariable defines the number of I/O operations per second (IOPS) available toInnoDBbackground tasks, such as flushing pages from the buffer pool and merging data from the change buffer.有关配置
innodb_io_capacity变量的信息,请参见 第 17.8.7 节,“配置 InnoDB I/O 容量”。For information about configuring theinnodb_io_capacityvariable, see Section 17.8.7, “Configuring InnoDB I/O Capacity”.命令行格式Command-Line Format --innodb-io-capacity-max=#系统变量System Variable innodb_io_capacity_max范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2 * innodb_io_capacity最小值Minimum Value 100最大值Maximum Value 2**32-1如果刷新活动滞后,
InnoDB可以更积极地刷新,其每秒 I/O 操作次数 (IOPS) 可以高于innodb_io_capacity变量定义的值。innodb_io_capacity_max变量定义了在这种情况下InnoDB后台任务执行的最大 IOPS 数。这一选项不控制innodb_flush_sync的行为。If flushing activity falls behind,InnoDBcan flush more aggressively, at a higher rate of I/O operations per second (IOPS) than defined by theinnodb_io_capacityvariable. Theinnodb_io_capacity_maxvariable defines a maximum number of IOPS performed byInnoDBbackground tasks in such situations. This option does not controlinnodb_flush_syncbehavior.默认值是
innodb_io_capacity值的两倍。The default value is twice the value ofinnodb_io_capacity.有关配置
innodb_io_capacity_max变量的信息,请参阅 第 17.8.7 节,“配置 InnoDB I/O 容量”。For information about configuring theinnodb_io_capacity_maxvariable, see Section 17.8.7, “Configuring InnoDB I/O Capacity”.innodb_limit_optimistic_insert_debug命令行格式Command-Line Format --innodb-limit-optimistic-insert-debug=#系统变量System Variable innodb_limit_optimistic_insert_debug范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 2**32-1限制每个 B 树 页面上的记录数。默认值为 0 表示不施加限制。此选项仅在使用
WITH_DEBUGCMake 选项编译了调试支持时可用。Limits the number of records per B-tree page. A default value of 0 means that no limit is imposed. This option is only available if debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-lock-wait-timeout=#系统变量System Variable innodb_lock_wait_timeout范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 50最小值Minimum Value 1最大值Maximum Value 1073741824单位Unit 秒seconds InnoDB事务 在放弃之前等待 行锁 的时间长度(以秒为单位)。默认值为 50 秒。尝试访问被另一个InnoDB事务锁定的行的事务,最多等待这么多秒来获取该行的写访问权限,然后会出现以下错误:The length of time in seconds anInnoDBtransaction waits for a row lock before giving up. The default value is 50 seconds. A transaction that tries to access a row that is locked by anotherInnoDBtransaction waits at most this many seconds for write access to the row before issuing the following error:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
当发生锁等待超时时,当前语句会被回滚(而不是整个事务)。如果希望整个事务回滚,可以在启动服务器时使用
--innodb-rollback-on-timeout选项。另请参见第 17.20.5 节,“InnoDB 错误处理”。When a lock wait timeout occurs, the current statement is rolled back (not the entire transaction). To have the entire transaction roll back, start the server with the--innodb-rollback-on-timeoutoption. See also Section 17.20.5, “InnoDB Error Handling”.对于高度交互式的应用或OLTP系统,您可能会降低此值,以便快速显示用户反馈或将更新放入队列以便稍后处理。对于长时间运行的后端操作,例如数据仓库中的转换步骤等待其他大规模插入或更新操作完成,您可能会增加此值。You might decrease this value for highly interactive applications or OLTP systems, to display user feedback quickly or put the update into a queue for processing later. You might increase this value for long-running back-end operations, such as a transform step in a data warehouse that waits for other large insert or update operations to finish.
innodb_lock_wait_timeout适用于InnoDB行锁。MySQL 的 表锁 不会在InnoDB内发生,并且此超时不适用于等待表锁。innodb_lock_wait_timeoutapplies toInnoDBrow locks. A MySQL table lock does not happen insideInnoDBand this timeout does not apply to waits for table locks.当启用
innodb_deadlock_detect(默认设置)时,锁等待超时值不适用于 死锁,因为InnoDB会立即检测到死锁并回滚其中一个死锁事务。当innodb_deadlock_detect被禁用时,InnoDB将依赖innodb_lock_wait_timeout在发生死锁时回滚事务。参见 第 17.7.5.2 节,“死锁检测”。The lock wait timeout value does not apply to deadlocks wheninnodb_deadlock_detectis enabled (the default) becauseInnoDBdetects deadlocks immediately and rolls back one of the deadlocked transactions. Wheninnodb_deadlock_detectis disabled,InnoDBrelies oninnodb_lock_wait_timeoutfor transaction rollback when a deadlock occurs. See Section 17.7.5.2, “Deadlock Detection”.innodb_lock_wait_timeout可以在运行时通过SET GLOBAL或SET SESSION语句进行设置。更改GLOBAL设置需要具有足够权限以设置全局系统变量(请参见 第 7.1.9.1 节,“系统变量权限”)并会影响随后连接的所有客户端的操作。任何客户端都可以更改SESSION设置的innodb_lock_wait_timeout,这仅影响该客户端。innodb_lock_wait_timeoutcan be set at runtime with theSET GLOBALorSET SESSIONstatement. Changing theGLOBALsetting requires privileges sufficient to set global system variables (see Section 7.1.9.1, “System Variable Privileges”) and affects the operation of all clients that subsequently connect. Any client can change theSESSIONsetting forinnodb_lock_wait_timeout, which affects only that client.命令行格式Command-Line Format --innodb-log-buffer-size=#系统变量System Variable innodb_log_buffer_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 67108864最小值Minimum Value 1048576最大值Maximum Value 4294967295The size in bytes of the buffer that
InnoDBuses to write to the log files on disk. The default is 64MB. A large log buffer enables large 事务 to run without the need to write the log to disk before the transactions 相关 I/O 操作重新排列并批量执行时可能实现的更高性能之间的平衡。通过更改默认值可以获得更好的性能,但那样可能会在崩溃时丢失事务。. Thus, if you have transactions that update, insert, or delete many rows, making the log buffer larger saves disk I/O. For related information, see Memory Configuration,以及Section 10.5.4, “Optimizing InnoDB Redo Logging”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.The size in bytes of the buffer thatInnoDBuses to write to the log files on disk. The default is 64MB. A large log buffer enables large transactions to run without the need to write the log to disk before the transactions commit. Thus, if you have transactions that update, insert, or delete many rows, making the log buffer larger saves disk I/O. For related information, see Memory Configuration, and Section 10.5.4, “Optimizing InnoDB Redo Logging”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.innodb_log_checkpoint_fuzzy_now命令行格式Command-Line Format --innodb-log-checkpoint-fuzzy-now[={OFF|ON}]系统变量System Variable innodb_log_checkpoint_fuzzy_now范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用此调试选项以强制
InnoDB写入模糊检查点。只有在使用WITH_DEBUGCMake 选项编译了调试支持时,此选项才可用。Enable this debug option to forceInnoDBto write a fuzzy checkpoint. This option is only available if debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-log-checkpoint-now[={OFF|ON}]系统变量System Variable innodb_log_checkpoint_now范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用此调试选项以强制
InnoDB写入检查点。仅当使用WITH_DEBUGCMake 选项编译了调试支持时,此选项才可用。Enable this debug option to forceInnoDBto write a checkpoint. This option is only available if debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-log-checksums[={OFF|ON}]系统变量System Variable innodb_log_checksums范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON启用或禁用重做日志页的校验和。Enables or disables checksums for redo log pages.
innodb_log_checksums=ON为重做日志页启用CRC-32C校验和算法。当innodb_log_checksums被禁用时,重做日志页校验字段的内容将被忽略。innodb_log_checksums=ONenables theCRC-32Cchecksum algorithm for redo log pages. Wheninnodb_log_checksumsis disabled, the contents of the redo log page checksum field are ignored.重做日志头页和重做日志检查点页上的校验和永远不会被禁用。Checksums on the redo log header page and redo log checkpoint pages are never disabled.
命令行格式Command-Line Format --innodb-log-compressed-pages[={OFF|ON}]系统变量System Variable innodb_log_compressed_pages范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON指定是否将重新压缩的页镜像写入重做日志。当对压缩数据进行更改时,可能会发生重新压缩。Specifies whether images of re-compressed pages are written to the redo log. Re-compression may occur when changes are made to compressed data.
innodb_log_compressed_pages默认启用,以防止在恢复过程中使用不同版本的zlib压缩算法时可能发生的损坏。如果您确定zlib版本不会变化,您可以禁用innodb_log_compressed_pages,以减少修改压缩数据的工作负载所生成的重做日志。innodb_log_compressed_pagesis enabled by default to prevent corruption that could occur if a different version of thezlibcompression algorithm is used during recovery. If you are certain that thezlibversion is not subject to change, you can disableinnodb_log_compressed_pagesto reduce redo log generation for workloads that modify compressed data.要衡量启用或禁用
innodb_log_compressed_pages的效果,可在相同工作负载下比较两种设置的重做日志生成情况。衡量重做日志生成的选项包括观察Log sequence number输出中LOG部分的SHOW ENGINE INNODB STATUS(LSN),或监控Innodb_os_log_written状态,以查看写入重做日志文件的字节数。To measure the effect of enabling or disablinginnodb_log_compressed_pages, compare redo log generation for both settings under the same workload. Options for measuring redo log generation include observing theLog sequence number(LSN) in theLOGsection ofSHOW ENGINE INNODB STATUSoutput, or monitoringInnodb_os_log_writtenstatus for the number of bytes written to the redo log files.有关相关信息,请参见 第 17.9.1.6 节,“用于 OLTP 工作负载的压缩”。For related information, see Section 17.9.1.6, “Compression for OLTP Workloads”.
命令行格式Command-Line Format --innodb-log-file-size=#已弃用Deprecated 是Yes 系统变量System Variable innodb_log_file_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 50331648最小值Minimum Value 4194304最大值Maximum Value 512GB / innodb_log_files_in_group单位Unit 字节bytes Noteinnodb_log_file_size和innodb_log_files_in_group已被innodb_redo_log_capacity取代;参见 第 17.6.5 节,“重做日志”。innodb_log_file_sizeandinnodb_log_files_in_grouphave been superseded byinnodb_redo_log_capacity; see Section 17.6.5, “Redo Log”.每个日志文件在日志组中的字节大小。日志文件的总大小(
innodb_log_file_size*innodb_log_files_in_group)不能超过略小于 512GB 的最大值。例如,一对 255 GB 的日志文件接近限制但没有超过。默认值为 48MB。The size in bytes of each log file in a log group. The combined size of log files (innodb_log_file_size*innodb_log_files_in_group) cannot exceed a maximum value that is slightly less than 512GB. A pair of 255 GB log files, for example, approaches the limit but does not exceed it. The default value is 48MB.通常,日志文件的总大小应足够大,以便服务器能够平滑处理工作负载活动的高峰和低谷,这通常意味着有足够的重做日志空间来处理超过一小时的写入活动。值越大,缓冲池中所需的检查点刷新活动就越少,从而节省磁盘 I/O。较大的日志文件也会使故障恢复变慢。Generally, the combined size of the log files should be large enough that the server can smooth out peaks and troughs in workload activity, which often means that there is enough redo log space to handle more than an hour of write activity. The larger the value, the less checkpoint flush activity is required in the buffer pool, saving disk I/O. Larger log files also make crash recovery slower.
最小的
innodb_log_file_size为 4MB。The minimuminnodb_log_file_sizeis 4MB.有关相关信息,请参见 重做日志配置。有关一般 I/O 调优建议,请参见 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。For related information, see Redo Log Configuration. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.
如果服务器使用
--innodb-dedicated-server启动,那么如果没有明确定义,innodb_log_file_size的值将自动设置。有关更多信息,请参阅 第 17.8.12 节,“为专用 MySQL 服务器启用自动 InnoDB 配置”。If the server is started with--innodb-dedicated-server, the value ofinnodb_log_file_sizeis set automatically if it is not explicitly defined. For more information, see Section 17.8.12, “Enabling Automatic InnoDB Configuration for a Dedicated MySQL Server”.命令行格式Command-Line Format --innodb-log-files-in-group=#已弃用Deprecated 是Yes 系统变量System Variable innodb_log_files_in_group范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2最小值Minimum Value 2最大值Maximum Value 100Noteinnodb_log_file_size和innodb_log_files_in_group已被innodb_redo_log_capacity取代;参见 第 17.6.5 节,“重做日志”。innodb_log_file_sizeandinnodb_log_files_in_grouphave been superseded byinnodb_redo_log_capacity; see Section 17.6.5, “Redo Log”.日志文件在日志组中的数量。
InnoDB以循环方式写入这些文件。默认值(也是推荐值)为 2。文件的位置由innodb_log_group_home_dir指定。日志文件的总大小(innodb_log_file_size*innodb_log_files_in_group)可以达到 512GB。The number of log files in the log group.InnoDBwrites to the files in a circular fashion. The default (and recommended) value is 2. The location of the files is specified byinnodb_log_group_home_dir. The combined size of log files (innodb_log_file_size*innodb_log_files_in_group) can be up to 512GB.有关相关信息,请参阅 重做日志配置。For related information, see Redo Log Configuration.
如果服务器是使用
--innodb-dedicated-server启动的,则innodb_log_files_in_group的值会在未显式定义时自动设置。有关更多信息,请参阅 第 17.8.12 节,“为专用 MySQL 服务器启用自动 InnoDB 配置”。If the server is started with--innodb-dedicated-server, the value ofinnodb_log_files_in_groupis set automatically if it is not explicitly defined. For more information, see Section 17.8.12, “Enabling Automatic InnoDB Configuration for a Dedicated MySQL Server”.命令行格式Command-Line Format --innodb-log-group-home-dir=dir_name系统变量System Variable innodb_log_group_home_dir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name InnoDB重做日志 文件的目录路径。The directory path to theInnoDBredo log files.有关相关信息,请参阅 重做日志配置。For related information, see Redo Log Configuration.
命令行格式Command-Line Format --innodb-log-spin-cpu-abs-lwm=#系统变量System Variable innodb_log_spin_cpu_abs_lwm范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 80最小值Minimum Value 0最大值Maximum Value 4294967295定义了用户线程在等待已刷新重做日志时不再自旋的最低 CPU 使用量。该值以 CPU 核心使用总和表示。例如,默认值 80 表示单个 CPU 核心的 80%。在多核处理器系统上,值为 150 表示一个 CPU 核心的 100% 使用加上第二个 CPU 核心的 50% 使用。Defines the minimum amount of CPU usage below which user threads no longer spin while waiting for flushed redo. The value is expressed as a sum of CPU core usage. For example, The default value of 80 is 80% of a single CPU core. On a system with a multi-core processor, a value of 150 represents 100% usage of one CPU core plus 50% usage of a second CPU core.
有关相关信息,请参见 第 10.5.4 节,“优化 InnoDB 重做日志”。For related information, see Section 10.5.4, “Optimizing InnoDB Redo Logging”.
命令行格式Command-Line Format --innodb-log-spin-cpu-pct-hwm=#系统变量System Variable innodb_log_spin_cpu_pct_hwm范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 50最小值Minimum Value 0最大值Maximum Value 100定义用户线程在等待刷写的重做日志时不再自旋的最大 CPU 使用量。该值以所有 CPU 核心总处理能力的百分比表示。默认值为 50%。例如,在一个具有四个 CPU 核心的服务器上,两核心的 100%使用量相当于总 CPU 处理能力的 50%。Defines the maximum amount of CPU usage above which user threads no longer spin while waiting for flushed redo. The value is expressed as a percentage of the combined total processing power of all CPU cores. The default value is 50%. For example, 100% usage of two CPU cores is 50% of the combined CPU processing power on a server with four CPU cores.
innodb_log_spin_cpu_pct_hwm变量遵循处理器亲和性。例如,如果服务器有 48 个核心,但 mysqld 进程只绑定在四个 CPU 核心上,其余 44 个 CPU 核心将被忽略。Theinnodb_log_spin_cpu_pct_hwmvariable respects processor affinity. For example, if a server has 48 cores but the mysqld process is pinned to only four CPU cores, the other 44 CPU cores are ignored.有关相关信息,请参见 第 10.5.4 节,“优化 InnoDB 重做日志”。For related information, see Section 10.5.4, “Optimizing InnoDB Redo Logging”.
innodb_log_wait_for_flush_spin_hwm命令行格式Command-Line Format --innodb-log-wait-for-flush-spin-hwm=#系统变量System Variable innodb_log_wait_for_flush_spin_hwm范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 400最小值Minimum Value 0最大值Maximum Value 2**32-1单位Unit 微秒microseconds 定义了最大平均日志刷新时间,超过该时间用户线程在等待已刷新重做日志时将不再自旋。默认值是 400 微秒。Defines the maximum average log flush time beyond which user threads no longer spin while waiting for flushed redo. The default value is 400 microseconds.
有关相关信息,请参见 第 10.5.4 节,“优化 InnoDB 重做日志”。For related information, see Section 10.5.4, “Optimizing InnoDB Redo Logging”.
命令行格式Command-Line Format --innodb-log-write-ahead-size=#系统变量System Variable innodb_log_write_ahead_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 8192最小值Minimum Value 512 (log file block size)512 (log file block size)最大值Maximum Value Equal to innodb_page_sizeEqual to innodb_page_size单位Unit 字节bytes 定义重做日志的预写入块大小,单位为字节。为了避免“读写冲突”,请将
innodb_log_write_ahead_size设置为与操作系统或文件系统缓存块大小相匹配。默认设置为 8192 字节。当重做日志块由于重做日志的预写入块大小与操作系统或文件系统缓存块大小不匹配而未完全缓存到操作系统或文件系统时,就会发生读写冲突。Defines the write-ahead block size for the redo log, in bytes. To avoid “read-on-write”, setinnodb_log_write_ahead_sizeto match the operating system or file system cache block size. The default setting is 8192 bytes. Read-on-write occurs when redo log blocks are not entirely cached to the operating system or file system due to a mismatch between write-ahead block size for the redo log and operating system or file system cache block size.innodb_log_write_ahead_size的有效值为InnoDB日志文件块大小 (2n) 的倍数。最小值是InnoDB日志文件块大小 (512)。当指定最小值时,不会发生预写。最大值等于innodb_page_size值。如果您为innodb_log_write_ahead_size指定的值大于innodb_page_size值,innodb_log_write_ahead_size设置被截断为innodb_page_size值。Valid values forinnodb_log_write_ahead_sizeare multiples of theInnoDBlog file block size (2n). The minimum value is theInnoDBlog file block size (512). Write-ahead does not occur when the minimum value is specified. The maximum value is equal to theinnodb_page_sizevalue. If you specify a value forinnodb_log_write_ahead_sizethat is larger than theinnodb_page_sizevalue, theinnodb_log_write_ahead_sizesetting is truncated to theinnodb_page_sizevalue.将
innodb_log_write_ahead_size的值设置得相对于操作系统或文件系统缓存块大小过低会导致 “读写时读”。将该值设置得过高可能会对日志文件写入的fsync性能产生轻微影响,因为会同时写入多个块。Setting theinnodb_log_write_ahead_sizevalue too low in relation to the operating system or file system cache block size results in “read-on-write”. Setting the value too high may have a slight impact onfsyncperformance for log file writes due to several blocks being written at once.有关相关信息,请参见 第 10.5.4 节,“优化 InnoDB 重做日志”。For related information, see Section 10.5.4, “Optimizing InnoDB Redo Logging”.
命令行格式Command-Line Format --innodb-log-writer-threads[={OFF|ON}]系统变量System Variable innodb_log_writer_threads范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON启用专用日志写入线程,用于将日志缓冲区中的重做日志记录写入系统缓冲区,并将系统缓冲区刷新到重做日志文件。专用日志写入线程可以提高高并发系统的性能,但对于低并发系统,禁用专用日志写入线程可以提供更好的性能。Enables dedicated log writer threads for writing redo log records from the log buffer to the system buffers and flushing the system buffers to the redo log files. Dedicated log writer threads can improve performance on high-concurrency systems, but for low-concurrency systems, disabling dedicated log writer threads provides better performance.
有关更多信息,请参阅 第 10.5.4 节,“优化 InnoDB 重做日志”。For more information, see Section 10.5.4, “Optimizing InnoDB Redo Logging”.
命令行格式Command-Line Format --innodb-lru-scan-depth=#系统变量System Variable innodb_lru_scan_depth范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 1024最小值Minimum Value 100最大值Maximum Value 2**32-1一个影响
InnoDB缓冲池 刷新 操作的算法和启发式的参数。主要供性能专家在调优 I/O 密集型工作负载时参考。它指定了每个缓冲池实例中,页面清理线程在寻找要刷新的 脏页 时,需要扫描缓冲池 LRU 页面列表的深度。这是一种每秒执行一次的后台操作。A parameter that influences the algorithms and heuristics for the flush operation for theInnoDBbuffer pool. Primarily of interest to performance experts tuning I/O-intensive workloads. It specifies, per buffer pool instance, how far down the buffer pool LRU page list the page cleaner thread scans looking for dirty pages to flush. This is a background operation performed once per second.比默认值更小的设置通常适用于大多数工作负载。远高于所需的值可能会影响性能。只有在典型工作负载下有多余的 I/O 容量时,才考虑增加该值。相反,如果写入密集型工作负载使你的 I/O 容量达到饱和,则应降低该值,特别是在缓冲池较大的情况下。A setting smaller than the default is generally suitable for most workloads. A value that is much higher than necessary may impact performance. Only consider increasing the value if you have spare I/O capacity under a typical workload. Conversely, if a write-intensive workload saturates your I/O capacity, decrease the value, especially in the case of a large buffer pool.
在调优
innodb_lru_scan_depth时,从较低的值开始,并将其逐步调高,目标是很少看到零空闲页。此外,在更改缓冲池实例数量时,也应考虑调整innodb_lru_scan_depth,因为innodb_lru_scan_depth*innodb_buffer_pool_instances定义了页面清理线程每秒执行的工作量。When tuninginnodb_lru_scan_depth, start with a low value and configure the setting upward with the goal of rarely seeing zero free pages. Also, consider adjustinginnodb_lru_scan_depthwhen changing the number of buffer pool instances, sinceinnodb_lru_scan_depth*innodb_buffer_pool_instancesdefines the amount of work performed by the page cleaner thread each second.有关相关信息,请参见 第 17.8.3.5 节,“配置缓冲池刷新”。有关一般的 I/O 调优建议,请参见 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。For related information, see Section 17.8.3.5, “Configuring Buffer Pool Flushing”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.
命令行格式Command-Line Format --innodb-max-dirty-pages-pct=#系统变量System Variable innodb_max_dirty_pages_pct范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 数字Numeric 默认值Default Value 90最小值Minimum Value 0最大值Maximum Value 99.999InnoDB尝试从 缓冲池 刷新 数据,以使 脏页 的百分比不超过此值。InnoDBtries to flush data from the buffer pool so that the percentage of dirty pages does not exceed this value.innodb_max_dirty_pages_pct设置为刷新活动建立了一个目标。它不影响刷新速度。有关管理刷新速度的信息,请参见 第 17.8.3.5 节,“配置缓冲池刷新”。Theinnodb_max_dirty_pages_pctsetting establishes a target for flushing activity. It does not affect the rate of flushing. For information about managing the rate of flushing, see Section 17.8.3.5, “Configuring Buffer Pool Flushing”.有关相关信息,请参见 第 17.8.3.5 节,“配置缓冲池刷新”。有关一般的 I/O 调优建议,请参见 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。For related information, see Section 17.8.3.5, “Configuring Buffer Pool Flushing”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.
innodb_max_dirty_pages_pct_lwm命令行格式Command-Line Format --innodb-max-dirty-pages-pct-lwm=#系统变量System Variable innodb_max_dirty_pages_pct_lwm范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 数字Numeric 默认值Default Value 10最小值Minimum Value 0最大值Maximum Value 99.999脏页dirty pages at which preflushing is enabled to control the dirty page ratio. A value of 0 disables the pre-flushing behavior entirely. The configured value should always be lower than the
innodb_max_dirty_pages_pctvalue. For more information, see Section 17.8.3.5, “Configuring Buffer Pool Flushing”.Defines a low water mark representing the percentage of dirty pages at which preflushing is enabled to control the dirty page ratio. A value of 0 disables the pre-flushing behavior entirely. The configured value should always be lower than theinnodb_max_dirty_pages_pctvalue. For more information, see Section 17.8.3.5, “Configuring Buffer Pool Flushing”.命令行格式Command-Line Format --innodb-max-purge-lag=#系统变量System Variable innodb_max_purge_lag范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 4294967295定义所需的最大清理延迟。如果超过此值,将对
INSERT、UPDATE和DELETE操作施加延迟,以允许清理操作赶上。默认值为 0,这意味着没有最大清理延迟,也没有延迟。Defines the desired maximum purge lag. If this value is exceeded, a delay is imposed onINSERT,UPDATE, andDELETEoperations to allow time for purge to catch up. The default value is 0, which means there is no maximum purge lag and no delay.有关更多信息,请参见第 17.8.9 节,“清理配置”。For more information, see Section 17.8.9, “Purge Configuration”.
命令行格式Command-Line Format --innodb-max-purge-lag-delay=#系统变量System Variable innodb_max_purge_lag_delay范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 10000000单位Unit 微秒microseconds 指定当超出
innodb_max_purge_lag阈值时施加延迟的最大延迟时间(以微秒为单位)。指定的innodb_max_purge_lag_delay值是由innodb_max_purge_lag公式计算出的延迟期的上限。Specifies the maximum delay in microseconds for the delay imposed when theinnodb_max_purge_lagthreshold is exceeded. The specifiedinnodb_max_purge_lag_delayvalue is an upper limit on the delay period calculated by theinnodb_max_purge_lagformula.有关更多信息,请参见第 17.8.9 节,“清理配置”。For more information, see Section 17.8.9, “Purge Configuration”.
命令行格式Command-Line Format --innodb-max-undo-log-size=#系统变量System Variable innodb_max_undo_log_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 1073741824最小值Minimum Value 10485760最大值Maximum Value 2**64-1单位Unit 字节bytes 定义撤销表空间的阈值大小。如果撤销表空间超过该阈值,当启用
innodb_undo_log_truncate时,它可以被标记为截断。默认值为 1073741824 字节(1024 MiB)。Defines a threshold size for undo tablespaces. If an undo tablespace exceeds the threshold, it can be marked for truncation wheninnodb_undo_log_truncateis enabled. The default value is 1073741824 bytes (1024 MiB).更多信息,请参见 截断撤销表空间。For more information, see Truncating Undo Tablespaces.
innodb_merge_threshold_set_all_debug命令行格式Command-Line Format --innodb-merge-threshold-set-all-debug=#系统变量System Variable innodb_merge_threshold_set_all_debug范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 50最小值Minimum Value 1最大值Maximum Value 50定义索引页的满页百分比值,该值会覆盖字典缓存中当前所有索引的
MERGE_THRESHOLD设置。此选项仅在通过WITH_DEBUGCMake 选项编译了调试支持时可用。有关相关信息,请参阅 第 17.8.11 节,“配置索引页的合并阈值”。Defines a page-full percentage value for index pages that overrides the currentMERGE_THRESHOLDsetting for all indexes that are currently in the dictionary cache. This option is only available if debugging support is compiled in using theWITH_DEBUGCMake option. For related information, see Section 17.8.11, “Configuring the Merge Threshold for Index Pages”.命令行格式Command-Line Format --innodb-monitor-disable={counter|module|pattern|all}系统变量System Variable innodb_monitor_disable范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 此变量充当开关,禁用
InnoDB指标计数器。可以使用信息模式INNODB_METRICS表查询计数器数据。有关使用信息,请参见第 17.15.6 节,“InnoDB INFORMATION_SCHEMA 指标表”。This variable acts as a switch, disablingInnoDBmetrics counters. Counter data may be queried using the Information SchemaINNODB_METRICStable. For usage information, see Section 17.15.6, “InnoDB INFORMATION_SCHEMA Metrics Table”.innodb_monitor_disable='latch'禁用SHOW ENGINE INNODB MUTEX的统计收集。更多信息,请参见 第 15.7.7.16 节,“SHOW ENGINE 语句”。innodb_monitor_disable='latch'disables statistics collection forSHOW ENGINE INNODB MUTEX. For more information, see Section 15.7.7.16, “SHOW ENGINE Statement”.命令行格式Command-Line Format --innodb-monitor-enable={counter|module|pattern|all}系统变量System Variable innodb_monitor_enable范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 此变量充当开关,启用
InnoDB指标计数器。可以使用信息模式的INNODB_METRICS表查询计数器数据。有关使用信息,请参见第 17.15.6 节,“InnoDB INFORMATION_SCHEMA 指标表”。This variable acts as a switch, enablingInnoDBmetrics counters. Counter data may be queried using the Information SchemaINNODB_METRICStable. For usage information, see Section 17.15.6, “InnoDB INFORMATION_SCHEMA Metrics Table”.innodb_monitor_enable='latch'启用SHOW ENGINE INNODB MUTEX的统计收集。更多信息,请参见 第 15.7.7.16 节,“SHOW ENGINE 语句”。innodb_monitor_enable='latch'enables statistics collection forSHOW ENGINE INNODB MUTEX. For more information, see Section 15.7.7.16, “SHOW ENGINE Statement”.命令行格式Command-Line Format --innodb-monitor-reset={counter|module|pattern|all}系统变量System Variable innodb_monitor_reset范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value NULL有效值Valid Values countermodulepatternallall此变量充当开关,将
InnoDB指标计数器 的计数值重置为零。可以使用信息模式INNODB_METRICS表查询计数器数据。有关用法信息,请参见 第 17.15.6 节,“InnoDB INFORMATION_SCHEMA 指标表”。This variable acts as a switch, resetting the count value forInnoDBmetrics counters to zero. Counter data may be queried using the Information SchemaINNODB_METRICStable. For usage information, see Section 17.15.6, “InnoDB INFORMATION_SCHEMA Metrics Table”.innodb_monitor_reset='latch'重置由SHOW ENGINE INNODB MUTEX报告的统计信息。有关更多信息,请参见 第 15.7.7.16 节,“SHOW ENGINE 语句”。innodb_monitor_reset='latch'resets statistics reported bySHOW ENGINE INNODB MUTEX. For more information, see Section 15.7.7.16, “SHOW ENGINE Statement”.命令行格式Command-Line Format --innodb-monitor-reset-all={counter|module|pattern|all}系统变量System Variable innodb_monitor_reset_all范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value NULL有效值Valid Values countermodulepatternallall此变量充当开关,重置
InnoDB指标计数器 的所有值(最小值、最大值等)。计数器数据可以使用 Information SchemaINNODB_METRICS表进行查询。有关使用信息,请参见 第 17.15.6 节,“InnoDB INFORMATION_SCHEMA 指标表”。This variable acts as a switch, resetting all values (minimum, maximum, and so on) forInnoDBmetrics counters. Counter data may be queried using the Information SchemaINNODB_METRICStable. For usage information, see Section 17.15.6, “InnoDB INFORMATION_SCHEMA Metrics Table”.命令行格式Command-Line Format --innodb-numa-interleave[={OFF|ON}]系统变量System Variable innodb_numa_interleave范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON启用 NUMA 交错内存策略以分配
InnoDB缓冲池。当innodb_numa_interleave被启用时,NUMA 内存策略会被设置为MPOL_INTERLEAVE,用于 mysqld 进程。在分配InnoDB缓冲池之后,NUMA 内存策略会恢复为MPOL_DEFAULT。要使innodb_numa_interleave选项可用,MySQL 必须在支持 NUMA 的 Linux 系统上编译。如果系统支持,默认值为ON,否则默认为OFF。Enables the NUMA interleave memory policy for allocation of theInnoDBbuffer pool. Wheninnodb_numa_interleaveis enabled, the NUMA memory policy is set toMPOL_INTERLEAVEfor the mysqld process. After theInnoDBbuffer pool is allocated, the NUMA memory policy is set back toMPOL_DEFAULT. For theinnodb_numa_interleaveoption to be available, MySQL must be compiled on a NUMA-enabled Linux system. The default value isONif the system supports it, otherwise it defaults toOFF.CMake 根据当前平台是否支持
NUMA设置默认的WITH_NUMA值。更多信息,请参见 第 2.8.7 节,“MySQL 源代码配置选项”。CMake sets the defaultWITH_NUMAvalue based on whether the current platform hasNUMAsupport. For more information, see Section 2.8.7, “MySQL Source-Configuration Options”.命令行格式Command-Line Format --innodb-old-blocks-pct=#系统变量System Variable innodb_old_blocks_pct范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 37最小值Minimum Value 5最大值Maximum Value 95Specifies the approximate percentage of the
InnoDB缓冲池 used for the old block sublist. The range of values is 5 to 95. The default value is 37 (that is, 3/8 of the pool). Often used in combination withinnodb_old_blocks_time.Specifies the approximate percentage of theInnoDBbuffer pool used for the old block sublist. The range of values is 5 to 95. The default value is 37 (that is, 3/8 of the pool). Often used in combination withinnodb_old_blocks_time.欲了解更多信息,请参阅 第 17.8.3.3 节,“使缓冲池扫描具有抗性”。有关缓冲池管理、LRU 算法和 驱逐 策略的信息,请参阅 第 17.5.1 节,“缓冲池”。For more information, see Section 17.8.3.3, “Making the Buffer Pool Scan Resistant”. For information about buffer pool management, the LRU algorithm, and eviction policies, see Section 17.5.1, “Buffer Pool”.
命令行格式Command-Line Format --innodb-old-blocks-time=#系统变量System Variable innodb_old_blocks_time范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 1000最小值Minimum Value 0最大值Maximum Value 2**32-1单位Unit 毫秒milliseconds Non-zero values protect against the 缓冲池 being filled by data that is referenced only for a brief period, such as during a full table scan. Increasing this value offers more protection against full table scans interfering with data cached in the buffer pool.Non-zero values protect against the buffer pool being filled by data that is referenced only for a brief period, such as during a full table scan. Increasing this value offers more protection against full table scans interfering with data cached in the buffer pool.
指定在首次访问后,插入到旧子列表的块在多长时间(毫秒)内保持在旧子列表中,然后才可以移动到新子列表。如果值为 0,则插入到旧子列表的块在首次访问时会立即移动到新子列表,无论访问发生在插入后多久。如果值大于 0,则块会保持在旧子列表中,直到首次访问后至少经过那么多毫秒的再次访问。例如,值为 1000 会导致块在首次访问后在旧子列表中停留 1 秒钟,然后才有资格移动到新子列表。Specifies how long in milliseconds a block inserted into the old sublist must stay there after its first access before it can be moved to the new sublist. If the value is 0, a block inserted into the old sublist moves immediately to the new sublist the first time it is accessed, no matter how soon after insertion the access occurs. If the value is greater than 0, blocks remain in the old sublist until an access occurs at least that many milliseconds after the first access. For example, a value of 1000 causes blocks to stay in the old sublist for 1 second after the first access before they become eligible to move to the new sublist.
默认值为 1000。The default value is 1000.
该变量通常与
innodb_old_blocks_pct结合使用。有关更多信息,请参见 第 17.8.3.3 节,“使缓冲池具备扫描抗性”。有关缓冲池管理、LRU 算法以及 驱逐 策略的信息,请参见 第 17.5.1 节,“缓冲池”。This variable is often used in combination withinnodb_old_blocks_pct. For more information, see Section 17.8.3.3, “Making the Buffer Pool Scan Resistant”. For information about buffer pool management, the LRU algorithm, and eviction policies, see Section 17.5.1, “Buffer Pool”.innodb_online_alter_log_max_size命令行格式Command-Line Format --innodb-online-alter-log-max-size=#系统变量System Variable innodb_online_alter_log_max_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 134217728最小值Minimum Value 65536最大值Maximum Value 2**64-1单位Unit 字节bytes 指定在 在线 DDL 操作期间用于
InnoDB表的临时日志文件的大小上限(以字节为单位)。每个正在创建的索引或正在修改的表都有一个这样的日志文件。此日志文件在 DDL 操作期间存储插入、更新或删除的数据。当需要时,临时日志文件会按innodb_sort_buffer_size的值进行扩展,最大可达innodb_online_alter_log_max_size指定的上限。如果临时日志文件超过上限,ALTER TABLE操作将失败,并且所有未提交的并发 DML 操作将回滚。因此,此选项的较大值允许在在线 DDL 操作期间执行更多的 DML,但也会延长 DDL 操作结束时表被锁定以应用日志数据的时间。Specifies an upper limit in bytes on the size of the temporary log files used during online DDL operations forInnoDBtables. There is one such log file for each index being created or table being altered. This log file stores data inserted, updated, or deleted in the table during the DDL operation. The temporary log file is extended when needed by the value ofinnodb_sort_buffer_size, up to the maximum specified byinnodb_online_alter_log_max_size. If a temporary log file exceeds the upper size limit, theALTER TABLEoperation fails and all uncommitted concurrent DML operations are rolled back. Thus, a large value for this option allows more DML to happen during an online DDL operation, but also extends the period of time at the end of the DDL operation when the table is locked to apply the data from the log.命令行格式Command-Line Format --innodb-open-files=#系统变量System Variable innodb_open_files范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value -1(表示自动调整大小;不要分配此字面值)-1(signifies autosizing; do not assign this literal value)最小值Minimum Value 10最大值Maximum Value 2147483647指定
InnoDB一次可以打开的最大文件数。最小值为 10。如果innodb_file_per_table被禁用,则默认值为 300;否则,默认值为 300 或table_open_cache设置值,以较高者为准。Specifies the maximum number of files thatInnoDBcan have open at one time. The minimum value is 10. Ifinnodb_file_per_tableis disabled, the default value is 300; otherwise, the default value is 300 or thetable_open_cachesetting, whichever is higher.可以在运行时使用
innodb_open_files语句设置innodb_open_files限制,其中N是所需的SELECT innodb_set_open_files_limit(N)限制;例如:Theinnodb_open_fileslimit can be set at runtime using aSELECT innodb_set_open_files_limit(statement, whereN)Nis the desiredinnodb_open_fileslimit; for example:mysql>
SELECT innodb_set_open_files_limit(1000);该语句执行一个存储过程来设置新的限制。如果过程成功,它将返回新设置的限制值;否则,将返回失败信息。The statement executes a stored procedure that sets the new limit. If the procedure is successful, it returns the value of the newly set limit; otherwise, a failure message is returned.
不允许使用
SET语句来设置innodb_open_files。要在运行时设置innodb_open_files,请使用上面描述的SELECT innodb_set_open_files_limit(N)语句。It is not permitted to setinnodb_open_filesusing aSETstatement. To setinnodb_open_filesat runtime, use theSELECT innodb_set_open_files_limit(statement described above.N)不支持设置
innodb_open_files=default。只允许使用整数值。Settinginnodb_open_files=defaultis not supported. Only integer values are permitted.为了防止非 LRU 管理的文件消耗掉整个
innodb_open_files限额,非 LRU 管理的文件被限制使用该限额的 90%,从而为 LRU 管理的文件保留 10%。To prevent non-LRU managed files from consuming the entireinnodb_open_fileslimit, non-LRU managed files are limited to 90 percent of this limit, which reserves 10 percent of it for LRU managed files.命令行格式Command-Line Format --innodb-optimize-fulltext-only[={OFF|ON}]系统变量System Variable innodb_optimize_fulltext_only范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF更改
OPTIMIZE TABLE对InnoDB表的操作方式。意在临时启用,用于对具有FULLTEXT索引的InnoDB表进行维护操作时。Changes the wayOPTIMIZE TABLEoperates onInnoDBtables. Intended to be enabled temporarily, during maintenance operations forInnoDBtables withFULLTEXTindexes.默认情况下,
OPTIMIZE TABLE会重新组织表的 聚簇索引 中的数据。当启用此选项时,OPTIMIZE TABLE会跳过表数据的重新组织,而是处理InnoDBFULLTEXT索引中新添加、删除或更新的标记数据。有关更多信息,请参见 优化 InnoDB 全文索引。By default,OPTIMIZE TABLEreorganizes data in the clustered index of the table. When this option is enabled,OPTIMIZE TABLEskips the reorganization of table data, and instead processes newly added, deleted, and updated token data forInnoDBFULLTEXTindexes. For more information, see Optimizing InnoDB Full-Text Indexes.命令行格式Command-Line Format --innodb-page-cleaners=#系统变量System Variable innodb_page_cleaners范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value innodb_buffer_pool_instances最小值Minimum Value 1最大值Maximum Value 64将脏页从缓冲池实例刷新出去的页面清理线程的数量。页面清理线程执行刷新列表和 LRU 刷新。当存在多个页面清理线程时,每个缓冲池实例的缓冲池刷新任务会分配给空闲的页面清理线程。
innodb_page_cleaners的默认值设置为与innodb_buffer_pool_instances相同的值。如果指定的页面清理线程数量超过缓冲池实例的数量,则innodb_page_cleaners会自动设置为与innodb_buffer_pool_instances相同的值。The number of page cleaner threads that flush dirty pages from buffer pool instances. Page cleaner threads perform flush list and LRU flushing. When there are multiple page cleaner threads, buffer pool flushing tasks for each buffer pool instance are dispatched to idle page cleaner threads. Theinnodb_page_cleanersdefault value is set to the same value asinnodb_buffer_pool_instances. If the specified number of page cleaner threads exceeds the number of buffer pool instances, theninnodb_page_cleanersis automatically set to the same value asinnodb_buffer_pool_instances.如果在将脏页从缓冲池实例刷新到数据文件时,您的工作负载是写入 IO 瓶颈,并且您的系统硬件有可用容量,则增加页面清理线程的数量可能有助于提高写入 IO 吞吐量。If your workload is write-IO bound when flushing dirty pages from buffer pool instances to data files, and if your system hardware has available capacity, increasing the number of page cleaner threads may help improve write-IO throughput.
多线程页面清理支持扩展到关闭和恢复阶段。Multithreaded page cleaner support extends to shutdown and recovery phases.
在支持的 Linux 平台上,可以使用
setpriority()系统调用,并且 mysqld 执行用户被授权赋予page_cleaner线程比其他 MySQL 和InnoDB线程更高的优先级,以帮助页面刷新跟上当前的工作负载。setpriority()支持由以下InnoDB启动消息指示:Thesetpriority()system call is used on Linux platforms where it is supported, and where the mysqld execution user is authorized to givepage_cleanerthreads priority over other MySQL andInnoDBthreads to help page flushing keep pace with the current workload.setpriority()support is indicated by thisInnoDBstartup message:[Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
对于服务器启动和关闭不由 systemd 管理的系统,可以在
/etc/security/limits.conf中配置 mysqld 执行用户的授权。例如,如果 mysqld 在mysql用户下运行,可以通过向/etc/security/limits.conf添加以下行来授权mysql用户:For systems where server startup and shutdown is not managed by systemd, mysqld execution user authorization can be configured in/etc/security/limits.conf. For example, if mysqld is run under themysqluser, you can authorize themysqluser by adding these lines to/etc/security/limits.conf:mysql hard nice -20 mysql soft nice -20
对于由 systemd 管理的系统,可以通过在本地化的 systemd 配置文件中指定
LimitNICE=-20来实现相同的效果。例如,在/etc/systemd/system/mysqld.service.d/override.conf中创建一个名为override.conf的文件,并添加以下条目:For systemd managed systems, the same can be achieved by specifyingLimitNICE=-20in a localized systemd configuration file. For example, create a file namedoverride.confin/etc/systemd/system/mysqld.service.d/override.confand add this entry:[Service] LimitNICE=-20
创建或更改
override.conf后,重新加载 systemd 配置,然后告诉 systemd 重启 MySQL 服务:After creating or changingoverride.conf, reload the systemd configuration, then tell systemd to restart the MySQL service:systemctl daemon-reload systemctl restart mysqld # RPM platforms systemctl restart mysql # Debian platforms
有关使用本地化 systemd 配置文件的更多信息,请参阅 为 MySQL 配置 systemd。For more information about using a localized systemd configuration file, see Configuring systemd for MySQL.
在授权 mysqld 执行用户后,使用 cat 命令验证为 mysqld 进程配置的
Nice限制:After authorizing the mysqld execution user, use the cat command to verify the configuredNicelimits for the mysqld process:$> cat /proc/
mysqld_pid/limits | grep nice Max nice priority 18446744073709551596 18446744073709551596命令行格式Command-Line Format --innodb-page-size=#系统变量System Variable innodb_page_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value 16384有效值Valid Values 40968192163843276865536指定
InnoDB表空间 的 页面大小。值可以用字节或千字节指定。例如,16 千字节的页面大小可以指定为 16384、16KB 或 16k。Specifies the page size forInnoDBtablespaces. Values can be specified in bytes or kilobytes. For example, a 16 kilobyte page size value can be specified as 16384, 16KB, or 16k.innodb_page_size只能在初始化 MySQL 实例之前配置,之后无法更改。如果未指定值,实例将使用默认页面大小进行初始化。参见 第 17.8.1 节,“InnoDB 启动配置”。innodb_page_sizecan only be configured prior to initializing the MySQL instance and cannot be changed afterward. If no value is specified, the instance is initialized using the default page size. See Section 17.8.1, “InnoDB Startup Configuration”.对于 32KB 和 64KB 页面大小,最大行长度约为 16000 字节。当
innodb_page_size设置为 32KB 或 64KB 时,不支持ROW_FORMAT=COMPRESSED。对于innodb_page_size=32KB,区大小为 2MB。对于innodb_page_size=64KB,区大小为 4MB。使用 32KB 或 64KB 页面大小时,innodb_log_buffer_size应至少设置为 16MB(默认值为 64MB)。For both 32KB and 64KB page sizes, the maximum row length is approximately 16000 bytes.ROW_FORMAT=COMPRESSEDis not supported wheninnodb_page_sizeis set to 32KB or 64KB. Forinnodb_page_size=32KB, extent size is 2MB. Forinnodb_page_size=64KB, extent size is 4MB.innodb_log_buffer_sizeshould be set to at least 16MB (the default is 64MB) when using 32KB or 64KB page sizes.默认的 16KB 页大小或更大适用于各种工作负载,尤其是涉及表扫描和批量更新的 DML 操作的查询。较小的页大小可能对于涉及许多小写操作的OLTP工作负载更高效,因为当单页包含许多行时,争用可能成为问题。较小的页大小对于SSD存储设备也可能更高效,这类设备通常使用较小的块大小。将
InnoDB页大小保持接近存储设备的块大小,可最小化重写到磁盘的未更改数据量。The default 16KB page size or larger is appropriate for a wide range of workloads, particularly for queries involving table scans and DML operations involving bulk updates. Smaller page sizes might be more efficient for OLTP workloads involving many small writes, where contention can be an issue when single pages contain many rows. Smaller pages might also be efficient with SSD storage devices, which typically use small block sizes. Keeping theInnoDBpage size close to the storage device block size minimizes the amount of unchanged data that is rewritten to disk.第一个系统表空间数据文件(
ibdata1)的最小文件大小取决于innodb_page_size的值。有关详细信息,请参阅innodb_data_file_path选项说明。The minimum file size for the first system tablespace data file (ibdata1) differs depending on theinnodb_page_sizevalue. See theinnodb_data_file_pathoption description for more information.使用特定
InnoDB页面大小的 MySQL 实例不能使用来自使用不同页面大小的实例的数据文件或日志文件。A MySQL instance using a particularInnoDBpage size cannot use data files or log files from an instance that uses a different page size.有关一般 I/O 调优建议,请参阅 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.
命令行格式Command-Line Format --innodb-parallel-read-threads=#系统变量System Variable innodb_parallel_read_threads范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value (available logical processors / 8), min of 4(available logical processors / 8), min of 4最小值Minimum Value 1最大值Maximum Value 256Defines the number of threads that can be used for parallel clustered index reads. Parallel scanning of partitions is also supported. Parallel read threads can improve
CHECK TABLEperformance.InnoDBreads the clustered index twice during aCHECK TABLEoperation. The second read can be performed in parallel. This feature does not apply to secondary index scans. Theinnodb_parallel_read_threadssession variable must be set to a value greater than 1 for parallel clustered index reads to occur. The actual number of threads used to perform a parallel clustered index read is determined by theinnodb_parallel_read_threadssetting or the number of index subtrees to scan, whichever is smaller. The pages read into the buffer pool during the scan are kept at the tail of the buffer pool LRU list so that they can be discarded quickly when free buffer pool pages are required.并行读取线程的最大数量(256)是所有客户端连接的线程总数。如果达到线程限制,连接将回退到使用单线程。默认值由系统上可用的逻辑处理器数量除以 8 计算,最小默认值为 4。The maximum number of parallel read threads (256) is the total number of threads for all client connections. If the thread limit is reached, connections fall back to using a single thread. The default value is calculated by the number of available logical processors on the system divided by 8, with a minimum default value of 4.
在 MySQL 8.4 之前,默认值始终为 4。Before MySQL 8.4, the default value was always 4.
命令行格式Command-Line Format --innodb-print-all-deadlocks[={OFF|ON}]系统变量System Variable innodb_print_all_deadlocks范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用此选项时,所有 死锁 在
InnoDB用户事务中的信息都会记录在mysqld错误日志 中。否则,您只能看到最近一次死锁的信息,使用SHOW ENGINE INNODB STATUS语句查看。偶尔出现的InnoDB死锁不一定是问题,因为InnoDB会立即检测到该情况,并自动回滚其中一个事务。如果应用程序没有适当的错误处理逻辑来检测回滚并重试操作,您可以使用此选项来排查死锁发生的原因。大量死锁可能表明需要重新构建执行多表 DML 或SELECT ... FOR UPDATE语句的事务,使每个事务以相同顺序访问表,从而避免死锁情况。When this option is enabled, information about all deadlocks inInnoDBuser transactions is recorded in themysqlderror log. Otherwise, you see information about only the last deadlock, using theSHOW ENGINE INNODB STATUSstatement. An occasionalInnoDBdeadlock is not necessarily an issue, becauseInnoDBdetects the condition immediately and rolls back one of the transactions automatically. You might use this option to troubleshoot why deadlocks are occurring if an application does not have appropriate error-handling logic to detect the rollback and retry its operation. A large number of deadlocks might indicate the need to restructure transactions that issue DML orSELECT ... FOR UPDATEstatements for multiple tables, so that each transaction accesses the tables in the same order, thus avoiding the deadlock condition.有关相关信息,请参阅 第 17.7.5 节,“InnoDB 中的死锁”。For related information, see Section 17.7.5, “Deadlocks in InnoDB”.
命令行格式Command-Line Format --innodb-print-ddl-logs[={OFF|ON}]系统变量System Variable innodb_print_ddl_logs范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用此选项会导致 MySQL 将 DDL 日志写入
stderr。有关详细信息,请参阅 查看 DDL 日志。Enabling this option causes MySQL to write DDL logs tostderr. For more information, see Viewing DDL Logs.命令行格式Command-Line Format --innodb-purge-batch-size=#系统变量System Variable innodb_purge_batch_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 300最小值Minimum Value 1最大值Maximum Value 5000定义了从历史列表中每批解析和处理的回滚日志页数。在多线程清理配置中,协调清理线程会将
innodb_purge_batch_size除以innodb_purge_threads,并将该页数分配给每个清理线程。innodb_purge_batch_size变量还定义了在回滚日志迭代 128 次后清理释放的回滚日志页数。Defines the number of undo log pages that purge parses and processes in one batch from the history list. In a multithreaded purge configuration, the coordinator purge thread dividesinnodb_purge_batch_sizebyinnodb_purge_threadsand assigns that number of pages to each purge thread. Theinnodb_purge_batch_sizevariable also defines the number of undo log pages that purge frees after every 128 iterations through the undo logs.innodb_purge_batch_size选项旨在与innodb_purge_threads设置结合使用,以进行高级性能调优。大多数用户无需更改innodb_purge_batch_size的默认值。Theinnodb_purge_batch_sizeoption is intended for advanced performance tuning in combination with theinnodb_purge_threadssetting. Most users need not changeinnodb_purge_batch_sizefrom its default value.有关相关信息,请参见 第 17.8.9 节,“清除配置”。For related information, see Section 17.8.9, “Purge Configuration”.
命令行格式Command-Line Format --innodb-purge-threads=#系统变量System Variable innodb_purge_threads范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 1 if # of available logical processors is <= 16; otherwise 41 if # of available logical processors is <= 16; otherwise 4最小值Minimum Value 1最大值Maximum Value 32用于
InnoDB清理 操作的后台线程数量。增加该值会创建额外的清理线程,这可以提高在多个表上执行 DML 操作的系统的效率。The number of background threads devoted to theInnoDBpurge operation. Increasing the value creates additional purge threads, which can improve efficiency on systems where DML operations are performed on multiple tables.有关相关信息,请参见 第 17.8.9 节,“清除配置”。For related information, see Section 17.8.9, “Purge Configuration”.
innodb_purge_rseg_truncate_frequency命令行格式Command-Line Format --innodb-purge-rseg-truncate-frequency=#系统变量System Variable innodb_purge_rseg_truncate_frequency范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 128最小值Minimum Value 1最大值Maximum Value 128定义了清理系统以调用数量为单位释放回滚段的频率。撤消表空间在其回滚段被释放之前不能被截断。通常,清理系统每调用清理操作 128 次释放一次回滚段。默认值为 128。降低此值会增加清理线程释放回滚段的频率。Defines the frequency with which the purge system frees rollback segments in terms of the number of times that purge is invoked. An undo tablespace cannot be truncated until its rollback segments are freed. Normally, the purge system frees rollback segments once every 128 times that purge is invoked. The default value is 128. Reducing this value increases the frequency with which the purge thread frees rollback segments.
innodb_purge_rseg_truncate_frequency用于innodb_undo_log_truncate。有关更多信息,请参见 截断撤销表空间。innodb_purge_rseg_truncate_frequencyis intended for use withinnodb_undo_log_truncate. For more information, see Truncating Undo Tablespaces.命令行格式Command-Line Format --innodb-random-read-ahead[={OFF|ON}]系统变量System Variable innodb_random_read_ahead范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用随机 预读取 技术以优化
InnoDBI/O。Enables the random read-ahead technique for optimizingInnoDBI/O.有关不同类型预读取请求的性能考虑的详细信息,请参见 第 17.8.3.4 节,“配置 InnoDB 缓冲池预取(预读取)”。有关一般 I/O 调优建议,请参见 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。For details about performance considerations for different types of read-ahead requests, see Section 17.8.3.4, “Configuring InnoDB Buffer Pool Prefetching (Read-Ahead)”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.
命令行格式Command-Line Format --innodb-read-ahead-threshold=#系统变量System Variable innodb_read_ahead_threshold范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 56最小值Minimum Value 0最大值Maximum Value 64控制
InnoDB用于将页面预取到 缓冲池 的线性 预读 的敏感度。如果InnoDB从一个 区段(64 页)顺序读取至少innodb_read_ahead_threshold页,它将启动对整个下一个区段的异步读取。允许的取值范围是 0 到 64。值为 0 会禁用预读。默认值为 56 时,InnoDB必须从一个区段顺序读取至少 56 页,才能为下一个区段启动异步读取。Controls the sensitivity of linear read-ahead thatInnoDBuses to prefetch pages into the buffer pool. IfInnoDBreads at leastinnodb_read_ahead_thresholdpages sequentially from an extent (64 pages), it initiates an asynchronous read for the entire following extent. The permissible range of values is 0 to 64. A value of 0 disables read-ahead. For the default of 56,InnoDBmust read at least 56 pages sequentially from an extent to initiate an asynchronous read for the following extent.了解通过预读机制读取了多少页,以及这些页中有多少页在从未被访问的情况下就被从缓冲池中驱逐出去,对于微调
innodb_read_ahead_threshold设置非常有用。SHOW ENGINE INNODB STATUS输出显示了来自Innodb_buffer_pool_read_ahead和Innodb_buffer_pool_read_ahead_evicted全局状态变量的计数信息,这些变量分别报告通过预读请求带入 缓冲池 的页的数量,以及这些页在从未被访问的情况下从缓冲池中被 驱逐 的数量。状态变量报告自上次服务器重启以来的全局值。Knowing how many pages are read through the read-ahead mechanism, and how many of these pages are evicted from the buffer pool without ever being accessed, can be useful when fine-tuning theinnodb_read_ahead_thresholdsetting.SHOW ENGINE INNODB STATUSoutput displays counter information from theInnodb_buffer_pool_read_aheadandInnodb_buffer_pool_read_ahead_evictedglobal status variables, which report the number of pages brought into the buffer pool by read-ahead requests, and the number of such pages evicted from the buffer pool without ever being accessed, respectively. The status variables report global values since the last server restart.SHOW ENGINE INNODB STATUS还显示了预读页面的读取速率以及这些页面在未被访问的情况下被驱逐的速率。每秒平均值是基于自上次调用SHOW ENGINE INNODB STATUS以来收集的统计信息,并显示在BUFFER POOL AND MEMORY部分的SHOW ENGINE INNODB STATUS输出中。SHOW ENGINE INNODB STATUSalso shows the rate at which the read-ahead pages are read and the rate at which such pages are evicted without being accessed. The per-second averages are based on the statistics collected since the last invocation ofSHOW ENGINE INNODB STATUSand are displayed in theBUFFER POOL AND MEMORYsection of theSHOW ENGINE INNODB STATUSoutput.如需更多信息,请参见 第 17.8.3.4 节,“配置 InnoDB 缓冲池预读(Read-Ahead)”。关于一般的 I/O 调优建议,请参见 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。For more information, see Section 17.8.3.4, “Configuring InnoDB Buffer Pool Prefetching (Read-Ahead)”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.
命令行格式Command-Line Format --innodb-read-io-threads=#系统变量System Variable innodb_read_io_threads范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value (available logical processors / 2), min of 4(available logical processors / 2), min of 4最小值Minimum Value 1最大值Maximum Value 64用于
InnoDB读取操作的 I/O 线程数量。其写线程对应参数为innodb_write_io_threads。更多信息,请参见第 17.8.5 节,“配置后台 InnoDB I/O 线程数量”。有关一般 I/O 调整建议,请参见第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。默认值为系统上可用逻辑处理器数量的一半,最小默认值为 4。The number of I/O threads for read operations inInnoDB. Its counterpart for write threads isinnodb_write_io_threads. For more information, see Section 17.8.5, “Configuring the Number of Background InnoDB I/O Threads”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”. The default value is the number of available logical processors on the system divided by 2, with a minimum default value of 4.在 MySQL 8.4 之前,默认值始终为 4。Before MySQL 8.4, the default value was always 4.
Note在 Linux 系统上,以默认设置运行多个 MySQL 服务器(通常超过 12 个),对于
innodb_read_io_threads、innodb_write_io_threads和 Linuxaio-max-nr设置可能会超过系统限制。理想情况下,应增加aio-max-nr设置;作为一种解决方法,您可以减少一个或两个 MySQL 变量的设置。On Linux systems, running multiple MySQL servers (typically more than 12) with default settings forinnodb_read_io_threads,innodb_write_io_threads, and the Linuxaio-max-nrsetting can exceed system limits. Ideally, increase theaio-max-nrsetting; as a workaround, you might reduce the settings for one or both of the MySQL variables.命令行格式Command-Line Format --innodb-read-only[={OFF|ON}]系统变量System Variable innodb_read_only范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF以只读模式启动
InnoDB。用于在只读介质上分发数据库应用程序或数据集。也可以在数据仓库中使用,以便在多个实例之间共享相同的数据目录。更多信息,请参见 第 17.8.2 节,“配置 InnoDB 为只读操作”。StartsInnoDBin read-only mode. For distributing database applications or data sets on read-only media. Can also be used in data warehouses to share the same data directory between multiple instances. For more information, see Section 17.8.2, “Configuring InnoDB for Read-Only Operation”.启用
innodb_read_only会阻止为所有存储引擎创建和删除表,而不仅仅是InnoDB。任何存储引擎的表创建和删除操作都会修改mysql系统数据库中的数据字典表,但这些表使用InnoDB存储引擎,在启用innodb_read_only时无法被修改。同样的原理也适用于需要修改数据字典表的其他表操作。示例:Enablinginnodb_read_onlyprevents creating and dropping tables for all storage engines, and not onlyInnoDB. Table creation and drop operations for any storage engine modify data dictionary tables in themysqlsystem database, but those tables use theInnoDBstorage engine and cannot be modified wheninnodb_read_onlyis enabled. The same principle applies to other table operations that require modifying data dictionary tables. Examples:如果启用了
innodb_read_only系统变量,ANALYZE TABLE可能会失败,因为它无法更新使用InnoDB的数据字典中的统计表。对于更新键分布的ANALYZE TABLE操作,即使操作更新了表本身(例如,如果它是MyISAM表),也可能会失败。要获得更新的分布统计信息,请设置information_schema_stats_expiry=0。If theinnodb_read_onlysystem variable is enabled,ANALYZE TABLEmay fail because it cannot update statistics tables in the data dictionary, which useInnoDB. ForANALYZE TABLEoperations that update the key distribution, failure may occur even if the operation updates the table itself (for example, if it is aMyISAMtable). To obtain the updated distribution statistics, setinformation_schema_stats_expiry=0.ALTER TABLE tbl_name ENGINE=engine_name失败,因为它会更新存储在数据字典中的存储引擎指定信息。ALTER TABLEfails because it updates the storage engine designation, which is stored in the data dictionary.tbl_nameENGINE=engine_name
此外,
mysql系统数据库中的其他表使用InnoDB存储引擎。将这些表设置为只读会限制修改它们的操作。示例:In addition, other tables in themysqlsystem database use theInnoDBstorage engine. Making those tables read-only results in restrictions on operations that modify them. Examples:账户管理语句,例如
CREATE USER和GRANT会失败,因为授权表使用了InnoDB。Account-management statements such asCREATE USERandGRANTfail because the grant tables useInnoDB.INSTALL PLUGIN和UNINSTALL PLUGIN插件管理语句失败,因为mysql.plugin系统表使用InnoDB。TheINSTALL PLUGINandUNINSTALL PLUGINplugin-management statements fail because themysql.pluginsystem table usesInnoDB.CREATE FUNCTION和DROP FUNCTION可加载函数管理语句失败,因为mysql.func系统表使用InnoDB。TheCREATE FUNCTIONandDROP FUNCTIONloadable function-management statements fail because themysql.funcsystem table usesInnoDB.
命令行格式Command-Line Format --innodb-redo-log-archive-dirs系统变量System Variable innodb_redo_log_archive_dirs范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value NULL定义可以创建重做日志归档文件的标记目录。您可以在以分号分隔的列表中定义多个标记目录。例如:Defines labeled directories where redo log archive files can be created. You can define multiple labeled directories in a semicolon-separated list. For example:
innodb_redo_log_archive_dirs='label1:/backups1;label2:/backups2'
标签可以是任何字符字符串,但不允许使用冒号(:)。空标签也是允许的,但此时仍然需要冒号(:)。A label can be any string of characters, with the exception of colons (:), which are not permitted. An empty label is also permitted, but the colon (:) is still required in this case.
必须指定路径,并且目录必须存在。路径中可以包含冒号(':'),但不允许使用分号(;)。A path must be specified, and the directory must exist. The path can contain colons (':'), but semicolons (;) are not permitted.
命令行格式Command-Line Format --innodb-redo-log-capacity=#系统变量System Variable innodb_redo_log_capacity范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 104857600最小值Minimum Value 8388608最大值Maximum Value 549755813888单位Unit 字节bytes 定义重做日志文件占用的磁盘空间量。Defines the amount of disk space occupied by redo log files.
innodb_redo_log_capacity替代了innodb_log_files_in_group和innodb_log_file_size变量,如果定义了innodb_redo_log_capacity,这两个变量将被忽略。innodb_redo_log_capacitysupercedes theinnodb_log_files_in_groupandinnodb_log_file_sizevariables, which are both ignored ifinnodb_redo_log_capacityis defined.如果没有定义
innodb_redo_log_capacity,并且innodb_log_file_size或innodb_log_files_in_group也未定义,则使用默认的innodb_redo_log_capacity值。Ifinnodb_redo_log_capacityis not defined, and if neitherinnodb_log_file_sizeorinnodb_log_files_in_groupare defined, then the defaultinnodb_redo_log_capacityvalue is used.如果未定义
innodb_redo_log_capacity,并且定义了innodb_log_file_size和/或innodb_log_files_in_group,则 InnoDB 重做日志容量将计算为 (innodb_log_files_in_group * innodb_log_file_size)。此计算不会修改未使用的innodb_redo_log_capacity设置的值。Ifinnodb_redo_log_capacityis not defined, and ifinnodb_log_file_sizeand/orinnodb_log_files_in_groupis defined, then the InnoDB redo log capacity is calculated as (innodb_log_files_in_group * innodb_log_file_size). This calculation does not modify the unusedinnodb_redo_log_capacitysetting's value.Innodb_redo_log_capacity_resized服务器状态变量表示所有重做日志文件的总重做日志容量。TheInnodb_redo_log_capacity_resizedserver status variable indicates the total redo log capacity for all redo log files.如果服务器使用
--innodb-dedicated-server启动,则innodb_redo_log_capacity的值会在未显式定义时自动设置。更多信息请参见 第 17.8.12 节,“为专用 MySQL 服务器启用自动 InnoDB 配置”。If the server is started with--innodb-dedicated-server, the value ofinnodb_redo_log_capacityis set automatically if it is not explicitly defined. For more information, see Section 17.8.12, “Enabling Automatic InnoDB Configuration for a Dedicated MySQL Server”.更多信息请参见 第 17.6.5 节,“重做日志”。For more information, see Section 17.6.5, “Redo Log”.
命令行格式Command-Line Format --innodb-redo-log-encrypt[={OFF|ON}]系统变量System Variable innodb_redo_log_encrypt范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF控制使用
InnoDB静态数据加密功能 加密的表的重做日志数据的加密。默认情况下,重做日志数据的加密是禁用的。更多信息请参见 重做日志加密。Controls encryption of redo log data for tables encrypted using theInnoDBdata-at-rest encryption feature. Encryption of redo log data is disabled by default. For more information, see Redo Log Encryption.命令行格式Command-Line Format --innodb-replication-delay=#系统变量System Variable innodb_replication_delay范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 4294967295单位Unit 毫秒milliseconds 如果达到
innodb_thread_concurrency,副本服务器上的复制线程延迟(毫秒)。The replication thread delay in milliseconds on a replica server ifinnodb_thread_concurrencyis reached.命令行格式Command-Line Format --innodb-rollback-on-timeout[={OFF|ON}]系统变量System Variable innodb_rollback_on_timeout范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFFInnoDBrolls back only the last statement on a transaction timeout by default. If--innodb-rollback-on-timeoutis specified, a transaction timeout causesInnoDBto abort and roll back the entire transaction.更多信息,请参见 第 17.20.5 节,“InnoDB 错误处理”。For more information, see Section 17.20.5, “InnoDB Error Handling”.
命令行格式Command-Line Format --innodb-rollback-segments=#系统变量System Variable innodb_rollback_segments范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 128最小值Minimum Value 1最大值Maximum Value 128innodb_rollback_segments定义了为生成回滚记录的事务分配给每个撤销表空间和全局临时表空间的 回滚段 的数量。每个回滚段支持的事务数量取决于InnoDB页大小以及分配给每个事务的撤销日志数量。有关更多信息,请参见 第 17.6.6 节,“撤销日志”。innodb_rollback_segmentsdefines the number of rollback segments allocated to each undo tablespace and the global temporary tablespace for transactions that generate undo records. The number of transactions that each rollback segment supports depends on theInnoDBpage size and the number of undo logs assigned to each transaction. For more information, see Section 17.6.6, “Undo Logs”.有关相关信息,请参见 第 17.3 节,“InnoDB 多版本”。关于撤销表空间的信息,请参见 第 17.6.3.4 节,“撤销表空间”。For related information, see Section 17.3, “InnoDB Multi-Versioning”. For information about undo tablespaces, see Section 17.6.3.4, “Undo Tablespaces”.
innodb_saved_page_number_debug命令行格式Command-Line Format --innodb-saved-page-number-debug=#系统变量System Variable innodb_saved_page_number_debug范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 2**32-1保存一个页码。设置
innodb_fil_make_page_dirty_debug选项会将由innodb_saved_page_number_debug定义的页面标记为脏。innodb_saved_page_number_debug选项仅在使用WITH_DEBUGCMake 选项编译调试支持时可用。Saves a page number. Setting theinnodb_fil_make_page_dirty_debugoption dirties the page defined byinnodb_saved_page_number_debug. Theinnodb_saved_page_number_debugoption is only available if debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-segment-reserve-factor=#系统变量System Variable innodb_segment_reserve_factor范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 数字Numeric 默认值Default Value 12.5最小值Minimum Value 0.03最大值Maximum Value 40定义表空间文件段页作为空页保留的百分比。此设置适用于每表文件和通用表空间。
innodb_segment_reserve_factor的默认设置为 12.5%,这与之前 MySQL 版本中保留的页百分比相同。Defines the percentage of tablespace file segment pages reserved as empty pages. The setting is applicable to file-per-table and general tablespaces. Theinnodb_segment_reserve_factordefault setting is 12.5 percent, which is the same percentage of pages reserved in previous MySQL releases.更多信息,请参见 配置预留文件段页百分比。For more information, see Configuring the Percentage of Reserved File Segment Pages.
命令行格式Command-Line Format --innodb-sort-buffer-size=#系统变量System Variable innodb_sort_buffer_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 1048576最小值Minimum Value 65536最大值Maximum Value 67108864单位Unit 字节bytes 该变量定义在执行 在线 DDL 操作期间记录并发 DML 时临时日志文件扩展的大小,以及临时日志文件读取缓冲区和写入缓冲区的大小。This variable defines the amount by which the temporary log file is extended when recording concurrent DML during an online DDL operation, and the size of the temporary log file read buffer and write buffer.
更多信息,请参见 第 17.12.3 节,“在线 DDL 空间需求”。For more information, see Section 17.12.3, “Online DDL Space Requirements”.
命令行格式Command-Line Format --innodb-spin-wait-delay=#系统变量System Variable innodb_spin_wait_delay范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 6最小值Minimum Value 0最大值Maximum Value 1000轮询 自旋 锁之间的最大延迟。此机制的底层实现因硬件和操作系统的组合而异,因此延迟不对应固定的时间间隔。The maximum delay between polls for a spin lock. The low-level implementation of this mechanism varies depending on the combination of hardware and operating system, so the delay does not correspond to a fixed time interval.
可以与
innodb_spin_wait_pause_multiplier变量结合使用,从而更好地控制自旋锁轮询延迟的持续时间。Can be used in combination with theinnodb_spin_wait_pause_multipliervariable for greater control over the duration of spin-lock polling delays.更多信息,请参见 第 17.8.8 节,“配置自旋锁轮询”。For more information, see Section 17.8.8, “Configuring Spin Lock Polling”.
innodb_spin_wait_pause_multiplier命令行格式Command-Line Format --innodb-spin-wait-pause-multiplier=#系统变量System Variable innodb_spin_wait_pause_multiplier范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 50最小值Minimum Value 0最大值Maximum Value 100定义一个乘数值,用于确定在线程等待获取互斥锁或读写锁时,自旋等待循环中 PAUSE 指令的数量。Defines a multiplier value used to determine the number of PAUSE instructions in spin-wait loops that occur when a thread waits to acquire a mutex or rw-lock.
更多信息,请参见 第 17.8.8 节,“配置自旋锁轮询”。For more information, see Section 17.8.8, “Configuring Spin Lock Polling”.
命令行格式Command-Line Format --innodb-stats-auto-recalc[={OFF|ON}]系统变量System Variable innodb_stats_auto_recalc范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON当表中的数据发生较大变化时,会导致
InnoDB自动重新计算持久统计信息。阈值为表中行数的 10%。此设置适用于在启用innodb_stats_persistent选项时创建的表。也可以通过在CREATE TABLE或ALTER TABLE语句中指定STATS_AUTO_RECALC=1来配置自动统计信息重新计算。用于生成统计信息的数据采样量由innodb_stats_persistent_sample_pages变量控制。CausesInnoDBto automatically recalculate persistent statistics after the data in a table is changed substantially. The threshold value is 10% of the rows in the table. This setting applies to tables created when theinnodb_stats_persistentoption is enabled. Automatic statistics recalculation may also be configured by specifyingSTATS_AUTO_RECALC=1in aCREATE TABLEorALTER TABLEstatement. The amount of data sampled to produce the statistics is controlled by theinnodb_stats_persistent_sample_pagesvariable.更多信息,请参见 第 17.8.10.1 节,“配置持久优化器统计参数”。For more information, see Section 17.8.10.1, “Configuring Persistent Optimizer Statistics Parameters”.
innodb_stats_include_delete_marked命令行格式Command-Line Format --innodb-stats-include-delete-marked[={OFF|ON}]系统变量System Variable innodb_stats_include_delete_marked范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF默认情况下,
InnoDB在计算统计信息时会读取未提交的数据。在一个未提交的事务删除表中的行的情况下,InnoDB在计算行估计和索引统计信息时会排除被标记为删除的记录,这可能导致其他以不同于READ UNCOMMITTED事务隔离级别在表上并发操作的事务执行计划不够优化。为了避免这种情况,可以启用innodb_stats_include_delete_marked,以确保InnoDB在计算持久化优化器统计信息时包括被标记为删除的记录。By default,InnoDBreads uncommitted data when calculating statistics. In the case of an uncommitted transaction that deletes rows from a table,InnoDBexcludes records that are delete-marked when calculating row estimates and index statistics, which can lead to non-optimal execution plans for other transactions that are operating on the table concurrently using a transaction isolation level other thanREAD UNCOMMITTED. To avoid this scenario,innodb_stats_include_delete_markedcan be enabled to ensure thatInnoDBincludes delete-marked records when calculating persistent optimizer statistics.当
innodb_stats_include_delete_marked启用时,ANALYZE TABLE在重新计算统计信息时会考虑标记为删除的记录。Wheninnodb_stats_include_delete_markedis enabled,ANALYZE TABLEconsiders delete-marked records when recalculating statistics.innodb_stats_include_delete_marked是一个全局设置,影响所有InnoDB表。它仅适用于持久化优化器统计信息。innodb_stats_include_delete_markedis a global setting that affects allInnoDBtables. It is only applicable to persistent optimizer statistics.有关相关信息,请参见 第 17.8.10.1 节,“配置持久化优化器统计参数”。For related information, see Section 17.8.10.1, “Configuring Persistent Optimizer Statistics Parameters”.
命令行格式Command-Line Format --innodb-stats-method=value系统变量System Variable innodb_stats_method范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value nulls_equalnulls_equal有效值Valid Values nulls_equalnulls_equalnulls_unequalnulls_ignorednulls_ignored服务器在收集 统计信息 关于
InnoDB表的索引值分布时如何处理NULL值。允许的值有nulls_equal、nulls_unequal和nulls_ignored。对于nulls_equal,所有NULL索引值被视为相等,并形成一个单独的值组,其大小等于NULL值的数量。对于nulls_unequal,NULL值被视为不相等,每个NULL形成一个大小为 1 的独立值组。对于nulls_ignored,NULL值会被忽略。How the server treatsNULLvalues when collecting statistics about the distribution of index values forInnoDBtables. Permitted values arenulls_equal,nulls_unequal, andnulls_ignored. Fornulls_equal, allNULLindex values are considered equal and form a single value group with a size equal to the number ofNULLvalues. Fornulls_unequal,NULLvalues are considered unequal, and eachNULLforms a distinct value group of size 1. Fornulls_ignored,NULLvalues are ignored.用于生成表统计信息的方法会影响优化器如何为查询执行选择索引,如第 10.3.8 节,“InnoDB 和 MyISAM 索引统计信息收集”中所述。The method used to generate table statistics influences how the optimizer chooses indexes for query execution, as described in Section 10.3.8, “InnoDB and MyISAM Index Statistics Collection”.
命令行格式Command-Line Format --innodb-stats-on-metadata[={OFF|ON}]系统变量System Variable innodb_stats_on_metadata范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF此选项仅在优化器统计信息配置为非持久时适用。当
innodb_stats_persistent被禁用或当单个表在创建或修改时使用STATS_PERSISTENT=0时,优化器统计信息不会持久化到磁盘。有关更多信息,请参见 第 17.8.10.2 节,“配置非持久优化器统计参数”。This option only applies when optimizer statistics are configured to be non-persistent. Optimizer statistics are not persisted to disk wheninnodb_stats_persistentis disabled or when individual tables are created or altered withSTATS_PERSISTENT=0. For more information, see Section 17.8.10.2, “Configuring Non-Persistent Optimizer Statistics Parameters”.当
innodb_stats_on_metadata启用时,InnoDB会在执行元数据语句(如SHOW TABLE STATUS)或访问信息模式TABLES或STATISTICS表时,更新非持久性的统计信息。(这些更新类似于ANALYZE TABLE的行为。)当禁用时,InnoDB在这些操作中不会更新统计信息。保持该设置为禁用状态可以提高具有大量表或索引的模式的访问速度,还可以提高涉及InnoDB表的查询的执行计划的稳定性。Wheninnodb_stats_on_metadatais enabled,InnoDBupdates non-persistent statistics when metadata statements such asSHOW TABLE STATUSor when accessing the Information SchemaTABLESorSTATISTICStables. (These updates are similar to what happens forANALYZE TABLE.) When disabled,InnoDBdoes not update statistics during these operations. Leaving the setting disabled can improve access speed for schemas that have a large number of tables or indexes. It can also improve the stability of execution plans for queries that involveInnoDBtables.要更改设置,请执行语句
SET GLOBAL innodb_stats_on_metadata=mode,其中可以是modeON或OFF(或1或0)。更改此设置需要具有足够权限以设置全局系统变量(参见 第 7.1.9.1 节,“系统变量权限”)并会立即影响所有连接的操作。To change the setting, issue the statementSET GLOBAL innodb_stats_on_metadata=, wheremodeis eithermodeONorOFF(or1or0). Changing the setting requires privileges sufficient to set global system variables (see Section 7.1.9.1, “System Variable Privileges”) and immediately affects the operation of all connections.命令行格式Command-Line Format --innodb-stats-persistent[={OFF|ON}]系统变量System Variable innodb_stats_persistent范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON指定
InnoDB索引统计信息是否持久化到磁盘。否则,统计信息可能会经常重新计算,从而导致 查询执行计划 出现变化。此设置在创建表时会随每个表存储。您可以在创建表之前在全局级别设置innodb_stats_persistent,或者使用STATS_PERSISTENT子句在CREATE TABLE和ALTER TABLE语句中覆盖系统设置,为单个表配置持久化统计信息。Specifies whetherInnoDBindex statistics are persisted to disk. Otherwise, statistics may be recalculated frequently which can lead to variations in query execution plans. This setting is stored with each table when the table is created. You can setinnodb_stats_persistentat the global level before creating a table, or use theSTATS_PERSISTENTclause of theCREATE TABLEandALTER TABLEstatements to override the system-wide setting and configure persistent statistics for individual tables.更多信息,请参见 第 17.8.10.1 节,“配置持久优化器统计参数”。For more information, see Section 17.8.10.1, “Configuring Persistent Optimizer Statistics Parameters”.
innodb_stats_persistent_sample_pages命令行格式Command-Line Format --innodb-stats-persistent-sample-pages=#系统变量System Variable innodb_stats_persistent_sample_pages范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 20最小值Minimum Value 1最大值Maximum Value 18446744073709551615在估算索引列的基数(cardinality)和其他统计信息(statistics)时,要采样的索引页的数量,例如由
ANALYZE TABLE计算的那些。增加该值可以提高索引统计信息的准确性,从而改善查询执行计划,但在执行ANALYZE TABLE针对InnoDB表时会增加 I/O。更多信息请参见 第 17.8.10.1 节,“配置持久优化器统计参数”。The number of index pages to sample when estimating cardinality and other statistics for an indexed column, such as those calculated byANALYZE TABLE. Increasing the value improves the accuracy of index statistics, which can improve the query execution plan, at the expense of increased I/O during the execution ofANALYZE TABLEfor anInnoDBtable. For more information, see Section 17.8.10.1, “Configuring Persistent Optimizer Statistics Parameters”.Note将
innodb_stats_persistent_sample_pages设置为较高的值可能导致ANALYZE TABLE执行时间延长。要估算ANALYZE TABLE访问的数据库页数,请参见 第 17.8.10.3 节,“估算 InnoDB 表的 ANALYZE TABLE 复杂性”。Setting a high value forinnodb_stats_persistent_sample_pagescould result in lengthyANALYZE TABLEexecution time. To estimate the number of database pages accessed byANALYZE TABLE, see Section 17.8.10.3, “Estimating ANALYZE TABLE Complexity for InnoDB Tables”.innodb_stats_persistent_sample_pages仅在表启用innodb_stats_persistent时适用;当innodb_stats_persistent被禁用时,改用innodb_stats_transient_sample_pages。innodb_stats_persistent_sample_pagesonly applies wheninnodb_stats_persistentis enabled for a table; wheninnodb_stats_persistentis disabled,innodb_stats_transient_sample_pagesapplies instead.innodb_stats_transient_sample_pages命令行格式Command-Line Format --innodb-stats-transient-sample-pages=#系统变量System Variable innodb_stats_transient_sample_pages范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 8最小值Minimum Value 1最大值Maximum Value 18446744073709551615在估算索引列的基数和其他统计时,需要抽样的索引页数,例如通过
ANALYZE TABLE计算的那样。默认值为 8。增加该值可以提高索引统计的准确性,从而可能改善查询执行计划,但这会增加在打开InnoDB表或重新计算统计信息时的 I/O。更多信息,请参见第 17.8.10.2 节,“配置非持久化优化器统计参数”。The number of index pages to sample when estimating cardinality and other statistics for an indexed column, such as those calculated byANALYZE TABLE. The default value is 8. Increasing the value improves the accuracy of index statistics, which can improve the query execution plan, at the expense of increased I/O when opening anInnoDBtable or recalculating statistics. For more information, see Section 17.8.10.2, “Configuring Non-Persistent Optimizer Statistics Parameters”.Note将
innodb_stats_transient_sample_pages设置为较高的值可能导致ANALYZE TABLE执行时间延长。要估算ANALYZE TABLE访问的数据库页数,请参见 第 17.8.10.3 节,“估算 InnoDB 表的 ANALYZE TABLE 复杂性”。Setting a high value forinnodb_stats_transient_sample_pagescould result in lengthyANALYZE TABLEexecution time. To estimate the number of database pages accessed byANALYZE TABLE, see Section 17.8.10.3, “Estimating ANALYZE TABLE Complexity for InnoDB Tables”.innodb_stats_transient_sample_pages仅在表的innodb_stats_persistent被禁用时适用;当innodb_stats_persistent启用时,则适用innodb_stats_persistent_sample_pages。它取代了已在 MySQL 8.0 中移除的innodb_stats_sample_pages。有关更多信息,请参见 第 17.8.10.2 节,“配置非持久化优化器统计参数”。innodb_stats_transient_sample_pagesonly applies wheninnodb_stats_persistentis disabled for a table; wheninnodb_stats_persistentis enabled,innodb_stats_persistent_sample_pagesapplies instead. Takes the place ofinnodb_stats_sample_pagesthat was removed in MySQL 8.0. For more information, see Section 17.8.10.2, “Configuring Non-Persistent Optimizer Statistics Parameters”.命令行格式Command-Line Format --innodb-status-output[={OFF|ON}]系统变量System Variable innodb_status_output范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用或禁用标准
InnoDB监视器的周期性输出。也可与innodb_status_output_locks结合使用,以启用或禁用InnoDB锁监视器的周期性输出。有关更多信息,请参见第 17.17.2 节,“启用 InnoDB 监视器”。Enables or disables periodic output for the standardInnoDBMonitor. Also used in combination withinnodb_status_output_locksto enable or disable periodic output for theInnoDBLock Monitor. For more information, see Section 17.17.2, “Enabling InnoDB Monitors”.命令行格式Command-Line Format --innodb-status-output-locks[={OFF|ON}]--innodb-status-output-locks[={OFF|ON}]系统变量System Variable innodb_status_output_locks范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用或禁用
InnoDB锁监视器。启用时,InnoDB锁监视器会在SHOW ENGINE INNODB STATUS输出中以及打印到 MySQL 错误日志的周期性输出中显示有关锁的附加信息。InnoDB锁监视器的周期性输出作为标准InnoDB监视器输出的一部分打印。因此,必须启用标准InnoDB监视器,才能使InnoDB锁监视器定期将数据打印到 MySQL 错误日志中。有关更多信息,请参阅 第 17.17.2 节,“启用 InnoDB 监视器”。Enables or disables theInnoDBLock Monitor. When enabled, theInnoDBLock Monitor prints additional information about locks inSHOW ENGINE INNODB STATUSoutput and in periodic output printed to the MySQL error log. Periodic output for theInnoDBLock Monitor is printed as part of the standardInnoDBMonitor output. The standardInnoDBMonitor must therefore be enabled for theInnoDBLock Monitor to print data to the MySQL error log periodically. For more information, see Section 17.17.2, “Enabling InnoDB Monitors”.命令行格式Command-Line Format --innodb-strict-mode[={OFF|ON}]系统变量System Variable innodb_strict_mode范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON当
innodb_strict_mode被启用时,InnoDB在检查无效或不兼容的表选项时会返回错误而不是警告。Wheninnodb_strict_modeis enabled,InnoDBreturns errors rather than warnings when checking for invalid or incompatible table options.它会检查
KEY_BLOCK_SIZE、ROW_FORMAT、DATA DIRECTORY、TEMPORARY和TABLESPACE选项是否彼此兼容,以及是否与其他设置兼容。It checks thatKEY_BLOCK_SIZE,ROW_FORMAT,DATA DIRECTORY,TEMPORARY, andTABLESPACEoptions are compatible with each other and other settings.innodb_strict_mode=ON还会在创建或修改表时启用行大小检查,以防止由于记录对于所选页面大小过大而导致INSERT或UPDATE失败。innodb_strict_mode=ONalso enables a row size check when creating or altering a table, to preventINSERTorUPDATEfrom failing due to the record being too large for the selected page size.You can enable or disable
innodb_strict_modeon the command line when startingmysqld, or in a MySQL configuration file. You can also enable or disableinnodb_strict_modeat runtime with the statementSET [GLOBAL|SESSION] innodb_strict_mode=,其中modeis eithermodeON或者OFF. Changing theGLOBALsetting requires privileges sufficient to set global system variables (see Section 7.1.9.1, “System Variable Privileges”) and affects the operation of all clients that subsequently connect. Any client can change theSESSIONsetting forinnodb_strict_mode, and the setting affects only that client.You can enable or disableinnodb_strict_modeon the command line when startingmysqld, or in a MySQL configuration file. You can also enable or disableinnodb_strict_modeat runtime with the statementSET [GLOBAL|SESSION] innodb_strict_mode=, wheremodeis eithermodeONorOFF. Changing theGLOBALsetting requires privileges sufficient to set global system variables (see Section 7.1.9.1, “System Variable Privileges”) and affects the operation of all clients that subsequently connect. Any client can change theSESSIONsetting forinnodb_strict_mode, and the setting affects only that client.设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.
命令行格式Command-Line Format --innodb-sync-array-size=#系统变量System Variable innodb_sync_array_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 1最小值Minimum Value 1最大值Maximum Value 1024定义互斥锁/锁等待数组的大小。增加该值会分割用于协调线程的内部数据结构,从而在等待线程数量较多的工作负载中提高并发性。此设置必须在 MySQL 实例启动时配置,之后无法更改。对于经常产生大量等待线程的工作负载(通常超过 768 个线程),建议增加该值。Defines the size of the mutex/lock wait array. Increasing the value splits the internal data structure used to coordinate threads, for higher concurrency in workloads with large numbers of waiting threads. This setting must be configured when the MySQL instance is starting up, and cannot be changed afterward. Increasing the value is recommended for workloads that frequently produce a large number of waiting threads, typically greater than 768.
命令行格式Command-Line Format --innodb-sync-spin-loops=#系统变量System Variable innodb_sync_spin_loops范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 30最小值Minimum Value 0最大值Maximum Value 4294967295线程在被挂起之前等待
InnoDB互斥锁释放的次数。The number of times a thread waits for anInnoDBmutex to be freed before the thread is suspended.命令行格式Command-Line Format --innodb-sync-debug[={OFF|ON}]系统变量System Variable innodb_sync_debug范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF启用
InnoDB存储引擎的同步调试检查。此选项仅在使用WITH_DEBUGCMake 选项编译时启用调试支持时可用。Enables sync debug checking for theInnoDBstorage engine. This option is only available if debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-table-locks[={OFF|ON}]系统变量System Variable innodb_table_locks范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON如果
autocommit = 0,InnoDB会遵守LOCK TABLES;MySQL 直到其他所有线程释放了它们对该表的所有锁之后,才会从LOCK TABLES返回。innodb_table_locks的默认值为 1,这意味着如果autocommit = 0,LOCK TABLES ... WRITE会导致 InnoDB 内部锁定表。Ifautocommit = 0,InnoDBhonorsLOCK TABLES; MySQL does not return fromLOCK TABLES ... WRITEuntil all other threads have released all their locks to the table. The default value ofinnodb_table_locksis 1, which means thatLOCK TABLEScauses InnoDB to lock a table internally ifautocommit = 0.innodb_table_locks = 0对于通过LOCK TABLES ... WRITE显式锁定的表没有影响。它对通过LOCK TABLES ... WRITE隐式锁定(例如,通过触发器)或通过LOCK TABLES ... READ锁定的表则有影响。innodb_table_locks = 0has no effect for tables locked explicitly withLOCK TABLES ... WRITE. It does have an effect for tables locked for read or write byLOCK TABLES ... WRITEimplicitly (for example, through triggers) or byLOCK TABLES ... READ.相关信息,请参见 第 17.7 节,“InnoDB 锁定和事务模型”。For related information, see Section 17.7, “InnoDB Locking and Transaction Model”.
命令行格式Command-Line Format --innodb-temp-data-file-path=file_name系统变量System Variable innodb_temp_data_file_path范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value ibtmp1:12M:autoextend定义全局临时表空间数据文件的相对路径、名称、大小和属性。全局临时表空间存储用于用户创建的临时表所做更改的回滚段。Defines the relative path, name, size, and attributes of global temporary tablespace data files. The global temporary tablespace stores rollback segments for changes made to user-created temporary tables.
如果没有为
innodb_temp_data_file_path指定值,默认行为是在innodb_data_home_dir目录中创建一个名为ibtmp1的自动扩展数据文件。初始文件大小略大于 12MB。If no value is specified forinnodb_temp_data_file_path, the default behavior is to create a single auto-extending data file namedibtmp1in theinnodb_data_home_dirdirectory. The initial file size is slightly larger than 12MB.全局临时表空间数据文件规范的语法包括文件名、文件大小,以及
autoextend和max属性:The syntax for a global temporary tablespace data file specification includes the file name, file size, andautoextendandmaxattributes:file_name:file_size[:autoextend[:max:max_file_size]]全局临时表空间数据文件不能与另一个
InnoDB数据文件同名。创建全局临时表空间数据文件的任何失败或错误都被视为严重错误,服务器将拒绝启动。The global temporary tablespace data file cannot have the same name as anotherInnoDBdata file. Any inability or error creating the global temporary tablespace data file is treated as fatal and server startup is refused.文件大小通过在数值后面加上
K、M或G来以 KB、MB 或 GB 为单位表示。文件大小的总和必须略大于 12MB。File sizes are specified in KB, MB, or GB by appendingK,MorGto the size value. The sum of file sizes must be slightly larger than 12MB.单个文件的大小限制由操作系统决定。在支持大文件的操作系统上,文件大小可以超过 4GB。不支持为全局临时表空间数据文件使用原始磁盘分区。The size limit of individual files is determined by the operating system. File size can be more than 4GB on operating systems that support large files. Use of raw disk partitions for global temporary tablespace data files is not supported.
该
autoextend以及maxattributes can be used only for the data file specified last in theinnodb_temp_data_file_pathsetting. For example:Theautoextendandmaxattributes can be used only for the data file specified last in theinnodb_temp_data_file_pathsetting. For example:[mysqld] innodb_temp_data_file_path=ibtmp1:50M;ibtmp2:12M:autoextend:max:500M
autoextend选项会导致数据文件在空间不足时自动增加大小。autoextend的默认增量为 64MB。要修改增量,请更改innodb_autoextend_increment变量设置。Theautoextendoption causes the data file to automatically increase in size when it runs out of free space. Theautoextendincrement is 64MB by default. To modify the increment, change theinnodb_autoextend_incrementvariable setting.全局临时表空间数据文件的目录路径是通过连接
innodb_data_home_dir和innodb_temp_data_file_path定义的路径形成的。The directory path for global temporary tablespace data files is formed by concatenating the paths defined byinnodb_data_home_dirandinnodb_temp_data_file_path.在以只读模式运行
InnoDB之前,将innodb_temp_data_file_path设置到数据目录之外的位置。该路径必须相对于数据目录。例如:Before runningInnoDBin read-only mode, setinnodb_temp_data_file_pathto a location outside of the data directory. The path must be relative to the data directory. For example:--innodb-temp-data-file-path=../../../tmp/ibtmp1:12M:autoextend
更多信息,请参见 全局临时表空间。For more information, see Global Temporary Tablespace.
命令行格式Command-Line Format --innodb-temp-tablespaces-dir=dir_name系统变量System Variable innodb_temp_tablespaces_dir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name 默认值Default Value #innodb_temp定义了
InnoDB在启动时创建会话临时表空间池的位置。默认位置是数据目录中的#innodb_temp目录。允许使用完整路径或相对于数据目录的路径。Defines the location whereInnoDBcreates a pool of session temporary tablespaces at startup. The default location is the#innodb_tempdirectory in the data directory. A fully qualified path or path relative to the data directory is permitted.会话临时表空间总是存储用户创建的临时表以及由优化器使用
InnoDB创建的内部临时表。(以前,内部临时表的磁盘存储引擎由internal_tmp_disk_storage_engine系统变量决定,该变量现在已不再受支持。请参见磁盘上的内部临时表的存储引擎。)Session temporary tablespaces always store user-created temporary tables and internal temporary tables created by the optimizer usingInnoDB. (Previously, the on-disk storage engine for internal temporary tables was determined by theinternal_tmp_disk_storage_enginesystem variable, which is no longer supported. See Storage Engine for On-Disk Internal Temporary Tables.)欲了解更多信息,请参见会话临时表空间。For more information, see Session Temporary Tablespaces.
命令行格式Command-Line Format --innodb-thread-concurrency=#系统变量System Variable innodb_thread_concurrency范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 1000定义允许在
InnoDB内运行的最大线程数。值为 0(默认)表示无限并发(无限制)。此变量用于对高并发系统进行性能调优。Defines the maximum number of threads permitted inside ofInnoDB. A value of 0 (the default) is interpreted as infinite concurrency (no limit). This variable is intended for performance tuning on high concurrency systems.InnoDB尽量保持InnoDB内的线程数量小于或等于innodb_thread_concurrency限制。等待锁的线程不计入当前执行线程数。InnoDBtries to keep the number of threads insideInnoDBless than or equal to theinnodb_thread_concurrencylimit. Threads waiting for locks are not counted in the number of concurrently executing threads.正确的设置取决于工作负载和计算环境。如果您的 MySQL 实例与其他应用程序共享 CPU 资源,或者您的工作负载或并发用户数量在增长,请考虑设置此变量。测试一系列值以确定能够提供最佳性能的设置。
innodb_thread_concurrency是一个动态变量,允许在实时测试系统上尝试不同的设置。如果某个特定设置性能不佳,您可以快速将innodb_thread_concurrency重新设置为 0。The correct setting depends on workload and computing environment. Consider setting this variable if your MySQL instance shares CPU resources with other applications or if your workload or number of concurrent users is growing. Test a range of values to determine the setting that provides the best performance.innodb_thread_concurrencyis a dynamic variable, which permits experimenting with different settings on a live test system. If a particular setting performs poorly, you can quickly setinnodb_thread_concurrencyback to 0.请使用以下指南来帮助找到和维持合适的设置:Use the following guidelines to help find and maintain an appropriate setting:
如果工作负载的并发用户线程数量始终较少且不影响性能,请将
innodb_thread_concurrency=0(不限制)。If the number of concurrent user threads for a workload is consistently small and does not affect performance, setinnodb_thread_concurrency=0(no limit).如果您的工作负载始终很重或偶尔出现峰值,请设置一个
innodb_thread_concurrency值,并调整直到找到提供最佳性能的线程数。例如,假设您的系统通常有 40 到 50 个用户,但有时用户数量会增加到 60、70 或更多。通过测试,您发现将并发用户限制在 80 时,性能保持基本稳定。在这种情况下,将innodb_thread_concurrency设置为 80。If your workload is consistently heavy or occasionally spikes, set aninnodb_thread_concurrencyvalue and adjust it until you find the number of threads that provides the best performance. For example, suppose that your system typically has 40 to 50 users, but periodically the number increases to 60, 70, or more. Through testing, you find that performance remains largely stable with a limit of 80 concurrent users. In this case, setinnodb_thread_concurrencyto 80.如果你不希望
InnoDB为用户线程使用超过一定数量的虚拟 CPU(例如 20 个虚拟 CPU),请将innodb_thread_concurrency设置为这个数字(或者可能更低,取决于性能测试)。如果你的目标是将 MySQL 与其他应用程序隔离,请考虑将mysqld进程专门绑定到这些虚拟 CPU。需要注意的是,如果mysqld进程并非持续繁忙,专用绑定可能会导致硬件使用不佳。在这种情况下,你可以将mysqld进程绑定到虚拟 CPU,但允许其他应用程序使用部分或全部虚拟 CPU。If you do not wantInnoDBto use more than a certain number of virtual CPUs for user threads (20 virtual CPUs, for example), setinnodb_thread_concurrencyto this number (or possibly lower, depending on performance testing). If your goal is to isolate MySQL from other applications, consider binding themysqldprocess exclusively to the virtual CPUs. Be aware, however, that exclusive binding can result in non-optimal hardware usage if themysqldprocess is not consistently busy. In this case, you can bind themysqldprocess to the virtual CPUs but allow other applications to use some or all of the virtual CPUs.Note从操作系统的角度来看,使用资源管理解决方案来管理 CPU 时间在应用程序之间的分配,可能比绑定
mysqld进程更可取。例如,当其他关键进程 未 运行时,您可以将虚拟 CPU 时间的 90% 分配给某个应用程序,而当其他关键进程 正在 运行时,将该数值缩减到 40%。From an operating system perspective, using a resource management solution to manage how CPU time is shared among applications may be preferable to binding themysqldprocess. For example, you could assign 90% of virtual CPU time to a given application while other critical processes are not running, and scale that value back to 40% when other critical processes are running.在某些情况下,最优的
innodb_thread_concurrency设置可能小于虚拟 CPU 的数量。In some cases, the optimalinnodb_thread_concurrencysetting can be smaller than the number of virtual CPUs.过高的
innodb_thread_concurrency值可能会由于系统内部和资源的争用增加而导致性能下降。Aninnodb_thread_concurrencyvalue that is too high can cause performance regression due to increased contention on system internals and resources.请定期监控和分析您的系统。工作负载、用户数量或计算环境的变化可能需要您调整
innodb_thread_concurrency设置。Monitor and analyze your system regularly. Changes to workload, number of users, or computing environment may require that you adjust theinnodb_thread_concurrencysetting.
值为 0 会禁用
SHOW ENGINE INNODB STATUS输出的ROW OPERATIONS部分中的queries inside InnoDB和queries in queue计数器。A value of 0 disables thequeries inside InnoDBandqueries in queuecounters in theROW OPERATIONSsection ofSHOW ENGINE INNODB STATUSoutput.有关相关信息,请参见 第 17.8.4 节,“配置 InnoDB 的线程并发”。For related information, see Section 17.8.4, “Configuring Thread Concurrency for InnoDB”.
命令行格式Command-Line Format --innodb-thread-sleep-delay=#系统变量System Variable innodb_thread_sleep_delay范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 10000最小值Minimum Value 0最大值Maximum Value 1000000单位Unit 微秒microseconds InnoDB线程在加入InnoDB队列之前休眠的时间,单位为微秒。默认值为 10000。值为 0 则禁用休眠。你可以将innodb_adaptive_max_sleep_delay设置为你允许的innodb_thread_sleep_delay的最大值,而InnoDB会根据当前线程调度活动自动上下调整innodb_thread_sleep_delay。这种动态调整有助于在线程调度机制在系统负载较轻或接近满负荷运行时平稳工作。How longInnoDBthreads sleep before joining theInnoDBqueue, in microseconds. The default value is 10000. A value of 0 disables sleep. You can setinnodb_adaptive_max_sleep_delayto the highest value you would allow forinnodb_thread_sleep_delay, andInnoDBautomatically adjustsinnodb_thread_sleep_delayup or down depending on current thread-scheduling activity. This dynamic adjustment helps the thread scheduling mechanism to work smoothly during times when the system is lightly loaded or when it is operating near full capacity.欲了解更多信息,请参见第 17.8.4 节,“配置 InnoDB 的线程并发”。For more information, see Section 17.8.4, “Configuring Thread Concurrency for InnoDB”.
命令行格式Command-Line Format --innodb-tmpdir=dir_name系统变量System Variable innodb_tmpdir范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name 默认值Default Value NULL用于定义在在线
ALTER TABLE操作中重建表时创建的临时排序文件的备选目录。Used to define an alternate directory for temporary sort files created during onlineALTER TABLEoperations that rebuild the table.在线
ALTER TABLE操作在重建表时,也会在原表所在目录中创建一个 中间 表文件。innodb_tmpdir选项不适用于中间表文件。OnlineALTER TABLEoperations that rebuild the table also create an intermediate table file in the same directory as the original table. Theinnodb_tmpdiroption is not applicable to intermediate table files.有效的值是除 MySQL 数据目录路径之外的任何目录路径。如果值为 NULL(默认值),临时文件将在 MySQL 临时目录中创建(Unix 上为
$TMPDIR,Windows 上为%TEMP%,或由--tmpdir配置选项指定的目录)。如果指定了目录,只有在使用SET语句配置innodb_tmpdir时,才会检查目录是否存在及权限。如果目录字符串中提供了符号链接,则符号链接将被解析并存储为绝对路径。路径不应超过 512 字节。如果innodb_tmpdir设置为无效目录,则在线ALTER TABLE操作会报告错误。innodb_tmpdir会覆盖 MySQL 的tmpdir设置,但仅适用于在线ALTER TABLE操作。A valid value is any directory path other than the MySQL data directory path. If the value is NULL (the default), temporary files are created MySQL temporary directory ($TMPDIRon Unix,%TEMP%on Windows, or the directory specified by the--tmpdirconfiguration option). If a directory is specified, existence of the directory and permissions are only checked wheninnodb_tmpdiris configured using aSETstatement. If a symlink is provided in a directory string, the symlink is resolved and stored as an absolute path. The path should not exceed 512 bytes. An onlineALTER TABLEoperation reports an error ifinnodb_tmpdiris set to an invalid directory.innodb_tmpdiroverrides the MySQLtmpdirsetting but only for onlineALTER TABLEoperations.配置
innodb_tmpdir需要FILE权限。TheFILEprivilege is required to configureinnodb_tmpdir.innodb_tmpdir选项的引入是为了帮助避免位于tmpfs文件系统上的临时文件目录溢出。由于在在线ALTER TABLE操作中生成用于重建表的大型临时排序文件,可能会发生这种溢出。Theinnodb_tmpdiroption was introduced to help avoid overflowing a temporary file directory located on atmpfsfile system. Such overflows could occur as a result of large temporary sort files created during onlineALTER TABLEoperations that rebuild the table.在复制环境中,只有在所有服务器具有相同操作系统环境时,才考虑复制
innodb_tmpdir设置。否则,在运行需要重建表的在线ALTER TABLE操作时,复制innodb_tmpdir设置可能导致复制失败。如果服务器操作环境不同,建议在每台服务器上单独配置innodb_tmpdir。In replication environments, only consider replicating theinnodb_tmpdirsetting if all servers have the same operating system environment. Otherwise, replicating theinnodb_tmpdirsetting could result in a replication failure when running onlineALTER TABLEoperations that rebuild the table. If server operating environments differ, it is recommended that you configureinnodb_tmpdiron each server individually.更多信息,请参见 第 17.12.3 节,“在线 DDL 空间需求”。有关在线
ALTER TABLE操作的信息,请参见 第 17.12 节,“InnoDB 和在线 DDL”。For more information, see Section 17.12.3, “Online DDL Space Requirements”. For information about onlineALTER TABLEoperations, see Section 17.12, “InnoDB and Online DDL”.innodb_trx_purge_view_update_only_debug命令行格式Command-Line Format --innodb-trx-purge-view-update-only-debug[={OFF|ON}]系统变量System Variable innodb_trx_purge_view_update_only_debug范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF在允许清除视图更新的同时暂停删除标记记录的清除。此选项人为地创建了一种清除视图已更新但清除操作尚未执行的情况。仅当使用
WITH_DEBUGCMake 选项编译了调试支持时才可用。Pauses purging of delete-marked records while allowing the purge view to be updated. This option artificially creates a situation in which the purge view is updated but purges have not yet been performed. This option is only available if debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-trx-rseg-n-slots-debug=#系统变量System Variable innodb_trx_rseg_n_slots_debug范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 1024设置一个调试标志,将
TRX_RSEG_N_SLOTS限制为给定值,用于trx_rsegf_undo_find_free函数,该函数用于查找撤消日志段的空闲槽。此选项仅在使用WITH_DEBUGCMake 选项编译时包含调试支持时可用。Sets a debug flag that limitsTRX_RSEG_N_SLOTSto a given value for thetrx_rsegf_undo_find_freefunction that looks for free slots for undo log segments. This option is only available if debugging support is compiled in using theWITH_DEBUGCMake option.命令行格式Command-Line Format --innodb-undo-directory=dir_name系统变量System Variable innodb_undo_directory范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name The path where
InnoDBcreates undo tablespaces. Typically used to place undo tablespaces on a different storage device.没有默认值(为 NULL)。如果
innodb_undo_directory变量未定义,回滚表空间将创建在数据目录中。There is no default value (it is NULL). If theinnodb_undo_directoryvariable is undefined, undo tablespaces are created in the data directory.MySQL 实例初始化时创建的默认回滚表空间(
innodb_undo_001和innodb_undo_002)始终位于innodb_undo_directory变量定义的目录中。The default undo tablespaces (innodb_undo_001andinnodb_undo_002) created when the MySQL instance is initialized always reside in the directory defined by theinnodb_undo_directoryvariable.使用
CREATE UNDO TABLESPACE语法创建的回滚表空间会被创建在innodb_undo_directory变量定义的目录中,如果没有指定其他路径。Undo tablespaces created usingCREATE UNDO TABLESPACEsyntax are created in the directory defined by theinnodb_undo_directoryvariable if a different path is not specified.欲了解更多信息,请参见 第 17.6.3.4 节,“Undo 表空间”。For more information, see Section 17.6.3.4, “Undo Tablespaces”.
命令行格式Command-Line Format --innodb-undo-log-encrypt[={OFF|ON}]系统变量System Variable innodb_undo_log_encrypt范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF控制使用
InnoDB静态数据加密功能加密的表的撤消日志数据的加密。仅适用于位于单独 撤消表空间中的撤消日志。请参阅 第 17.6.3.4 节,“撤消表空间”。位于系统表空间中的撤消日志数据不支持加密。更多信息,请参阅 撤消日志加密。Controls encryption of undo log data for tables encrypted using theInnoDBdata-at-rest encryption feature. Only applies to undo logs that reside in separate undo tablespaces. See Section 17.6.3.4, “Undo Tablespaces”. Encryption is not supported for undo log data that resides in the system tablespace. For more information, see Undo Log Encryption.命令行格式Command-Line Format --innodb-undo-log-truncate[={OFF|ON}]系统变量System Variable innodb_undo_log_truncate范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON启用后,超过
innodb_max_undo_log_size定义阈值的撤销表空间会被标记为截断。只有撤销表空间可以被截断。位于系统表空间中的撤销日志不支持截断。要进行截断,必须至少有两个撤销表空间。When enabled, undo tablespaces that exceed the threshold value defined byinnodb_max_undo_log_sizeare marked for truncation. Only undo tablespaces can be truncated. Truncating undo logs that reside in the system tablespace is not supported. For truncation to occur, there must be at least two undo tablespaces.可以使用
innodb_purge_rseg_truncate_frequency变量来加快撤销表空间的截断速度。Theinnodb_purge_rseg_truncate_frequencyvariable can be used to expedite truncation of undo tablespaces.更多信息,请参见 截断撤销表空间。For more information, see Truncating Undo Tablespaces.
命令行格式Command-Line Format --innodb-undo-tablespaces=#已弃用Deprecated 是Yes 系统变量System Variable innodb_undo_tablespaces范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2最小值Minimum Value 2最大值Maximum Value 127定义
InnoDB使用的 撤销表空间 的数量。默认值和最小值为 2。Defines the number of undo tablespaces used byInnoDB. The default and minimum value is 2.Noteinnodb_undo_tablespaces变量已不推荐使用;设置它不会有任何效果。您应预计它将在未来的 MySQL 版本中被移除。Theinnodb_undo_tablespacesvariable is deprecated; setting it has no effect. You should expect it to be removed in a future MySQL release.欲了解更多信息,请参见 第 17.6.3.4 节,“Undo 表空间”。For more information, see Section 17.6.3.4, “Undo Tablespaces”.
命令行格式Command-Line Format --innodb-use-fdatasync[={OFF|ON}]系统变量System Variable innodb_use_fdatasync范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON在支持
fdatasync()系统调用的平台上,启用innodb_use_fdatasync允许在操作系统刷新时使用fdatasync()代替fsync()系统调用。fdatasync()调用不会刷新文件元数据的更改,除非后续数据检索需要,从而提供潜在的性能优势。On platforms that supportfdatasync()system calls, havinginnodb_use_fdatasyncenabled permits usingfdatasync()instead offsync()system calls for operating system flushes. Anfdatasync()call does not flush changes to file metadata unless required for subsequent data retrieval, providing a potential performance benefit.innodb_flush_method设置的子集,例如fsync、O_DSYNC和O_DIRECT使用fsync()系统调用。使用这些设置时,innodb_use_fdatasync变量适用。A subset ofinnodb_flush_methodsettings such asfsync,O_DSYNC, andO_DIRECTusefsync()system calls. Theinnodb_use_fdatasyncvariable is applicable when using those settings.在 MySQL 8.4 之前,该选项默认是禁用的。Before MySQL 8.4, this option was disabled by default.
命令行格式Command-Line Format --innodb-use-native-aio[={OFF|ON}]系统变量System Variable innodb_use_native_aio范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON指定是否使用异步 I/O 子系统。此变量在服务器运行时无法更改。通常,您无需配置此选项,因为它默认启用。Specifies whether to use the asynchronous I/O subsystem. This variable cannot be changed while the server is running. Normally, you do not need to configure this option, because it is enabled by default.
此功能提高了 I/O 高负载系统的可扩展性,这类系统通常在
SHOW ENGINE INNODB STATUS输出中显示许多待处理的读取/写入操作。This feature improves the scalability of heavily I/O-bound systems, which typically show many pending reads/writes inSHOW ENGINE INNODB STATUSoutput.在大量运行
InnoDBI/O 线程时,尤其是在同一台服务器上运行多个此类实例时,可能会超出 Linux 系统的容量限制。在这种情况下,您可能会收到以下错误:Running with a large number ofInnoDBI/O threads, and especially running multiple such instances on the same server machine, can exceed capacity limits on Linux systems. In this case, you may receive the following error:EAGAIN: The specified maxevents exceeds the user's limit of available events.
通常可以通过向
/proc/sys/fs/aio-max-nr写入一个更高的限制来解决此错误。You can typically address this error by writing a higher limit to/proc/sys/fs/aio-max-nr.但是,如果操作系统中的异步 I/O 子系统出现问题,导致
InnoDB无法启动,你可以通过innodb_use_native_aio=0启动服务器。如果InnoDB检测到潜在问题,例如tmpdir位置、tmpfs文件系统以及 Linux 内核组合不支持tmpfs上的 AIO,这个选项也可能在启动时自动禁用。However, if a problem with the asynchronous I/O subsystem in the OS preventsInnoDBfrom starting, you can start the server withinnodb_use_native_aio=0. This option may also be disabled automatically during startup ifInnoDBdetects a potential problem such as a combination oftmpdirlocation,tmpfsfile system, and Linux kernel that does not support AIO ontmpfs.更多信息,请参见 第 17.8.6 节,“在 Linux 上使用异步 I/O”。For more information, see Section 17.8.6, “Using Asynchronous I/O on Linux”.
innodb_validate_tablespace_paths命令行格式Command-Line Format --innodb-validate-tablespace-paths[={OFF|ON}]系统变量System Variable innodb_validate_tablespace_paths范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON控制表空间文件路径验证。在启动时,
InnoDB会将已知表空间文件的路径与存储在数据字典中的表空间文件路径进行验证,以防表空间文件被移动到不同位置。innodb_validate_tablespace_paths变量允许禁用表空间路径验证。此功能适用于表空间文件不会被移动的环境。在具有大量表空间文件的系统上,禁用路径验证可以提高启动速度。Controls tablespace file path validation. At startup,InnoDBvalidates the paths of known tablespace files against tablespace file paths stored in the data dictionary in case tablespace files have been moved to a different location. Theinnodb_validate_tablespace_pathsvariable permits disabling tablespace path validation. This feature is intended for environments where tablespaces files are not moved. Disabling path validation improves startup time on systems with a large number of tablespace files.Warning在移动表空间文件后,如果在启动服务器时禁用表空间路径验证,可能会导致未定义的行为。Starting the server with tablespace path validation disabled after moving tablespace files can lead to undefined behavior.
有关更多信息,请参见 第 17.6.3.7 节,“禁用表空间路径验证”。For more information, see Section 17.6.3.7, “Disabling Tablespace Path Validation”.
InnoDB版本号。该变量是遗留变量,其值与 MySQL 服务器的version相同。TheInnoDBversion number. This is a legacy variable, the value is the same as the MySQL serverversion.命令行格式Command-Line Format --innodb-write-io-threads=#系统变量System Variable innodb_write_io_threads范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 4最小值Minimum Value 1最大值Maximum Value 64InnoDB中用于写操作的 I/O 线程数。默认值为 4。其读线程对应项为innodb_read_io_threads。更多信息请参见 第 17.8.5 节,“配置后台 InnoDB I/O 线程数量”。有关一般 I/O 调优建议,请参见 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。The number of I/O threads for write operations inInnoDB. The default value is 4. Its counterpart for read threads isinnodb_read_io_threads. For more information, see Section 17.8.5, “Configuring the Number of Background InnoDB I/O Threads”. For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.Note在 Linux 系统上,以默认设置运行多个 MySQL 服务器(通常超过 12 个),对于
innodb_read_io_threads、innodb_write_io_threads和 Linuxaio-max-nr设置可能会超过系统限制。理想情况下,应增加aio-max-nr设置;作为一种解决方法,您可以减少一个或两个 MySQL 变量的设置。On Linux systems, running multiple MySQL servers (typically more than 12) with default settings forinnodb_read_io_threads,innodb_write_io_threads, and the Linuxaio-max-nrsetting can exceed system limits. Ideally, increase theaio-max-nrsetting; as a workaround, you might reduce the settings for one or both of the MySQL variables.还要考虑
sync_binlog的值,它控制二进制日志同步到磁盘。Also take into consideration the value ofsync_binlog, which controls synchronization of the binary log to disk.有关一般 I/O 调优建议,请参阅 第 10.5.8 节,“优化 InnoDB 磁盘 I/O”。For general I/O tuning advice, see Section 10.5.8, “Optimizing InnoDB Disk I/O”.