rabbitmq a key deployment script

1, create a file named auto_install_rabbitmq.sh

 

2, will now be copied to the script file in which specific steps in comments

# Linux environment 
# one-click installation rabitmq, using a script to run the file (sh auto_install_rabbitmq.sh) in a linux environment 
# / bin /! Bash 
# function: rabbitmq installed automatically. 
# Need to put the installation files to / opt / tools / directory, 
# and then execute this script, installed to / opt / app / directory. 
# Default Administrator account: account: admin password: admin123456 

# view the file if there are windows line breaks: CAT - v auto_install_redis.sh 
# replace windows line breaks: sed 'S / \ r //' original filename> New File name 

rabbitmq_install () { 
 
# variable is set ERLANG 
ERLANG_FILE = otp_src_21.1 .tar.gz 
ERLANG_FILE_DIR = otp_src_21.1 
ERLANG_PATH = / opt / App / Erlang 
 
# rabbitmq setting environment variables 
RB_FILERabbitMQ-Server-3.6.8 = 
RB_FILE_DIR = / opt / App / 
RB_PATH = / opt / App / RabbitMQ-Server-3.6.8 

cd / usr / local / src 
# download the installation package 
wget HTTP: // erlang.org/download / $ ERLANG_FILE 
 
#yum install dependencies 
yum -Y-C the install the make GCC GCC ++ Kernel-devel-M4 the ncurses devel OpenSSL-devel unixODBC- devel 
 
# erlang extracting file and install 
the tar - zxvf $ ERLANG_FILE 
CD $ ERLANG_FILE_DIR 
. / Configure --with --prefix = -ssl $ ERLANG_PATH 
the make && the make install 

# erlang verify whether the installation was successful 
#. / bin / ERL 

# decompression RabbitMQ 
#tar-xvJf $RB_FILE -C $RB_FILE_DIR
wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.8/rabbitmq-server-3.6.8-1.el7.noarch.rpm
rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
yum install rabbitmq-server-3.6.8-1.el7.noarch.rpm
cp /usr/share/doc/rabbitmq-server-3.6.8/rabbitmq.config.example  /etc/rabbitmq

########写入rabbitmq-env.conf配置文件########
echo '#!/bin/sh
RABBITMQ_MNESIA_BASE=/usr/local/rabbitmq-server/data
RABBITMQ_LOG_BASE=/usr/local/rabbitmq-server/log
' > /etc/rabbitmq/rabbitmq-env.conf

cd /usr/local
mkdir rabbitmq-server
chmod -R 777 /usr/local/rabbitmq-server
 
#设定erlang/rabbitmq环境变量 
#PATH=/opt/app/erlang/bin:$PATH
echo "###erlang/rabbitmq PATH #####" >>/etc/profile
echo "PATH=${ERLANG_PATH}/bin:{}/sbin:$PATH" >>/etc/profile
echo "PATH=${RB_PATH}/sbin:{}/sbin:$PATH" >>/etc/profile
echo "export PATH " >>/etc/profile
echo "###erlang PATH END ###   ">>/ etc / 
# refresh configuration fileProfile

source /etc/profile

systemctl start rabbitmq-server.service
#添加到启动项并设置开机自启
chkconfig rabbitmq-server on
systemctl enable rabbitmq-server.service
#开启管理界面
rabbitmq-plugins enable rabbitmq_management
#设置账号
rabbitmqctl add_user admin admin123456
rabbitmqctl set_user_tags admin  administrator
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
}

read -p " Do you want to install rabbitmq:Y/N " REDISCONFIRM
if [ "$REDISCONFIRM" = "Y" ] || [ "$REDISCONFIRM" = "y" ];then
    rabbitmq_install
else
echo "=================== install the next thing =============="
fi

 

Guess you like

Origin www.cnblogs.com/cjyboy/p/11249404.html