4

service memcached restart yields:
stopping memcached: [failed]
starting memcached: [ ok ]

service memcached status yields:
memcached dead but subsys locked

ls inside /var/lock/subsys/ shows a file named memcached

ls inside /var/run/ shows no pid file named memcached
there is another folder named memcached in here but there is nothing in that folder.

rm /var/lock/subsys/memcached gets rid of the memcached lock file

service restart memcached yeilds:
stopping memcached: [failed]
starting memcached: [ ok ]

service memcached status yields:
memcached dead but subsys locked

what am I doing wrong?

EDIT: I'd like to add that I've searched for this before posting and I'm either already doing the steps listed in said post or that post is years old.

Colin Hilbert
  • 69
  • 2
  • 10
  • I wound up restarting linux to get it back to a working condition, but it would be nice to know a softer way to get this working again – Colin Hilbert Mar 05 '14 at 20:25

7 Answers7

2

Is there another process binding to TCP/11211?

Perhaps you tried to start the memcached service as a non-privileged user and it failed with:

$ service memcached start
Starting memcached:                                        [  OK  ]
touch: cannot touch ‘/var/lock/subsys/memcached’: Permission denied

After that, service memcached status will falsely report that memcached is not running:

$ service memcached status
memcached dead but subsys locked

But it is, and it is binding to port 11211, in order to check for this you can use:

$ fuser -n tcp 11211
11211/tcp:            4439

Or:

$ pgrep -l memcached
4439 memcached

Memcached will fail to start because it cannot bind to 11211, as the running instance is already bound to it. Unfortunately there are some systems (I'm looking at you, CENTOS) where it may not leave any useful hint at /var/log/messages or /var/log/syslog. That is why many of the previous answers to this question that fiddle with the binding address will look like they solved the problem.

How do you fix it?

Since service stop memcached will not work, you have to kill it:

$ pkill memcached

Or this (where 4439 is the pid you found in the previous step):

$ kill 4439

Then you can do it right, using sudo:

$ sudo service memcached start
Starting memcached:                                        [  OK  ]
$ service memcached status
memcached (pid 6643) is running... 
Paulo Scardine
  • 73,447
  • 11
  • 124
  • 153
1

Solved this problem by typing the following commands in terminal:

1) su (becoming root).

2) killall -9 memcached (killing memcached).

3) /etc/init.d/memcached start (starting memcached by hands).

Alternatively: 3) service memcached start.

cofirazak
  • 562
  • 6
  • 16
1

check /etc/sysconfig/memcached make sure the OPTIONS="-l 127.0.0.1" is correct

Miguel
  • 11
  • 1
0

Remove -l from OPTION.

e.g., Instead of OPTION="-l 2.2.2.2" try using OPTION="2.2.2.2"

This worked for me.

avaj
  • 299
  • 1
  • 5
  • 11
0

To resolve this problem, run the following script as root rm /var/run/memcached/memcached.pid rm /var/lock/subsys/memcached service memcached start

Rotceh
  • 1
0

Removing and reinstalling memcached is what worked for me:

[acool@acool super-confidential-dir]$ sudo yum remove memcached
...
[acool@acool super-confidential-dir]$ sudo yum install memcached

After the above commands and starting it I got:

[acool@acool super-confidential-dir]$ sudo service memcached status
memcached dead but pid file exists

At that point I killed it and removed the pid file:

[acool@acool super-confidential-dir]$ sudo killall -s 9 memcached
...
[acool@acool super-confidential-dir]$ sudo rm /var/run/memcached/memcached.pid

And finally started it and checked its status:

[acool@acool super-confidential-dir]$ sudo service memcached start
...
[acool@acool super-confidential-dir]$ sudo service memcached status
memcached (pid  13804) is running...

And then I was happy again.

Good luck.

angelcool.net
  • 2,505
  • 1
  • 24
  • 26
0

In my case I wanted to use memcache through the socket with

OPTIONS="-t 8 -s /run/memcached/memcached.sock -a 0777 -U 0"

copied from another OS, and get the same problem. Then I realized that I just forgot, that in my OS /run/ doesn't exist. That's it. Just check your path, hah