rabbitmq安装

[环境:centos 7]

##下在erlang安装包
wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm   或者 yum localinstall   erlang-solutions-1.0-1.noarch.rpm
##下载rabbimq 仓库
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
cat > /etc/yum.repos.d/rabbitmq.repo << EOF
[rabbitmq]
name=rabbitmq
baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.7.x/el/7/
gpgcheck=0
enabled=1
EOF
#安装erlang和rabbixmq
yum repolist 
yum -y install erlang.x86_64
yum -y install erlang-solutions-1.0-1.noarch.rpm
yum -y install rabbitmq-server.noarch 

###########

可能会报错,erlang版本不匹配

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

yum -y  install  rabbitmq-server-3.6.6-1.el6.noarch.rpm

##########

systemctl enabled  rabbitmq-server

systemctl start  rabbitmq-server

#rabbitmq 启动管理插件与增加用户和设置权限
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user leo leo123 
rabbitmqctl setset_user_tags administrator 
rabbitmqctl set_user_tags administrator 
rabbitmqctl set_permissions -p / leo ".*" ".*" ".*"

#启动服务  

systemctl  start rabbitmq

###########################################
###########################################

#修改主机名 (各台主机上操作)

echo "leo1"  > /etc/hostname ;hostname leo1

echo "leo2"  > /etc/hostname;hostname leo2

echo "leo3"  > /etc/hostname;hostname leo3

#修改host(三台主机都需要操作)

cat  > /etc/hosts << EOF

172.20.101.56  leo1  

172.20.101.114 leo2 

172.20.101.18 leo3

EOF

##########################################

集群配置:

ip                        主机名 

172.20.101.56      leo1  

172.20.101.114    leo2 

172.20.101.18      leo3

#保证他们直接能够用主机名ping通 

#杀死从进程节点

ps -ef|grep rab|grep -v grep |awk '{print $2}'|xargs kill -9

#集群主节点操作(保证cookie相同)

 cd /var/lib/rabbitmq/

chmod 777 .erlang.cookie

scp .erlang.cookie  rabbitmq@172.20.101.114:/var/lib/rabbitmq/

scp .erlang.cookie  rabbitmq@172.20.101.18:/var/lib/rabbitmq/

chmod 400 .erlang.cookie

#启动从节点

systemctl restart rabbitmq-server.service

rabbitmqctl cluster_status

#从节点加入集群

rabbitmqctl stop_app

rabbitmqctl join_cluster rabbit@leo1

rabbitmqctl start_app

rabbitmqctl cluster_status

#登陆http://172.20.101.56:15672/#/查看web界面

#增加镜像

 rabbitmqctl set_policy ha-all "hello" '{"ha-mode":"all"}'  #增加hellp队列镜像

posted @ 2019-03-07 18:45  舍&得  阅读(128)  评论(0编辑  收藏  举报