linux-rabbitmq安裝使用(方式二)
技術標籤:linuxrabbitmqlinuxcentoscrypto
linux-rabbitmq安裝使用(方式二)
1、環境準備
RabbitMQ是由Erlang語言編寫的,因此在安裝RabbitMQ之前需要安裝Erlang。
https://www.erlang.org/downloads
下載otp_src_23.2.tar.gz到/opt/software目錄下
2、解壓安裝包,並配置安裝目錄
[[email protected] software]# tar -zxvf otp_src_23.2.tar.gz
[[email protected] software]# cd otp_src_23.2[[email protected] otp_src_23.2]# ./configure --prefix=/opt/erlang
3、依賴包安裝
如果在第二步的時候出現configure: error: No curses library functions found相關錯誤,請按照提示安裝對應的依賴,其他依賴類似
[[email protected] otp_src_23.2]# yum install ncurses-devel
4、安裝Erlang,make的時間可能比較長
[[email protected] otp_src_23.2]# make
[[email protected] otp_src_23.2]# make install
5、配置ERLANG_HOME
[[email protected] otp_src_23.2]# vim /etc/profile
# ERLANG_HOME
export ERLANG_HOME=/opt/erlang
export PATH=$PATH:$ERLANG_HOME/bin
使配置檔案生效並使用erl命令檢視
[[email protected] otp_src_23.2]# source /etc/profile
[[email protected] otp_src_23.2]# erlErlang/OTP 23 [erts-11.1.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]
6、下載RabbitMQ安裝包到/opt/softwate
https://github.com/rabbitmq/rabbitmq-server/releases
這裡選用的版本是
rabbitmq-server-generic-unix-3.8.11.tar.xz
7、解壓壓縮包到指定目錄
[[email protected] software]# xz -d rabbitmq-server-generic-unix-3.8.9.tar.xz
[[email protected] software]# tar -xvf rabbitmq-server-generic-unix-3.8.9.tar -C /opt
簡化目錄名稱
[[email protected] opt]# mv rabbitmq_server-3.8.9 rabbitmq
8、配置RabbitMQ環境變數
[[email protected] opt]# vim /etc/profile
#RABBITMQ_HOME
export RABBITMQ_HOME=/opt/rabbitmq
export PATH=$PATH:$RABBITMQ_HOME/sbin
使配置生效
[[email protected] opt]# source /etc/profile
9、嘗試啟動RabbitMQ,若出現下列資訊說明安裝成功了
[[email protected] opt]# rabbitmq-server
[[email protected] otp_src_23.2]# rabbitmq-server
Configuring logger redirection
## ## RabbitMQ 3.8.9
## ##
########## Copyright (c) 2007-2020 VMware, Inc. or its affiliates.
###### ##
########## Licensed under the MPL 2.0. Website: https://rabbitmq.com
Doc guides: https://rabbitmq.com/documentation.html
Support: https://rabbitmq.com/contact.html
Tutorials: https://rabbitmq.com/getstarted.html
Monitoring: https://rabbitmq.com/monitoring.html
Logs: /opt/rabbitmq/var/log/rabbitmq/[email protected]
/opt/rabbitmq/var/log/rabbitmq/[email protected]_upgrade.log
Config file(s): (none)
Starting broker... completed with 0 plugins.
10、異常情況解決
[[email protected] otp_src_23.2]# rabbitmq-server
{"init terminating in do_boot",{error,{crypto,{"no such file or directory","crypto.app"}}}}
init terminating in do_boot ({error,{crypto,{no such file or directory,crypto.app}}})
Crash dump is being written to: erl_crash.dump...done
[[email protected] ~]# rabbitmqctl status
Error: unable to perform an operation on node '[email protected]'. 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 [email protected]
* If target node is configured to use long node names, don't forget to use --longnames with CLI tools
DIAGNOSTICS
===========
attempted to contact: [[email protected]]
[email protected]:
* connected to epmd (port 4369) on localhost
* epmd reports: node 'rabbit' not running at all
no other nodes on localhost
* suggestion: start the node
Current node details:
* node name: '[email protected]'
* effective user's home directory: /root
* Erlang cookie hash: vOogHV5kjszkP3LUdJLpdw==
如果遇到上述錯誤,經過排查既不是埠號被佔用,erlang版本與rabbitmq版本也匹配的話。很大概率是編譯安裝erlang時出現問題了。
經過重新執行configure,發現如下片段
*********************************************************************
********************** APPLICATIONS DISABLED **********************
*********************************************************************
crypto : No usable OpenSSL found
jinterface : No Java compiler found
odbc : ODBC library - link check failed
ssh : No usable OpenSSL found
ssl : No usable OpenSSL found
*********************************************************************
*********************************************************************
********************** APPLICATIONS INFORMATION *******************
*********************************************************************
因為啟動rabbitmq時涉及到crypto,這裡crypto又涉及到OpenSSL,後面我嘗試安裝了openssl openssl-devel,然後重新make make install後。發現rabbitmq可以正常啟動了。
[[email protected] otp_src_23.2]# yum install openssl
[[email protected] otp_src_23.2]# yum install openssl-devel
11、以守護程序啟動RabbitMQ並檢視狀態
[[email protected] otp_src_23.2]# rabbitmq-server -detached
[[email protected] otp_src_23.2]# rabbitmqctl status
Status of node [email protected] ...
Runtime
OS PID: 61523
OS: Linux
Uptime (seconds): 33
Is under maintenance?: false
RabbitMQ version: 3.8.9
Node name: [email protected]
Erlang configuration: Erlang/OTP 23 [erts-11.1.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:64]
Erlang processes: 278 used, 1048576 limit
Scheduler run queue: 1
Cluster heartbeat timeout (net_ticktime): 60
Plugins
Enabled plugin file: /opt/rabbitmq/etc/rabbitmq/enabled_plugins
Enabled plugins:
Data directory
Node data directory: /opt/rabbitmq/var/lib/rabbitmq/mnesia/[email protected]
Raft data directory: /opt/rabbitmq/var/lib/rabbitmq/mnesia/[email protected]/quorum/[email protected]
Config files
Log file(s)
* /opt/rabbitmq/var/log/rabbitmq/[email protected]
* /opt/rabbitmq/var/log/rabbitmq/[email protected]_upgrade.log
Alarms
(none)
Memory
Total memory used: 0.09 gb
Calculation strategy: rss
Memory high watermark setting: 0.4 of available memory, computed to: 0.7632 gb
other_proc: 0.0341 gb (37.84 %)
code: 0.0249 gb (27.69 %)
other_system: 0.0124 gb (13.8 %)
allocated_unused: 0.0083 gb (9.21 %)
reserved_unallocated: 0.0054 gb (6.04 %)
other_ets: 0.0028 gb (3.06 %)
atom: 0.0014 gb (1.52 %)
plugins: 0.0002 gb (0.27 %)
metrics: 0.0002 gb (0.22 %)
binary: 0.0002 gb (0.18 %)
mnesia: 0.0001 gb (0.09 %)
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: 927
Sockets: 0, limit: 832
Free Disk Space
Low free disk space watermark: 0.05 gb
Free disk space: 14.7559 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
12、新增使用者、設定許可權、設定角色
[[email protected] otp_src_23.2]# rabbitmqctl add_user dev dev
Adding user “dev” …
[[email protected] otp_src_23.2]# rabbitmqctl set_permissions -p / dev “." ".” “.*”
Setting permissions for user “dev” in vhost “/” …
[[email protected] otp_src_23.2]# rabbitmqctl set_user_tags dev administrator
Setting tags for user “dev” to [administrator] …
13、啟動web外掛
[[email protected] otp_src_23.2]# rabbitmq-plugins list
Listing plugins with pattern ".*" ...
Configured: E = explicitly enabled; e = implicitly enabled
| Status: * = running on [email protected]
|/
[ ] rabbitmq_amqp1_0 3.8.9
[ ] rabbitmq_auth_backend_cache 3.8.9
[ ] rabbitmq_auth_backend_http 3.8.9
[ ] rabbitmq_auth_backend_ldap 3.8.9
[ ] rabbitmq_auth_backend_oauth2 3.8.9
[ ] rabbitmq_auth_mechanism_ssl 3.8.9
[ ] rabbitmq_consistent_hash_exchange 3.8.9
[ ] rabbitmq_event_exchange 3.8.9
[ ] rabbitmq_federation 3.8.9
[ ] rabbitmq_federation_management 3.8.9
[ ] rabbitmq_jms_topic_exchange 3.8.9
[ ] rabbitmq_management 3.8.9
[ ] rabbitmq_management_agent 3.8.9
[ ] rabbitmq_mqtt 3.8.9
[ ] rabbitmq_peer_discovery_aws 3.8.9
[ ] rabbitmq_peer_discovery_common 3.8.9
[ ] rabbitmq_peer_discovery_consul 3.8.9
[ ] rabbitmq_peer_discovery_etcd 3.8.9
[ ] rabbitmq_peer_discovery_k8s 3.8.9
[ ] rabbitmq_prometheus 3.8.9
[ ] rabbitmq_random_exchange 3.8.9
[ ] rabbitmq_recent_history_exchange 3.8.9
[ ] rabbitmq_sharding 3.8.9
[ ] rabbitmq_shovel 3.8.9
[ ] rabbitmq_shovel_management 3.8.9
[ ] rabbitmq_stomp 3.8.9
[ ] rabbitmq_top 3.8.9
[ ] rabbitmq_tracing 3.8.9
[ ] rabbitmq_trust_store 3.8.9
[ ] rabbitmq_web_dispatch 3.8.9
[ ] rabbitmq_web_mqtt 3.8.9
[ ] rabbitmq_web_mqtt_examples 3.8.9
[ ] rabbitmq_web_stomp 3.8.9
[ ] rabbitmq_web_stomp_examples 3.8.9
[[email protected] otp_src_23.2]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node [email protected]:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to [email protected]...
The following plugins have been enabled:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
started 3 plugins.
14、通過web介面進行管理
通過ip:15672開啟web管理介面,使用剛才建立的dev dev進行登陸。guest guset預設只能本地登入。
15、至此,整個安裝過程基本完成,以及安裝過程中遇到的問題得到解決。
小尾巴~~
只要有積累,就會有進步