RabbitMQ 系列之快速部署
RabbitMQ 系列之快速部署
张士滨 发表于9个月前
RabbitMQ 系列之快速部署
  • 发表于 9个月前
  • 阅读 8
  • 收藏 0
  • 点赞 0
  • 评论 0

【腾讯云】新注册用户域名抢购1元起>>>   

摘要: 消息队列服务 RabbitMQ

集群目标

通过 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
×
张士滨
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: