Chinaunix首页 | 论坛 | 博客
  • 博客访问: 424265
  • 博文数量: 121
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1101
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-20 19:29
个人简介

http://meetbill.github.io/

文章分类

全部博文(121)

我的朋友

分类: Mysql/postgreSQL

2015-12-25 21:07:49

通过内网连另外一台机器的mysql服务, 确发现速度N慢! 等了大约几十秒才等到提示输入密码。  但是ping mysql所在服务器却很快!  想到很久之前有过类似的经验, telnet等一些服务在连接请求的时候,会做一些反向域名解析(如果反向解析不顺畅, 估计就会延迟很多,  给人的感觉是连接速度N慢!)
    在网上搜索了下解决办法, 发现有两种:
    一. 两边机器配置的resolve.conf不一样, 把resolve.conf配置成速度比较快的DNS就OK
    二. 把mysql配置中的DNS反向解析关掉, 也OK 

    当远程访问mysql时,mysql会解析域名,会导致访问速度很慢,加上下面这个配置可解决此问题
    # 禁止mysql做域名解析
    [mysqld]
    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 support the above thread-safe calls, the thread will lock a mutex and call gethostbyaddr() and gethostbyname() instead. Note that in this case no other thread can resolve other hostnames that is not in the hostname cache until the first thread is ready.
    You can disable DNS host lookup by starting mysqld with --skip-name-resolve. In this case you can however only use IP names in the MySQL privilege tables.
    If you have a very slow DNS and many hosts, you can get more performance by either disabling DNS lookop with --skip-name-resolve or by increasing the HOST_CACHE_SIZE define (default: 128) and recompile mysqld.
    You can disable the hostname cache with --skip-host-cache. You can clear the hostname cache with FLUSH HOSTS or mysqladmin flush-hosts.
    If you don't want to allow connections over TCP/IP, you can do this by starting mysqld with --skip-networking.

  
修改之后,结果我的root用户登录不上去了,看了下root用户而且host是127.0.0.1的记录中没有密码,增加上记录就可以了

阅读(793) | 评论(0) | 转发(0) |
0

上一篇:crontab常用

下一篇:html背景设置为大图

给主人留下些什么吧!~~