文档章节

RabbitMQ 系列之快速部署

张士滨
 张士滨
发布于 2017/07/11 15:49
字数 1283
阅读 12
收藏 0

集群目标

通过 Erlang 的分布式特性(magic cookie 认证节点)进行 RabbitMQ 集群,各 RabbitMQ 服务为对等节点,即每个节点都提供服务给客户端连接,进行消息发送与接收。 这些节点通过镜像队列进行消息队列结构复制。只要有任何一个节点能够工作,RabbitMQ 集群对外就能提供服务。 ###安装环境

  • CentOS 7.2,64位
  • RabbitMQ 3.6.10
  • HAProxy 1.7.8   RabbitMQ两台机器两个节点,HAProxy 用于对外提供 RabbitMQ 负载均衡服务。 ###1. 安装erlang 下载最新版http://www.rabbitmq.com/releases/erlang/ 输入图片说明
[root@izwz96fsxeqvr01uj5tfpnz software]# wget http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm
--2017-07-11 15:21:08--  http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm
Resolving www.rabbitmq.com (www.rabbitmq.com)... 192.240.153.117
Connecting to www.rabbitmq.com (www.rabbitmq.com)|192.240.153.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18580960 (18M) [application/x-redhat-package-manager]
Saving to: ‘erlang-19.0.4-1.el7.centos.x86_64.rpm’

100%[====================================================================================================================================================================================================================================>] 18,580,960  2.97MB/s   in 8.7s   

2017-07-11 15:21:17 (2.04 MB/s) - ‘erlang-19.0.4-1.el7.centos.x86_64.rpm’ saved [18580960/18580960]

