单节点部署脚本
RabbitMQ.sh
#!/bin/bash
# 时间:2021年6月2日18点21分
# 项目:单节点部署RabbitMQ消息队列
# ================================脚本开始================================
# 变量定义:
# 下载链接
erlang_url=https://github.com/rabbitmq/erlang-rpm/releases/download/v22.0.7/erlang-22.0.7-1.el7.x86_64.rpm
rabbitmq_url=https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.18/rabbitmq-server-3.7.18-1.el7.noarch.rpm
# 下载后rpm的名字
erlang_rpm=`echo $erlang_url | rev | cut -d'/' -f 1 | rev`
rabbitmq_rpm=`echo $rabbitmq_url | rev | cut -d'/' -f 1 | rev`
# 1.下载并安装软件和依赖RPM包
cd /usr/local/src/
if [ ! -f "$erlang_rpm" ];then
wget $erlang_url
if [ ! `rpm -qa|grep erlang` ];then
rpm -ivh $erlang_rpm
fi
elif [ ! `rpm -qa|grep erlang` ];then
rpm -ivh $erlang_rpm
fi
if [ ! -f "$rabbitmq_rpm" ];then
wget $rabbitmq_url
if [ ! `rpm -qa|grep rabbitmq` ];then
yum localinstall -ivh $rabbitmq_rpm
fi
elif [ ! `rpm -qa|grep rabbitmq` ];then
yum localinstall -ivh $rabbitmq_rpm
fi
# 2.复制模板文件
cp /usr/share/doc/rabbitmq-server-3.7.18/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config
# 3.修改配置文件
sed -i '61a {loopback_users, []}' /etc/rabbitmq/rabbitmq.config
# 4.启用页面管理插件
rabbitmq-plugins enable rabbitmq_management
# 5.启动rabbitmq服务
systemctl start rabbitmq-server.service
# 访问:开启管理界面后,查看15672端口是否成功启动
# 在浏览器地址栏输入:IP地址+端口号访问,默认的账号密码是guest/guest
# ================================脚本结束================================
网友评论