今早發現mysql日志中有非常多例如以下的警告:
140724 18:41:25 [Warning] IP address '172.16.18.217' could not be resolved: Temporary failure in name resolution
140724 18:41:25 [Warning] IP address '172.16.18.217' could not be resolved: Temporary failure in name resolution
140724 18:41:26 [Warning] IP address '172.16.18.217' could not be resolved: Temporary failure in name resolution
140724 18:41:26 [Warning] IP address '172.16.18.217' could not be resolved: Temporary failure in name resolution
140724 18:41:27 [Warning] IP address '172.16.18.217' could not be resolved: Temporary failure in name resolution
140724 18:41:28 [Warning] IP address '172.16.18.217' could not be resolved: Temporary failure in name resolution
140724 18:41:28 [Warning] IP address '172.16.18.217' could not be resolved: Temporary failure in name resolution
140724 18:41:28 [Warning] IP address '172.16.18.217' could not be resolved: Temporary failure in name resolution
140724 18:41:28 [Warning] IP address '172.16.18.217' could not be resolved: Temporary failure in name resolution
140724 18:44:54 [Warning] IP address '61.143.209.110' could not be resolved: Temporary failure in name resolution
140724 18:44:54 [Warning] IP address '61.143.209.110' could not be resolved: Temporary failure in name resolution
140724 18:44:54 [Warning] IP address '61.143.209.110' could not be resolved: Temporary failure in name resolution
140724 18:44:54 [Warning] IP address '61.143.209.110' could not be resolved: Temporary failure in name resolution
140724 18:44:54 [Warning] IP address '61.143.209.110' could not be resolved: Temporary failure in name resolution
140724 18:44:55 [Warning] IP address '61.143.209.110' could not be resolved: Temporary failure in name resolution
140724 18:44:55 [Warning] IP address '61.143.209.110' could not be resolved: Temporary failure in name resolution
140724 18:44:55 [Warning] IP address '61.143.209.110' could not be resolved: Temporary failure in name resolution
140724 18:44:55 [Warning] IP address '61.143.209.110' could not be resolved: Temporary failure in name resolution
問題產生的原因:
出現錯誤的原因是MYSQL Server在本地內存中維護了一個非本地的Client TCP cache。這個cache中包括了遠程Client的登錄信息,比方IP地址。hostname等信息。
假設Client連接到server后,Mysql首先會在本地TCP池中依據IP地址解析client的hostname或者反解析,假設解析不到。就會去DNS中進行解析,假設還是解析失敗
就是在error log中寫入這種警告信息。
解決的辦法:
1.能夠通過兩個參數來disable這個功能,在MYSQL的配置文件里[mysqld]中增加以下的參數:
[mysqld]
--skip-host-cache
--skip-name-resolve
又一次授權,將全部訪問數據庫server的授權方式都改成IP形式的。
grant all on *.* to ‘root’@’172.16.12.68’identified by ‘123456’;
2.加入授權。
將全部訪問數據庫server的授權方式都改成IP形式。
不同的用戶用不同的username和password。
grant all on *.* to ‘user_68’@’172.16.12.68’identified by ‘pwd_68’;
grant all on *.* to ‘user_67’@’172.16.12.67’identified by ‘pwd_67’;
....
然后去 mysql數據庫以下的 user表 和db表 以下刪除掉那些含有含有主機名字的權限記錄。
總結:
1.要么加上
--skip-host-cache
--skip-name-resolve
使得MySQL將不再通過DNS解析地址。
2.要么在賦予權限的時候 直接用ip地址,去掉那些用主機名字的權限。