首頁 > 軟體

CentOS7下安裝RabbitMQ

2020-06-16 17:29:17

由於在CentOS環境安裝RabbitMQ 極度麻煩,所以要寫下這個過程,以免以後忘記再次麻煩多一次。

由於 RabbitMQ 使用通過 Erlang 來開發的,需要需要安裝Erlang 然而在安裝Erlang 又一大波依賴需要安裝,而且這些依賴不在CentOS 預設的yum 庫中。所以就鬱悶了。

我這次全程都會使用yum來按照,所以準備好yum

首先呢 噁心一下 先嘗試來安裝 erlang

新增Erlang Solutions key 支援

[root@localhost ~]# rpm --import http://binaries.erlang-solutions.com/debian/erlang_solutions.asc 

[root@localhost ~]# wget http://binaries.erlang-solutions.com/rpm/centos/erlang_solutions.repo  
--2016-11-04 11:45:16--  http://binaries.erlang-solutions.com/rpm/centos/erlang_solutions.repo
正在解析主機 binaries.erlang-solutions.com (binaries.erlang-solutions.com)... 31.172.186.53
正在連線 binaries.erlang-solutions.com (binaries.erlang-solutions.com)|31.172.186.53|:80... 已連線。
已發出 HTTP 請求,正在等待回應... 302 Found
位置:http://packages.erlang-solutions.com/rpm/centos/erlang_solutions.repo [跟隨至新的 URL]
--2016-11-04 11:45:16--  http://packages.erlang-solutions.com/rpm/centos/erlang_solutions.repo
正在解析主機 packages.erlang-solutions.com (packages.erlang-solutions.com)... 31.172.186.53
再次使用存在的到 binaries.erlang-solutions.com:80 的連線。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:245
正在儲存至: “erlang_solutions.repo”

100%[=====================================>] 245         --.-K/s 用時 0s      

2016-11-04 11:45:18 (49.7 MB/s) - 已儲存 “erlang_solutions.repo” [245/245])

[root@localhost ~]# mv erlang_solutions.repo /etc/yum.repos.d/ 

因為由於centos 原來的庫沒有erlang所需的依賴 所以安裝一下 RPMforge 但是我看了一下 CentOS 官網 發現 他們已經不推薦使用RPMfoge 也告訴我們這個專案已經沒有繼續維護了,因為我在很多個渠道中也無法獲得這個rpm檔案 然後看了一下CentOS 所推薦的第三方庫 然後我選擇了這個:

http://rpmfusion.org/Configuration

那我就用了這個rmpfusion 這個第三方庫。在安裝之前需要按安裝一下它所依賴的epel-release 所以先yum 一下

[root@localhost ~]# yum install epel-release
已載入外掛:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.cn99.com
正在解決依賴關係
--> 正在檢查事務
---> 軟體包 epel-release.noarch.0.7-6 將被 安裝
--> 解決依賴關係完成

依賴關係解決

===============================================================================
 Package                架構             版本           源                大小
===============================================================================
正在安裝:
 epel-release           noarch           7-6            extras            14 k

事務概要
===============================================================================
安裝  1 軟體包

總下載量:14 k
安裝大小:24 k
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/extras/packages/epel-release-7-6.noarch.rpm: 頭V3 RSA/SHA256 Signature, 金鑰 ID f4a80eb5: NOKEY
epel-release-7-6.noarch.rpm 的公鑰尚未安裝
epel-release-7-6.noarch.rpm                               |  14 kB   00:00     
從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 檢索金鑰
匯入 GPG key 0xF4A80EB5:
 使用者ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指紋       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 軟體包     : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@anaconda)
 來自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
是否繼續?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安裝    : epel-release-7-6.noarch                                    1/1 
  驗證中      : epel-release-7-6.noarch                                    1/1 

已安裝:
  epel-release.noarch 0:7-6                                                    

完畢!

然後開始安裝 rpmfusion :

[root@localhost ~]# rpm -ivh https://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm
獲取https://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm
警告:/var/tmp/rpm-tmp.maBr5M: 頭V3 RSA/SHA256 Signature, 金鑰 ID 849c449f: NOKEY
準備中...                          ################################# [100%]
正在升級/安裝...
   1:rpmfusion-free-release-6-1       ################################# [100%]

然後開始按照 erlang

[root@localhost ~]# yum install erlang

其實什麼要搞這麼多東西不直接了當安裝erlang 我也想啊 但是CentOS本來的yum 沒有erlang所依賴的東西啊。所以要安裝一下第三方庫。

所需要的第三方庫【這個可以了解一下不用命令去下載 yum install erlang 會自動下載所需的庫的】:

unixODBC | unixODBC-devel | wxBase | wxGTK | SDL | wxGTK-gl

