整个工具的代码都在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:managementcontainer_name: rabbitmqports:- "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
thenecho "wget not found, installing..."apt-get update && apt-get install -y wgetif [ $? -ne 0 ]; thenecho "Failed to install wget"exit 1fi
elseecho "wget is already installed"
fi# 创建插件目录,如果不存在的话
mkdir -p /plugins# 下载 RabbitMQ 延迟消息插件
if [ ! -f /plugins/rabbitmq_delayed_message_exchange-3.13.0.ez ]; thenecho "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.ezif [ $? -ne 0 ]; thenecho "Failed to download rabbitmq_delayed_message_exchange plugin"exit 1fi
elseecho "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