文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 17 InnoDB 存储引擎 / 17.8 InnoDB 配置 / 17.8.12 为专用 MySQL 服务器启用自动 InnoDB 配置
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 85%

17.8.12 为专用 MySQL 服务器启用自动 InnoDB 配置17.8.12 Enabling Automatic InnoDB Configuration for a Dedicated MySQL Server

当服务器使用 --innodb-dedicated-server 启动时,InnoDB 会自动计算以下系统变量的值并进行设置:When the server is started with --innodb-dedicated-server, InnoDB automatically calculates values for and sets the following system variables:

Note

innodb_redo_log_capacity 取代了 innodb_log_file_size 和 innodb_log_files_in_group,这些参数在旧版本的 MySQL 中由 --innodb-dedicated-server 设置,但现在已经被弃用。你应该预期 innodb_log_file_size 和 innodb_log_files_in_group 在未来的 MySQL 版本中会被移除。innodb_redo_log_capacity supersedes both innodb_log_file_size and innodb_log_files_in_group, which were set by --innodb-dedicated-server in older versions of MySQL, but which have since been deprecated. You should expect innodb_log_file_size and innodb_log_files_in_group to be removed in a future version of MySQL.

在 MySQL 8.0 中,innodb_flush_method 也会由此选项自动设置,但在 MySQL 8.4 中,这种情况已不再适用。In MySQL 8.0, innodb_flush_method was also set automatically by this option, but in MySQL 8.4, this is no longer the case.

只有在 MySQL 实例运行在专用服务器上并且可以使用所有可用系统资源时,你才应该考虑使用 --innodb-dedicated-server——例如,如果你在 Docker 容器或只运行 MySQL 的专用虚拟机中运行 MySQL 服务器。如果 MySQL 实例与其他应用程序共享系统资源,则不建议使用 --innodb-dedicated-server。You should consider using --innodb-dedicated-server only if the MySQL instance resides on a dedicated server where it can use all available system resources—for example, if you run MySQL Server in a Docker container or dedicated VM that runs MySQL only. using --innodb-dedicated-server is not recommended if the MySQL instance shares system resources with other applications.

每个受影响变量的值由 --innodb-dedicated-server 确定并应用,如下列表所示:The value for each affected variable is determined and applied by --innodb-dedicated-server as described in the following list:

  • innodb_buffer_pool_size

    缓冲池大小根据服务器检测到的内存量计算,如下表所示:Buffer pool size is calculated according to the amount of memory detected on the server, as shown in the following table:

    表 17.8 自动配置的缓冲池大小Table 17.8 Automatically Configured Buffer Pool Size

    检测到的服务器内存Detected Server Memory 缓冲池大小Buffer Pool Size
    少于 1GBLess than 1GB 128MB(默认值)128MB (the default value)
    1GB 到 4GB1GB to 4GB detected server memory * 0.5detected server memory * 0.5
    大于 4GBGreater than 4GB detected server memory * 0.75detected server memory * 0.75

  • innodb_redo_log_capacity

    重做日志容量根据服务器上可用的逻辑处理器数量计算。公式为(可用逻辑处理器数量 / 2)GB,最大动态默认值为 16 GB。Redo log capacity is calculated according to the number of logical processors available on the server. The formula is (number of available logical processors / 2) GB, with a maximum dynamic default value of 16 GB.

  • innodb_log_file_size(已弃用)innodb_log_file_size (deprecated)

    日志文件大小根据自动配置的缓冲池大小设置,如下表所示:Log file size is set according to the automatically configured buffer pool size, as shown in the following table:

    表 17.9 自动配置的日志文件大小Table 17.9 Automatically Configured Log File Size

    缓冲池大小Buffer Pool Size 日志文件大小Log File Size
    小于 8GBLess than 8GB 512MB
    8GB 到 128GB8GB to 128GB 1024MB
    大于 128GBGreater than 128GB 2048MB

  • innodb_log_files_in_group(已弃用)innodb_log_files_in_group (deprecated)

    日志文件的数量是根据自动配置的缓冲池大小确定的,如下表所示:The number of log files is determined according to the automatically configured buffer pool size, as shown in the following table:

    表 17.10 自动配置的日志文件数量Table 17.10 Automatically Configured Number of Log Files

    缓冲池大小Buffer Pool Size 日志文件数量Number of Log Files
    小于 8GBLess than 8GB round(buffer pool size)round(buffer pool size)
    8GB 到 128GB8GB to 128GB round(buffer pool size * 0.75)round(buffer pool size * 0.75)
    大于 128GBGreater than 128GB 64

    Note

    innodb_log_files_in_group 的最小值为 2;如果四舍五入后的缓冲池大小值小于此数字,则会强制执行此下限。The minimum value for innodb_log_files_in_group value is 2; this lower limit is enforced if the rounded buffer pool size value is less than this number.

如果先前列出的变量之一在选项文件或其他地方被显式设置,则使用此显式值,并在 stderr 打印类似如下的启动警告:If one of the variables listed previously is set explicitly in an option file or elsewhere, this explicit value is used, and a startup warning similar to this one is printed to stderr:

[警告] [000000] InnoDB:由于已明确指定 innodb_buffer_pool_size=134217728,选项 innodb_dedicated_server 对 innodb_buffer_pool_size 被忽略。[Warning] [000000] InnoDB: Option innodb_dedicated_server is ignored for innodb_buffer_pool_size because innodb_buffer_pool_size=134217728 is specified explicitly.

显式设置一个变量不会阻止其他选项的自动配置。Setting one variable explicitly does not prevent the automatic configuration of other options.

如果服务器使用 --innodb-dedicated-server 启动,并且 innodb_buffer_pool_size 被明确设置,则基于缓冲池大小的变量设置将使用根据服务器检测到的内存量计算的缓冲池大小值,而不是显式定义的缓冲池大小值。If the server is started with --innodb-dedicated-server and innodb_buffer_pool_size is set explicitly, variable settings based on buffer pool size use the buffer pool size value calculated according to the amount of memory detected on the server rather than the explicitly defined buffer pool size value.

Note

自动配置设置仅在 MySQL 服务器启动时由 --innodb-dedicated-server 应用。如果您之后显式设置任何受影响的变量,这将覆盖其预设值,并应用显式设置的值。将这些变量之一设置为 DEFAULT 会将其设置为手册中变量说明所示的实际默认值,而 不会 将其恢复为由 --innodb-dedicated-server 设置的值。相应的系统变量 innodb_dedicated_server 仅通过使用 --innodb-dedicated-server(或 --innodb-dedicated-server=ON 或 --innodb-dedicated-server=OFF)启动服务器时更改;否则,它是只读的。Automatic configuration settings are applied by --innodb-dedicated-server only when the MySQL server is started. If you later set any of the affected variables explicitly, this overrides its predetermined value, and the value that was explicitly set is applied. Setting one of these variables to DEFAULT causes it to be set to the actual default value as shown in the variable's description in the Manual, and does not cause it to revert to the value set by --innodb-dedicated-server. The corresponding system variable innodb_dedicated_server is changed only by starting the server with --innodb-dedicated-server (or with --innodb-dedicated-server=ON or --innodb-dedicated-server=OFF); it is otherwise read-only.