rabbitmq3.6.6安装,环境centos7

一,需求描述
在centos7上安装rabbitmq3.6.6
附上安装脚本 ,附上官网地址 http://www.rabbitmq.com/ ,从这上面可以下载rabbitmq-server-3.6.6-1.el7.noarch.rpm包。注意,运行脚本之前需要设置机器的主机名名添加主机名解析,不然rabbitmq会启动报错。详细内容可看第三条问题记录
#/bin/bash 
SRC_URI="https://github.com/rabbitmq/rabbitmq-server/releases/download/rabbitmq_v3_6_6/rabbitmq-server-3.6.6-1.el7.noarch.rpm"
PKG_NAME=`basename $SRC_URI`
DIR=`pwd`
DATE=`date +%Y%m%d%H%M%S`
 
yum install -y erlang.x86_64
yum install -y socat.x86_64
 
if [ ! -s $PKG_NAME ]; then
wget -c $SRC_URI
fi
rpm -ivh rabbitmq-server-3.6.6-1.el7.noarch.rpm
 
service rabbitmq-server start #启动
rabbitmqctl add_user admin adminpasswd #设置密码
rabbitmqctl set_user_tags admin administrator
rabbitmq-plugins enable rabbitmq_management
 
if ! cat /etc/rc.d/rc.local | grep 'service rabbitmq-server start' &> /dev/null;then
echo "service rabbitmq-server start" >> /etc/rc.d/rc.local
fi #加入开机启动
chmod +x /etc/rc.d/rc.local  #centos7里面默认这个文件没有执行权限

脚本使用方法:

将上面的内容copy下来保存为文件rabbitmq_install.sh,在机器上执行bash rabbitmq_install.sh即可

 
 二,验证
访问rabbitmq的网址ip:15672
 
可以网页了,进行登录,大功告成!
 
三,问题记录
1,rabbitmq启动报错
Feb 20 18:30:09 test rabbitmqctl[822]: attempted to contact: [rabbit@test]
Feb 20 18:30:09 test rabbitmqctl[822]: rabbit@test:
Feb 20 18:30:09 test rabbitmqctl[822]: * unable to connect to epmd (port 4369) on test: address (cannot connect to host/port)
Feb 20 18:30:09 test rabbitmqctl[822]: current node details:
Feb 20 18:30:09 test rabbitmqctl[822]: - node name: 'rabbitmq-cli-76@test'
Feb 20 18:30:09 test rabbitmqctl[822]: - home dir: .
Feb 20 18:30:09 test rabbitmqctl[822]: - cookie hash:xxxxxxxxxxxxx==
Feb 20 18:30:09 test systemd[1]: Failed to start RabbitMQ broker.
Feb 20 18:30:09 test systemd[1]: Unit rabbitmq-server.service entered failed state.
Feb 20 18:30:09 test systemd[1]: rabbitmq-server.service failed.
解决:
在/etc/hosts里添加主机名解析
 运行如下命令即可
sed -i s/"127.0.0.1 localhost"/"127.0.0.1 localhost `hostname`"/g /etc/hosts  #解释:将/etc/hosts 里的127.0.0.1 localhos字段替换成127.0.0.1 localhost `本机主机名`
 
2,附上centos7查看所有已启动的服务的命令
systemctl list-units --type=service
 
posted @ 2017-02-27 17:22  冰壶  阅读(490)  评论(0编辑  收藏  举报