欢迎访问昆山宝鼎软件有限公司网站! 设为首页 | 网站地图 | XML | RSS订阅 | 宝鼎邮箱 | 宝鼎售后问题提交 | 后台管理


新闻资讯

MENU

软件开发知识

导致连接被MySQL进程终止 mysql show global variables like interactive_

点击: 次  来源:劳务派遣管理系统 时间:2018-06-26

原文出处: 潇湘隐者

关于MySQL的状态变量Aborted_clients & Aborted_connects别离代表的意义,以及哪些环境或因素会导致这些状态变量变革呢?下文通过尝试测试来验证一下,首先我们来看看状态变量的描写:

Aborted Connect

Aborted Connect暗示实验毗连到MySQL处事器失败的次数。这个状态变量可以团结host_cache表和其错误日志一起来阐明问题。 引起这个状态变量激增的原因如下: 

  1. 客户端没有权限可是实验会见MySQL数据库。
  2. 客户端输入的暗码有误。 
  3. A connection packet does not contain the right information.
  4. 高出毗连时间限制,主要是这个系统变量connect_timeout节制(mysql默认是10s,根基上,除非网络情况极度欠好,一般不会超时。)

官方表明如下: 

If a client is unable even to connect, the server increments the Aborted_connects status variable. Unsuccessful connection attempts can occur for the following reasons:

  • A client attempts to access a database but has no privileges for it.
  • A client uses an incorrect password. 
  • A connection packet does not contain the right information.
  • It takes more than connect_timeout seconds to obtain a connect packet. See Section 5.1.7, “Server System Variables”.  
  • Aborted Clients:

    Aborted Clients暗示由于客户端没有正确封锁毗连而中止的毗连数。官方表明如下:

    The number of connections that were aborted because the client died without closing the connection properly. See Section B.5.2.10, “Communication Errors and Aborted Connections”

    当Aborted Clients增大的时候意味着有客户端乐成成立毗连,可是由于某些原因断开毗连可能被终止了,这种环境一般产生在网络不不变的情况中。主要的大概性有: 

    1. 客户端措施在退出之前未挪用mysql_close()正确封锁MySQL毗连。 
    2. 客户端休眠的时间高出了系统变量wait_timeout和interactive_timeout的值,导致毗连被MySQL历程终止
    3. 客户端措施在数据传输进程中溘然竣事

    官方文档B.5.2.10 Communication Errors and Aborted Connections的先容如下:

    If a client successfully connects but later disconnects improperly or is terminated, the server increments the Aborted_clients status variable, and logs an Aborted connection message to the error log. The cause can be any of the following:

  • The client program did not call mysql_close() before exiting.
  • The client had been sleeping more than wait_timeout or interactive_timeout seconds without issuing any requests to the server. See Section 5.1.7, “Server System Variables”.
  • The client program ended abruptly in the middle of a data transfer.
  • Other reasons for problems with aborted connections or aborted clients:

  • The max_allowed_packet variable value is too small or queries require more memory than you have allocated for mysqld. See Section B.5.2.9, “Packet Too Large”.
  • Use of Ethernet protocol with Linux, both half and full duplex. Some Linux Ethernet drivers have this bug. You should test for this bug by transferring a huge file using FTP between the client and server machines. If a transfer goes in burst-pause-burst-pause mode, you are experiencing a Linux duplex syndrome. Switch the duplex mode for both your network card and hub/switch to either full duplex or to half duplex and test the results to determine the best setting.
  • A problem with the thread library that causes interrupts on reads.
  • Badly configured TCP/IP.
  • Faulty Ethernets, hubs, switches, cables, and so forth. This can be diagnosed properly only by replacing hardware.  
  • 如上先容所示,有许多因素引起这些状态变量的值变革,那么我们来一个个阐明、演示一下吧。首先,我们来测试一下导致Aborted Connect状态变量增加的大概因素

    1、 客户端没有权限可是实验会见MySQL数据库。 

    其实这里所说的没有权限,小我私家领略是:客户端利用没有授权的账号会见数据库 。打个例如,你实验用账号kkk会见MySQL数据库,其实你也不知道数据库是否存在这个用户,劳务派遣管理系统,实际上不存在这个用户。

    尝试比拟测试前,先将状态变量清零。

    mysql> flush status;
    Query OK, 0 rows affected (0.01 sec)
    mysql> show status like 'Abort%';
    +------------------+-------+
    | Variable_name    | Value |
    +------------------+-------+
    | Aborted_clients  | 0     |
    | Aborted_connects | 0     |
    +------------------+-------+
    2 rows in set (0.01 sec)
     
    mysql> 
    mysql> select host,user from mysql.user;
    +-------------------------------+-----------+
    | host                          | user      |
    +-------------------------------+-----------+
    | %                             | mydba     |
    | %                             | root      |
    | %                             | test      |
    | 127.0.0.1                     | root      |
    | 192.168.%                     | mydbadmin |
    | 192.168.103.18,192.168.103,22 | LimitIP   |
    | ::1                           | root      |
    | db-server.localdomain         | root      |
    | localhost                     | backuser  |
    | localhost                     | root      |
    +-------------------------------+-----------+