使用docker-compose快速部署RabbitMQ

直接上配置文件

docker-compose.yml

version: '3'

networks:
  web-network:

services:
  docker-rabbitmq:
    environment:
#      RABBITMQ_DEFAULT_VHOST: "/"
      RABBITMQ_DEFAULT_USER: "guest"
      RABBITMQ_DEFAULT_PASS: "guest"
    image: "rabbitmq:3.9.5-management"
    hostname: rabbitmq
    restart: always
    tty: true
    volumes:
      - ./rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins
      - ../apps/rabbitmq/data:/var/lib/rabbitmq
      - ../apps/rabbitmq/log:/var/log/rabbitmq
    ports:
      - 15670:15670
      - 15674:15674
      - 15672:15672
      - 5672:5672
      - 1883:1883
      - 15675:15675
      - 15676:15676
    networks:
      - web-network

插件

cat ./rabbitmq/enabled_plugins
[rabbitmq_management,rabbitmq_prometheus,rabbitmq_stomp,rabbitmq_web_stomp,rabbitmq_web_stomp_examples,rabbitmq_mqtt,rabbitmq_web_mqtt].
  • rabbitmq_management 管理后台1️⃣
  • rabbitmq_prometheus 监控插件,提供了对Prometheus指标收集的支持2️⃣
  • rabbitmq_stomp 3️⃣
  • rabbitmq_web_stomp 在Web应用程序中启用STOMP消息传递4️⃣
  • rabbitmq_web_stomp_examples 一些简单的Web STOMP示例4️⃣
  • rabbitmq_mqtt 5️⃣
  • rabbitmq_web_mqtt 在Web应用程序中启用MQTT消息传递6️⃣

启动服务

docker-compose up -d

注意,如果是Linux,第一次启动可能失败。提示../apps/rabbitmq/log目录没有写入权限,这时执行chmod -R 777 log/即可,另一个data目录无需处理

相关文档

1️⃣https://www.rabbitmq.com/management.html

2️⃣https://www.rabbitmq.com/prometheus.html

3️⃣https://www.rabbitmq.com/stomp.html

4️⃣https://www.rabbitmq.com/web-stomp.html

5️⃣https://www.rabbitmq.com/mqtt.html

6️⃣https://www.rabbitmq.com/web-mqtt.html

感谢阅读这篇文章,如果你喜欢,或者遇到了问题,可以关注我的公众号