Linux(Centos平台)RabbitMQ消息中间件服务器搭建

本篇结合接口测试平台部署来讲,不了解的请先查看我的另一篇文档,HttpRunnerManager接口测试平台部署在服务器上(Centos + python3.6 + Mysql5.7 + uwsgi + nginx)

https://www.cnblogs.com/Sandy-1128/p/HttpRunner-sandy-0323.html

 

RabbitMQ概念

RabbitMQ是流行的开源消息队列系统,是AMQP(Advanced Message Queuing Protocol高级消息队列协议)的标准实现,用erlang语言开发。RabbitMQ据说具有良好的性能和时效性,同时还能够非常好的支持集群和负载部署,非常适合在较大规模的分布式系统中使用

系统环境:

操作系统:CentOS7.3

erlang:OTP 19.3

rabbitmq:rabbitmq-server 3.6.6

 

1.安装erlang ,安装过程中会有提示,一路输入“y”即可

 

yum install erlang

 

2.安装RabbitMQ

先下载rpm:
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm

下载完成后安装

 

yum install rabbitmq-server-3.6.6-1.el7.noarch.rpm

 

完成后启动服务

 

service rabbitmq-server start

 

 

3.配置RabbitMQ

自己创建配置文件:
cd /etc/rabbitmq/
vim rabbitmq.config
编辑内容如下:
[{rabbit, [{loopback_users, []}]}].

 

这里的意思是开放使用,rabbitmq默认创建的用户guest,密码也是guest,这个用户默认只能是本机访问,localhost或者127.0.0.1,从外部访问需要添加上面的配置。

保存配置后重启服务:

service rabbitmq-server stop
service rabbitmq-server start

 

4.安装插件:

/sbin/rabbitmq-plugins enable rabbitmq_management

然后重启rabbitmq服务:
service rabbitmq-server restart

 

 

5.启动rabbitmq,有以下两种方法:

第一种方法是,直接运行rabbitmq-server命令

第二种方法是,运行service rabbitmq-server xxx命令。

 

service rabbitmq-server start #启动
service rabbitmq-server stop #停止
service rabbitmq-server restart #重启
service rabbitmq-server status #查看状态

 

 

启动rabbitmq后就可以通过http://ip:15672 使用guest,guest 进行登陆web页面

 

 

 要想启动定时任务,还需要启动worker

python3 manage.py celery -A HttpRunnerManager worker --loglevel=info  #启动worker
python3 manage.py celery beat --loglevel=info #启动定时任务监听器
Celery flower #启动任务监控后台

 

我们建立一个定时任务,执行完成后查看报告:

 

日志截图:

 

[2019-03-26 17:18:50,812: WARNING/Worker-2] INFO     render with html report template: /home/HttpRunnerManager-master/templates/extent_report_template.html
[2019-03-26 17:18:50,813: WARNING/Worker-2] INFO     render with html report template: /home/HttpRunnerManager-master/templates/extent_report_template.html
[2019-03-26 17:18:50,813: WARNING/Worker-2] INFO     render with html report template: /home/HttpRunnerManager-master/templates/extent_report_template.html
[2019-03-26 17:18:50,813: WARNING/Worker-2] INFO     render with html report template: /home/HttpRunnerManager-master/templates/extent_report_template.html
[2019-03-26 17:18:50,813: INFO/Worker-2] Start to render Html report ...
[2019-03-26 17:18:50,813: WARNING/Worker-2] INFO     Start to render Html report ...
[2019-03-26 17:18:50,813: WARNING/Worker-2] INFO     Start to render Html report ...
[2019-03-26 17:18:50,813: WARNING/Worker-2] INFO     Start to render Html report ...
[2019-03-26 17:18:50,814: WARNING/Worker-2] INFO     Start to render Html report ...
[2019-03-26 17:18:50,896: INFO/Worker-2] Generated Html report: /home/HttpRunnerManager-master/reports/1553591930.html
[2019-03-26 17:18:50,897: WARNING/Worker-2] INFO     Generated Html report: /home/HttpRunnerManager-master/reports/1553591930.html
[2019-03-26 17:18:50,897: WARNING/Worker-2] INFO     Generated Html report: /home/HttpRunnerManager-master/reports/1553591930.html
[2019-03-26 17:18:50,897: WARNING/Worker-2] INFO     Generated Html report: /home/HttpRunnerManager-master/reports/1553591930.html
[2019-03-26 17:18:50,897: WARNING/Worker-2] INFO     Generated Html report: /home/HttpRunnerManager-master/reports/1553591930.html
[2019-03-26 17:19:59,956: INFO/MainProcess] Writing entries (1)...
[2019-03-26 17:22:59,990: INFO/MainProcess] Writing entries (1)...
[2019-03-26 17:26:00,002: INFO/MainProcess] Writing entries (1)...

 

 

报告详情:

 

posted @ 2019-03-26 17:39  Sandy1128  阅读(269)  评论(0编辑  收藏  举报