文档章节

RabbitMQ 系列之快速部署

张士滨
 张士滨
发布于 2017/07/11 15:49
字数 1283
阅读 21
收藏 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
Docker下RabbitMQ三部曲之一:极速体验(单机和集群)

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

boling_cavalry
2018/05/12
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.2K
3
阿里云Kubernetes SpringCloud 实践进行时(2): 分布式配置管理

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

osswangxining
2018/05/25
0
0
在Kubernetes上使用Sateful Set部署RabbitMQ集群

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

店家小二
2018/12/14
0
0

没有更多内容

加载失败,请刷新页面

加载更多

OSChina 周日乱弹 —— 我,小小编辑,食人族酋长

Osc乱弹歌单(2019)请戳(这里) 【今日歌曲】 @宇辰OSC :分享娃娃的单曲《飘洋过海来看你》: #今日歌曲推荐# 《飘洋过海来看你》- 娃娃 手机党少年们想听歌,请使劲儿戳(这里) @宇辰OSC...

小小编辑
今天
672
10
MongoDB系列-- SpringBoot 中对 MongoDB 的 基本操作

SpringBoot 中对 MongoDB 的 基本操作 Database 库的创建 首先 在MongoDB 操作客户端 Robo 3T 中 创建数据库: 增加用户User: 创建 Collections 集合(类似mysql 中的 表): 后面我们大部分都...

TcWong
今天
38
0
spring cloud

一、从面试题入手 1.1、什么事微服务 1.2、微服务之间如何独立通讯的 1.3、springCloud和Dubbo有哪些区别 1.通信机制:DUbbo基于RPC远程过程调用;微服务cloud基于http restFUL API 1.4、spr...

榴莲黑芝麻糊
今天
25
0
Executor线程池原理与源码解读

线程池为线程生命周期的开销和资源不足问题提供了解决方 案。通过对多个任务重用线程,线程创建的开销被分摊到了多个任务上。 线程实现方式 Thread、Runnable、Callable //实现Runnable接口的...

小强的进阶之路
昨天
71
0
maven 环境隔离

解决问题 即 在 resource 文件夹下面 ,新增对应的资源配置文件夹,对应 开发,测试,生产的不同的配置内容 <resources> <resource> <directory>src/main/resources.${deplo......

之渊
昨天
69
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部