Shuting down Redis

匿名 (未验证) 提交于 2019-12-03 03:08:02

问题:

I started up Redis for the first time on my local machine today and then later closed all terminal windows after I shutdown my Rails app. An hour later, I started up the Rails app again and did the following to start the redis server

redis-server /usr/local/etc/redis.conf 

However, it told me

# Opening port 6379: bind: Address already in use 

I therefore assumed it was still running its earlier instance even though I closed the terminal windows on my Mac.

Looking at this page http://redis.io/commands/shutdown, I tried to run

SHUTDOWN 

in the terminal window but I get this response

SHUTDOWN: NOT super-user 

I therefore tried (Even though I didn't use sudo to start it)

sudo SHUTDOWN  

and after it asked me for my password, it output this

usage: shutdown [-] [-h [-u] [-n] | -r [-n] | -s | -k] time [warning-message ...] 

but when I randomly ran shutdown -s it said

 SHUTDOWN: NOT super-user 

What's the proper way to shutdown Redis when I close up my app?

回答1:

This is meant to be sent as a command to redis, not to be executed on your terminal.

In this case you can actually just kill redis from the terminal, since upon receiving a SIGTERM signal it will schedule a SHUTDOWN instead of simply exiting.

For reference see the signal handling doc page.



回答2:

Use the built-in redis client: redis-cli shutdown



回答3:

Find out the process id of the Redis instance running on your machine...

> ps aux | grep redis  impadmin 23277  0.0  0.0  35044  1976 pts/2    Sl+  14:19   0:00 src/redis-server 

... and then run:

> kill 23277 


文章来源: Shuting down Redis
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!