文档章节

RabbitMQ 系列之快速部署

张士滨
 张士滨
发布于 2017/07/11 15:49
字数 1283
阅读 14
收藏 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
朝阳
私信 提问
RabbitMQ系列(五)使用Docker部署RabbitMQ集群

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

王磊的博客
2018/07/24
0
0
在Kubernetes上使用Sateful Set部署RabbitMQ集群

前面我们已经在Kubernetes上部署了Redis – 《在Kubernetes上使用Sateful Set部署Redis》。 本篇我们继续把RabbitMQ也跑在K8S上。 1.RabbitMQ的基础知识 在正式开始部署工作之前,我们先来复...

店家小二
2018/12/14
0
0
Docker下RabbitMQ三部曲之一:极速体验(单机和集群)

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

boling_cavalry
2018/05/12
0
0
阿里云Kubernetes SpringCloud 实践进行时(2): 分布式配置管理

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

osswangxining
2018/05/25
0
0
RabbitMQ 3.4.0 发布,AMQP 消息服务器

基于Erlang的高级消息队列RabbitMQ 3.4.0发布.新产品系列。2014-10-21。之前版本2014-08-11的3.3.5.遗留产品3.2.4/3.1.5 在高级消息队列里,RabbitMQ应该最主流的。 此版本的新特性主要有: 1...

fei
2014/10/22
5.1K
3

没有更多内容

加载失败,请刷新页面

加载更多

徒手撸一个简单的RPC框架

徒手撸一个简单的RPC框架 之前在牛逼哄哄的 RPC 框架,底层到底什么原理得知了RPC(远程过程调用)简单来说就是调用远程的服务就像调用本地方法一样,其中用到的知识有序列化和反序列化、动态...

不学无数的程序员
31分钟前
1
0
Java 面试题目最全集合1000+ 大放送,能答对70%就去BATJTMD试试~

2019,相对往年我们会发现今年猎头电话少了,大部分企业年终奖缩水,加薪幅度也不如往年,选择好offer就要趁早,现在开始准备吧,刷一波Java面试题,能回答70%就去BATJTMD大胆试试~ 以下是2...

mikechen优知
36分钟前
2
0
玩转Koa之核心原理分析

Koa作为下一代Web开发框架,不仅让我们体验到了async/await语法带来同步方式书写异步代码的酸爽,而且本身简洁的特点,更加利于开发者结合业务本身进行扩展。 本文从以下几个方面解读Koa源码...

前端小攻略
37分钟前
1
0
分布式之数据库和缓存双写一致性方案解析

为什么写这篇文章? 首先,缓存由于其高并发和高性能的特性,已经在项目中被广泛使用。在读取缓存方面,大家没啥疑问,都是按照下图的流程来进行业务操作。 ![] 但是在更新缓存方面,对于更新...

hensemlee
今天
5
0
怎么学习大数据

最近有很多人在找,大数据是怎么学?需要学什么技术以及这些技术的学习顺序是什么?今天有时间我把个问题总结成文章分享给大家。 那大数据处理技术怎么学习呢?首先我们要学习Java语言和Lin...

董黎明
今天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部