docker开启rabbitmq

问题

docker rabbitmq failed: Connection refused.

排除问题的干扰项;
- 1、在访问 rabbitmq 后台的时候 无法访问,是否是端口没有对外开放
- 2、在1没有问题的情况下 ,lsof -i:port 监听依然在,也可能是docker由于服务器,挂起导致服务不可用,此时需要重启docker服务,再重启对应的服务。


spring boot + rabbitMq

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
            <version>1.5.3.RELEASE</version>
 </dependency>


spring.rabbitmq.host=192.168.6.7
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest


[root@wecash wecash]# firewall-cmd --state
running
[root@wecash wecash]# firewall-cmd --list
usage: see firewall-cmd man page
firewall-cmd: error: ambiguous option: --list could match --list-lockdown-whitelist-contexts, --list-all, --list-lockdown-whitelist-uids, --list-ports, --list-source-ports, --list-lockdown-whitelist-users, --list-forward-ports, --list-icmp-blocks, --list-interfaces, --list-rich-rules, --list-services, --list-lockdown-whitelist-commands, --list-all-zones, --list-sources, --list-protocols
[root@wecash wecash]# firewall-cmd --permanent --zone=public --list-ports 5672/tcp 15672/tcp 6379/tcp
usage: see firewall-cmd man page
firewall-cmd: error: unrecognized arguments: 5672/tcp 15672/tcp 6379/tcp
[root@wecash wecash]# firewall-cmd --zone=public --add-port=5672/tcp --permanent
Warning: ALREADY_ENABLED: 5672:tcp
success
[root@wecash wecash]# firewall-cmd --zone=public --add-port=15672/tcp --permanent
Warning: ALREADY_ENABLED: 15672:tcp
success
[root@wecash wecash]# firewall-cmd --zone=public --add-port=6279/tcp --permanent
success
[root@wecash wecash]# 
[root@wecash wecash]# firewall-cmd --list
usage: see firewall-cmd man page
firewall-cmd: error: ambiguous option: --list could match --list-lockdown-whitelist-contexts, --list-all, --list-lockdown-whitelist-uids, --list-ports, --list-source-ports, --list-lockdown-whitelist-users, --list-forward-ports, --list-icmp-blocks, --list-interfaces, --list-rich-rules, --list-services, --list-lockdown-whitelist-commands, --list-all-zones, --list-sources, --list-protocols
[root@wecash wecash]# firewall-cmd --list-ports
5672/tcp 6379/tcp 15672/tcp
[root@wecash wecash]# 
[root@wecash wecash]# firewall-cmd --reload
success
[root@wecash wecash]# docker run -d -p 5672:5672 -p 15672:15672 rabbitmq:3-management
b056508560ba043f4280c2bcf2844f1c4e4d737a7bf649125c66e7207280ef07
[root@wecash wecash]# docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                                                        NAMES
b056508560ba        rabbitmq:3-management   "docker-entrypoint.sh"   6 seconds ago       Up 4 seconds        4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp   angry_boyd
[root@wecash wecash]# 

可访问
http://192.168.6.7:15672/#/
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