安裝後提示安裝了這些依賴:

  SDL.x86_64 0:1.2.15-14.el7                                                   
  erlang-asn1.x86_64 0:19.1-1.el7.centos                                       
  erlang-common_test.x86_64 0:19.1-1.el7.centos                                
  erlang-compiler.x86_64 0:19.1-1.el7.centos                                   
  erlang-cosEvent.x86_64 0:19.1-1.el7.centos                                   
  erlang-cosEventDomain.x86_64 0:19.1-1.el7.centos                             
  erlang-cosFileTransfer.x86_64 0:19.1-1.el7.centos                            
  erlang-cosNotification.x86_64 0:19.1-1.el7.centos                            
  erlang-cosProperty.x86_64 0:19.1-1.el7.centos                                
  erlang-cosTime.x86_64 0:19.1-1.el7.centos                                    
  erlang-cosTransactions.x86_64 0:19.1-1.el7.centos                            
  erlang-crypto.x86_64 0:19.1-1.el7.centos                                     
  erlang-debugger.x86_64 0:19.1-1.el7.centos                                   
  erlang-dialyzer.x86_64 0:19.1-1.el7.centos                                   
  erlang-diameter.x86_64 0:19.1-1.el7.centos                                   
  erlang-edoc.x86_64 0:19.1-1.el7.centos                                       
  erlang-eldap.x86_64 0:19.1-1.el7.centos                                      
  erlang-erl_docgen.x86_64 0:19.1-1.el7.centos                                 
  erlang-erl_interface.x86_64 0:19.1-1.el7.centos                              
  erlang-erts.x86_64 0:19.1-1.el7.centos                                       
  erlang-et.x86_64 0:19.1-1.el7.centos                                         
  erlang-eunit.x86_64 0:19.1-1.el7.centos                                      
  erlang-examples.x86_64 0:19.1-1.el7.centos                                   
  erlang-gs.x86_64 0:19.1-1.el7.centos                                         
  erlang-hipe.x86_64 0:19.1-1.el7.centos                                       
  erlang-ic.x86_64 0:19.1-1.el7.centos                                         
  erlang-inets.x86_64 0:19.1-1.el7.centos                                      
  erlang-jinterface.x86_64 0:19.1-1.el7.centos                                 
  erlang-kernel.x86_64 0:19.1-1.el7.centos                                     
  erlang-megaco.x86_64 0:19.1-1.el7.centos                                     
  erlang-mnesia.x86_64 0:19.1-1.el7.centos                                     
  erlang-observer.x86_64 0:19.1-1.el7.centos                                   
  erlang-odbc.x86_64 0:19.1-1.el7.centos                                       
  erlang-orber.x86_64 0:19.1-1.el7.centos                                      
  erlang-os_mon.x86_64 0:19.1-1.el7.centos                                     
  erlang-otp_mibs.x86_64 0:19.1-1.el7.centos                                   
  erlang-parsetools.x86_64 0:19.1-1.el7.centos                                 
  erlang-percept.x86_64 0:19.1-1.el7.centos                                    
  erlang-public_key.x86_64 0:19.1-1.el7.centos                                 
  erlang-reltool.x86_64 0:19.1-1.el7.centos                                    
  erlang-runtime_tools.x86_64 0:19.1-1.el7.centos                              
  erlang-sasl.x86_64 0:19.1-1.el7.centos                                       
  erlang-snmp.x86_64 0:19.1-1.el7.centos                                       
  erlang-ssh.x86_64 0:19.1-1.el7.centos                                        
  erlang-ssl.x86_64 0:19.1-1.el7.centos                                        
  erlang-stdlib.x86_64 0:19.1-1.el7.centos                                     
  erlang-syntax_tools.x86_64 0:19.1-1.el7.centos                               
  erlang-tools.x86_64 0:19.1-1.el7.centos                                      
  erlang-typer.x86_64 0:19.1-1.el7.centos                                      
  erlang-wx.x86_64 0:19.1-1.el7.centos                                         
  erlang-xmerl.x86_64 0:19.1-1.el7.centos                                      
  tcl.x86_64 1:8.5.13-8.el7                                                    
  tk.x86_64 1:8.5.13-6.el7                                                     
  unixODBC.x86_64 0:2.3.1-11.el7                                               
  wxBase.x86_64 0:2.8.12-20.el7                                                
  wxGTK.x86_64 0:2.8.12-20.el7                                                 
  wxGTK-gl.x86_64 0:2.8.12-20.el7 

最後下載好你的rabbitMQ rpm 或者你可以直接使用yum 安裝也可以 我就懶得搞直接用rpm的方式去安裝算了。

然後提示我需要另外一個依賴 socat 然後繼續yum 一下:

[root@localhost ~]# rpm -ivh  http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.5/rabbitmq-server-3.6.5-1.noarch.rpm
獲取http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.5/rabbitmq-server-3.6.5-1.noarch.rpm
警告:/var/tmp/rpm-tmp.gNKhnj: 頭V4 RSA/SHA1 Signature, 金鑰 ID 6026dfca: NOKEY
錯誤:依賴檢測失敗:
    socat 被 rabbitmq-server-3.6.5-1.noarch 需要
[root@localhost ~]# yum install socat
已載入外掛:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.aliyun.com
 * rpmfusion-free-updates: mirror.bjtu.edu.cn
 * updates: mirrors.cn99.com
