本地包安装
# elang - 25.0.3
# wget https://github.com/erlang/otp/releases/download/OTP-25.0.3/otp_src_25.0.3.tar.gz
# rabbit - 3.10.7
自动化安装脚本:
java
#!/bin/bash
# 自动安装rabbitmq脚本(需要保证当前包已经上传到存储为止)
#项目路径上传路径【/usr/local/src/packer/rabbitmq】
# 如果使用的是wget 下载rabbitmq包,需要你安装wget ,命令:yum -y install wget
# elang - 25.0.3
# wget https://github.com/erlang/otp/releases/download/OTP-25.0.3/otp_src_25.0.3.tar.gz
# rabbit - 3.10.7
# wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.10.7/rabbitmq-server-generic-unix-3.10.7.tar.xz
#本文考虑到rabbit包下载时间较长,所以采用本地上传固定文件包进行安装
#
#安装包上传存储的路径
RABBIT_PACKER=/usr/local/src/packer/rabbitmq
#erlang 的版本名称
OTP_NAME=otp_src_25.0.3
#mq版本名称
RABBMQ_NAME=rabbitmq-server-generic-unix-3.10.7
#mq文件名称(解压之后,配置文件里面需要,如果名称不对,需要修改下面的配置文件路径)
RABBMQ_file=rabbitmq_server-3.10.7
#rlang 的压缩包完整名称
ELAND_ADDRESS_ZIP=$RABBIT_PACKER/$OTP_NAME.tar.gz
#mq的压缩包完整地址
RABBIT_ADDRESS_TAR_XZ=$RABBIT_PACKER/$RABBMQ_NAME.tar.xz
RABBIT_ADDRESS_TAR=$RABBIT_PACKER/$RABBMQ_NAME.tar
#erl存储位置
ELR_MEMOEY=/usr/local/erlang
#MQ存储位置
MQ_MEMOEY=/usr/local
# 下载wget
isInstallWget=`yum list installed | grep wget`
if [ $? -ne 0 ];then
yum -y install wget &>/dev/null
fi
# 首先需要安装一些依赖
echo "开始删除安装过erlang..."
#如果之前安装过erlang,请先删除!
yum remove erlang*
echo "开始安装依赖1..."
#安装依赖
yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget gtk2-devel binutils-devel 1>/dev/null
echo "开始安装依赖2..."
#安装依赖
yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget gtk2-devel binutils-devel
if [ $? -ne 0 ];then
echo "yum install soft package fail";
fi
echo "安装依赖包已完成"
sleep 5
echo "开始安装erlang"
#新建erlang文件
mkdir $ELR_MEMOEY
#进入新建的erlang文件
cd $ELR_MEMOEY
#解压erlan文件
tar -xvf $ELAND_ADDRESS_ZIP
#进入解压的文件
cd $ELR_MEMOEY/$OTP_NAME
#编译安装
./configure --prefix=$ELR_MEMOEY
#maker编译
make && make install
#添加环境变量
sed -i '$aERLANG_PATH=\/usr\/local\/erlang\/bin \nexport PATH=\${ERLANG_PATH}:${PATH} ' /etc/profile
#环境变量生效
source /etc/profile
echo "至此erlang1⃣️安装完成"
#下一个安装进度进行睡眠
sleep 5
echo "开始安装rabbitmq"
#由于下载的安装包为xz文件,我们先将xz解压为tar
#进行文件解压
xz -d $RABBIT_ADDRESS_TAR_XZ
#进行文件解压缩
tar -xvf $RABBIT_ADDRESS_TAR -C $MQ_MEMOEY
cd $MQ_MEMOEY
#修改mq名称
# 移动
#mv $MQ_MEMOEY/$RABBMQ_NAME /$MQ_MEMOEY/$RABBMQ_file
# mv /usr/local/rabbitmq-server-generic-unix-3.10.7 /usr/local/usrabbitmq_3.10.7
#添加环境变量
sed -i '$aRABBITMQ_PATH=\/usr\/local\/rabbitmq_server-3.10.7\/sbin \nexport PATH=\${RABBITMQ_PATH}:${PATH}' /etc/profile
#环境变量生效
source /etc/profile
echo "至此rabbitmq安装完成"
#下一个执行脚本睡眠
sleep 5
echo "rabbitmq设置开始"
#mq启动类目录
cd $MQ_MEMOEY/$RABBMQ_file/sbin
#启动rabbitmq
./rabbitmq-server -detached
#安装可视化页面
./rabbitmq-plugins enable rabbitmq_management
#新增admin账号
# 查看所有用户
./rabbitmqctl list_users
# # 添加用户
./rabbitmqctl add_user admin 123456
# # 配置权限
./rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
# # 查看用户权限
./rabbitmqctl list_user_permissions admin
# # 设置tag
./rabbitmqctl set_user_tags admin administrator
echo "rabbitmq设置结束"
# 启动rabbitmq
#需要进入到mq的安装目录中进行处理
#/usr/local/rabbitmq_server-3.10.7/sbin
# rabbitmq-server --detached
# 查看状态
# rabbitmqctl status
# 停止
# rabbitmqctl stop
# 查看进程
# ps -ef | grep rabbitmq
# 开启web插件
#[root@server-a sbin]# ./rabbitmq-plugins enable rabbitmq_management
# rabbitmq-plugins enable rabbitmq_management
# 浏览器访问 ip:15672
# 默认账号密码:guest guest(这个账号只允许本机访问)
# 创建rabbitmq用户账号
# <<rabbitmqAccount
# # 查看所有用户
# rabbitmqctl list_users
# # 添加用户
# rabbitmqctl add_user admin 123456
# # 配置权限
# rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
# # 查看用户权限
# rabbitmqctl list_user_permissions admin
# # 设置tag
# rabbitmqctl set_user_tags admin administrator
# # 删除用户
# rabbitmqctl delete_user guest
# rabbitmqAccount
# 设置开机自动重启
# <<rabbitmqAutoStart
# cd /etc/init.d
# # 新建脚本
# # 添加权限+加入
# chmod +x rabbitmq
# chkconfig --add rabbitmq
# #启动
# service rabbitmq start|stop
# rabbitmqAutoStart