意外关闭后,如果删除持久性数据,RabbitMQ只能启动

时间:2016-02-18 14:33:04

标签: windows rabbitmq

我使用单个RabbitMQ实例(不是群集),并且声明的所有队列都是持久的,并且发送的所有消息都是持久的。

我不断向RabbitMQ发送消息,然后(模拟崩溃)我杀死了rabbitmq进程,然后再次启动RabbitMQ服务。

我遇到的问题是在第二次意外关机后,RabbitMQ服务无法正常启动。

即使 rabbitmq-service.bat start 返回:

C:\Program Files\erl7.1\erts-7.1\bin\erlsrv: Service RabbitMQ started.

但该服务未运行。 rabbitmqctl.bat状态输出:

Error: unable to connect to node 'rabbit@HCE-G971WY1': nodedown

任何建议,为什么服务无法启动?

如果我删除所有持久性数据(\ AppData \ Roaming \ RabbitMQ \ db),则RabbitMQ正常启动,但随后我的所有消息和队列都将丢失。

我正在使用:

  • Windows 7
  • 关于Erlang 18.1的RabbitMQ 3.6.0

这是日志文件:

    =ERROR REPORT==== 18-Feb-2016::14:46:03 ===
    ** Generic server <0.154.0> terminating
    ** Last message in was {'$gen_cast',
                               {submit_async,
                                   #Fun<rabbit_queue_index.32.56515753>}}
    ** When Server state == undefined
    ** Reason for termination == 
    ** {{case_clause,{{true,<<189,10,73,71,182,201,144,167,110,15,200,171,200,160,
                              ...101>>},
                      no_del,no_ack}},
        [{rabbit_queue_index,action_to_entry,3,
                             [{file,"src/rabbit_queue_index.erl"},{line,780}]},
         {rabbit_queue_index,add_to_journal,3,
                             [{file,"src/rabbit_queue_index.erl"},{line,757}]},
         {rabbit_queue_index,add_to_journal,3,
                             [{file,"src/rabbit_queue_index.erl"},{line,748}]},
         {rabbit_queue_index,parse_journal_entries,2,
                             [{file,"src/rabbit_queue_index.erl"},{line,895}]},
         {rabbit_queue_index,recover_journal,1,
                             [{file,"src/rabbit_queue_index.erl"},{line,869}]},
         {rabbit_queue_index,scan_segments,3,
                             [{file,"src/rabbit_queue_index.erl"},{line,692}]},
         {rabbit_queue_index,queue_index_walker_reader,2,
                             [{file,"src/rabbit_queue_index.erl"},{line,680}]},
         {rabbit_queue_index,'-queue_index_walker/1-fun-0-',2,
                             [{file,"src/rabbit_queue_index.erl"},{line,661}]}]}

    =INFO REPORT==== 18-Feb-2016::14:46:03 ===
    Error description:
       {could_not_start,rabbit,
           {{badmatch,
                {error,
                    {{{{case_clause,
                           {{true,
                                <<189,10,73,71,182,201,144,167,110,15,200,171,200,
                                  ...101>>},
                            no_del,no_ack}},
                       [{rabbit_queue_index,action_to_entry,3,
                            [{file,"src/rabbit_queue_index.erl"},{line,780}]},
                        {rabbit_queue_index,add_to_journal,3,
                            [{file,"src/rabbit_queue_index.erl"},{line,757}]},
                        {rabbit_queue_index,add_to_journal,3,
                            [{file,"src/rabbit_queue_index.erl"},{line,748}]},
                        {rabbit_queue_index,parse_journal_entries,2,
                            [{file,"src/rabbit_queue_index.erl"},{line,895}]},
                        {rabbit_queue_index,recover_journal,1,
                            [{file,"src/rabbit_queue_index.erl"},{line,869}]},
                        {rabbit_queue_index,scan_segments,3,
                            [{file,"src/rabbit_queue_index.erl"},{line,692}]},
                        {rabbit_queue_index,queue_index_walker_reader,2,
                            [{file,"src/rabbit_queue_index.erl"},{line,680}]},
                        {rabbit_queue_index,'-queue_index_walker/1-fun-0-',2,
                            [{file,"src/rabbit_queue_index.erl"},{line,661}]}]},
                      {gen_server2,call,[<0.211.0>,out,infinity]}},
                     {child,undefined,msg_store_persistent,
                         {rabbit_msg_store,start_link,
                             [msg_store_persistent,
                              "c:/Users/212303924/AppData/Roaming/RabbitMQ/db/rabbit@HCE-G971WY1-mnesia",
                              [],
                              {#Fun<rabbit_queue_index.2.56515753>,
                               {start,
                                   [{resource,<<"/">>,queue,
                                        <<"execution-processed-request">>},
                                    {resource,<<"/">>,queue,
                                        <<"execution-result">>},
                                    {resource,<<"/">>,queue,
                                        <<"job-result-queue-mirror">>}]}}]},
                         transient,4294967295,worker,
                         [rabbit_msg_store]}}}},
            [{rabbit_variable_queue,start_msg_store,2,
                 [{file,"src/rabbit_variable_queue.erl"},{line,458}]},
             {rabbit_variable_queue,start,1,
                 [{file,"src/rabbit_variable_queue.erl"},{line,440}]},
             {rabbit_priority_queue,start,1,
                 [{file,"src/rabbit_priority_queue.erl"},{line,92}]},
             {rabbit_amqqueue,recover,0,
                 [{file,"src/rabbit_amqqueue.erl"},{line,234}]},
             {rabbit,recover,0,[{file,"src/rabbit.erl"},{line,538}]},
             {rabbit_boot_steps,'-run_step/2-lc$^1/1-1-',1,
                 [{file,"src/rabbit_boot_steps.erl"},{line,49}]},
             {rabbit_boot_steps,run_step,2,
                 [{file,"src/rabbit_boot_steps.erl"},{line,49}]},
             {rabbit_boot_steps,'-run_boot_steps/1-lc$^0/1-0-',1,
                 [{file,"src/rabbit_boot_steps.erl"},{line,26}]}]}}

1 个答案:

答案 0 :(得分:1)

<强>解决

关键工程师在这里回答了这个问题:https://groups.google.com/forum/#!topic/rabbitmq-users/f0akEFlQATU

问题是RabbitMQ在强制终止后无法启动,因为它无法读取队列索引。

解决方案是更改RabbitMQ配置。

rabbit.queue_index_max_journal_entries 的值从默认值65536更改为64解决了此问题。此配置值控制将队列索引刷新到磁盘的速度。

请注意,这可能会对吞吐量产生影响,但在我的情况下,安全性能够在强制终止之后启动更为重要。