正在解決依賴關係
--> 正在檢查事務
---> 軟體包 socat.x86_64.0.1.7.2.2-5.el7 將被 安裝
--> 解決依賴關係完成

依賴關係解決

===============================================================================
 Package         架構             版本                    源              大小
===============================================================================
正在安裝:
 socat           x86_64           1.7.2.2-5.el7           base           255 k

事務概要
===============================================================================
安裝  1 軟體包

總下載量:255 k
安裝大小:924 k
Is this ok [y/d/N]: y
Downloading packages:
socat-1.7.2.2-5.el7.x86_64.rpm                            | 255 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安裝    : socat-1.7.2.2-5.el7.x86_64                                 1/1 
  驗證中      : socat-1.7.2.2-5.el7.x86_64                                 1/1 

已安裝:
  socat.x86_64 0:1.7.2.2-5.el7                                                 

完畢!

然後安裝:

[root@localhost ~]# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.5/rabbitmq-server-3.6.5-1.noarch.rpm
--2016-11-04 14:13:10--  http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.5/rabbitmq-server-3.6.5-1.noarch.rpm
正在解析主機 www.rabbitmq.com (www.rabbitmq.com)... 192.240.153.117
正在連線 www.rabbitmq.com (www.rabbitmq.com)|192.240.153.117|:80... 已連線。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:5520417 (5.3M) [application/x-RedHat-package-manager]
正在儲存至: “rabbitmq-server-3.6.5-1.noarch.rpm”

100%[=====================================>] 5,520,417    113KB/s 用時 82s    

2016-11-04 14:14:34 (65.9 KB/s) - 已儲存 “rabbitmq-server-3.6.5-1.noarch.rpm” [5520417/5520417])

[root@localhost ~]# rpm -ivh rabbitmq-server-3.6.5-1.noarch.rpm 
警告:rabbitmq-server-3.6.5-1.noarch.rpm: 頭V4 RSA/SHA1 Signature, 金鑰 ID 6026dfca: NOKEY
準備中...                          ################################# [100%]
正在升級/安裝...
   1:rabbitmq-server-3.6.5-1          ################################# [100%]

啟動一下服務:

[root@localhost ~]# service rabbitmq-server start
Starting rabbitmq-server (via systemctl):                  [  確定  ]
[root@localhost ~]# rabbitmqctl status
Status of node rabbit@localhost ...
[{pid,111980},
 {running_applications,[{rabbit,"RabbitMQ","3.6.5"},
                        {mnesia,"MNESIA  CXC 138 12","4.14.1"},
                        {ranch,"Socket acceptor pool for TCP protocols.",
                               "1.2.1"},
                        {rabbit_common,[],"3.6.5"},
                        {os_mon,"CPO  CXC 138 46","2.4.1"},
                        {xmerl,"XML parser","1.3.12"},
                        {sasl,"SASL  CXC 138 11","3.0.1"},
                        {stdlib,"ERTS  CXC 138 10","3.1"},
                        {kernel,"ERTS  CXC 138 10","5.1"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang/OTP 19 [erts-8.1] [source-77fb4f8] [64-bit] [async-threads:64] [hipe] [kernel-poll:true]n"},
 {memory,[{total,44257520},
          {connection_readers,0},
          {connection_writers,0},
          {connection_channels,0},
          {connection_other,0},
          {queue_procs,2688},
          {queue_slave_procs,0},
          {plugins,0},
          {other_proc,18667352},
          {mnesia,58168},
          {mgmt_db,0},
          {msg_index,39080},
          {other_ets,947536},
          {binary,20448},
          {code,17857909},
          {atom,752561},
          {other_system,5911778}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,765403136},
 {disk_free_limit,50000000},
 {disk_free,25630208000},
 {file_descriptors,[{total_limit,924},
                    {total_used,2},
                    {sockets_limit,829},
                    {sockets_used,0}]},
 {processes,[{limit,1048576},{used,137}]},
 {run_queue,0},
 {uptime,14},
 {kernel,{net_ticktime,60}}]
[root@localhost ~]# 

然後就沒有然後了。

CentOS 5.6 安裝RabbitMQ http://www.linuxidc.com/Linux/2013-02/79508.htm

RabbitMQ用戶端C++安裝詳細記錄 http://www.linuxidc.com/Linux/2012-02/53521.htm

Python嘗試RabbitMQ http://www.linuxidc.com/Linux/2011-12/50653.htm

RabbitMQ叢集環境生產範例部署 http://www.linuxidc.com/Linux/2012-10/72720.htm

CentOS7環境安裝使用專業的訊息佇列產品RabbitMQ http://www.linuxidc.com/Linux/2016-11/13673.htm

在CentOS上安裝RabbitMQ流程 http://www.linuxidc.com/Linux/2011-12/49610.htm

RabbitMQ概念及環境搭建 http://www.linuxidc.com/Linux/2014-12/110449.htm

RabbitMQ入門教學  http://www.linuxidc.com/Linux/2015-02/113983.htm


IT145.com E-mail:sddin#qq.com