skip-name-resolve && skip-host-cache && mysql IP address could not be resolved
来源:互联网 发布:sql select order by 编辑:程序博客网 时间:2024/05/16 16:10
官方的解释
--skip-name-resolve
Do not resolve host names when checking client connections. Use only IP addresses. If you use this option, allHost
column values in the grant tables must be IP addresses orlocalhost
. SeeSection 8.12.6.2, “DNS Lookup Optimization and the Host Cache”.
Depending on the network configuration of your system and the Host
values for your accounts, clients may need to connect using an explicit--host
option, such as--host=localhost
,--host=127.0.0.1
, or--host=::1
.
An attempt to connect to the host 127.0.0.1
normally resolves to thelocalhost
account. However, this fails if the server is run with the--skip-name-resolve
option, so make sure that an account exists that can accept a connection. For example, to be able to connect asroot
using--host=127.0.0.1
or--host=::1
, create these accounts:CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY 'root-password
';CREATE USER 'root'@'::1' IDENTIFIED BY 'root-password
';
root-password
';CREATE USER 'root'@'::1' IDENTIFIED BY 'root-password
';8.12.6.2 DNS Lookup Optimization and the Host Cache
The MySQL server maintains a host cache in memory that contains information about clients: IP address, host name, and error information. The server uses this cache for nonlocal TCP connections. It does not use the cache for TCP connections established using a loopback interface address (127.0.0.1
or ::1
), or for connections established using a Unix socket file, named pipe, or shared memory.
For each new client connection, the server uses the client IP address to check whether the client host name is in the host cache. If not, the server attempts to resolve the host name. First, it resolves the IP address to a host name and resolves that host name back to an IP address. Then it compares the result to the original IP address to ensure that they are the same. The server stores information about the result of this operation in the host cache. If the cache is full, the least recently used entry is discarded.
The server performs host name resolution using the thread-safe gethostbyaddr_r()
and gethostbyname_r()
calls if the operating system supports them. Otherwise, the thread performing the lookup locks a mutex and callsgethostbyaddr()
andgethostbyname()
instead. In this case, no other thread can resolve host names that are not in the host cache until the thread holding the mutex lock releases it.
The server uses the host cache for several purposes:
By caching the results of IP-to-host name lookups, the server avoids doing a DNS lookup for each client connection. Instead, for a given host, it needs to perform a lookup only for the first connection from that host.
The cache contains information about errors that occur during the connection process. Some errors are considered“blocking.” If too many of these occur successively from a given host without a successful connection, the server blocks further connections from that host. The
max_connect_errors
system variable determines the number of permitted errors before blocking occurs. SeeSection B.5.2.6, “Host 'host_name' is blocked”.
To unblock blocked hosts, flush the host cache by issuing a FLUSH HOSTS
statement or executing a mysqladmin flush-hosts command.
It is possible for a blocked host to become unblocked even without FLUSH HOSTS
if activity from other hosts has occurred since the last connection attempt from the blocked host. This can occur because the server discards the least recently used cache entry to make room for a new entry if the cache is full when a connection arrives from a client IP not in the cache. If the discarded entry is for a blocked host, that host becomes unblocked.
The host cache is enabled by default. To disable it, start the server with the--skip-host-cache
option.
To disable DNS host name lookups, start the server with the --skip-name-resolve
option. In this case, the server uses only IP addresses and not host names to match connecting hosts to rows in the MySQL grant tables. Only accounts specified in those tables using IP addresses can be used. (Be sure that an account exists that specifies an IP address or you may not be able to connect.)
If you have a very slow DNS and many hosts, you might be able to improve performance either by disabling DNS lookups with--skip-name-resolve
or by increasing theHOST_CACHE_SIZE
define (default value: 128) and recompiling the server
To disallow TCP/IP connections entirely, start the server with the --skip-networking
option.
Some connection errors are not associated with TCP connections, occur very early in the connection process (even before an IP address is known), or are not specific to any particular IP address (such as out-of-memory conditions).
有时我们会看到告警日志中总有下面的告警,不过不影响使用
150910 23:39:03 [Warning] IP address '192.168.61.42' could not be resolved: Temporary failure in name resolution150910 23:59:35 [Warning] IP address '192.168.61.42' could not be resolved: Temporary failure in name resolution
出现错误的原因是MYSQL Server在本地内存中维护了一个非本地的Client TCP cache,这个cache中包含了远程Client的登录信息,比如IP地址,hostname等信息。
如果Client连接到服务器后,Mysql首先会在本地TCP池中根据IP地址解析客户端的hostname或者反解析,如果解析不到,就会去DNS中进行解析,如果还是解析失败
就是在error log中写入这样的警告信息。
如果因为这个域名解析造成响应慢的话,按照上面的方式要么增大HOST_CACHE_SIZE
,要么用skip-name-resolve禁用解析功能。
关于为啥要有host cache,看上面的官方解析。
- skip-name-resolve && skip-host-cache && mysql IP address could not be resolved
- [MySQL]IP address '192.168.31.110' could not be resolved: Temporary failure in name resolution
- mysql之skip-name-resolve
- Mysql skip-name-resolve 问题
- mysql IP address 'xxx' could not be resolved
- mysql显示[Warning] IP address 'xxxx' could not be resolved: Name or service not known错误解决
- MySQL禁止反向解析客户端IP(skip-name-resolve)
- IP address '121.41.35.30' could not be resolved: Name or service not known解决方法
- IP address could not be resolved: Temporary failure in name resolution
- IP address could not be resolved: Temporary failure in name resolution
- IP address could not be resolved: Temporary failure in name resolution
- IP address '172.172.200.88' could not be resolved: Temporary failure in name resolution
- [Warning] IP address'10.0.9.121' could not be resolved: Temporary failure in name resolution
- IP address could not be resolved: Temporary failure in name resolution
- skip-name-resolve
- mysql中的 skip-name-resolve 问题
- 加快mysql速度之skip-name-resolve
- mysql中的 skip-name-resolve 问题
- 动态规划之背包问题-总结和拓展(二)
- hdu 2444 The Accomodation of Students(二分图的判断+匈牙利算法)
- 没有必要想那么多
- MySQL学习笔记之多表连接
- Linux服务器上监控网络带宽的18个常用命令和工具
- skip-name-resolve && skip-host-cache && mysql IP address could not be resolved
- Swift 闭包循环引用安全
- KJframeforandroid框架之 KJBlog学习(二)
- 汉诺塔问题
- redis异常解决:jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set
- java Scanner中的 next() 方法和 nextLine() 方法的区别
- 作为一个初学者,总结一下一个月来学习IOS的成果,使用swift语言
- Session和Cookie的作用和区别
- 动态规划之背包问题-总结和拓展(二)