我们在docker-compose
设置中具有RabbitMQ管理docker映像,我们正在尝试与一些已添加的用户,虚拟主机和交换一起启动Rabbit。但是,启动程序崩溃了,我们不知道为什么。
我们有一个名为“ rabbitmq”的文件夹,其中包含以下文件(这是我们的配置文件夹):
definitions.json
{
"rabbit_version": "3.8.2",
"users": [
{
"name": "user1",
"password_hash": "user1",
"hashing_algorithm": "rabbit_password_hashing_sha256",
"tags": ""
}
],
"vhosts": [
{
"name": "\/vhost1"
}
],
"permissions": [
{
"user": "user1",
"vhost": "\/vhost1",
"configure": ".*",
"write": ".*",
"read": ".*"
}
],
"parameters": [],
"policies": [],
"queues": [],
"exchanges": [
{
"name": "Pizza",
"vhost": "\/vhost1",
"type": "fanout"
}
],
"bindings": []
}
rabbitmq.conf
loopback_users.guest = false
listeners.tcp.default = 5672
management.load_definitions = "/etc/rabbitmq/definitions.json"
要使用此设置,我们有以下docker-compose
文件:
version: '3'
services:
rabbit:
image: rabbitmq:3.8.2-management
ports:
- "8080:15672"
- "5672:5672"
volumes:
- ${PWD}/rabbitmq:/etc/rabbitmq
我们知道RabbitMQ找到了该文件夹并尝试加载rabbitmq.conf
文件。实际上,这就是我们问题的起点。
当我们尝试启动安装程序时,RabbitMQ无法启动并显示以下消息:
BOOT FAILED
rabbit_1 | ===========
rabbit_1 |
rabbit_1 | Config file generation failed:
rabbit_1 | 10:46:43.479 [error] You've tried to set management.load_definitions, but there is no setting with that name.
rabbit_1 | 10:46:43.479 [error] Did you mean one of these?
rabbit_1 | 10:46:43.537 [error] load_definitions
rabbit_1 | 10:46:43.537 [error] raft.segment_max_entries
rabbit_1 | 10:46:43.537 [error] log.syslog.identity
rabbit_1 | 10:46:43.537 [error] Error generating configuration in phase transform_datatypes
rabbit_1 | 10:46:43.537 [error] Conf file attempted to set unknown variable: management.load_definitions
rabbit_1 | In case the setting comes from a plugin, make sure that the plugin is enabled.
rabbit_1 | Alternatively remove the setting from the config.
rabbit_1 |
rabbit_1 | init terminating in do_boot (generate_config_file)
rabbit_1 | {"init terminating in do_boot",generate_config_file}
rabbit_1 |
rabbit_1 | Crash dump is being written to: /var/log/rabbitmq/erl_crash.dump...done
这令人困惑。我们正在使用rabbitmq:3.8.2-management
图片,因此默认情况下应启用管理插件。
我们在做什么错了?
答案 0 :(得分:1)
我们收到此错误的原因是在docker-compose
文件中:
version: '3'
services:
rabbit:
image: rabbitmq:3.8.2-management
ports:
- "8080:15672"
- "5672:5672"
volumes:
- ${PWD}/rabbitmq:/etc/rabbitmq
具体来说,卷部分:${PWD}/rabbitmq:/etc/rabbitmq
这里的问题是,此命令用我们的文件夹彻底粉碎了原始的rabbitmq文件夹。这意味着原始/ etc / rabbitmq文件夹中的所有其他文件都会丢失。
这不是我们的目的,我们的目的是将文件添加到原始文件夹中,如果文件已经存在,请替换它们。
以下docker-compose
可解决此问题:
version: '3'
services:
rabbit:
image: rabbitmq:3.8.2-management
ports:
- "8080:15672"
- "5672:5672"
volumes:
- ${PWD}/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
- ${PWD}/rabbitmq/definitions.json:/etc/rabbitmq/definitions.json
在这里,我们仅推送和替换所需文件,而保留原始文件夹中的其余内容。
这意味着/etc/rabbitmq
内的plugins文件夹不会被删除,并且插件(例如管理版)将被加载,我们将能够通过rabbitmq.conf
文件对其进行配置