阿里雲服務centOS7下安裝rabbitmq
環境:
centos: 7.4;阿里雲伺服器
erlang :18.3;
rabbitmq :rabbitmq-server-generic-unix-3.6.15
參考:1、erlang與centos,rabbitmq與erlang,這些都是有依賴關係的,不同版本會存在不相容性。
2、rabbitmq官方給出的與erlang/OTP的版本相容要求: http://www.rabbitmq.com/which-erlang.html;
3、erlang官方下載地址(壓縮包):http://www.erlang.org/downloads;
下面二進位制(rpm)格式的下載地址:https://www.erlang-solutions.com/resources/download.html
4、rabbitmq官方下載地址:http://www.rabbitmq.com/install-rpm.html;
step1安裝erlang;這個連結安裝的是18.3的erlang
#####使用wget 方式下載rpm並安裝
Ø wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
Ø rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
Ø rpm -import http://packages.erlang-solutions.com/rpm/erlang_solutions.asc
Ø yum install erlang
成功介面截圖()
驗證是否成功
step2下載安裝rabbitmq
v wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-generic-unix-3.6.15.tar.xz
v xz -d rabbitmq-server-generic-unix-3.6.15.tar.xz
v tar xvf rabbitmq-server-generic-unix-3.6.15.tar
####將解壓後的rabbitmq_server-3.6.15移動到/usr/loca目錄下,
v sudo mv rabbitmq_server-3.6.15/ /usr/local/rabbitmq
step3設定環境變數
第一種方式:臨時變數,在shell視窗中執行下面的命令即可
export PATH=$PATH:/usr/local/rabbitmq/sbin
第二種方式:持久變數,需要更改/etc/profile檔案,在該檔案最後新增export PATH=$PATH:/usr/local/rabbitmq/sbin,然後退出編輯,是/etc/profile檔案生效
##編輯 profile 檔案
vi /etc/profile
#使編輯後的profile檔案生效
source /etc/profile
step4啟動rabbitmq
進入/usr/local/rabbitmq/sbin目錄,執行rabbitmq-server 出現如下資訊就說明已經啟動了
rabbitmq-server -detatched 以守護程序方式啟動
rabbitmq-server在當前session中啟動,當session過期後,會關閉rabbitmq
異常記錄:
-bash-4.2$ rabbitmq-server
/usr/local/rabbitmq/sbin/rabbitmq-server: line 51: /usr/local/rabbitmq/var/lib/rabbitmq/mnesia/[email protected]: Permission denied
Failed to write pid file: /usr/local/rabbitmq/var/lib/rabbitmq/mnesia/[email protected]
-bash-4.2$ sudo ./rabbitmq-server
[sudo] password for ddps:
BOOT FAILED
===========
Error description:
noproc
Log files (may contain more information):
/usr/local/rabbitmq/var/log/rabbitmq/[email protected]
/usr/local/rabbitmq/var/log/rabbitmq/[email protected]
Stack trace:
[{gen,do_for_proc,2,[{file,"gen.erl"},{line,228}]},
{gen_event,rpc,2,[{file,"gen_event.erl"},{line,239}]},
{rabbit,ensure_working_log_handlers,0,
[{file,"src/rabbit.erl"},{line,856}]},
{rabbit,'-boot/0-fun-0-',0,[{file,"src/rabbit.erl"},{line,288}]},
{rabbit,start_it,1,[{file,"src/rabbit.erl"},{line,424}]},
{init,start_em,1,[]},
{init,do_boot,3,[]}]
=INFO REPORT==== 10-Jul-2018::09:39:00.860378 ===
Error description:
noproc
Log files (may contain more information):
/usr/local/rabbitmq/var/log/rabbitmq/[email protected]
/usr/local/rabbitmq/var/log/rabbitmq/[email protected]
Stack trace:
[{gen,do_for_proc,2,[{file,"gen.erl"},{line,228}]},
{gen_event,rpc,2,[{file,"gen_event.erl"},{line,239}]},
{rabbit,ensure_working_log_handlers,0,
[{file,"src/rabbit.erl"},{line,856}]},
{rabbit,'-boot/0-fun-0-',0,[{file,"src/rabbit.erl"},{line,288}]},
{rabbit,start_it,1,[{file,"src/rabbit.erl"},{line,424}]},
{init,start_em,1,[]},
{init,do_boot,3,[]}]
{"init terminating in do_boot",noproc}
init terminating in do_boot (noproc)
Crash dump is being written to: erl_crash.dump...done
-bash-4.2$
原因:許可權問題
從上面的方法可以看出,先是用普通賬戶啟動的,但是報:[email protected]**.pid: Permission denied;然後又用sudo方式啟動,結果還是失敗,報Error description: noproc錯誤;
之後使用root賬戶,能啟動,然後檢視日誌檔案,發現許可權有問題,擁有者是root
解決方案有兩種,一種是用root賬戶啟動,另一種是更改檔案的擁有者,將/usr/local/下的rabbitmq資料夾及其所有子檔案全部更改擁有者。 --------------------- 作者:高傲的孤獨 來源:CSDN 原文:https://blog.csdn.net/qq_35131811/article/details/80985142 版權宣告:本文為博主原創文章,轉載請附上博文連結!