RabbitMQ版本包括适用于Linux,MacOS和* BSD系统的二进制软件包。它是极简主义的,对于如何安装,配置和管理它没有意见。在无法使用更多自觉的安装选项(Debian或RPM软件包,Homebrew,BSD端口)的环境中,建议使用此软件包。这也是在开发环境中在同一台计算机上运行多个版本的最方便的选择,例如预览发布测试。Windows有一个单独的二进制包。
RabbitMQ | ErLang | SystemVersion |
---|---|---|
3.7.15 | 23.0 | CentOS 7 x86_64 |
mq依赖环境:erlang,确保已安装Erlang / OTP
otp网盘下载链接:https://pan.baidu.com/s/1bPpsO3Vd0u8bQbm1UtZedw .
提取码:4pay
RabbitMQ version | Minimum required Erlang/OTP | Maximum supported Erlang/OTP | Notes |
---|---|---|---|
3.8.16 | 23.2 | 24.x | Erlang/OTP 24 support announcementErlang 24 was released on May 12, 2021Some community plugins and tools may be incompatible with Erlang 24 |
3.8.153.8.143.8.133.8.123.8.113.8.103.8.9 | 22.3 | 23.x | Erlang/OTP 23 compatibility notesErlang 23.x is recommendedErlang 22.x dropped support for HiPE |
3.8.83.8.73.8.63.8.53.8.4 | 21.3 | 23.x | Erlang/OTP 23 compatibility notesErlang 22.x or 23.x is recommendedErlang 22.x dropped support for HiPE |
3.8.33.8.23.8.13.8.0 | 21.3 | 22.x | Erlang 22.x is recommended.Erlang 22.x dropped support for HiPE |
3.7.273.7.263.7.253.7.243.7.233.7.223.7.213.7.203.7.19 | 21.3 | 22.x | Erlang/OTP 20.x support is discontinuedErlang 22.x dropped support for HiPE |
3.7.183.7.173.7.163.7.15 | 20.3 | 22.x | Erlang/OTP 22.0 compatibility notesTLSv1.0 and TLSv1.1 support is disabled by default on Erlang 22.x |
3.7.143.7.133.7.123.7.11 | 20.3 | 21.x | Erlang/OTP 19.x support is discontinuedFor the best TLS support, the latest version of Erlang/OTP 21.x is recommended |
3.7.103.7.93.7.83.7.7 | 19.3 | 21.x | Erlang/OTP 21.0 compatibility notes |
3.7.63.7.53.7.43.7.33.7.23.7.13.7.0 | 19.3 | 20.x | For the best TLS support, the latest version of Erlang/OTP 20.x is recommendedErlang versions prior to 19.3.6.4 have known bugs (e.g. ERL-430, ERL-448) that can prevent RabbitMQ nodes from accepting connections (including from CLI tools) and stoppingVersions prior to 19.3.6.4 are vulnerable to the ROBOT attack (CVE-2017-1000385)On Windows, Erlang/OTP 20.2 changed default cookie file location |
下载erlang安装包后,上传到服务器进行解压
mkdir /root/erlang
tar -zxvf otp_src_23.0.tar.gz -C /root/erlang
安装依赖类库以及软件包
yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget gtk2-devel binutils-devel
依赖安装完成后,进入erlang目录
cd /root/erlang
./configure --prefix=/opt/erlang --编译
--编译完成后,确保无错误信息,执行一下操作
make install --此过程执行时间较长
make install完成后打印如下代表安装完成:
echo 'export PATH=$PATH:/opt/erlang/bin' >> ~/.bashrc
source ~/.bashrc
注意:rabbitmq启动时需要使用rabbitmq用户,所以需要我们创建用户、用户组rabbitmq
上传安装包到服务器后,进行解压
groupadd rabbitmq --添加用户组
useradd rabbitmq -g rabbitmq --添加用户并将用户加入用户组
su - rabbitmq -- 切换到rabbitmq用户
-- 上传rabbitmq安装包到/home/rabbitmq目录并进行赋权
tar -xvf rabbitmq-server-generic-unix-3.7.15.tar.xz
mv rabbitmq-server-3.7.15 rabbitmq
echo 'export RABBITMQ_HOME=/home/rabbitmq/rabbitmq' >> ~/.bashrc
echo 'export PATH=$PATH:$RABBITMQ_HOME/sbin' >> ~/.bashrc
echo 'export PATH=$PATH:/opt/erlang/bin' >> ~/.bashrc
source ~/.bashrc
--启动rabbitmq
rabbitmq-server start
ps -ef | grep rabbitmq --查看rabbitmq进程是否存在
rabbitmqctl start_app --启动RabbitMQ的应用
--默认情况下,rabbitmq没有安装web端的客户端软件,需要安装才可以生效
rabbitmq-plugins enable rabbitmq_management --打开RabbitMQWeb管理界面插件
rabbitmq默认端口为15672,通过web界面访问rabbitmq
使用rabbitmq默认的用户名密码为guest登录,出现以下报错
表示只能通过本机登录,解决方案如下:
--进入rabbitmq安装目录下
cd $RABBITMQ_HOME/ebin
vim rabbit.app
-- 将下图中红框选项中的guest删除
rabbitmqctl stop
rabbitmq-server -detached
--重启刷新web界面使用guest登录即可
rabbitmq默认的用户名密码为guest,为访客权限,且只能通过本机localhost访问,远程访问用户需要我们手动添加
rabbitmqctl add_user rbmq 123 -- rabbitmqctl add_user 用户名 密码
rabbitmqctl set_user_tags rbmq administrator --设置用户角色 rabbitmqctl set_user_tags 用户名 角色
rabbitmqctl set_permissions -p / rbmq ".*" ".*" ".*" --添加主机
rabbitmq角色说明:
administrator
:超级管理员,可以登录控制台、查看所有信息、并对rabbitmq进行管理monToring
:监控者;登录控制台,查看所有信息policymaker
:策略制定者;登录控制台指定策略managment
:普通管理员;登录控制
rabbitmqctl set_permissions说明:
sendMQ.py
import pika
import sys
import time
from datetime import datetime
import random
# rabbitmq信息
username = "rbmq"
password = "123"
ip_addr = "xxx.xxx.xxx.xxx"
alphabet = 'abcdefghijklmnopqrstuvwxyz!@#$%^&*()'
port_num = "5672"
# 创建证数
credentials = pika.PlainCredentials(username, password)
# 创建连接
connection = pika.BlockingConnection(pika.ConnectionParameters(ip_addr, port_num, '/', credentials))
# 连接管道
channel = connection.channel()
# 申明queue,如果在rabbitmq上已经添加了queue,则无需执行此步
# channel.queue_declare(queue="balance",durable=True)
# 向rabbitmq的queue中发送消息
i = 0
while(i < sys.maxsize):
channel.basic_publish(
exchange='',
routing_key='s_network_q',
body="["
+ str(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
+ "] _" + str(random.sample(alphabet, 10))
+ "_",
properties=pika.BasicProperties(delivery_mode=2,)
)
i += 1
print("[%s] Sent 'Hello world !'\t" % i)
time.sleep(3)
# 断开连接
connection.close()
revMQ.py
import pika
import time
username = "rbmq"
password = "123"
ip_addr = "xxx.xxx.xxx.xxx"
port_num = "5672"
credentials = pika.PlainCredentials(username, password)
connection = pika.BlockingConnection(pika.ConnectionParameters(ip_addr, port_num, '/', credentials))
channel = connection.channel()
def callback(ch, method, properties, body):
print(" [%s] Received %r" % (time.time(), body))
channel.basic_consume(queue='s_network_q',on_message_callback=callback,auto_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
TODO : Docker环境下部署RabbitMQ
https://blog.csdn.net/qq_36244204/article/details/89493693
https://www.rabbitmq.com/which-erlang.html
https://www.rabbitmq.com/install-generic-unix.html
https://github.com/rabbitmq/rabbitmq-server/releases?after=v3.7.17-rc.2