日期:2014-05-16 浏览次数:20725 次
--skip-name-resolve Do not resolve host names when checking client connections. Use only IP addresses. If you use this option, all Host column values in the grant tables must be IP addresses or localhost. See Section 7.9.8, “How MySQL Uses DNS”. --skip-networking Do not listen for TCP/IP connections at all. All interaction with mysqld must be made using named pipes or shared memory (on Windows) or Unix socket files (on Unix). This option is highly recommended for systems where only local clients are permitted. See Section 7.9.8, “How MySQL Uses DNS”.
?
如果反解析很慢,则会造成很多请求unauthenticated user 在login状态
配置文件中加入
--skip-name-resolve
?
When a new client connects to mysqld , mysqld spawns a new thread to handle the request. This thread first checks whether the host name is in the host name cache. If not, the thread attempts to resolve the host name:
The thread takes the IP address and resolves it to a host name (using gethostbyaddr()
). It then takes that host name and
resolves it back to the IP address (using gethostbyname()
) and compares to ensure it is the original
IP address.
If the operating system supports the thread-safe gethostbyaddr_r()
and gethostbyname_r()
calls, the thread uses them to perform
host name resolution.
If the operating system does not support the thread-safe calls, the thread
locks a mutex and calls gethostbyaddr()
and gethostbyname()
instead. In this case, no other thread can
resolve host names that are not in the host name cache until the first thread
unlocks the mutex.
You can disable DNS host name lookups by starting mysqld
with the --skip-name-resolve
option. However, in this case, you
can use only IP addresses in the MySQL grant tables.
If you have a very slow DNS and many hosts, you can get more performance by
either disabling DNS lookups with --skip-name-resolve
or by increasing the HOST_CACHE_SIZE
define (default value: 128) and recompiling
mysqld
.
You can disable the host name cache by starting the server with the --skip-host-cache
option. To clear the host name cache,
issue a FLUSH HOSTS
statement or execute the mysqladmin
flush-hosts
command.
To disallow TCP/IP connections entirely, start mysqld
with the --skip-networking
option.