记录一下centos7安装rabbitmq遇到的坑

一、安装Erlang

1.安装Erlang编译依赖:
yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget

2.下载Erlang:
wget http://www.erlang.org/download/otp_src_19.3.tar.gz
3.解压并安装
tar -xzvf otp_src_19.3.tar.gz

cd otp_src_19.3

./configure --prefix=/usr/local/erlang

make && make install
4.配置环境变量

vi /etc/profile

/usr/local/erlang/otp_src_19.3/bin

添加配置:

ER_LANG=/usr/local/erlang/otp_src_19.3
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$MAVEN_HOME/bin:$ER_LANG/bin:

source /etc/profile
查看环境变量配置:
echo $PATH

输入erl查看版本

[root@ONLINE rabbitmq]# erl
Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Eshell V10.3  (abort with ^G)

二、安装Rabbitmq

wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm

yum install rabbitmq-server-3.6.6-1.el7.noarch.rpm

此时会报错

#vim /etc/yum.repos.d/rabbitmq-erlang.repo
[rabbitmq-erlang]
name=rabbitmq-erlang
baseurl=https://dl.bintray.com/rabbitmq/rpm/erlang/20/el/7
gpgcheck=1
gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
repo_gpgcheck=0
enabled=1

#yum clean all
#yum makecache
这个方法无效未解决问题

有效的安装方法

wget https://dl.bintray.com/rabbitmq/all/rabbitmq-server/3.7.8/rabbitmq-server-3.7.8-1.el7.noarch.rpm
rpm -ivh --nodeps rabbitmq-server-3.7.8-1.el7.noarch.rpm

两句话搞定,此时安装rabbitmq结束

三、启动Rabbitmq

报错1:Failed to create cookie file '/home/rabbitmq/.erlang.cookie

解决方法:rpm安装rabbitmq的时候,会自动建立rabbitmq的用户,但是/home/下无目录,需要根据提示自行创建目录

Jan 16 14:03:35 ONLINE rabbitmqctl[17843]: 14:03:35.219 [error] Failed to create cookie file '/home/rabbitmq/.erlang.cookie': eacces
Jan 16 14:03:35 ONLINE  rabbitmqctl[17843]: 14:03:35.219 [error] Failed to create cookie file '/home/rabbitmq/.erlang.cookie': eacces
Jan 16 14:03:35 ONLINE  rabbitmqctl[17843]: 14:03:35.996 [error] Failed to create cookie file '/home/rabbitmq/.erlang.cookie': eacces
Jan 16 14:03:35 ONLINE  rabbitmqctl[17843]: 14:03:35.996 [error] Failed to create cookie file '/home/rabbitmq/.erlang.cookie': eacces
Jan 16 14:03:36 ONLINE  rabbitmqctl[17843]: 14:03:36.771 [error] Failed to create cookie file '/home/rabbitmq/.erlang.cookie': eacces
Jan 16 14:03:36 ONLINE  rabbitmqctl[17843]: Distribution failed: {{:shutdown, {:failed_to_start_child, :auth, {'Failed to create cookie file \'/home/rabbitmq/.erlang.cookie\': eacces', [{:auth, :init_cookie, 0, [file: 'auth.erl', line: 286]},
Jan 16 14:03:36 ONLINE  systemd[1]: rabbitmq-server.service: control process exited, code=exited status=78
Jan 16 14:03:36 ONLINE  systemd[1]: Failed to start RabbitMQ broker.
-- Subject: Unit rabbitmq-server.service has failed
-- Defined-By: systemd

报错2:Too short cookie string

解决方法:删除/home/rabbitmq/.erlang.cookie

rm -rf /home/rabbitmq/.erlang.cookie

Jan 16 13:59:58 ONLINE rabbitmqctl[8965]: 13:59:58.491 [error] Too short cookie string
Jan 16 13:59:59 ONLINE rabbitmqctl[8965]: 13:59:59.264 [error] Too short cookie string
Jan 16 13:59:59 ONLINE rabbitmqctl[8965]: 13:59:59.265 [error] Too short cookie string
Jan 16 14:00:00 ONLINE rabbitmqctl[8965]: 14:00:00.039 [error] Too short cookie string
Jan 16 14:00:00 ONLINE rabbitmqctl[8965]: 14:00:00.040 [error] Too short cookie string
Jan 16 14:00:00 ONLINE rabbitmqctl[8965]: 14:00:00.814 [error] Too short cookie string
Jan 16 14:00:00 ONLINE rabbitmqctl[8965]: 14:00:00.814 [error] Too short cookie string
Jan 16 14:00:01 ONLINE systemd[1]: Started Session 2706 of user root.
-- Subject: Unit session-2706.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-2706.scope has finished starting up.

报错3:rabbitmq 启动错误 Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces

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

解决方法:授权解决一切权限访问问题
chmod 777 /home/rabbitmq
其他人的授权方法:
chown rabbitmq:rabbitmq .erlang.cookie
chmod 400 .erlang.cookie

rabbitmq-server启动

rabbitmq-server start
rabbitmq-plugins enable rabbitmq_management 启用插件
vi /etc/sysconfig/iptables 添加端口
-A INPUT -p tcp -m state --state NEW -m tcp --dport 15672 -j ACCEPT
systemctl restart iptables 重启生效

rabbitmq创建用户授权

rabbitmqctl add_user mq mq123 #添加用户mq,密码mq123
rabbitmqctl set_permissions -p / mq ".*" ".*" ".*"#添加权限
rabbitmqctl set_user_tags mq administrator #修改用户角色

#其它操作
rabbitmqctl delete_user Username #删除一个用户
rabbitmqctl change_password Username Newpassword #修改用户密码
rabbitmqctl list_users #查看当前用户列表

发布了17 篇原创文章 · 获赞 3 · 访问量 6541
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览