同一个mysql数据库,不同的服务器连接,速度不同
最近业务人员在部署线上业务站点的时发现有一台服务器的站点访问数据库特别慢,但是其他服务器访问缺没有出现慢的情况,得知情况之后首先是考虑源服务器区别,是不是网络有问题 或者是不是执行sql不同导致的,经过排查都排除了这两种可能,然后就想到了mysql的skip-name-resolve参数 是不是因为这个导致的呢?上去mysql一看真的没有配置这个参数,然后就抱着尝试下的心态试了下,结果还真的解决了问题同样你可可以参考MySQL在远程访问时非常慢的解决skip-name-resolve 并且出现 Reading from net,这里因为这个mysql是业务临时安装的 没想到之后会长期使用 所以也没在意去看 ,这里详细说下skip-name-resolve这个参数啥意思:
我们就没必要重新造轮子,首先看下官方的解释:
How MySQL
uses DNS When a new thread connects to mysqld, mysqld will spawn a new thread to handle the request. This thread will first check if the hostname is in the hostname cache. If not the thread will call gethostbyaddr_r() and gethostbyname_r() to resolve the hostname. If the operating system doesn't s