最近一直在捣鼓zabbix 优化的问题,系统的做了一遍优化,性能,稳定性提升了不少。但是内存使用率高居不下,起初认为会mysql一直占用那么多内存,不会释放。其实不然,最近在观察,mysql进程连接的时候发现很多sleep进程时长上千秒,如果这么多空闲进程存在的话,新的连接进来就要重新创建,又消耗了一部分系统资源,而原来的并没有释放,但是又什么事都没做,岂不是浪费。对此进行了一番考究。
怎么知道mysql的连接时长是多少呢?
这个与interactive_timeout和wait_timeout两个参数的的设置有关。
查看官方文档,对两个参数的定义。
Property Value Command-Line Format --interactive-timeout=#
System Variable interactive_timeout
Scope Global, Session Dynamic Yes Type Integer Default Value 28800
Minimum Value 1
The number of seconds the server waits for activity on an interactive connection before closing it. An interactive client is defined as a client that uses the
CLIENT_INTERACTIVE
option to