docker rabbitmq在启动时崩溃

zd287kbt  于 2022-11-08  发布在  RabbitMQ
关注(0)|答案(1)|浏览(401)

启动(docker run)rabbitmq映像会导致崩溃。startup_err的内容:

Crash dump was written to: erl_crash.dump
  init terminating in do_boot ()

启动日志

BOOT FAILED
   ===========

   Error description:
     {error,{cannot_create_mnesia_dir,"/var/lib/rabbitmq/mnesia/rabbit@localhost/",
                                eacces}}

   Log files (may contain more information):
        /var/log/rabbitmq/rabbit@localhost.log
        /var/log/rabbitmq/rabbit@localhost-sasl.log

   Stack trace:
       [{rabbit_mnesia,ensure_mnesia_dir,0,
               [{file,"src/rabbit_mnesia.erl"},{line,472}]},
       {rabbit_node_monitor,prepare_cluster_status_files,0,
                     [{file,"src/rabbit_node_monitor.erl"},{line,99}]},
        {rabbit,'-boot/0-fun-1-',0,[{file,"src/rabbit.erl"},{line,326}]},
        {rabbit,start_it,1,[{file,"src/rabbit.erl"},{line,354}]},
        {init,start_it,1,[]},
        {init,start_em,1,[]}]

         {"init terminating in do_boot",{rabbit,failure_during_boot,{error,            {cannot_create_mnesia_dir,"/var/lib/rabbitmq/mnesia/rabbit@localhost/",eacces}}}}

下面是Dockerfile的rabbitmq部分:

RUN apt-get install rabbitmq-server -y

  ENV RABBITMQ_CONFIG_FILE /etc/rabbitmq/rabbitmq
  ADD rabbitmq.config /etc/rabbitmq/rabbitmq.config

  # plugins --offline
  RUN /usr/sbin/rabbitmq-plugins enable rabbitmq_management
  RUN /usr/sbin/rabbitmq-plugins enable rabbitmq_shovel
  RUN /usr/sbin/rabbitmq-plugins enable rabbitmq_shovel_management

  EXPOSE 5672 15672 4369
  VOLUME ["/var/log/rabbitmq", "/var/lib/rabbitmq/mnesia"]

这是docker run命令,rabbitmqbase变量保存了卷要Map到的主机(我的OSX)目录的值。

fab.local('docker run -itd -h rabbithost -p 5672:5672 -p 15672:15672 -p 4369:4369 -p 9001:9001 -v {}/data/mnesia:/var/lib/rabbitmq/mnesia -v {}/data/log:/var/log/rabbitmq --name rabbitmq dtwill/rabbitmq'.format(rabbitmqbase, rabbitmqbase))

所以是的,它看起来像一个权利问题...我不知道如何解决它。
[更新]所以我想这可能是-h参数,并尝试了boot 2docker ip,localhost &一起删除它-仍然崩溃。
谢谢你!

yfjy0ee7

yfjy0ee71#

实际上,rabbitmq不能写入容器内的/var/lib/rabbitmq/mnesia(容器Map到主机上的rabbitmqbase + /data/mnesia)。
这可能是因为在docker挂载你的卷之前/var/lib/rabbitmq/mnesia并不存在,所以挂载点是由docker创建的,但是拥有它的用户不是rabbitmq。
在启动容器之前,请确保映像中存在/var/lib/rabbitmq/mnesia

相关问题