DNS Lookup Optimization and the Host Cache
730
# Increase total amount of shared memory. The value
# is the number of pages. At 4KB/page, 4194304 = 16GB.
echo 4194304 > /proc/sys/kernel/shmall
For MySQL usage, you normally want the value of
shmmax
to be close to the value of
shmall
.
To verify the large page configuration, check
/proc/meminfo
again as described previously. Now you
should see some nonzero values:
shell>
cat /proc/meminfo | grep -i huge
HugePages_Total: 20
HugePages_Free: 20
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 4096 kB
The final step to make use of the
hugetlb_shm_group
is to give the
mysql
user an “unlimited”
value for the memlock limit. This can by done either by editing
/etc/security/limits.conf
or by
adding the following command to your
mysqld_safe
script:
ulimit -l unlimited
Adding the
ulimit
command to
mysqld_safe
causes the
root
user to set the memlock limit to
unlimited
before switching to the
mysql
user. (This assumes that
mysqld_safe
is started by
root
.)
Large page support in MySQL is disabled by default. To enable it, start the server with the
--large-
pages
[410]
option. For example, you can use the following lines in your server's
my.cnf
file:
[mysqld]
large-pages
With this option,
InnoDB
uses large pages automatically for its buffer pool and additional memory pool.
If
InnoDB
cannot do this, it falls back to use of traditional memory and writes a warning to the error log:
Warning: Using conventional memory pool
To verify that large pages are being used, check
/proc/meminfo
again:
shell>
cat /proc/meminfo | grep -i huge
HugePages_Total: 20
HugePages_Free: 20
HugePages_Rsvd: 2
HugePages_Surp: 0
Hugepagesize: 4096 kB
8.9.8. 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 the loopback interface address
(
127.0.0.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 calls
gethostbyaddr()
and
gethostbyname()
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.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...