RabbitMQ 集群 之 单节点安装部署
环境变量文件
[root@GZ-V-L-MQ-11 zeze] #!/usr/bin/bash
export NODE_IPS=(192.168.100.11 192.168.100.12 192.168.100.13)
export NODE_NAMES=(GZ-V-L-MQ-11 GZ-V-L-MQ-12 GZ-V-L-MQ-13)
export RBMQ_NODE_NAMES=(rbmq.n1.linuxhub.cn rbmq.n2.linuxhub.cn rbmq.n3.linuxhub.cn)
|
主机名Hosts
echo "192.168.100.11 GZ-V-L-MQ-11" >> /etc/hosts echo "192.168.100.12 GZ-V-L-MQ-12" >> /etc/hosts echo "192.168.100.13 GZ-V-L-MQ-13" >> /etc/hosts
|
下载
cd /data/down wget -O rabbitmq-server-3.7.8-1.el7.noarch.rpm https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.8/rabbitmq-server-3.7.8-1.el7.noarch.rpm wget -O erlang-21.1.1-1.el7.centos.x86_64.rpm https://bintray.com/rabbitmq/rpm/download_file?file_path=erlang%2F21%2Fel%2F7%2Fx86_64%2Ferlang-21.1.1-1.el7.centos.x86_64.rpm
|
安装
#!/bin/bash source /data/app/environment.sh for node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" ssh root@${node_ip} "cd /data/down/ && yum localinstall -y erlang-21.1.1-1.el7.centos.x86_64.rpm && yum localinstall -y rabbitmq-server-3.7.8-1.el7.noarch.rpm " done
|
配置信息-配置文件
cat > rabbitmq.config <<EOF [ { rabbit, [ { loopback_users, [ ] }, { tcp_listeners, [ 5672 ] }, { ssl_listeners, [ ] }, { hipe_compile, false } ] }, { rabbitmq_management, [ { listener, [ { port, 15672 }, { ssl, false } ] } ] } ]. EOF
|
环境变量-配置文件
cat > rabbitmq-env.conf <<EOF RABBITMQ_NODE_PORT=5672 RABBITMQ_MNESIA_BASE=/data/rabbitmq/mnesia RABBITMQ_LOG_BASE=/data/rabbitmq/log RABBITMQ_NODENAME=rabbit EOF
|
配置分发
#!/bin/bash source /data/app/environment.sh for node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" scp rabbitmq.config root@${node_ip}:/etc/rabbitmq/rabbitmq.config scp rabbitmq-env.conf root@${node_ip}:/etc/rabbitmq/rabbitmq-env.conf done
|
目录权限
#!/bin/bash source /data/app/environment.sh for node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" ssh root@${node_ip} "mkdir -p /data/rabbitmq/{mnesia,log} && chown -R rabbitmq.rabbitmq /data/rabbitmq/" done
|
启动服务
#!/bin/bash source /data/app/environment.sh for node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" ssh root@${node_ip} "systemctl restart rabbitmq-server && systemctl status rabbitmq-server && systemctl enable rabbitmq-server" done
|
查看服务状态
#!/bin/bash source /data/app/environment.sh for node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" ssh root@${node_ip} "netstat -nltp | grep beam.smp" done
|
返回值
>>> 192.168.100.11 tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 23770/beam.smp tcp6 0 0 :::5672 :::* LISTEN 23770/beam.smp
>>> 192.168.100.12
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 2667/beam.smp tcp6 0 0 :::5672 :::* LISTEN 2667/beam.smp
>>> 192.168.100.13 tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 4669/beam.smp tcp6 0 0 :::5672 :::* LISTEN 4669/beam.smp
|
启动插件
#!/bin/bash source /data/app/environment.sh for node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" ssh root@${node_ip} "rabbitmq-plugins enable rabbitmq_management" done
|
端口: 15672
默认帐号密码: guest/guest
Web界面管理地址
http://rbmq.n1.linuxhub.cn:15672
http://rbmq.n2.linuxhub.cn:15672
http://rbmq.n3.linuxhub.cn:15672