How can I stop redis-server?

2019-01-15 23:49发布

I apparently have a redis-server instance running because when I try to start a new server by entering redis-server, I'm greeted with the following:

Opening port: bind: Address already in use

I can't figure out how to stop this server and start a new one.

Is there any command I can append to redis-server when I'm typing in the CLI?

My OS is Ubuntu 10.04.

21条回答
走好不送
2楼-- · 2019-01-16 00:12

A cleaner, more reliable way is to go into redis-cli and then type shutdown

In redis-cli, type help @server and you will see this near the bottom of the list:

SHUTDOWN - summary: Synchronously save the dataset to disk and then shut down the server since: 0.07

And if you have a redis-server instance running in a terminal, you'll see this:

User requested shutdown...
[6716] 02 Aug 15:48:44 * Saving the final RDB snapshot before exiting.
[6716] 02 Aug 15:48:44 * DB saved on disk
[6716] 02 Aug 15:48:44 # Redis is now ready to exit, bye bye...
查看更多
forever°为你锁心
3楼-- · 2019-01-16 00:12

In my case it was:

/etc/init.d/redismaster stop
/etc/init.d/redismaster start

To find out what is your service name, you can run:

sudo updatedb
locate redis

And it will show you every Redis files in your system.

查看更多
看我几分像从前
4楼-- · 2019-01-16 00:12

The commands below works for me on Ubuntu Server

$ service /etc/init.d/redis_6379 stop
$ service /etc/init.d/redis_6379 start
$ service /etc/init.d/redis_6379 restart
查看更多
做自己的国王
5楼-- · 2019-01-16 00:14

Following worked for me on MAC

 ps aux | grep 'redis-server' | awk '{print $2}' | xargs sudo kill -9
查看更多
Anthone
6楼-- · 2019-01-16 00:17

MacOSX - It Worked :)

Step 1 : Find the previously Running Redis Server

ps auxx | grep redis-server

Step 2 : Kill the specific process by finding PID (Process ID) - Redis Sever

kill -9 PID
查看更多
啃猪蹄的小仙女
7楼-- · 2019-01-16 00:17

If you know on what port it would be running(by default it would be 6379), you can use below command to get the pid of the process using that port and then can execute kill command for the same pid.

sudo lsof -i : <port> | awk '{print $2}'

the above command will give you pid.

kill <pid>;

This would shutdown your server.

查看更多
登录 后发表回答