OS: Linux ---Centos7
RabbitMQ版本:RabbitMQ version: 3.8.1
erlang版本:Erlang configuration: Erlang/OTP 22 [erts-10.6.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:64] [hipe]
安裝方式:使用rpm安裝
后台啟動方式:
cd /usr/lib/rabbitmq/bin
./rabbitmq-server start &
或者
./rabbitmq-server start -detached # Warning: PID file not written; -detached was passed.#忽略警告,貌似是rabbitmq bug
問題1:用 rabbitmq-server start &啟動報錯
[root@lyy bin]# rabbitmq-server start & [1] 9900 [root@lyy bin]# /usr/lib/rabbitmq/bin/rabbitmq-server:行51: /var/lib/rabbitmq/mnesia/rabbit.pid: 權限不夠 Failed to write pid file: /var/lib/rabbitmq/mnesia/rabbit.pid
解決方法:
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/mnesia/
問題2: rabbitmqctl 用不了
[root@lyy bin]# rabbitmqctl status Error: unable to perform an operation on node 'rabbit@lyy'. Please see diagnostics information and suggestions below. Most common reasons for this are: * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues) * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server) * Target node is not running In addition to the diagnostics info below: * See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more * Consult server logs on node rabbit@lyy * If target node is configured to use long node names, don't forget to use --longnames with CLI tools DIAGNOSTICS =========== attempted to contact: [rabbit@lyy] rabbit@lyy: * connected to epmd (port 4369) on lyy * epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic * TCP connection succeeded but Erlang distribution failed * Authentication failed (rejected by the remote node), please check the Erlang cookie Current node details: * node name: 'rabbitmqcli-4109-rabbit@lyy' * effective user's home directory: /var/lib/rabbitmq * Erlang cookie hash: 8y/oHO82So4EqWKv6DO9vw==
解決辦法:
[root@lyy bin]# vim /var/lib/rabbitmq/.erlang.cookie [root@lyy rabbitmq]# cd /home [root@lyy ~]# vim .erlang.cookie
把兩個文件中內容改為一致,重啟rabbitmq即可