在 CentOS 上停止 Redis,常见有以下几种方式,按使用场景给你说明:
systemctl list-units | grep redis
常见服务名:
redisredis-serverredis@6379sudo systemctl stop redis
如果是多实例(如 redis@6379):
sudo systemctl stop redis@6379
sudo systemctl disable redis
这是 最安全 的方式,会先保存数据再退出。
redis-cli shutdown
redis-cli -a 密码 shutdown
redis-cli -p 6379 shutdown
✅ 优点:
SAVE / BGSAVEps -ef | grep redis
kill -15 PID
kill -9 PID
⚠️ kill -9 可能导致数据未保存,慎用。
ps -ef | grep redis
或
ss -lntp | grep 6379
systemctl stop 无效?可能原因:
✅ 解决:
redis-cli shutdown
✅ 首选
redis-cli shutdown
✅ 系统服务方式
systemctl stop redis
⚠️ 万不得已
kill -15 PID
如果你能贴出:
我可以给你 更精确 的停止方法。