MySQL8.0~open_files_limit 和 innodb_open_files 参数生效取值标准

前置条件

设置参数

/etc/security/limits.conf中设置如下

* soft nofile 100001
* hard nofile 100002
root soft nofile 100001
root hard nofile 100002
mysql soft nofile 65535
mysql hard nofile 65535

my.cnf中设置如下

table_open_cache=5000
open_files_limit=20000
innodb_open_files=10000                          

open_files_limit 取值标准

mysql用户重启服务

重启mysql,以mysql用户启动服务

/bin/sh /usr/local/mysql8/bin/mysqld_safe --defaults-file=/etc/my8.cnf --user=mysql &

查询参数值

mysql> show variables like '%open%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| have_openssl               | YES   |
| innodb_open_files          | 10000 |
| mysqlx_port_open_timeout   | 0     |
| open_files_limit           | 65535 |
| table_open_cache           | 5000  |
| table_open_cache_instances | 16    |
+----------------------------+-------+

innodb_open_files 10000 和配置文件中一致
open_files_limit 65535 和操作系统mysql用户文件句柄数一致
table_open_cache 5000 和配置文件中一致

root用户重启服务

重启mysql,以root用户启动服务

查看参数值

mysql> show variables like '%open%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| have_openssl               | YES   |
| innodb_open_files          | 10000 |
| mysqlx_port_open_timeout   | 0     |
| open_files_limit           | 20000 |
| table_open_cache           | 5000  |
| table_open_cache_instances | 16    |
+----------------------------+-------+

innodb_open_files 10000 和配置文件中一致
open_files_limit 20000 和配置文件中一致
table_open_cache 5000 和配置文件中一致

innodb_open_files取值标准

修改innodb_open_files的值
table_open_cache=5000
open_files_limit=20000
innodb_open_files=30000

使用mysql用户启动

mysql> show variables like '%open%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| have_openssl               | YES   |
| innodb_open_files          | 30000 |
| mysqlx_port_open_timeout   | 0     |
| open_files_limit           | 65535 |
| table_open_cache           | 5000  |
| table_open_cache_instances | 16    |
+----------------------------+-------+

innodb_open_files 读取配置文件的值

使用root用户启动

mysql> show variables like '%open%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| have_openssl               | YES   |
| innodb_open_files          | 5000  |
| mysqlx_port_open_timeout   | 0     |
| open_files_limit           | 20000 |
| table_open_cache           | 5000  |
| table_open_cache_instances | 16    |
+----------------------------+-------+

如果它大于 open_files_limit 且大于 table_open_cache 则取值table_open_cache

总结

1、innodb_open_files 和open_files_limit 两个参数值生效,和操作系统配置和配置文件配置有关系,且和不同操作系统启动服务也有关。

2、open_files_limit : 如果是root账号启动 以my.cnf文件里面的值为准, 如果是mysql启动, 就可能是 ulimit -n 看到的那个值

3、innodb_open_files :如果以mysql账户启动,则取my.cnf文件里面的值为准;
如果用root账户启动, 如果它大于 open_files_limit 且大于 table_open_cache 则取值table_open_cache,否则取配置文件my.cnf的值。

相关推荐

  1. MySQL商城数据表(80-88

    2024-07-09 22:56:04       24 阅读
  2. MySQL商城数据表(80-84

    2024-07-09 22:56:04       26 阅读
  3. MySQL inexists的取舍

    2024-07-09 22:56:04       56 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 22:56:04       50 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 22:56:04       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 22:56:04       43 阅读
  4. Python语言-面向对象

    2024-07-09 22:56:04       54 阅读

热门阅读

  1. Linux下网络编程-简易poll服务器和客户端

    2024-07-09 22:56:04       20 阅读
  2. ClickHouse表引擎概述

    2024-07-09 22:56:04       18 阅读
  3. svn常用命令

    2024-07-09 22:56:04       21 阅读
  4. 面向对象——继承、封装、多态

    2024-07-09 22:56:04       17 阅读
  5. CoppeliaSim的简单教程

    2024-07-09 22:56:04       21 阅读
  6. cadence许可管理策略

    2024-07-09 22:56:04       18 阅读
  7. Android动态设置系统音量最大值

    2024-07-09 22:56:04       23 阅读