RabbitMQ的web访问

1.在CentOS7中拉取RabbitMQ的镜像

docker pull rabbitmq:3-management

.2.创建rabbitmq容器(用户名和密码均不设置)

docker run -p 15672:15672 -p 5672:5672 -d rabbitmq:3-management

.3.查看容器

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                                     NAMES
e49d146708de        rabbitmq:3-management   "docker-entrypoint.s鈥   31 seconds ago      Up 29 seconds       4369/tcp, 5671/tcp, 15671-15672/tcp, 25672/tcp, 0.0.0.0:15672->5672/tcp   rabbitmq

4.可以看到,STATUS是 Up 29 seconds ,rabbitmq已经运行.而此时通过http://192.168.211.132:15672/访问一直访问不到.在网上也搜索到了大量的解决方案
 1)关闭容器,删除容器,重新安装,更换版本
 2)由于rabbitmq默认支持web的启用插件是关闭状态,需要设置:rabbitmq-plugins enable rabbitmq_management.如下,如果出现Plugin configuration unchanged,则代表配置没有变化,支持的插件已经启用了.下面共启用了两次,第二次重复了

[root@localhost ~]# docker exec -it rabbitmq sh
# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@d42bfaa6abe4:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@d42bfaa6abe4...
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch

started 3 plugins.
# exit
[root@localhost ~]# docker exec -it rabbitmq sh
# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@d42bfaa6abe4:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@d42bfaa6abe4...
Plugin configuration unchanged.

. 3)然而还是没有用,于是再次重装,注意重装时的log,有一个警告,问题就在这里.想要访问rabbitmq的web需要设置IPv4.

[root@localhost ~]# docker run -p 15672:15672 -p 5672:5672 -d rabbitmq:3-management
WARNING: IPv4 forwarding is disabled. Networking will not work.
7be1d95631a5b991d2e80a387b37cead4c0b088d6fed7d7ab419d186c758f490

4)解决:https://blog.csdn.net/w719566673/article/details/83182759

vi /usr/lib/sysctl.d/00-system.conf
添加如下代码:

net.ipv4.ip_forward=1

重启network服务
systemctl restart network

5.访问成功(http://192.168.211.132:15672/)
username:guest
password:guest
RabbitMQ的web访问_第1张图片

你可能感兴趣的:(消息中间件,rabbitmq,docker)