RabbitMQ的安装

安装erlang
yum –y install epel-release

rpm -ivh erlang-solutions-1.0-1.noarch.rpm

vim /etc/yum.repos.d/erlang_solutions.repo
把里面的内容更改为以下内容

[erlang-solutions] 
name=Centos $releasever - $basearch - Erlang Solutions baseurl=https://mirrors.tuna.tsinghua.edu.cn/erlang-solutions/centos/7/ 
gpgcheck=0 
gpgkey=http://packages.erlang-solutions.com/debian/erlang_solutions.asc 
enabled=1

yum -y install erlang

yum localinstall rabbitmq-server-3.8.3-1.el7.noarch.rpm

开启用户远程访问
vim /etc/rabbitmq/rabbitmq.config 创建rabbitmq.config
添加:

[{rabbit, [{loopback_users, []}]}].

#执行插件命令rabbitmq-plugins enable rabbitmq_management 开启管理后台的插件
rabbitmq-plugins enable rabbitmq_management

cd /usr/local/src/
wget https://dl.bintray.com/rabbitmq/communityplugins/rabbitmq_delayed_message_exchange-0.0.1.ez

cp rabbitmq_delayed_message_exchange-0.0.1-rmq3.5.x-9bf265e4.ez /usr/lib/rabbitmq/lib/rabbitmq_server-3.8.3/plugins/

rabbitmq-plugins enable rabbitmq_delayed_message_exchange
firewall-cmd --add-port=15672/tcp --permanent 
firewall-cmd --add-port=5672/tcp --permanent 
firewall-cmd --reload
systemctl status rabbitmq-server.service
systemctl start  rabbitmq-server.service

netstat -anpt | grep 15672

访问管理页面127.0.0.1:15672
通过默认账户 guest/guest 登录 如果能够登录,说明安装成功。

学习队列
yum -y install python-devel

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

pip install pika

cd /usr/local/src/
mkdir -p simplest
rabbitmq消息列队_第1张图片

1、简单队列
rabbitmq消息列队_第2张图片

2、工作队列WorkQueue 模型(消息轮流被多个消费者消费) 此时有两个消费者同时监听一个的队列。 轮询分发。
rabbitmq消息列队_第3张图片