1. 程式人生 > >線上rabbitmq啟動失敗緊急修復

線上rabbitmq啟動失敗緊急修復

一上班就說服務不能用,趕緊解決一下,然後重啟服務試試,結果發現是mq沒啟動

[root@localhost rabbit@localhost]# service rabbitmq-server start
Starting rabbitmq-server: SUCCESS
rabbitmq-server.

然後網頁訪問管理頁

http://127.0.0.1:15672/

無法訪問,一下心理就慌了,好不,試了幾次都是沒有
檢查端口占用

[root@localhost ~]# netstat -anp |grep 4369
tcp        0      0 0.0.0.0:4369                0
.0.0.0:* LISTEN 5582/epmd tcp 0 0 :::4369 :::* LISTEN 5582/epmd

其實上面的是正常的。
檢視服務啟動指令碼

vi /etc/init.d/rabbitmq-server

rabbitmq-server日誌

tail /var/log/rabbitmq/startup_log
{"init terminating in do_boot",{error,{cannot_delete_plugins_expand_dir,["/var/lib/rabbitmq/mnesia/rabbit@localhost
-plugins-expand"
,{cannot_delete,"/var/lib/rabbitmq/mnesia/rabbit@localhost-plugins-expand/rabbitmq_web_dispatch-3.5.0/ebin/rabbit_webmachine.beam",eacces}]}}}

最後發現是外掛目錄許可權問題, 修改屬主

chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/mnesia/[email protected]-plugins-expand/

【誤區】
1、不要隨便重置,或者rabbitmqctl reset,重置佇列
2、隨便禁用外掛, /etc/rabbitmq/enabled_plugins
3、 sudo /usr/sbin/rabbitmq-server 報錯pid許可權不夠

【總結】一下,防止後人採坑:
1、檢查防火牆

service iptables status

2、檢查rabbitmq

[root@localhost rabbit@localhost]# service rabbitmq-server status
Status of node rabbit@localhost ...
Error: unable to connect to node rabbit@localhost: nodedown

DIAGNOSTICS
===========

attempted to contact: [rabbit@localhost]

rabbit@localhost:
  * connected to epmd (port 4369) on localhost
  * epmd reports: node 'rabbit' not running at all
                  no other nodes on localhost
  * suggestion: start the node

current node details:
- node name: '[email protected]'
- home dir: /var/lib/rabbitmq
- cookie hash: upI9R3WzVaK8x5qUau1aHg==

3、localhost 是否能夠解析

ping localhost
vi /etc/hosts  //檢視host  dns配置

4、RabbitMQ日誌

日誌目錄
tail /var/log/rabbitmq/startup_log

5、外掛目錄許可權

ll /var/lib/rabbitmq/mnesia/
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/mnesia/[email protected]-plugins-expand/