CentOS8.1中RabbitMQ的安裝


  Linux軟件包的安裝方法有很多,RabbitMQ也不例外,這里記錄一下官方強列推薦的安裝方法!

  首先進入RabbitMQ官方下載頁(https://www.rabbitmq.com/download.html),選擇合適你的操作系統的下載和安裝指引,我這邊是CentOS(請確保你的服務器能連上外網,否則請用離線安裝方式):

  進去后,我們根據說明,點進強列推薦的安裝方式(即使用Package Cloud上的Yum庫)的說明鏈接:

  由於Package Cloud簽發安裝包時使用的是他們自己的GPG key,雖然2018他們開始做Key遷移,但還是建設大家先導一下Package Cloud的Key:

  

# rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
# rpm --import https://packagecloud.io/gpg.key

  然后,因為RabbitMQ是由Erlang語言開發,RabbitMQ安裝包也依賴於Erlang,所以我們先根據提示安裝好Erlang相關的包:

# curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash

  然后再回過頭來根據提示安裝RabbitMQ:

# curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash

  當然,以后有新版本了,你還可以用下面的命令將RabbitMQ更新到最新版本(生產環境不要隨便更新升級哦!!!):

# yum install rabbitmq-server.noarch

  做完這些以后,安裝工作可以說是完成了!是不是很快!但是,我們后面還得做一下基本配置的和驗證的!

  安裝完后,我們設置RabbitMQ為開機啟動

# chkconfig rabbitmq-server on
# systemctl enable rabbitmq-server.service

  然后我們在 /etc/rabbitmq/ 目錄下新增一個環境配置文件 rabbitmq-env.conf 

# vim /etc/rabbitmq/rabbitmq-env.conf
NODENAME=rabbit@localhost

  接着嘗試啟動RabbitMQ服務:

# systemctl start rabbitmq-server

  最后查看一下RabbitMQ是否啟動成功:

# rabbitmqctl status
Error: unable to perform an operation on node 'rabbit@localhost'. Please see diagnostics information and suggestions below.

Most common reasons for this are:

 * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)
 * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)
 * Target node is not running

In addition to the diagnostics info below:

 * See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more
 * Consult server logs on node rabbit@localhost
 * If target node is configured to use long node names, don't forget to use --longnames with CLI tools

DIAGNOSTICS
===========

attempted to contact: [rabbit@localhost]

rabbit@localhost:
  * connected to epmd (port 4369) on localhost
  * epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic 
  * TCP connection succeeded but Erlang distribution failed 

  * Node name (or hostname) mismatch: node "rabbit@mqserver" believes its node name is not "rabbit@mqserver" but something else.
    All nodes and CLI tools must refer to node "rabbit@mqserver" using the same name the node itself uses (see its logs to find out what it is)


Current node details:
 * node name: 'rabbitmqcli-33080-rabbit@localhost'
 * effective user's home directory: /var/lib/rabbitmq
 * Erlang cookie hash: V4dlxLzzzHnrAyZ80UrlSg==

  結果報錯了!!!給出的可能原因的第一條是“Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)”,目標節點不可達!所謖的目標節點,就是我們在 /etc/rabbitmq/rabbitmq-env.conf 文件中配置的 rabbit@localhost ,進於步推測的原因是hostname解析問題,或防火牆問題

  我們先試將localhost這個主機名做一個host映射(映射的IP 192.168.0.108是我的,你要換成你自己的):

# echo 192.168.0.108 localhost >> /etc/hosts

  完了后,重啟一下RabbitMQ服務:

# systemctl restart rabbitmq-server

  再次查看一下RabbitMQ服務的狀態(竟然好了,果然是hostname解析的問題):

# rabbitmqctl status
Status of node rabbit@localhost ...
Runtime

OS PID: 33539
OS: Linux
Uptime (seconds): 23
RabbitMQ version: 3.8.7
Node name: rabbit@localhost
Erlang configuration: Erlang/OTP 23 [erts-11.0.3] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:64] [hipe]
Erlang processes: 276 used, 1048576 limit
Scheduler run queue: 1
Cluster heartbeat timeout (net_ticktime): 60

Plugins

Enabled plugin file: /etc/rabbitmq/enabled_plugins
Enabled plugins:


Data directory

Node data directory: /var/lib/rabbitmq/mnesia/rabbit@localhost
Raft data directory: /var/lib/rabbitmq/mnesia/rabbit@localhost/quorum/rabbit@localhost

Config files


Log file(s)

 * /var/log/rabbitmq/rabbit@localhost.log
 * /var/log/rabbitmq/rabbit@localhost_upgrade.log

Alarms

(none)

Memory

Total memory used: 0.0976 gb
Calculation strategy: rss
Memory high watermark setting: 0.4 of available memory, computed to: 0.7576 gb

other_proc: 0.0295 gb (30.22 %)
code: 0.0289 gb (29.62 %)
reserved_unallocated: 0.0191 gb (19.61 %)
other_system: 0.0126 gb (12.89 %)
other_ets: 0.0029 gb (2.95 %)
allocated_unused: 0.0023 gb (2.34 %)
atom: 0.0013 gb (1.37 %)
plugins: 0.0005 gb (0.47 %)
metrics: 0.0002 gb (0.2 %)
binary: 0.0002 gb (0.18 %)
mnesia: 0.0001 gb (0.08 %)
quorum_ets: 0.0 gb (0.05 %)
msg_index: 0.0 gb (0.03 %)
connection_channels: 0.0 gb (0.0 %)
connection_other: 0.0 gb (0.0 %)
connection_readers: 0.0 gb (0.0 %)
connection_writers: 0.0 gb (0.0 %)
mgmt_db: 0.0 gb (0.0 %)
queue_procs: 0.0 gb (0.0 %)
queue_slave_procs: 0.0 gb (0.0 %)
quorum_queue_procs: 0.0 gb (0.0 %)

File Descriptors

Total: 2, limit: 32671
Sockets: 0, limit: 29401

Free Disk Space

Low free disk space watermark: 0.05 gb
Free disk space: 12.3948 gb

Totals

Connection count: 0
Queue count: 0
Virtual host count: 1

Listeners

Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0

  至此使用官方推薦方法初步安裝RabbitMQ就算完成了!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM