RabbitMQ 重启后,死活起不来。直接用
sudo /etc/rc.d/init.d/rabbitmq-server start
得到FAILED。到/var/log/rabbitmq/startup_log查看,得到
node_already_running(结点正在运行)
sudo /etc/rc.d/init.d/rabbitmq-server restart
得到TIMEOUT。查看日志得到
starting Persister Timeout
如果此时仍然得到FAILED异常并且是结点正在运行的Error,则使用
/usr/sbin/rabbitmqctl stop
停止正在运行的结点。同时用sudo /usr/sbin/lsof -i:5672检查是否还有RabbitMQ在监听5672端口。
然后检查Persister目录/var/lib/rabbitmq/mnesia/rabbit/,看到一个很大的文件persister.LOG。当RabbitMQ重启时,会同步一下Mnesia数据库,调用这个日志文件来写入数据库,如果该文件太大,就会导致启动Mnesia超时。原来如此!
上网赶紧找补丁包,说是1.7.0没有相应的补丁包,下一版本可能会修订Persister文件的结构,让它不那么大从而超时了。
http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2009-May/003539.html
RabbitMQ has become overfull, and crashed during persister log rollover
as a result. You probably have a zero-byte-long rabbit_persister.LOG,
and a large rabbit_persister.LOG.previous. Make a backup of the
.previous file somewhere else, just in case, and then copy it over top
of the rabbit_persister.LOG file and start the broker. You shouldn't
need to delete the whole database.
We're working on fixing the underlying cause, but for now, you must not
store more messages than (some proportion of) your available RAM can
hold. If you are simply buffering things without trying to consume them,
then you will probably need to introduce some consumers of some kind :-)
and if you do have consumers running, but Rabbit is running out of
memory anyway, you should probably check that you are acknowledging
deliveries from the broker properly.
解决办法:
(1)临时解决办法,直接删除persister.LOG文件,再重启启动。一切OK. 只是以前永久放在消息队列的的消息可能被永远地删除了:)
(2)从源码得到一个分支重新编译来解决该问题:
The new persister is available only from our mercurial repository at
http://hg.rabbitmq .com/rabbitmq -server
You should be on branch bug21673
(3)升级至1.7.2或者最新的1.8.0. 注意1.8.0修改了数据的存储结构,这意味着所有的用户、虚拟机路径、权限设置都要从新设了。1.7.2的数据结构支持1.6.0到1.7.2.
如果在“优化”文件的存储结构(即升级程序)后,仍然得到Timeout异常。则只能通过延长时间来解决 :
修改/etc/rabbitmq/rabbitmq.conf(如果没有该文件,创建一个),找到或者新建一个配置项:
MULTI_START_ARGS="-maxwait 600"
此时,已经将 Timeout 改为 600 秒。注意引号。
如果修改该文件无效,则可能安装的RabbitMQ并没有默认加载该配置文件,打开rabbitmq-server(如/etc/rc.d/init.d/rabbitmq-server)文件,查看:
DEFAULTS_FILE=/etc/sysconfig/rabbitmq
将 DEFAULTS_FILE 指向的文件按 /etc/rabbitmq/rabbitmq.conf 改动。如果该文件没有则新建。