安裝環境: Alibaba Cloud Linux
安裝erlang命令:
rpm --import https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
yum install erlang -y
查看erl版本命令:
erl -version
查看具體erl的版本命令:
erl
會出現以下信息:
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe] Eshell V10.4.4 (abort with ^G)
將看到Erlang/OTP 22這樣一行信息,說明erlang版本為Erlang/OTP 22
然后通過 https://www.rabbitmq.com/which-erlang.html 找到對應兼容rabbitmq的版本號,然后選擇版本進行下載rabbitmq,我這邊下載的rabbmit版本號為3.8.3
下載rabbitmq命令:
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.3/rabbitmq-server-3.8.3-1.el7.noarch.rpm
安裝rabbitmq命令:
yum install -y rabbitmq-server-3.8.3-1.el7.noarch.rpm
啟動rabbitmq命令:
rabbitmqctl start_app
開啟rabbitmq界面管理命令:
rabbitmq-plugins enable rabbitmq_management
添加新用戶命令(第一個admin為賬戶名,第二個admin為密碼):
rabbitmqctl add_user admin admin
給admin用戶添加標簽命令:
rabbitmqctl set_user_tags admin administrator
給admin用戶授權命令:
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
關閉rabbitmq命令:
rabbitmqctl stop
開啟rabbitmq命令:
rabbitmqctl start_app
阿里雲服務器需注意開啟端口,設置安全組
15672、5672
設置完成,重啟阿里雲服務器即可
瀏覽器地址輸入 http://阿里雲服務器公網ip:15672
輸入之前創建的用戶名和密碼(admin/admin),就可以看到rabbitmq的管理界面了。
ps:
如果想卸載erlang版本就輸入:
rpm -qa | grep erlang | xargs rpm -e --nodeps
另外我在另外一台服務器按照這個步驟安裝的時候,發現執行
rabbitmqctl start_app
啟動rabbitmq的命令時候,會出現以下異常:
Error: unable to perform an operation on node 'rabbit@iZbp138tf0alwpZ'. 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@iZbp138tf0alwpZ * If target node is configured to use long node names, don't forget to use --longnames with CLI tools DIAGNOSTICS =========== attempted to contact: [rabbit@iZbp138tf0alwpZ] rabbit@iZbp138tf0alwpZ: * connected to epmd (port 4369) on iZbp138tf0alwpZ * epmd reports: node 'rabbit' not running at all no other nodes on iZbp138tf0alwpZ * suggestion: start the node Current node details: * node name: 'rabbitmqcli-1180384-rabbit@iZbp138tf0alwpZ' * effective user's home directory: /var/lib/rabbitmq * Erlang cookie hash: PH2aegzBB8pInmMp3ar8Jg==
根據上述信息,翻閱資料,最后執行
echo 192.168.1.101 iZbp138tf0alwpZ>>/etc/hosts
192.168.1.101 為服務器IP
iZbp138tf0alwpZ 為服務器主機名,也是上述錯誤信息rabbit@iZbp138tf0alwpZ中后面一截字符串
意思就是把服務器IP和主機名寫入到host文件,這樣就可以解析成功。
然后繼續執行,重啟rabbitmq服務
service rabbitmq-server restart
接着上面的 開啟rabbitmq界面管理命令 步驟繼續執行即可。