How can I stop redis-server?

前端 未结 26 1833
清歌不尽
清歌不尽 2020-12-07 06:51

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 followin

26条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 07:10

    One thing to check if the redis commands are not working for you is if your redis-server.pid is actually being created. You specify the location of where this file is in

    /etc/systemd/system/redis.service 
    

    and it should have a section that looks something like this:

    [Service]
    Type=forking
    User=redis
    Group=redis
    ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
    PIDFile=/run/redis/redis-server.pid
    TimeoutStopSec=0
    Restart=always
    

    Check the location and permissions of the PIDFile directory (in my case, '/run/redis'). I was trying to restart the service logged in as deploy but the directory permissions were listed as

    drwxrwsr-x  2 redis    redis      40 Jul 20 17:37 redis

    If you need a refresher on linux permissions, check this out. But the problem was I was executing the restart as my deploy user which the permissions above are r-x, not allowing my user to write to the PIDFile directory.

    Once I realized that, I logged in using root, reran the restart command on the redis (service redis restart) and everything worked. That was a headache but hopefully this saves someone a little time.

提交回复
热议问题