我正在尝试在我的AWS服务器上安装Redis。我已经安装了Ubuntu 18.04。我正在按照digitalocean文章的步骤安装Redis。
当我运行sudo systemctl status redis
命令时,我遇到了错误。
我尝试编辑/etc/systemd/system/redis.service
文件,并在Type=forking
部分下添加了[Service]
,但是仍然遇到相同的错误。
有人可以建议我如何修复它吗?
谢谢。
答案 0 :(得分:0)
我也遇到了这个问题,然后我尝试再次检查。
最终,我发现授权/var/lib/redis
时,输入了错误的命令,导致Redis帐户无法访问/var/lib/redis
。
sudo chown redis:redis /var/lib/redis
sudo systemctl restart redis
成功。
答案 1 :(得分:0)
基于相同的 digitalocean 教程,实际上它运行良好。
运行此命令 sudo systemctl restart redis.service
,我们得到(在最后一行显示“failed”):
● redis.service - Redis In-Memory Data Store
Loaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2021-06-28 12:03:11 +03; 1min 0s ago
Process: 20428 ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf (code=exited, status=
Main PID: 20428 (code=exited, status=203/EXEC)
Jun 28 12:03:11 XYZ systemd[1]: redis.service: Service hold-off time over, scheduling restar
Jun 28 12:03:11 XYZ systemd[1]: redis.service: Scheduled restart job, restart counter is at
Jun 28 12:03:11 XYZ systemd[1]: Stopped Redis In-Memory Data Store.
Jun 28 12:03:11 XYZ systemd[1]: redis.service: Start request repeated too quickly.
Jun 28 12:03:11 XYZ systemd[1]: redis.service: Failed with result 'exit-code'.
Jun 28 12:03:11 XYZ systemd[1]: Failed to start Redis In-Memory Data Store.
但是如果你运行 sudo service redis-server status
,我们得到(在第三行显示“running”):
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-06-28 11:50:13 +03; 19min ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Process: 19278 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 19371 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCC
Main PID: 19382 (redis-server)
Tasks: 4 (limit: 4915)
CGroup: /system.slice/redis-server.service
└─19382 /usr/bin/redis-server 127.0.0.1:6379
Jun 28 11:50:13 XYZ systemd[1]: Starting Advanced key-value store...
Jun 28 11:50:13 XYZ systemd[1]: redis-server.service: Can't open PID file /var/run/redis/red
Jun 28 11:50:13 XYZ systemd[1]: Started Advanced key-value store.
搜索了几个小时后,似乎systemctl
和service
之间有一些区别,仅此而已,但实际redis服务器运行良好。如果不是这样,请纠正我。这是链接:https://askubuntu.com/questions/903354/difference-between-systemctl-and-service-commands
你甚至可以检查redis是否工作正常,通过redis-cli ping
,应该打印PONG