我正在从Docker映像运行Rabbitmq。这是Dockerfile
FROM rabbitmq:3-management
RUN rabbitmq-plugins enable --offline rabbitmq_mqtt rabbitmq_peer_discovery_k8s rabbitmq_stomp rabbitmq_management
COPY rabbitmq.conf /etc/rabbitmq/rabbitmq.conf
COPY rabbit_init.sh /rabbit_init.sh
RUN ["chmod", "+x", "/rabbit_init.sh"]
RUN ["chmod", "+x", "/etc/rabbitmq/rabbitmq.conf"]
CMD ["/rabbit_init.sh"]
rabbit_init.sh
#!/bin/sh
( sleep 12 ; \
echo "Add VirtualHost ..."; \
rabbitmqctl add_vhost EVhost; \
echo "Enable ha-mode for queue mirroring ..."; \`
rabbitmqctl set_policy -p / ha-all ".*" '{"ha-mode":"all","ha-sync-mode":"automatic"}' --priority 1; \
rabbitmqctl set_policy -p EVhost ha-all ".*" '{"ha-mode":"all","ha-sync-mode":"automatic"}' --priority 1; \
echo "Creating RabbitMQ user '$RABBITMQ_USER' ...";\
rabbitmqctl add_user $RABBITMQ_USER $RABBITMQ_PASSWORD; \
rabbitmqctl set_user_tags $RABBITMQ_USER administrator; \
rabbitmqctl set_permissions -p / $RABBITMQ_USER ".*" ".*" ".*" ; \
rabbitmqctl set_permissions -p EVhost $RABBITMQ_USER ".*" ".*" ".*" ; \
echo "Delete rabbitMq guest user ..."; \
rabbitmqctl delete_user guest; \
)&
rabbitmq-server $@
我在/etc/rabbitmq/rabbitmq.conf中有这些配置
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_k8s
cluster_formation.k8s.host = kubernetes.default.svc.cluster.local
cluster_formation.k8s.address_type = ip
cluster_formation.node_cleanup.interval = 30
cluster_formation.node_cleanup.only_log_warning = false
cluster_partition_handling = autoheal
queue_master_locator=min-masters
loopback_users.guest = false
log.file = rabbitmq.log
log.dir = /var/log/rabbitmq
log.file.level = debug
log.file.rotation.date = $D0
运行新容器时出现此错误
BOOT FAILED
===========
Error description:
rabbit:start_it/1 line 484
rabbit:boot_error/2 line 972
rabbit_lager:log_locations/0 line 97
rabbit_lager:ensure_lager_configured/0 line 198
rabbit_lager:lager_configured/0 line 206
lager:list_all_sinks/0 line 341
lager_config:get/2 line 71
ets:lookup(lager_config, {'_global',handlers})
error:badarg
Log file(s) (may contain more information):
{"init terminating in do_boot",badarg}
init terminating in do_boot (badarg)
Crash dump is being written to: /var/log/rabbitmq/erl_crash.dump...done
我无法把手放在根本原因上!
容器的文件系统不包含任何日志
甚至建议的日志文件/var/log/rabbitmq/erl_crash.dump
都不存在!
Windows 10
台式机泊坞窗
-
非常感谢您的帮助:)