How can i configure memcached to run on udp ports only on centos box ? Right now it is listening on TCP ports by default. Here is my memcached configuration file.

cat /etc/sysconfig/memcached
OPTIONS="-v -r"
  • why do you want it on UDP, it performs poorly on UDP... – Hrvoje Špoljar Mar 10 '16 at 11:59
  • We are testing something,can please give guidelines of how to run it only on UDP ports? – Aun Mar 10 '16 at 12:00

You will need to edit the memcached configuration file and change the OPTIONS section. On the CentOS 6 system I have to hand memcached is listening on UDP and TCP port 11211. To disable TCP and continue to allow UDP I had to do the following

OPTIONS='-p 0 -U 11211'

the -p 0 disables listening on TCP and -U 11222 enabled UDP/11211.

netstat -tunlp | grep memcached
udp        0      0 *          11159/memcached     
udp        0      0 :::11211                :::*               11159/memcached
  • is the -p 0 documented somewhere? I could only find how to explicitly disable UDP by using -U 0, but for the -p argument there was no mention of 0 disabling it. – BeerSerc Mar 10 '16 at 12:47
  • 1
    Not that I can see I tried it to see what would happen based on what the docs say about -U. – user9517 Mar 10 '16 at 12:55

OPTIONS="-U 22222" enables memcached on udp port 22222. just add it to the options you already have.

  • Do i need to add it to /etc/sysconfig/memcached file instead of PORT="11212" ? what should be exact parameter value. Thanks for the help, highly apperciated. – Aun Mar 10 '16 at 12:22
  • Change your line OPTIONS="-v -r" to OPTIONS="-v -r -U 22222" It doesn't disable TCP completely though, I think that's not possible. But you don't need to use the TCP connection and use the UDP connection instead – BeerSerc Mar 10 '16 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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