Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop redis server. Neither shutdown nor stop works

Tags:

redis

I want to stop the redis server and it just keeps going and going. I am using redis-2.6.7

Check that it is running:

redis-server 

It says "...bind: Address already in use" so it is already running.

I have tried

redis-cli redis 127.0.0.1:6379> shutdown 

It just hangs and nothing happens. I break out and check, yes, it is still running.

I have tried

redis-server stop 

I get "can't open config file 'stop'"

I tried:

killall redis-server 

Still running.

The reason that I want to stop it is that it is just hanging when I try to set or get a value via Python. So I thought that I would restart it.

EDIT:

No commands seem to work from redis-cli. I also tried INFO and it just hangs.

like image 501
user984003 Avatar asked Feb 26 '13 11:02

user984003


People also ask

How do I stop Redis from replicating?

You can gracefully shutdown Redis instances (sentinel, slave and master) with the shutdown command. For Redis version older than 3.0 (not very sure), there's no shutdown command for Redis sentinel. But you can just use killall or kill -9 process_id to kill it without any side effect.

How do I know if Redis is running?

you can do it by this way. $redis = new Redis(); $redis->connect('127.0. 0.1', 6379); echo $redis->ping(); and then check if it print +PONG , which show redis-server is running.

How do I start and stop Redis on Mac?

On OS X you'll probably have to use launchctl to do this, and on other systems, systemctl or service . On modern Ubuntu, I just use service redis-server stop and service redis-server start , after having installed it with apt-get install redis-server .


2 Answers

I finally got it down.

Get the PID of the process (this worked in Webfaction):

ps -u my_account -o pid,rss,command | grep redis 

Then

> kill -9 the_pid 

I was able to REPRODUCE this issue:

Start redis-server Then break it using Pause/Break key 

Now it hangs and it won't shutdown normally. Also the Python program trying to set/get a key hangs. To avoid this: Just close the window after starting redis-server. It's now running normally.

like image 172
user984003 Avatar answered Oct 15 '22 01:10

user984003


Shutdown Redis Server $ redis-cli -a password -p 6379 shutdown

Start Redis Server $ sudo service redis_6379 start

It works on Ubuntu Server 14.04 x86 Redis v2.8.15.

like image 28
xuri Avatar answered Oct 15 '22 00:10

xuri