ipv6 环境下搭建rabbitmq集群
程序员文章站
2022-03-05 18:29:12
...
环境信息
节点 | 地址 |
---|---|
node1 | 1111::1 |
node2 | 1111::2 |
node3 | 1111::3 |
rabbitmq-server-3.7.8-1.el7.src.rpm
erlang-21.1-2.el7.centos.src.rpm
centos7.5.1804
集群配置
- 配置/etc/hosts
1111::1 node1
1111::2 node2
1111::3 node3
- 配置/etc/rabbitmq/rabbitmq-env.conf
[email protected]
SERVER_ADDITIONAL_ERL_ARGS="-proto_dist inet6_tcp"
CTL_ERL_ARGS="-proto_dist inet6_tcp"
- 创建集群
#!/usr/bin/env bash
this_node=1111::1
other_node2=1111::2
other_node3=1111::3
scp_node2=[1111::2]
scp_node3=[1111::3]
other_name1=$(hostname)
other_name2=$(ssh ${other_node2} hostname)
other_name3=$(ssh ${other_node3} hostname)
#sync cookie
echo ">>> sync cookie"
rm /root/.erlang.cookie -f
cp /var/lib/rabbitmq/.erlang.cookie /root/.erlang.cookie
chown rabbitmq /root/.erlang.cookie
chgrp rabbitmq /root/.erlang.cookie
for i in 2 3
do
node=other_node$i
scp_node=scp_node$i
ssh ${!node} rm /var/lib/rabbitmq/.erlang.cookie /root/.erlang.cookie -f
scp /var/lib/rabbitmq/.erlang.cookie ${!scp_node}:/var/lib/rabbitmq/.erlang.cookie
scp /var/lib/rabbitmq/.erlang.cookie ${!scp_node}:/root/.erlang.cookie
ssh ${!node} chown rabbitmq /root/.erlang.cookie /var/lib/rabbitmq/.erlang.cookie
ssh ${!node} chgrp rabbitmq /root/.erlang.cookie /var/lib/rabbitmq/.erlang.cookie
done
#restart rabbit
echo ">>> restart rabbit"
echo "on ${this_node}"
systemctl restart rabbitmq-server
for i in 2 3
do
node=other_node$i
echo "on ${!node}"
ssh ${!node} rm /var/lib/rabbitmq/mnesia/ -rf
ssh ${!node} systemctl restart rabbitmq-server
done
#enable management
echo ">>> enable management"
rabbitmq-plugins enable rabbitmq_management
for i in 2 3
do
node=other_node$i
ssh ${!node} rabbitmq-plugins enable rabbitmq_management
done
#build cluster
echo ">>> build cluster"
for i in 2 3
do
node=other_node$i
ssh ${!node} rabbitmqctl stop_app
ssh ${!node} rabbitmqctl join_cluster [email protected]${other_name1}
ssh ${!node} rabbitmqctl start_app
done
#show rabbitmq cluster status
echo ">>> show status"
rabbitmqctl cluster_status
ssh ${other_node2} rabbitmqctl cluster_status
ssh ${other_node3} rabbitmqctl cluster_status
# set ha strategy: sync all nodes
echo ">>> set ha strategy"
rabbitmqctl set_policy ha-all "^" '{"ha-mode":"all"}'
#config haproxy
#echo ">>> config haproxy"
#edit_script2=/tmp/tmp_edit_ha_config_script.sh
#haproxy_conf_file=/etc/haproxy/haproxy.cfg
#if [ ! -e ${haproxy_conf_file} ];then
# echo -e "\033[47;31m the haproxy conifg file:${haproxy_conf_file} is not exit!\033[0m"
# exit 1
#fi
#echo ''>${edit_script2}
#echo 'sed -i "/rabbitmq_cluster/,/server.*5672/d" '$haproxy_conf_file >> ${edit_script2}
#echo 'sed -i "/server.*5672/d" '$haproxy_conf_file >> ${edit_script2}
#echo 'echo "listen rabbitmq_cluster '${ManageNetwork}':5672" >>'${haproxy_conf_file} >> ${edit_script2}
#echo 'echo " mode tcp" >>'${haproxy_conf_file} >> ${edit_script2}
#echo 'echo " balance roundrobin" >>'${haproxy_conf_file} >> ${edit_script2}
#for i in 1 2 3
#do
# node=other_node$i
# hostname=other_name$i
# echo 'echo " server '${!hostname}' '${!node}':5672 check inter 2000 rise 2 fall 3" >> '${haproxy_conf_file} >> ${edit_script2}
#done
#chmod +x ${edit_script2}
#$edit_script2
#for i in 2 3
#do
# node=other_node$i
# scp_node=scp_node$i
# scp ${edit_script2} ${!scp_node}:${edit_script2}
# ssh ${!node} ${edit_script2}
#done
#
#systemctl restart haproxy
#sleep 10
#ssh ${other_node2} systemctl restart haproxy
#sleep 10
#ssh ${other_node3} systemctl restart haproxy
上一篇: rabbitmq配置
下一篇: RabbitMQ指南(六) 远程过程调用
推荐阅读
-
centos下GitLab+Jenkins持续集成环境搭建(安装jenkins)
-
再整理:Visual Studio Code(vscode)下的通用C语言环境搭建
-
Win8.1系统下搭建IIS8.5+PHP5.5.4运行环境教程
-
详解mac下通过docker搭建LEMP环境
-
Ubuntu系统下搭建mysql环境教程
-
Ubuntu服务器下搭建php运行环境的方法
-
RabbitMQ在Windows环境下的安装与使用
-
ubuntu下搭建php开发环境(nginx+(cgi)php5fpm+memcached+xdebug)
-
[Hadoop] Windows 下的 Hadoop 2.7.5 环境搭建
-
mac下Apache + MySql + PHP搭建网站开发环境