【问题标题】:monitoring linux server sockets or files监控 linux 服务器套接字或文件
【发布时间】:2020-05-22 12:45:07
【问题描述】:

我有著名的socketexception too many open files 错误。 我正在我的服务器上运行一个 apache http 服务器、tomcat 服务器和一个 mysql 数据库。

我使用ulimit -n 检查了打开文件的限制,结果为 1024。 如果我想检查lsof -u tomcat 打开了多少文件,它给了我 5 对 mysql 也一样。我不确定问题是什么。但我也拒绝了读取链接权限。

我想监控我的套接字连接并在我的服务器上打开文件。我考虑过在 shell 脚本中使用所描述的 linux 命令并通过邮件将它们发送给我。

我认为的另一个选项是使用netstat 并可能计算连接数.. 但它的加载速度非常慢,并且让我 getnameinfo 失败。

监视我的错误的更好命令是什么?

编辑:

SHOW GLOBAL VARIABLES LIKE '%open%';
    Variable_name Value
    Com_ha_open 0
    Com_show_open_tables 0
    Open_files 8
    Open_streams 0
    Open_table_definitions 87
    Open_tables 64
    Opened_files 673
    Opened_table_definitions 87
    Opened_tables 628
    Slave_open_temp_tables 0



    SHOW GLOBAL VARIABLES LIKE '%open%';

    Variable_name Value
    have_openssl DISABLED
    innodb_open_files 300
    open_files_limit 2000
    table_open_cache 64



    SHOW GLOBAL VARIABLES LIKE '%connect%'

    character_set_connection latin1
    collation_connection latin1_swedish_ci
    connect_timeout 10 
    init_connect 
    max_connect_errors 10
    max_connections 400
    max_user_connections 0


    SHOW GLOBAL STATUS LIKE '%connect%';

    Variable_name Value
    Aborted_connects 1
    Connections 35954
    Max_used_connections 102
    Ssl_client_connects 0
    Ssl_connect_renegotiates 0
    Ssl_finished_connects 0
    Threads_connected 11

【问题讨论】:

  • 使用 MySQL 客户端登录,发布 A) SHOW GLOBAL VARIABLES LIKE '%open%'; 的 TEXT 结果;和 B) 显示全局变量,例如 '%open%';和 C) 显示全局变量,例如 '%connect%';和 D) 显示 '%connect%' 之类的全局状态;请。
  • 你能制定一个好的答案并格式化吗?也可能是命令的一些注释。 TY ;)
  • 显示全局变量,例如 '%open%';
  • 显示全局状态,如 '%open%'
  • 显示全局变量,例如 '%connect%';

标签: linux sockets tomcat netstat ulimit


【解决方案1】:

您可以使用 'ulimit -a' 检查 ulimit 值以确定打开文件的容量。 在操作系统命令提示符中,ulimit -n 8192 并按 Enter 以动态启用更多打开文件。 要使此更改在操作系统重新启动后持续存在,下一个 URL 可以作为您的指南。

https://glassonionblog.wordpress.com/2013/01/27/increase-ulimit-and-file-descriptors-limit/

如果他们的示例是 500000 容量,请为您的系统使用 8192。

为您的 my.cnf [mysqld] 部分考虑的建议,

thread_cache_size=100  # to support your max_used_connections of 102
max_user_connections=400  # from 0 to match max_connections requested
table_open_cache=800  # from 64 to reduce Opened_tables count
innodb_open_files=800  # from 300 to match table_open_cache requested

实施这些细节应避免出现“打开的文件过多”消息。如需更多帮助,请查看配置文件、网络配置文件以获取联系信息以及免费下载的实用程序脚本以帮助进行性能调整。

【讨论】:

    猜你喜欢
    • 2016-07-24
    • 1970-01-01
    • 1970-01-01
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 2014-12-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多