rabbitmq 前言
RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件)。RabbitMQ服务器是用Erlang语言编写的,而集群和故障转移是构建在开放电信平台框架上的。所有主要的编程语言均有与代理接口通讯的客户端库。
rabbitmq 参考
- 版本兼容性参考
rabbitmq | erlang | java | wxWidgets |
download | download | download | download |
备用download |
Linux 各系统下载使用参考
Red Hat | Rocky Linux | Oracle Linux | AlmaLinux | ubuntu | suselinux | esxi | RHEL标准安装 | 系统安装参考 | YUM参考 | MobaXterm 远程连接工具 | Red Hat Enterprise 9.0 文档 | Kickstart 生成器 | |||||
download | download | download | download | download | download | download | 参考 | 参考 | 配置参考 | download | 参考 | Kickstart | |||||
版本兼容性 |
安装 rabbitmq
-
创建安装自动化脚本
-
版本兼容性参考
- 实现在线安装rabbitmq,erlang,java,wxWidgets,配置rabbitmq配置文件,防火墙配置,企业微信机器人通知。
- 以下基于Redhat系统
- find / -name rabbitmq #rabbitmq目录查看
- find / -name erlang #erlang目录查看
- rabbitmq 用户名密码admin/Report@123
- curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXXX' #更改自己的企业微信机器人地址
- curl -o /etc/yum.repos.d/redhat.repo http://mirrors.aliyun.com/repo/Centos-8.repo #阿里在线repo
- yum install figlet -y #用于将文字转换为放大艺术字(使用figlet Mysql显示)
vi /erlang_rabbitmq.sh
#!/bin/bash -e
# Author: CIASM
# Date: 2023/0412
<<!
██████╗ █████╗ ██████╗ ██████╗ ██╗████████╗███╗ ███╗ ██████╗
██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║╚══██╔══╝████╗ ████║██╔═══██╗
██████╔╝███████║██████╔╝██████╔╝██║ ██║ ██╔████╔██║██║ ██║
██╔══██╗██╔══██║██╔══██╗██╔══██╗██║ ██║ ██║╚██╔╝██║██║▄▄ ██║
██║ ██║██║ ██║██████╔╝██████╔╝██║ ██║ ██║ ╚═╝ ██║╚██████╔╝
╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═
!
<<!
#Centos 8 rabbitmq+erlang 安装依赖插件
yum install -y gcc gcc-c++ glibc-devel make cmake m4 ncurses-devel unixODBC unixODBC-devel openssl-devel autoconf net-tools socat mesa-libGLU-devel unzip zip xml-common zlib zlib-devel
yum install -y libxslt libxml2 wget vim bzip2
yum install -y gtk2-devel binutils-devel
!
<<!
#ubuntu rabbitmq+erlang 安装依赖插件
apt-get install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop
!
#Define data path variables
data_downloads=/data/downloads
#Define rabbitmq path variables
rabbitmq_URL=https://mirrors.huaweicloud.com/rabbitmq-server/v3.11.6/
rabbitmq_gz=rabbitmq-server-generic-unix-3.11.6.tar.xz
rabbitmq_FILE_DIR=rabbitmq_server-3.11.6
rabbitmq_PREFIX=/opt/rabbitmq
disk=/opt
#Plug-in download
zlib_devel_url=https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64/getPackage/zlib-devel-1.2.11-20.el8.x86_64.rpm
zlib_url=https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64/getPackageSource/zlib-1.2.11-20.el8.src.rpm
unzip_url=http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/unzip-6.0-45.el8.x86_64.rpm
zip_url=http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/zip-3.0-23.el8.x86_64.rpm
xml_common_url=http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/xml-common-0.6.3-50.el8.noarch.rpm
#erlang path variables
erlang_url=https://erlang.org/download/
erlang_gz=otp_src_25.3.tar.gz
erlang_FILE_DIR=otp_src_25.3
erlang_new=erlang
#java path variables
java_url=https://repo.huaweicloud.com/java/jdk/13+33/
java_gz=jdk-13_linux-x64_bin.tar.gz
java_catalogue=jdk-13
java_catalogue_new=jdk
#wxWidgets path variables
wxWidgets_url=https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.0/
wxWidgets_bz=wxWidgets-3.2.0.tar.bz2
wxWidgets_catalogue=wxWidgets-3.2.0
install_depend () {
mkdir -p $data_downloads
wget -N -P $data_downloads $zlib_devel_url
wget -N -P $data_downloads $zlib_url
wget -N -P $data_downloads $unzip_url
wget -N -P $data_downloads $zip_url
wget -N -P $data_downloads $xml_common_url
rpm -ihv $data_downloads/*.rpm --nodeps --force
yum install -y gcc gcc-c++ glibc-devel make cmake m4 ncurses-devel unixODBC unixODBC-devel openssl-devel autoconf net-tools socat mesa-libGLU-devel
yum install -y libxslt libxml2 wget vim bzip2
yum install -y gtk2-devel binutils-devel
}
install_java (){
wget -N -P $data_downloads $java_url$java_gz
tar -zxf $data_downloads/$java_gz -C $disk
mv $disk/$java_catalogue $disk/$java_catalogue_new
echo 'export JAVA_HOME=/opt/jdk' >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile
echo 'export JAVA_HOME' >> /etc/profile
source /etc/profile
}
install_wxWidgets (){
wget -N -P $data_downloads $wxWidgets_url/$wxWidgets_bz
tar -jxf $data_downloads/$wxWidgets_bz -C $disk
cd $disk/$wxWidgets_catalogue
./configure --prefix=/opt/wxWidgets --disable-shared --enable-unicode -enable-debug --enable-webview -with-regex=builtin --with-gtk
make -j8 && make install
echo 'export PATH=$PATH:/opt/wxWidgets/bin' >> /etc/profile
source /etc/profile
wx-config --version
}
install_erlang (){
if [ ! -d ${rabbitmq_PREFIX} ];then
install_depend
install_java
install_wxWidgets
wget -N -P $data_downloads $erlang_url/$erlang_gz
tar -xf $data_downloads/$erlang_gz -C $disk
if [ $? -eq 0 ];then
cd $disk/$erlang_FILE_DIR
./configure --prefix=/opt/erlang --without-javac
make -j8 && make install
echo 'export ERLANG_HOME=/opt/erlang' >> /etc/profile
echo 'export PATH=$PATH:$ERLANG_HOME/bin' >> /etc/profile
echo 'export ERLANG_HOME' >> /etc/profile
source /etc/profile
ln -s $disk/$erlang_new/bin/* /usr/local/sbin/
install_rabbitmq
action "\033[32mThe rabbitmq Install Sussess...\033[0m"
else
action "\033[33mThe rabbitmq Install Failed...\033[0m"
exit 1
fi
else
echo -e "\033[31mThe rabbitmq already Install...\033[0m"
fi
}
install_rabbitmq () {
wget -N -P $data_downloads $rabbitmq_URL/$rabbitmq_gz
tar -xf $data_downloads/$rabbitmq_gz -C $disk
mv $disk/$rabbitmq_FILE_DIR $rabbitmq_PREFIX
ln -s $rabbitmq_PREFIX/sbin/* /usr/local/sbin/
echo 'export RABBITMQ_HOME=/opt/rabbitmq' >> /etc/profile
echo 'export PATH=$PATH:$RABBITMQ_HOME/sbin' >> /etc/profile
echo 'export RABBITMQ_HOME' >> /etc/profile
source /etc/profile
cat >>/usr/lib/systemd/system/rabbitmq-server.service<<EOF
[Unit]
Description=RabbitMQ broker
After=syslog.target network.target
[Service]
User=root
Group=root
WorkingDirectory=/opt/rabbitmq
ExecStart=/opt/rabbitmq/sbin/rabbitmq-server
ExecStop=/opt/rabbitmq/sbin/rabbitmqctl stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now rabbitmq-server.service
sh /rabbitmq_config.sh
firewall-cmd --zone=public --permanent --add-port={4369,25672,5671,5672,15672,61613,61614,1883,8883}/tcp
firewall-cmd --reload
rm -rf $data_downloads/*
rm -rf $disk/$erlang_FILE_DIR
}
Deployment_completion_notification (){
host_ID=`dmidecode -s system-serial-number | sed -r 's/\s+//g'`
host_IP=`ifconfig -a | grep inet | grep -v '127.0.0.1' | awk '{ print $2}' | awk 'NR==1'`
memory_Size=`dmidecode -t memory | grep Size | grep -v No | awk '{sum+=$2} END {printf "%.0fG\n",sum/1^C4}'`
CPU_Model=`cat /proc/cpuinfo | grep 'model name' | awk '{print $6}' | uniq`
Disk_size=`fdisk -l | grep "sda:" | awk '{print $3$4}'`
redhat_version=`cat /etc/redhat-release | grep "release" | awk '{print $6}'`
redhat_core=`cat /proc/version | grep "version" | awk '{print $3}'`
rabbitmq_server=`rabbitmqctl version`
erl_version=`erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell`
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXX' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": " **system check** <font color=\"info\"> complete </font> \n
> **Host IP Address** \n
[http://'$host_IP'](http://'$host_IP') \n
> **Hardware information** \n
hostSN:<font color=\"info\"> '$host_ID' </font> \n
CPU_Model:<font color=\"info\"> '$CPU_Model' </font> \n
memory_Size:<font color=\"info\"> '$memory_Size' </font> \n
Disk_size:<font color=\"info\"> '$Disk_size' </font> \n
System_version:<font color=\"info\"> '$redhat_version' </font> \n
system_core:<font color=\"info\"> '$redhat_core' </font> \n
> **rabbitmq install** \n
rabbitmq_server:<font color=\"info\"> '$rabbitmq_server' </font> \n
erl_version:<font color=\"info\"> '$erl_version' </font> \n",
}
}'
}
main (){
install_erlang
Deployment_completion_notification
}
main
插件开启管理,用户创建
cat >>/rabbitmq_config.sh<<EOF
#!/bin/bash -e
# Author: CIASM
# Date: 2023/04/12
rabbitmqctl start_app && \
rabbitmq-plugins enable rabbitmq_management && \
rabbitmqctl add_user admin Report@123 && \
rabbitmqctl set_user_tags admin administrator && \
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*" && \
rabbitmq-plugins enable rabbitmq_mqtt && \
rabbitmq-plugins enable rabbitmq_web_mqtt
EOF
执行安装
sh /erlang_rabbitmq.sh