MySQL出現大量unauthenticated user錯誤解決

來源:互聯網
上載者:User

最近發現兩台MySQL server在中午的時候忽然(很突然的那種)發飆,不斷的掛掉。重啟mysql也儘是失敗,看mysql的errorlog,只能看到類似如下的資訊:

Forcing close of thread 12232 user: 'root'

用mysqladmin 簡單的監控了下mysql的情況:

mysqladmin -uroot -p******** status -i 1

發現Queries per second avg只有200左右,可以說很低,但是Threads 確非常不穩定,居然會瞬間升級200以上,一般情況下這個線程這個值都是不會高於5的個位元!

然後繼續看

mysqladmin -uroot -p******** processlist

居然有大量的unauthenticated user?? 如下情況 

+------+-----------+---------+----+---------+------+-------+------------------+
[root@app028 ~]# mysqladmin -uroot -p************ processlist
+------+-----------+---------+----+---------+------+-------+------------------+
| Id  | User                | Host              | db | Command | Time | State | Info      |
+------+-----------+---------+----+---------+------+-------+------------------+
| 2007 | unauthenticated user | 192.168.4.29:58519 |    | Connect |    | login | |
| 2008 | unauthenticated user | 192.168.4.29:58553 |    | Connect |    | login | |
| 2009 | unauthenticated user | 192.168.4.29:58571 |    | Connect |    | login | |
| 2010 | unauthenticated user | 192.168.4.29:58577 |    | Connect |    | login | |
| 2011 | unauthenticated user | 192.168.4.29:58579 |    | Connect |    | login | |
| 2012 | unauthenticated user | 192.168.4.29:58589 |    | Connect |    | login | |

google了一下,

發現這算屬MySQL的一個bug,不管串連是通過hosts還是ip的方式,MySQL都會對DNS做反查,IP到DNS,由於反查的接續速度過慢(不管是不是isp提供的dns伺服器的問題或者其他原因),大量的查詢就難以應付,線程不夠用就使勁增加線程,但是卻得不到釋放,所以MySQL會“假死”。

解決的方案很簡單,結束這個反查的過程,禁止任何解析。

開啟mysql的設定檔(my.cnf),在[mysqld]下面增加一行:

skip-name-resolve

重新載入設定檔或者重啟MySQL服務即可。

另一例:

  • 1
  • 2
  • 下一頁

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.