1 問題
環境: CentOS7.8.2003 (x86 / 64bit)
版本: RabbitMQ 3.6.15 (Erlang 19.3)
安裝方式: 二進制源碼壓縮安裝

2 解決思路
2.1 思路1 關閉進程,並重啟
step1 查詢mq的進程
ps -ef | grep rabbitmq
step2 殺掉mq進程
ps -ef | grep rabbitmq | grep -v grep | awk '{print $2}' | xargs kill -9
step3 啟動mq
rabbitmq-server -detached
Warning: PID file not written; -detached was passed.
step4 在查詢mq的狀態
rabbitmqctl status

2.2 思路2 erlang安裝版本與rabbitmq版本不兼容
查詢erlang與rabbitmq的版本兼容性地址: https://www.rabbitmq.com/which-erlang.html
2.3 思路3 RabbitMQ的依賴件: erlang的cookie
1 安裝方式:
Linux中,rabbitmq安裝方式主要有兩種:RPM安裝 和 二進制安裝(編譯安裝/壓縮包安裝)
2 .erlang.cookie是什么?
.erlang.cookie是erlang實現分布式的必要文件;
erlang分布式的每一個節點上要保持相同的.erlang.cookie文件,同時該文件的權限至少應為400。
3 .erlang.cookie文件路徑?
- Linux
- $HOME/.erlang.cookie 【二進制安裝(編譯安裝/壓縮包安裝)】
- 若用root角色安裝,則 /root/.erlang.cookie;其他用戶為/home/用戶名/.erlang.cookie
- ~/.erlang.cookie
- /var/lib/rabbitmq/.erlang.cookie 【RPM安裝】
- $HOME/.erlang.cookie 【二進制安裝(編譯安裝/壓縮包安裝)】
- Windows
- C:\Users${username}.erlang
- 用上面這個文件覆蓋下面目錄的文件
- C:\Windows.erlang.cookie
- C:\Windows\System64\config\systemprofile
- C:\Windows\System32\config\systemprofile
4 可通過rabbitmq的啟動日志,查看rabbitmq的home目錄以及.erlang.cookie文件的位置等信息。
=INFO REPORT==== 20-Jul-2018::13:34:56 ===
node : rabbit@he10
home dir : /root (我是用root用戶啟動的)
config file(s) : /home/rabbitmq_server-3.6.1/etc/rabbitmq/rabbitmq.config (not found)
cookie hash : 063Gh+RyPjHRzyuSPf9wWA==
...
rabbit@localhost:
* connected to epmd (port 4369) on localhost
* epmd reports: node 'rabbit' not running at all
other nodes on localhost: ['rabbitmq-cli-17']
* suggestion: start the node
current node details:
- node name: 'rabbitmq-cli-17@Hydrant'
- home dir: /root
- cookie hash: 063Gh+RyPjHRzyuSPf9wWA==
2.4 思路4 重新安裝RabbitMQ的服務
代價最高
3 補充
RabbitMQ相關的命令
[rabbitmq-server]
[service] rabbitmq-server stop #[service] : 表示中括號內的service命令可加可不加,下同
[service] rabbitmq-server start #前台啟動rabbitmq服務
[service] rabbitmq-server restart
[service] rabbitmq-service remove
[service] rabbitmq-server -detached #后台啟動rabbitmq服務
[rabbitmqctl]
rabbitmqctl status
rabbitmqctl stop
Stops the Erlang node on which RabbitMQ is running. To restart the node follow the instructions for Running the Server in the installation guide[1].
rabbitmqctl start_app
rabbitmqctl stop_app
rabbitmqctl shutdown
Shuts down the Erlang process on which RabbitMQ is running. The command is blocking and will return after the Erlang process exits. If RabbitMQ fails to stop, it will return a non-zero exit code.
rabbitmqctl change_password {username} {password}
rabbitmqctl list_users #查看監聽用戶
rabbitmqctl add_user {username} {password}
rabbitmqctl set_user_tags {username} {tag ...}
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions [-p vhost] {user} {conf} {write} {read}
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
rabbitmqctl delete_user {username}
[rabbitmq-plugins]
rabbitmq-plugins enable/disable rabbitmq_management #開啟/禁用 rabbitmq的web管理插件
rabbitmq-plugins enable/disable rabbitmq_web_stomp
rabbitmq-plugins enable/disable rabbitmq_tracing #開啟/禁用 rabbitmq_tracing能跟蹤RabbitMQ中消息的流入流出情況