[root@izwz96fsxeqvr01uj5tfpnz software]# rpm -ivh erlang-19.0.4-1.el7.centos.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:erlang-19.0.4-1.el7.centos       ################################# [100%]
[root@izwz96fsxeqvr01uj5tfpnz software]# erl
Erlang/OTP 19 [erts-8.0.3] [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.0.3  (abort with ^G)
1> 


###2. 安装rabbitmq 下载最新版3.6.10 http://www.rabbitmq.com/download.html

[root@izwz96fsxeqvr01uj5tfpnz software]# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
--2017-07-11 15:31:32--  http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
Resolving www.rabbitmq.com (www.rabbitmq.com)... 192.240.153.117
Connecting to www.rabbitmq.com (www.rabbitmq.com)|192.240.153.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4930939 (4.7M) [application/x-redhat-package-manager]
Saving to: ‘rabbitmq-server-3.6.10-1.el7.noarch.rpm’

100%[====================================================================================================================================================================================================================================>] 4,930,939   1.43MB/s   in 3.3s   

2017-07-11 15:31:35 (1.43 MB/s) - ‘rabbitmq-server-3.6.10-1.el7.noarch.rpm’ saved [4930939/4930939]
[root@izwz96fsxeqvr01uj5tfpnz software]#  rpm -ivh rabbitmq-server-3.6.10-1.el7.noarch.rpm 
warning: rabbitmq-server-3.6.10-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 6026dfca: NOKEY
error: Failed dependencies:
	socat is needed by rabbitmq-server-3.6.10-1.el7.noarch

--提示错误(rpm不支持自动依赖解析,换yum来安装)

[root@izwz96fsxeqvr01uj5tfpnz software]#  yum install -y socat 
Loaded plugins: fastestmirror
base                                                                                                                                                                                                                                                   | 3.6 kB  00:00:00     
epel                                                                                                                                                                                                                                                   | 4.3 kB  00:00:00     
extras                                                                                                                                                                                                                                                 | 3.4 kB  00:00:00     
updates                                                                                                                                                                                                                                                | 3.4 kB  00:00:00     
(1/4): extras/7/x86_64/primary_db                                                                                                                                                                                                                      | 188 kB  00:00:00     
(2/4): epel/x86_64/updateinfo                                                                                                                                                                                                                          | 789 kB  00:00:00     
(3/4): epel/x86_64/primary_db                                                                                                                                                                                                                          | 4.8 MB  00:00:01     
(4/4): updates/7/x86_64/primary_db                                                                                                                                                                                                                     | 7.7 MB  00:00:02     
Loading mirror speeds from cached hostfile
Error: Nothing to do
[root@izwz96fsxeqvr01uj5tfpnz software]#  rpm -ivh rabbitmq-server-3.6.10-1.el7.noarch.rpm 
warning: rabbitmq-server-3.6.10-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 6026dfca: NOKEY
error: Failed dependencies:
	socat is needed by rabbitmq-server-3.6.10-1.el7.noarch
[root@izwz96fsxeqvr01uj5tfpnz software]# yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm 
Loaded plugins: fastestmirror
Examining rabbitmq-server-3.6.10-1.el7.noarch.rpm: rabbitmq-server-3.6.10-1.el7.noarch
Marking rabbitmq-server-3.6.10-1.el7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package rabbitmq-server.noarch 0:3.6.10-1.el7 will be installed
--> Processing Dependency: socat for package: rabbitmq-server-3.6.10-1.el7.noarch
Loading mirror speeds from cached hostfile
--> Running transaction check
---> Package socat.x86_64 0:1.7.2.2-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================================================
 Package                                                        Arch                                                  Version                                                       Repository                                                                           Size
==============================================================================================================================================================================================================================================================================
Installing:
 rabbitmq-server                                                noarch                                                3.6.10-1.el7                                                  /rabbitmq-server-3.6.10-1.el7.noarch                                                5.3 M
Installing for dependencies:
 socat                                                          x86_64                                                1.7.2.2-5.el7                                                 base                                                                                255 k

Transaction Summary
==============================================================================================================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total size: 5.6 M
Total download size: 255 k
Installed size: 6.2 M
Is this ok [y/d/N]: y
Downloading packages:
socat-1.7.2.2-5.el7.x86_64.rpm                                                                                                                                                                                                                         | 255 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : socat-1.7.2.2-5.el7.x86_64                                                                                                                                                                                                                                 1/2 
  Installing : rabbitmq-server-3.6.10-1.el7.noarch                                                                                                                                                                                                                        2/2 
  Verifying  : socat-1.7.2.2-5.el7.x86_64                                                                                                                                                                                                                                 1/2 
  Verifying  : rabbitmq-server-3.6.10-1.el7.noarch                                                                                                                                                                                                                        2/2 

Installed:
  rabbitmq-server.noarch 0:3.6.10-1.el7                                                                                                                                                                                                                                       

Dependency Installed:
  socat.x86_64 0:1.7.2.2-5.el7                                                                                                                                                                                                                                                

Complete!

###3. 启动rabbitmq

[root@izwz96fsxeqvr01uj5tfpnz software]# service rabbitmq-server start
Redirecting to /bin/systemctl start  rabbitmq-server.service
[root@izwz96fsxeqvr01uj5tfpnz software]# rabbitmqctl -q status
[{pid,3290},
 {running_applications,
     [{rabbit,"RabbitMQ","3.6.10"},
      {mnesia,"MNESIA  CXC 138 12","4.14"},
      {ranch,"Socket acceptor pool for TCP protocols.","1.3.0"},
      {ssl,"Erlang/OTP SSL application","8.0.1"},
      {public_key,"Public key infrastructure","1.2"},
      {crypto,"CRYPTO","3.7"},
      {os_mon,"CPO  CXC 138 46","2.4.1"},
      {rabbit_common,
          "Modules shared by rabbitmq-server and rabbitmq-erlang-client",
          "3.6.10"},
      {xmerl,"XML parser","1.3.11"},
      {syntax_tools,"Syntax tools","2.0"},
      {compiler,"ERTS  CXC 138 10","7.0.1"},
      {asn1,"The Erlang ASN1 compiler version 4.0.3","4.0.3"},
      {sasl,"SASL  CXC 138 11","3.0"},
      {stdlib,"ERTS  CXC 138 10","3.0.1"},
      {kernel,"ERTS  CXC 138 10","5.0.1"}]},
 {os,{unix,linux}},
 {erlang_version,
     "Erlang/OTP 19 [erts-8.0.3] [source] [64-bit] [smp:2:2] [async-threads:64] [hipe] [kernel-poll:true]\n"},
 {memory,
     [{total,54492856},
      {connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,0},
      {queue_procs,2832},
      {queue_slave_procs,0},
      {plugins,0},
      {other_proc,22288944},
      {mnesia,61584},
      {metrics,184080},
      {mgmt_db,0},
      {msg_index,43992},
      {other_ets,2135584},
      {binary,32728},
      {code,21154371},
      {atom,891849},
      {other_system,7878140}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1590040985},
 {disk_free_limit,50000000},
 {disk_free,34632982528},
 {file_descriptors,
     [{total_limit,924},{total_used,2},{sockets_limit,829},{sockets_used,0}]},
 {processes,[{limit,1048576},{used,147}]},
 {run_queue,0},
 {uptime,17},
 {kernel,{net_ticktime,60}}]

###4.安装rabbitmq管理工具

[root@izwz96fsxeqvr01uj5tfpnz ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
  amqp_client
  cowlib
  cowboy
  rabbitmq_web_dispatch
  rabbitmq_management_agent
  rabbitmq_management

Applying plugin configuration to rabbit@izwz96fsxeqvr01uj5tfpnz... started 6 plugins.

rabbitmq常用命令大全

  • 查看所有队列信息 rabbitmqctl list_queues

  • 关闭应用 rabbitmqctl stop_app

  • 启动应用,和上述关闭命令配合使用,达到清空队列的目的

    rabbitmqctl start_app

  • 清除所有队列

rabbitmqctl reset

  • 更多用法及参数,可以执行如下命令查看

rabbitmqctl查看所有队列信息

  • rabbitmqctl list_queues
  • 关闭应用

rabbitmqctl stop_app

  • 启动应用,和上述关闭命令配合使用,达到清空队列的目的

rabbitmqctl start_app

  • 清除所有队列

rabbitmqctl reset

  • 更多用法及参数,可以执行如下命令查看

  • rabbitmqctl查看所有队列信息

    rabbitmqctl list_queues

  • 关闭应用

rabbitmqctl stop_app

  • 启动应用,和上述关闭命令配合使用,达到清空队列的目的

    rabbitmqctl start_app

  • 清除所有队列

rabbitmqctl reset

  • 更多用法及参数,可以执行如下命令查看

rabbitmqctl

  • 卸载

    rpm -qa|grep rabbitmq

再选择一台主机也同样的方式安装一遍备用。

下集预告- rabbitmq集群配置

© 著作权归作者所有

共有 人打赏支持
张士滨
粉丝 1
博文 3
码字总数 2491
作品 0
朝阳
Docker下RabbitMQ三部曲之一:极速体验(单机和集群)

从本章开始,我们一起在Docker环境实战RabbitMQ环境部署和对应的Java开发,当前是《Docker下RabbitMQ三部曲》系列的第一篇,整个三部曲由以下三篇文章组成: 1. 第一篇,即本章,我们用最快的...

boling_cavalry
05/12
0
0
RabbitMQ系列(五)使用Docker部署RabbitMQ集群

使用Docker部署RabbitMQ集群 RabbitMQ系列文章 RabbitMQ在Ubuntu上的环境搭建 深入了解RabbitMQ工作原理及简单使用 RabbitMQ交换器Exchange介绍与实践 RabbitMQ事务和Confirm发送方消息确认—...

王磊的博客
07/24
0
0
阿里云Kubernetes SpringCloud 实践进行时(2): 分布式配置管理

简介 为了更好地支撑日益增长的庞大业务量,我们常常需要把服务进行整合、拆分,使我们的服务不仅能通过集群部署抵挡流量的冲击,又能根据业务在其上进行灵活的扩展。随着分布式的普及、服务...

osswangxining
05/25
0
0
SpringBoot | 第十二章:RabbitMQ的集成和使用

前言 上节讲了缓存数据库的使用,在实际工作中,一般上在系统或者应用间通信或者进行异步通知(登录后发送短信或者邮件等)时,都会使用消息队列进行解决此业务场景的解耦问题。这章节讲解下消...

oKong
07/25
0
0
RabbitMQ 实战教程 文集

RabbitMQ 实战教程 文集 此系列博客经梁总(梁桂钊的博客)授权录入本站点,下面推荐下梁总的技术公众号【服务端的思维】,公众号不定时更新技术文章,干货满满!! RabbitMQ 实战教程(一) He...

chenssy
10/06
0
0

没有更多内容

加载失败,请刷新页面

加载更多

5whys分析法在美团工程师中的实践

前言 网站的质量和稳定性对于用户和公司来说至关重要,但是在网站的快速发展过程中,由于各种原因导致事故不可避免的发生,这些大大小小的事故对公司难免会造成一些负面的影响,为了避免同类...

Skqing
20分钟前
0
0
Android 接收监听开机完成,并且开机自启动

1,定义一个广播接收者的类 ,并重写抽象方法 public class BootCompleteReceiver extends BroadcastReceiver 2,在Androidmanifest 注册 <receiver android:name=".receiver.BootCompleteRece......

lanyu96
23分钟前
1
0
小程序记录

1、button的边框、角等需要在伪元素after修改去除

originDu
25分钟前
0
0
微博什么技术啊……还说支持八个明星并发出轨,结果…

是的,大家可能都知道了,女神张靓颖结婚了。。 我去,写错了,是————赵丽颖。 为什么我头脑一瞬间出现的是张靓颖,作为一个码农,技术宅,拼音缩小都是 ZLY,博主我真有点傻傻分不清楚了...

Java技术栈
26分钟前
3
0
模块化

1,什么是模块化? 模块化是指将一个复杂的系统分解为多个模块,方便编码。 2,为什么要用模块化? 降低复杂性,降低代码耦合度,部署方便,提高效率。 3,模块化的好处? a,避免命名冲突,减少...

羊皮卷
26分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部