Has anyone used Memcached with IPv6? Can you provide any configuration tips, gotchas, or mention any stability issues you've had?
memcached does support IPv6. You can specify it at startup using the
-l parameter. How do IPv4 and IPv6 behave compared to a default install? Let's look at a Debian session where we install memcached, listening on the default port(s), and start two memcached daemons, one bound to a v6 IP, and one bound to a v4 IP.
Linux hostname 3.0.4-linode38 #1 SMP Thu Sep 22 14:59:08 EDT 2011 i686 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. root@hostname:~# apt-get install memcached Setting up memcached (1.4.5-1) ... Starting memcached: memcached. root@hostname:~# apt-get install libmemcached-tools libmemcached-dev Setting up libmemcached-tools (0.40-1) ... root@hostname:~# memccapable ascii quit [pass] ascii version [pass] ascii verbosity [FAIL] 1 of 54 tests failed
We can use
memccapable to check that
memcached is indeed running.
root@hostname:~# memcached -d -P /tmp/mcd.pid -v -l 2600:3c03::dead:beef:feeb:daed -u nobody -p 10001 -U 10001 root@hostname:~# memcached -d -P /tmp/mcd2.pid -v -l 10.0.1.2 -u nobody -p 10002 -U 10002
We just started our IPv6 memcached on port
10001 and our IPv4 memcached on port
root@hostname:~# memcstat --servers=127.0.0.1:11211,127.0.0.1:10001,127.0.0.1:10002 Server: 127.0.0.1 (11211) pid: 2131 uptime: 689 time: 1325757557 version: 1.4.5 Server: 127.0.0.1 (10001) pid: 0 uptime: 0 time: 0 version: Server: 127.0.0.1 (10002) pid: 0 uptime: 0 time: 0 version:
memcstat allows us to check the status of multiple hosts at once. We see that memcached is not bound to localhost ports
10002, which makes sense, since we specified our IP(s) explicitly. Now lets check our IPv4 address for memcached servers on each of the ports.
root@hostname:~# memcstat --servers=10.0.1.2:11211,10.0.1.2:10001,10.0.1.2:10002 Server: 10.0.1.2 (11211) pid: 0 uptime: 0 time: 0 version: Server: 10.0.1.2 (10001) pid: 0 uptime: 0 time: 0 version: Server: 10.0.1.2 (10002) pid: 2699 uptime: 89 time: 1325757596 version: 1.4.5
We see that our IPv6 memcached is not accessible from our IPv4 address. memcstat is not (as of Debian 6.0.3) ccapable of taking IPv6 addresses on the command line, so we will do three separate memccapable's.
root@hostname:~# memccapable -h 2600:3c03::dead:beef:feeb:daed -p 11211 ascii quit [pass] ascii version [pass] ascii verbosity [FAIL] 1 of 54 tests failed root@hostname:~# memccapable -h 2600:3c03::dead:beef:feeb:daed -p 10001 ascii quit [pass] ascii version [pass] ascii verbosity [FAIL] 1 of 54 tests failed root@hostname:~# memccapable -h 2600:3c03::dead:beef:feeb:daed -p 10002 Failed to connect socket: Connection refused Failed to connect to : Connection refused root@hostname:~#
This is interesting. The default install of memcached is bound to localhost and to the IPv6 address, but not to our IPv4 address. This could be server/hosting environment specific. Of note is that our explicitly defined port 10002 on the IPv4 address is not available by specifying our IPv6 address, and our port 10001 instance is.
So, yes, memcached does support IPv6. You can also specify these options in the /etc/memcached.conf file. Please take note of the warning in that file that suggests only listening on an interface which is firewalled. If your IPv6 interface is public/accessible, you risk exposing sensitive cache items.