zoukankan      html  css  js  c++  java
  • mysql打开文件数太多的解决办法

    http://www.orczhou.com/index.php/2010/10/mysql-open-file-limit/

    http://www.cnblogs.com/end/archive/2013/02/02/2890018.html

    然后, 以root身份重新启动 mysqld. 在这里, 尽管 my.cnf 中指定的运行用户不是root, 一样可以以root身份来启动mysqld, 否则 open_files_limit 选项无法生效, 因为内核限制了普通用户的最多打开文件数.

    判断方法:

    在系统运行一段时间后,可以通过show processlist命令查看当前系统的连接状态,如果发现有大量的sleep状态的连接进程,则说明该参数设置的过大,可以进行适当的调整小些。

    http://blog.chinaunix.net/uid-24426415-id-77347.html
    http://www.cnblogs.com/jiunadianshi/articles/2475475.html
    http://www.cnblogs.com/jiunadianshi/articles/2388871.html
    http://www.cnblogs.com/littlehb/p/5846701.html
    ===============================================================


    注意事项:

    1、为了防止发生too many connections时候无法登录的问题,mysql manual有如下的说明:
    mysqld actually allows max_connections+1 clients to connect. The extra connection is reserved for use by accounts that have the SUPER privilege. By granting the SUPER privilege to administrators and not to normal users (who should not need it), an administrator can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected.

    因此, 必须只赋予root用户的SUPER权限,同时所有数据库连接的帐户不能赋予SUPER权限。前面说到的报错后无法登录就是由于我们的应用程序直接配置的root用户。


    2、修改MySQL配置文件/etc/my.cnf,设置成max_connections=1000,wait_timeout=10。如果没有此项设置可以自行添加,修改后重启MySQL服务即可。要不经常性报此错误,则要对服务器作整体性能优化。(单位是秒)


    1)interactive_timeout:
    参数含义:服务器关闭交互式连接前等待活动的秒数。交互式客户端定义为在mysql_real_connect()中使用CLIENT_INTERACTIVE选项的客户端。
    参数默认值:28800秒(8小时)

    (2)wait_timeout:
    参数含义:服务器关闭非交互连接之前等待活动的秒数。
    在线程启动时,根据全局wait_timeout值或全局interactive_timeout值初始化会话wait_timeout值,取决于客户端类型(由mysql_real_connect()的连接选项CLIENT_INTERACTIVE定义)。
    参数默认值:28800秒(8小时)


    查看的办法:
    show global variables like 'wait_timeout';

    会话变量wait_timeout初始化的问题,这一点在手册里已经明确指出了,我就直接拷贝了:
    On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect()).


    建议配置:
    【mysqld】
    wait_timeout=100
    interactive_timeout=100

    http://www.cnblogs.com/jiunadianshi/articles/2475475.html

    http://www.cnblogs.com/losesea/archive/2013/11/24/3440107.html


  • 相关阅读:
    创建web应用程序时出现 SharePoint HRESULT:0x80070094 问题
    用Javascript获取SharePoint当前登录用户的用户名及Group信息
    javascript连接数据库
    sharepoint 中banner 图片的放大
    GridView导出Excel 类库
    SQL Server 性能调优
    GridView长字段的显示
    MOSS母版页制作学习笔记(二)
    sharepoint 中批量导入导出
    JavaScript 动态更改sharepoint 列表的颜色
  • 原文地址:https://www.cnblogs.com/littlehb/p/5846701.html
Copyright © 2011-2022 走看看