zoukankan      html  css  js  c++  java
  • How MySQL Opens and Closes Tables refuse connections 拒绝连接的原因 file descriptors

    MySQL :: MySQL 5.7 Reference Manual :: 8.4.3.1 How MySQL Opens and Closes Tables https://dev.mysql.com/doc/refman/5.7/en/table-cache.html

    MySQL 5.7 Reference Manual  /  ...  /  How MySQL Opens and Closes Tables

    8.4.3.1 How MySQL Opens and Closes Tables

    When you execute a mysqladmin status command, you should see something like this:

    Uptime: 426 Running threads: 1 Questions: 11082
    Reloads: 1 Open tables: 12

    The Open tables value of 12 can be somewhat puzzling if you have only six tables.

    MySQL is multi-threaded, so there may be many clients issuing queries for a given table simultaneously. To minimize the problem with multiple client sessions having different states on the same table, the table is opened independently by each concurrent session. This uses additional memory but normally increases performance. With MyISAM tables, one extra file descriptor is required for the data file for each client that has the table open. (By contrast, the index file descriptor is shared between all sessions.)

    The table_open_cache and max_connections system variables affect the maximum number of files the server keeps open. If you increase one or both of these values, you may run up against a limit imposed by your operating system on the per-process number of open file descriptors. Many operating systems permit you to increase the open-files limit, although the method varies widely from system to system. Consult your operating system documentation to determine whether it is possible to increase the limit and how to do so.

    table_open_cache is related to max_connections. For example, for 200 concurrent running connections, specify a table cache size of at least 200 * N, where N is the maximum number of tables per join in any of the queries which you execute. You must also reserve some extra file descriptors for temporary tables and files.

    Make sure that your operating system can handle the number of open file descriptors implied by the table_open_cachesetting. If table_open_cache is set too high, MySQL may run out of file descriptors and refuse connections, fail to perform queries, and be very unreliable.

    0-连接数不够:软件,增大max_connections;

    1-系统资源不足:硬件,file descriptors 不足,改善硬件(增大 --open-files-limit)。

    You should also take into account the fact that the MyISAM storage engine needs two file descriptors for each unique open table. For a partitioned MyISAM table, two file descriptors are required for each partition of the opened table. (Note further that when MyISAM opens a partitioned table, it opens every partition of this table, whether or not a given partition is actually used. See MyISAM and partition file descriptor usage.) You can increase the number of file descriptors available to MySQL using the --open-files-limit startup option to mysqld. SeeSection B.5.2.17, “File Not Found and Similar Errors”.

    The cache of open tables is kept at a level of table_open_cache entries. The server autosizes the cache size at startup. To set the size explicitly, set the table_open_cache system variable at startup. Note that MySQL may temporarily open more tables than this to execute queries.

    MySQL closes an unused table and removes it from the table cache under the following circumstances:

    • When the cache is full and a thread tries to open a table that is not in the cache.

    • When the cache contains more than table_open_cache entries and a table in the cache is no longer being used by any threads.

    • When a table flushing operation occurs. This happens when someone issues a FLUSH TABLES statement or executes a mysqladmin flush-tables or mysqladmin refresh command.

  • 相关阅读:
    C# 图形普通处理,resize ,水印..
    图像处理 形态学 (腐蚀 膨胀 开闭运算 连通分量....)
    获取usb设备父系或子代
    aforge通过角点匹配图片相似度
    CentOS 手动增加、删除swap区
    Zabbix 中文使用手册
    CentOS7下Firewall防火墙配置用法详解
    CentOS7安装Zabbix
    宅男也可变形男-我是如何在11个月零27天减掉80斤的
    CentOS环境下使用GIT基于Nginx的私服搭建全过程
  • 原文地址:https://www.cnblogs.com/rsapaper/p/8006830.html
Copyright © 2011-2022 走看看