我有一个著名的socketexception too many open files bug。Iam在我的服务器上运行apache http服务器、tomcat服务器和mysql数据库。
我用ulimit -n检查了打开文件的限制,得到了1024个文件。如果我想检查lsof -u tomcat打开了多少个文件,它会给我5个相同的结果。我不知道问题出在哪里。但我也有一个读取链接权限被拒绝。
我想要监视我的套接字连接和服务器上打开的文件。我想过在shell脚本中使用所描述的linux命令,并通过邮件将它们发送给我。
我认为另一种选择是使用netstat并计算连接数。但是它的加载速度非常慢,并且让我的getnameinfo失败。
用什么命令来监控我的bug会更好呢?
编辑:
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发布于 2020-05-30 23:12:21
您可以使用'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实现这些细节应该避免“打开的文件太多”的消息。要获得更多帮助,请查看配置文件、网络配置文件以获取联系信息,以及可免费下载的实用程序脚本,以帮助进行性能调整。
https://stackoverflow.com/questions/61955373
复制相似问题