Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Has anyone used Memcached with IPv6? Can you provide any configuration tips, gotchas, or mention any stability issues you've had?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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 10002

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 10001 or 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.

share|improve this answer
    
@amateur barista Old thread, new answer. –  mpbloch Jan 5 '12 at 10:24
    
Great answer, you provided all the tools necessary to confirm your claim. –  amateur barista Jan 20 '12 at 22:58

memcached 1.2.5 and later should have IPv6 support.
I can't vouch for its functionality as I don't personally use memcached, but a search for "IPv6" in their bug tracker doesn't show anything egregiously broken, so I have to assume it works to at least a first approximation :)

share|improve this answer
    
+1 for the useful info. –  amateur barista May 25 '11 at 3:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.