Stop redis server. Neither shutdown nor stop works

后端 未结 16 763
深忆病人
深忆病人 2021-01-31 08:43

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 say

相关标签:
16条回答
  • 2021-01-31 08:47

    Best way check pid of redis opened port :

    lsof -i:<redis-port>
    

    for default redis port

    lsof -i:6379
    
    kill -9 <pid>
    
    0 讨论(0)
  • 2021-01-31 08:48
    redis-cli -a password shutdown
    

    or

    ps aux|grep redis
    kill -9 <redis pid>
    

    The above solutions doesn't work. The redis server will restart with a new pid. But the below command works.

    /etc/init.d/redis-server stop
    

    My server is Ubuntu 18.04.2 and Redis version is v4.0.9

    0 讨论(0)
  • 2021-01-31 08:49

    On windows this worked:

    Open terminal(PowerShell/CMD), type: wsl --shutdown

    It will end your virtual machine.

    0 讨论(0)
  • 2021-01-31 08:49
    start redis: $REDIS_HOME/src/redis-server
    stop redis: $REDIS_HOME/src/redis-cli shutdown
    

    $REDIS_HOME where you have installed/extracted redis.

    0 讨论(0)
  • 2021-01-31 08:50

    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.

    0 讨论(0)
  • 2021-01-31 08:52

    This is possibly an really important note for some people reading this. If your redis doesn't seem to be responding to a shutdown. CHECK THE LOGS.

    They may say something like this:

    Apr 24 00:48:54 redis[828]: Received SIGTERM, scheduling shutdown...
    Apr 24 00:48:54 redis[828]: User requested shutdown, saving DB...
    Apr 24 00:55:37 redis[828]: DB saved on disk
    

    Maybe your DB is multiple GB, or tens of GBs in which case it will take time to shutdown. If instead you want to clean out all keys, there is a better way to do that than shutdown. FLUSHALL

    0 讨论(0)
提交回复
热议问题