我尝试使用Ubuntu 18.04映像在Docker容器中安装RabbitMQ,以便对它运行单元测试。
为了安装,我运行的是普通的sudo apt-get install rabbitmq-server
,它看起来安装得很好,但是当我试图启动服务或与服务通信时,我收到错误消息:
Error: unable to connect to node rabbit@b562da1810ce: nodedown
DIAGNOSTICS
===========
attempted to contact: [rabbit@b562da1810ce]
rabbit@b562da1810ce:
* connected to epmd (port 4369) on b562da1810ce
* epmd reports node 'rabbit' running on port 25672
* TCP connection succeeded but Erlang distribution failed
* Authentication failed (rejected by the remote node), please check the Erlang cookie
current node details:
- node name: 'rabbitmq-cli-69@b562da1810ce'
- home dir: /var/lib/rabbitmq
- cookie hash: YUZIPS6zyhfUBX5afdKGcw==
研究“请检查Erlang cookie”文本让我得到了大量的similar questions,其中似乎没有一个适用于Docker或我的情况。
我试过删除~/.erlang.cookie
,然后重新启动服务,完全清除软件包并重新安装,但没有任何效果。
如何在Docker中运行RabbitMQ?
编辑:这是我的安装过程。
root@b562da1810ce:$ sudo apt-get purge -yq rabbitmq-server
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
erlang-asn1 erlang-base erlang-corba erlang-crypto erlang-diameter erlang-edoc erlang-eldap erlang-erl-docgen erlang-eunit erlang-ic erlang-inets erlang-mnesia erlang-nox erlang-odbc erlang-os-mon erlang-parsetools erlang-public-key erlang-runtime-tools erlang-snmp erlang-ssh
erlang-ssl erlang-syntax-tools erlang-tools erlang-xmerl libodbc1
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
rabbitmq-server*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 5,678 kB disk space will be freed.
(Reading database ... 69832 files and directories currently installed.)
Removing rabbitmq-server (3.6.10-1) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of stop.
(Reading database ... 69618 files and directories currently installed.)
Purging configuration files for rabbitmq-server (3.6.10-1) ...
Processing triggers for systemd (237-3ubuntu10.33) ...
root@b562da1810ce:$ rm -Rf /var/log/rabbitmq/*
root@b562da1810ce:$ sudo apt-get install -yq rabbitmq-server
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
rabbitmq-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,625 kB of archives.
After this operation, 5,678 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 rabbitmq-server all 3.6.10-1 [4,625 kB]
Fetched 4,625 kB in 4s (1,070 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package rabbitmq-server.
(Reading database ... 69613 files and directories currently installed.)
Preparing to unpack .../rabbitmq-server_3.6.10-1_all.deb ...
Unpacking rabbitmq-server (3.6.10-1) ...
Setting up rabbitmq-server (3.6.10-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service → /lib/systemd/system/rabbitmq-server.service.
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Processing triggers for systemd (237-3ubuntu10.33) ...
root@b562da1810ce:$ sudo service rabbitmq-server status
Status of node rabbit@b562da1810ce
Error: unable to connect to node rabbit@b562da1810ce: nodedown
DIAGNOSTICS
===========
attempted to contact: [rabbit@b562da1810ce]
rabbit@b562da1810ce:
* connected to epmd (port 4369) on b562da1810ce
* epmd reports node 'rabbit' running on port 25672
* TCP connection succeeded but Erlang distribution failed
* Authentication failed (rejected by the remote node), please check the Erlang cookie
current node details:
- node name: 'rabbitmq-cli-30@b562da1810ce'
- home dir: /var/lib/rabbitmq
- cookie hash: DHe9O00f7sIHn/dTThKVVQ==
root@b562da1810ce:$ sudo service rabbitmq-server start
* Starting RabbitMQ Messaging Server rabbitmq-server * FAILED - check /var/log/rabbitmq/startup_\{log, _err\}
[fail]
root@b562da1810ce:$ sudo service rabbitmq-server status
Status of node rabbit@b562da1810ce
Error: unable to connect to node rabbit@b562da1810ce: nodedown
DIAGNOSTICS
===========
attempted to contact: [rabbit@b562da1810ce]
rabbit@b562da1810ce:
* connected to epmd (port 4369) on b562da1810ce
* epmd reports node 'rabbit' running on port 25672
* TCP connection succeeded but Erlang distribution failed
* Authentication failed (rejected by the remote node), please check the Erlang cookie
current node details:
- node name: 'rabbitmq-cli-13@b562da1810ce'
- home dir: /var/lib/rabbitmq
- cookie hash: DHe9O00f7sIHn/dTThKVVQ==
root@b562da1810ce:$ cat /var/log/rabbitmq/startup_err
root@b562da1810ce:$ cat /var/log/rabbitmq/startup_log
ERROR: node with name "rabbit" already running on "b562da1810ce"
根据日志的最后一行,我决定检查ps aux|grep -i rabbit
,它显示Rabbit正在运行。但是service
和rabbitmqctl
都无法与它通信。这是为什么呢?
1条答案
按热度按时间vzgqcmou1#
使用https://hub.docker.com//rabbitmq * 中的正式Docker映像,或者使用https://hub.docker.com/* /rabbitmq中的Docker文件
使用命令构建容器(点表示在当前目录中定位Dockerfile)。
映像构建完成后,您可以使用以下命令启动容器