安装 rabbitmq 后进行了一些配置,然后启动服务:
service rabbitmq-server start
无法启动。通过 journalctl -xe 查看日志后,有如下日志:
...
-- Unit rabbitmq-server.service has begun starting up.
May 23 17:01:50 db01 rabbitmq-server[3575]: /usr/lib/rabbitmq/bin/rabbitmq-server: line 84: /usr/local/rabbitmq-server/data/rabbit@db01.pid: Permission denied
May 23 17:01:50 db01 systemd[1]: rabbitmq-server.service: main process exited, code=exited, status=1/FAILURE
...
May 23 17:01:50 db01 systemd[1]: Unit rabbitmq-server.service entered failed state.
May 23 17:01:50 db01 systemd[1]: rabbitmq-server.service failed.
May 23 17:01:50 db01 polkitd[2980]: Unregistered Authentication Agent for unix-process:3559:624597926 (system bus name :1.24563, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF8
May 23 17:05:40 db01 su[3625]: (to rabbitmq) root on pts/0
...
看到上面的 permission denied,猜想是目录或文件的权限问题。将 /usr/local/rabbitmq-server/data 和 /usr/local/rabbitmq-server/log 通过 chmod 和 chown 给 rabbitmq.
chmod -R rabbitmq:rabbitmq /usr/local/rabbitmq-server
再次启动服务即成功。
可见 rabbitmq-server 服务会以 rabbitmq 身份运行。