shutdown redis-server from command line

2020-03-03 06:36发布

I am trying to shutdown my redis-server from a redis-cli. Whenever I issue a command from a client I receive the error "(error) NOAUTH Authentication required." I have tried the commands "SHUTDOWN" and "SHUTDOWN NOSAVE".

I have also tried "redis-server stop" from another terminal window but received the error "# Fatal error, can't open config file 'stop'"

How can I shut down this server? (I am on OSX).

4条回答
混吃等死
2楼-- · 2020-03-03 07:19

You have to manually edit the start/stop-service script:

sudo vi /etc/init.d/redis_6379

Find the following line:

$CLIEXEC -p $REDISPORT shutdown

And replace it with the following 'changeit' is where your password goes:

$CLIEXEC -p $REDISPORT -a changeit shutdown

Now you should be able to start and stop the service without any problems.

查看更多
仙女界的扛把子
3楼-- · 2020-03-03 07:24

On Amazon EC2 instance I could restart local Redis like this:

sudo /etc/init.d/redis restart

P.S. If you are using Redis Authentication you have to pass -a <pass> parameter.

查看更多
Explosion°爆炸
4楼-- · 2020-03-03 07:26

Your Redis server is configured with a password apparently. Therefore, when using redis-cli, you'll need to issue the AUTH password command before any other command or else you'll be getting that error message (replace password with your server's password).

Alternatively, you can invoke redis-cli with the -a switch followed by your password for the same result.

To find the password of your server, open the Redis configuration file (by default /etc/redis/6379.conf) and look for the line starting with requirepass - whatever value is next to it, is the password.

查看更多
够拽才男人
5楼-- · 2020-03-03 07:33
1. redis-cli
2. auth yourpassword
3. shutdown
4. sudo service redis_6379 start
查看更多
登录 后发表回答