Docker Compose部署Rabbitmq(脚本下载延迟插件)

整个工具的代码都在Gitee或者Github地址内

gitee:solomon-parent: 这个项目主要是总结了工作上遇到的问题以及学习一些框架用于整合例如:rabbitMq、reids、Mqtt、S3协议的文件服务器、mongodb

github:GitHub - ZeroNing/solomon-parent: 这个项目主要是总结了工作上遇到的问题以及学习一些框架用于整合例如:rabbitMq、reids、Mqtt、S3协议的文件服务器、mongodb

1.新增data文件夹

2.新增docker-compose.yml文件

version: '3.8'

services:
  rabbitmq:
    image: rabbitmq:management
    container_name: rabbitmq
    ports:
      - "15672:15672"
      - "5672:5672"
    volumes:
      - ./start-rabbitmq-with-plugin.sh:/usr/local/bin/start-rabbitmq-with-plugin.sh
      - ./data:/usr/etc/rabbitmq/data
      - /etc/localtime:/etc/localtime # 容器与宿主机时间同步
    command: ["/bin/bash", "-c", "chmod +x /usr/local/bin/start-rabbitmq-with-plugin.sh && /usr/local/bin/start-rabbitmq-with-plugin.sh"]
    restart: always

3.新增start-rabbitmq-with-plugin.sh脚本

#!/bin/bash

# 安装 wget
if ! command -v wget &> /dev/null
then
    echo "wget not found, installing..."
    apt-get update && apt-get install -y wget
    if [ $? -ne 0 ]; then
        echo "Failed to install wget"
        exit 1
    fi
else
    echo "wget is already installed"
fi

# 创建插件目录,如果不存在的话
mkdir -p /plugins

# 下载 RabbitMQ 延迟消息插件
if [ ! -f /plugins/rabbitmq_delayed_message_exchange-3.13.0.ez ]; then
    echo "Downloading rabbitmq_delayed_message_exchange plugin..."
    wget -O /plugins/rabbitmq_delayed_message_exchange-3.13.0.ez \
    https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/v3.13.0/rabbitmq_delayed_message_exchange-3.13.0.ez
    if [ $? -ne 0 ]; then
        echo "Failed to download rabbitmq_delayed_message_exchange plugin"
        exit 1
    fi
else
    echo "Plugin already downloaded"
fi

# 修改插件文件权限
echo "Setting permissions for the plugin..."
chmod 644 /plugins/rabbitmq_delayed_message_exchange-3.13.0.ez

# 启用插件
echo "Enabling the plugin..."
rabbitmq-plugins enable rabbitmq_delayed_message_exchange

# 启动 RabbitMQ 服务
echo "Starting RabbitMQ server..."
rabbitmq-server
相关推荐
灼烧的疯狂26 分钟前
K8S + Jenkins 做CICD
容器·kubernetes·jenkins
wenyue11211 小时前
Revolutionize Your Kubernetes Experience with Easegress: Kubernetes Gateway API
容器·kubernetes·gateway
yunfanleo2 小时前
docker run m3e 配置网络,自动重启,GPU等 配置渠道要点
linux·运维·docker
梅见十柒3 小时前
wsl2中kali linux下的docker使用教程(教程总结)
linux·经验分享·docker·云原生
O&REO5 小时前
单机部署kubernetes环境下Overleaf-基于MicroK8s的Overleaf应用部署指南
云原生·容器·kubernetes
运维小文6 小时前
K8S资源限制之LimitRange
云原生·容器·kubernetes·k8s资源限制
登云时刻6 小时前
Kubernetes集群外连接redis集群和使用redis-shake工具迁移数据(二)
redis·容器·kubernetes
wuxingge15 小时前
k8s1.30.0高可用集群部署
云原生·容器·kubernetes
志凌海纳SmartX16 小时前
趋势洞察|AI 能否带动裸金属 K8s 强势崛起?
云原生·容器·kubernetes
锅总16 小时前
nacos与k8s service健康检查详解
云原生·容器·kubernetes