使用root用戶,在centos7中安裝rabbitMQ

參考地址: javascript

https://www.linuxidc.com/Linux/2018-01/150600.htmcss

 

https://blog.csdn.net/summerhust/article/details/7201298html

 

遇到的問題:java

systemctl start rabbitmq-server 出現下面問題 Job for rabbitmq-server.service failed because the control process exited with error code. See "systemctl status rabbitmq-server.service" and "journalctl -xe" flinux

stemctl status rabbitmq-server.service
● rabbitmq-server.service - RabbitMQ broker
   Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled) Active: activating (auto-restart) (Result: exit-code) since Tue 2018-03-20 16:40:20 CST; 3s ago Process: 27573 ExecStop=/usr/sbin/rabbitmqctl shutdown (code=exited, status=78) Process: 27390 ExecStart=/usr/sbin/rabbitmq-server (code=exited, status=1/FAILURE) Main PID: 27390 (code=exited, status=1/FAILURE) Mar 20 16:40:20 vdevops systemd[1]: Failed to start RabbitMQ broker. Mar 20 16:40:20 vdevops systemd[1]: Unit rabbitmq-server.service entered failed state. Mar 20 16:40:20 vdevops systemd[1]: rabbitmq-server.service failed. 

查看具體錯誤c++

journalctl -xe
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: links: [<0.46.0>] Mar 20 16:43:36 vdevops rabbitmq-server[1578]: dictionary: [] Mar 20 16:43:36 vdevops rabbitmq-server[1578]: trap_exit: true Mar 20 16:43:36 vdevops rabbitmq-server[1578]: status: running Mar 20 16:43:36 vdevops rabbitmq-server[1578]: heap_size: 610 Mar 20 16:43:36 vdevops rabbitmq-server[1578]: stack_size: 27 Mar 20 16:43:36 vdevops rabbitmq-server[1578]: reductions: 954 Mar 20 16:43:36 vdevops rabbitmq-server[1578]: 2018-03-20 16:43:36 supervisor_report Mar 20 16:43:36 vdevops rabbitmq-server[1578]: supervisor: {local,net_sup} Mar 20 16:43:36 vdevops rabbitmq-server[1578]: errorContext: start_error Mar 20 16:43:36 vdevops rabbitmq-server[1578]: reason: {"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{li Mar 20 16:43:36 vdevops rabbitmq-server[1578]: offender: [{pid,undefined},{id,auth},{mfargs,{auth,start_link,[]}},{restart_type,permanent},{shutdown,2000},{child Mar 20 16:43:36 vdevops rabbitmq-server[1578]: 2018-03-20 16:43:36 supervisor_report Mar 20 16:43:36 vdevops rabbitmq-server[1578]: supervisor: {local,kernel_sup} Mar 20 16:43:36 vdevops rabbitmq-server[1578]: errorContext: start_error Mar 20 16:43:36 vdevops rabbitmq-server[1578]: reason: {shutdown,{failed_to_start_child,auth,{"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{aut Mar 20 16:43:36 vdevops rabbitmq-server[1578]: offender: [{pid,undefined},{id,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdo Mar 20 16:43:36 vdevops rabbitmq-server[1578]: 2018-03-20 16:43:36 crash_report Mar 20 16:43:36 vdevops rabbitmq-server[1578]: initial_call: {application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']} Mar 20 16:43:36 vdevops rabbitmq-server[1578]: pid: <0.35.0> Mar 20 16:43:36 vdevops rabbitmq-server[1578]: registered_name: [] Mar 20 16:43:36 vdevops rabbitmq-server[1578]: error_info: {exit,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,auth,{"Error when rea Mar 20 16:43:36 vdevops rabbitmq-server[1578]: ancestors: [<0.34.0>] Mar 20 16:43:36 vdevops rabbitmq-server[1578]: message_queue_len: 1 Mar 20 16:43:36 vdevops rabbitmq-server[1578]: messages: [{'EXIT',<0.36.0>,normal}] Mar 20 16:43:36 vdevops rabbitmq-server[1578]: links: [<0.34.0>,<0.33.0>] Mar 20 16:43:36 vdevops rabbitmq-server[1578]: dictionary: [] Mar 20 16:43:36 vdevops rabbitmq-server[1578]: trap_exit: true Mar 20 16:43:36 vdevops rabbitmq-server[1578]: status: running Mar 20 16:43:36 vdevops rabbitmq-server[1578]: heap_size: 987 Mar 20 16:43:36 vdevops rabbitmq-server[1578]: stack_size: 27 Mar 20 16:43:36 vdevops rabbitmq-server[1578]: reductions: 250 Mar 20 16:43:36 vdevops rabbitmq-server[1578]: 2018-03-20 16:43:36 std_info Mar 20 16:43:36 vdevops rabbitmq-server[1578]: application: kernel Mar 20 16:43:36 vdevops rabbitmq-server[1578]: exited: {{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,auth,{"Error when reading /var/ Mar 20 16:43:36 vdevops rabbitmq-server[1578]: type: permanent Mar 20 16:43:37 vdevops rabbitmq-server[1578]: {"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_chi Mar 20 16:43:37 vdevops rabbitmq-server[1578]: Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_chil Mar 20 16:43:37 vdevops rabbitmq-server[1578]: Crash dump is being written to: /var/log/rabbitmq/erl_crash.dump...done Mar 20 16:43:37 vdevops systemd[1]: rabbitmq-server.service: main process exited, code=exited, status=1/FAILURE Mar 20 16:43:37 vdevops rabbitmqctl[1761]: 16:43:37.884 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:38 vdevops rabbitmqctl[1761]: 16:43:38.769 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:38 vdevops rabbitmqctl[1761]: 16:43:38.770 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:39 vdevops rabbitmqctl[1761]: 16:43:39.659 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:39 vdevops rabbitmqctl[1761]: 16:43:39.660 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:40 vdevops rabbitmqctl[1761]: 16:43:40.553 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:40 vdevops rabbitmqctl[1761]: 16:43:40.554 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:41 vdevops rabbitmqctl[1761]: 16:43:41.450 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:41 vdevops rabbitmqctl[1761]: 16:43:41.450 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:42 vdevops rabbitmqctl[1761]: 16:43:42.347 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:42 vdevops rabbitmqctl[1761]: 16:43:42.347 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:43 vdevops rabbitmqctl[1761]: 16:43:43.241 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces Mar 20 16:43:43 vdevops rabbitmqctl[1761]: 16:43:43.242 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces 

錯誤日誌顯示訪問問題,查詢資料多是權限問題。web

chmod +x .erlang.cookie 重複上訴操做,錯誤改成:vim

Mar 20 16:54:59 vdevops rabbitmqctl[22540]: 16:54:59.815 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only Mar 20 16:54:59 vdevops rabbitmqctl[22540]: 16:54:59.815 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only Mar 20 16:55:00 vdevops rabbitmqctl[22540]: 16:55:00.721 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only Mar 20 16:55:00 vdevops rabbitmqctl[22540]: 16:55:00.722 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only Mar 20 16:55:01 vdevops rabbitmqctl[22540]: 16:55:01.632 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only Mar 20 16:55:01 vdevops rabbitmqctl[22540]: Distribution failed: {{:shutdown, {:failed_to_start_child, :auth, {'Cookie file /var/lib/rabbitmq/.erlang.cookie mus Mar 20 16:55:01 vdevops systemd[1]: rabbitmq-server.service: control process exited, code=exited status=78 Mar 20 16:55:01 vdevops systemd[1]: Failed to start RabbitMQ broker. -- Subject: Unit rabbitmq-server.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 

修改權限cookie

chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie chmod 400 .erlang.cookie 

再次運行,成功。app

 

系統環境

操做系統:CentOS6.9

erlang:OTP 19.3

rabbitmq:rabbitmq-server 3.6.12

安裝步驟

安裝erlang

1,安裝預環境

經過yum安裝如下組件,運行命令:

[root@rabbitmqserver erlang]# yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel

 

2,下載erlang的源代碼文件並解壓縮

clipboard

運行以下命令解壓。

[root@rabbitmqserver softwares]# tar -xvf otp_src_19.3.tar.gz

而後,運行以下命令重命名文件夾爲erlang。

[root@rabbitmqserver softwares]# mv otp_src_19.3 ./erlang

clipboard

 

3,配置安裝

首先是./configure,檢查編譯環境並配置安裝路徑,運行以下命令:

[root@rabbitmqserver erlang]# ./configure --prefix=/usr/erlang --without-javac

而後,make,對源代碼進行編譯,運行以下命令:

[root@rabbitmqserver erlang]# make

最後,make install,開始安裝,運行以下命令:

[root@rabbitmqserver erlang]# make install

 

4,設置環境變量

運行如下命令編輯/etc/profile文件。

[root@rabbitmqserver erlang]# vim /etc/profile

在末尾追加如下內容。

clipboard

保存,而後運行如下命令使環境變量當即生效。

[root@rabbitmqserver erlang]# source /etc/profile

 

5,驗證是否安裝成功

運行以下命令,驗證erlang是否安裝成功。

[root@rabbitmqserver erlang]# erl

clipboard

 

安裝rabbitmq-server

1,下載rpm包並安裝

運行以下命令開始安裝rpm包。

[root@rabbitmqserver softwares]# rpm -ivh rabbitmq-server-3.6.12-1.el6.noarch.rpm

可能碰到如下問題:

clipboard

解決辦法:

http://blog.csdn.net/yunfeng482/article/details/72853983

 

2,設置環境變量

運行如下命令編輯/etc/profile文件。

[root@rabbitmqserver softwares]# vim /etc/profile

在末尾追加如下內容。

clipboard

保存,而後運行如下命令使環境變量當即生效。

[root@rabbitmqserver erlang]# source /etc/profile

 

3,開啓Web監控

首先,運行如下命令,開啓rabbitmq

[root@rabbitmqserver rabbitmq]# rabbitmq-server

clipboard

ctrl+c取消進程後,運行如下命令,開啓web監控。

[root@rabbitmqserver rabbitmq]# rabbitmq-plugins enable rabbitmq_management

clipboard

 

4,啓動

開啓web監控以後,咱們就能夠正式啓動rabbitmq了。

啓動rabbitmq有如下兩種方法。

第一種方法是,直接運行rabbitmq-server命令。

clipboard

可是這種方式,一旦終端退出後,rabbitmq服務就中止了,因此不推薦這麼作。

第二種方法是,運行service rabbitmq-server xxx命令。

service rabbitmq-server start #啓動

service rabbitmq-server stop #中止

service rabbitmq-server restart #重啓

service rabbitmq-server status #查看狀態

service rabbitmq-server etc #查看有哪些命令能夠使用

同時將rabbitmq-server加入到開機自啓動服務中,運行如下命令:

[root@rabbitmqserver bin]# chkconfig rabbitmq-server on

最佳實踐是第二種方法。

相關文章
相關標籤/搜索