RabbitMQ:start_app 总是失败,重启服务就可以了吗?

RabbitMQ:start_app 总是失败,重启服务就可以了吗?

如果这是一个愚蠢的问题,请原谅,在 MQ 上的第一周我就陷入了困境。

MQVersion 是 3.7.6,操作系统是 Redhat 7.4(Maipo),Erlang 是 9.3.2

我们集群中有 2 个 RabbitMQ 服务器,都是 AWS 实例。如果启动它们,它们会非常顺利地构建并加入集群。但是,如果我想执行 stop_app、reset、start_app - start 命令会失败,并声明地址已在使用中

{ throw:{could_not_start,rabbitmq_management, {rabbitmq_management, {bad_return, {{rabbit_mgmt_app,start,[normal,[]]}, {'EXIT', {{could_not_start_listener, [{port,35672}], {shutdown, {failed_to_start_child,ranch_acceptors_sup, {listen_error,rabbit_web_dispatch_sup_35672,eaddrinuse}}}}, }

该端口肯定没有被使用,启动期间进行简单的端口检查可以看到端口从关闭变为打开(短暂),然后再次关闭。似乎解决这个问题的唯一方法是重新启动服务,然后节点就会恢复。

我还调整了配置文件并更改了端口,尝试启动并得到完全相同的错误。

我确实还有另一个问题,但我想先解决这个问题。

这是 rabbitmq-server.config 的内容

% This file managed by Puppet
% Template Path: rabbitmq/templates/rabbitmq.config
[
  {rabbit, [
    {cluster_nodes, {['rabbit@server1', 'rabbit@server2'], disc}},
    {cluster_partition_handling, ignore},
    {tcp_listen_options, [
         {keepalive,     true},
         {backlog,       128},
         {nodelay,       true},
         {linger,        {true, 0}},
         {exit_on_close, false}
    ]},
    {log_levels, [{connection, debug}]},
    {loopback_users, []},
    {default_user, <<"admin">>},
    {default_pass, <<"password">>}
  ]},
  {kernel, [

  ]}
,
  {rabbitmq_management, [
    {listener, [
      {port, 35672}
    ]}
  ]}
].
% EOF

调试/日志:

2018-06-14 14:09:35.712 [info] <0.33.0> Application rabbitmq_management_agent started on node rabbit@server2
2018-06-14 14:09:35.712 [debug] <0.1152.0> Supervisor rabbit_web_dispatch_sup started rabbit_web_dispatch_registry:start_link() at pid <0.1153.0>
2018-06-14 14:09:35.712 [debug] <0.1152.0> Supervisor rabbit_web_dispatch_sup started gen_event:start_link({local,webmachine_log_event}) at pid <0.1154.0>
2018-06-14 14:09:35.712 [info] <0.33.0> Application rabbitmq_web_dispatch started on node rabbit@server2
2018-06-14 14:09:35.712 [info] <0.33.0> Application amqp_client started on node rabbit@server2
2018-06-14 14:09:35.741 [debug] <0.1162.0> Supervisor {<0.1162.0>,ranch_listener_sup} started ranch_conns_sup:start_link(rabbit_web_dispatch_sup_35672, worker, 5000, ranch_tcp, 5000, cowboy_clear) at pid <0.1163.0>
2018-06-14 14:09:35.741 [error] <0.1164.0> Failed to start Ranch listener rabbit_web_dispatch_sup_35672 in ranch_tcp:listen([{port,35672}]) for reason eaddrinuse (address already in use)
2018-06-14 14:09:35.741 [error] <0.1164.0> CRASH REPORT Process <0.1164.0> with 0 neighbours exited with reason: {listen_error,rabbit_web_dispatch_sup_35672,eaddrinuse} in ranch_acceptors_sup:listen_error/4 line 59
2018-06-14 14:09:35.741 [error] <0.1162.0> Supervisor {<0.1162.0>,ranch_listener_sup} had child ranch_acceptors_sup started with ranch_acceptors_sup:start_link(rabbit_web_dispatch_sup_35672, 100, ranch_tcp, [{port,35672}]) at undefined exit with reason {listen_error,rabbit_web_dispatch_sup_35672,eaddrinuse} in context start_error
2018-06-14 14:09:35.742 [error] <0.1153.0> ** Generic server rabbit_web_dispatch_registry terminating

欢迎任何建议...

谢谢

答案1

经过大量挖掘后我找到了答案。

那些进行了初始设置但管理端口在 35672 上的人,似乎这是保留的 (35672-35680)。似乎当服务启动时它可以绑定到这个地址,但是,停止和启动应用程序的顺序必须略有不同。

我已将端口切换回 15672,这是它应有的位置。希望这能在未来帮助到其他人。

相关内容