2

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
PORT="11212"
USER="memcached"
MAXCONN="1000000"
CACHESIZE="64"
OPTIONS="-v -r"
user9517
  • 115,471
  • 20
  • 215
  • 297
Aun
  • 101
  • 1
  • 3
  • 8

2 Answers2

1

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 0.0.0.0:11211           0.0.0.0:*          11159/memcached     
udp        0      0 :::11211                :::*               11159/memcached
user9517
  • 115,471
  • 20
  • 215
  • 297
  • 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
0

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

BeerSerc
  • 499
  • 3
  • 6
  • 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