Archive for September, 2006


Followup: On IPs, hostnames, and MySQL

by Jeremy Cole on Tuesday, September 26th, 2006 at 18:15:44 in MySQL, MySQL Patches, MySQL Tips

Back in April, I wrote On IPs, hostnames, and MySQL, which described the (sometimes surprising) ways in which MySQL deals with IP addresses, hostnames, and privileges, as well as some basics about the host cache itself. In a footnote to that post, I mentioned a patch I had written against MySQL 4.1 to give some more visibility into the host cache.

Over the past two days, I have worked on porting that patch to MySQL 5.01, 2, and making some fairly large improvements to it. The patch implements a few things:

  1. Configurable Size — Without the patch, the size of the cache is fixed at 128 entries, and can only be changed by changing a #define and recompiling. You may now tune the size of the host cache using SET GLOBAL host_cache_size=X.
  2. Metrics — You may now see how well the cache is performing using SHOW GLOBAL STATUS LIKE ‘Host%’. (See example below.)
  3. Display — You may now see the complete contents of the cache using SHOW HOST CACHE. (See example below.)

The above new features should give MySQL DBAs much better insight into what’s happening in their MySQL server, in an area where there has historically been very little information and a lot of misunderstandings.

Now, for the examples:

SHOW GLOBAL STATUS LIKE ‘Host%’

mysql> show status like 'host%';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| Host_cache_free    | 127   |
| Host_cache_hits    | 2     |
| Host_cache_inserts | 1     |
| Host_cache_misses  | 1     |
| Host_cache_prunes  | 0     |
| Host_cache_used    | 1     |
+--------------------+-------+
6 rows in set (0.01 sec)

SHOW HOST CACHE

mysql> show host cache;
+-----------+----------+--------+------+
| IP        | Hostname | Errors | Hits |
+-----------+----------+--------+------+
| 10.0.0.22 | hiriko   |      0 |    2 |
+-----------+----------+--------+------+
1 row in set (0.00 sec)

Enjoy!

1 Hopefully this will be accepted into MySQL 5.0. Brian?

2 The patch is against mysql-5.0.25-nightly-20060823 specifically.

To reason why…

by Jeremy Cole on Tuesday, September 19th, 2006 at 15:17:47 in HOTCW, Quotes

Jeremy or Adrienne 2.0

by Jeremy Cole on Sunday, September 10th, 2006 at 20:37:40 in Baby

On 1U cases, PCI risers, and LSI MegaRAID

by Jeremy Cole on Monday, September 4th, 2006 at 15:42:29 in MySQL, MySQL Tips, Technology