192.168.15.240 主机名rabbitmq240
192.168.15.241 主机名rabbitmq241
vip: 192.168.15.1
vip: 192.168.15.2
1.两台机器安装
yum -y install erlang.x86_64
ln -s /usr/local/erlang/bin/erl /usr/bin/erl
ln -s /usr/local/erlang/bin/epmd /usr/bin/epmd
yum -y install rabbitmq.x86_64
2.配置主机名,
echo "192.168.15.240 rabbitmq240" >> /etc/hosts
echo "192.168.15.241 rabbitmq241" >> /etc/hosts
3.master 192.168.15.240操作
/usr/local/rabbitmq/sbin/rabbitmq-server -detached
生成文件:~/.erlang.cookie
cat ~/.erlang.cookie
在master上启动代理:python -m SimpleHTTPServer 7890,备机上执行:wget http://192.168.15.240:7890/.erlang.cookie获取文件
确保master和slave该文件一致,否则加不进集群。
权限也要一致
chmod 400 .erlang.cookie
4.在slave上 192.168.15.241
/usr/local/rabbitmq/sbin/rabbitmq-server -detached
/usr/local/rabbitmq/sbin/rabbitmqctl stop_app
/usr/local/rabbitmq/sbin/rabbitmqctl join_cluster rabbit@rabbitmq240
/usr/local/rabbitmq/sbin/rabbitmqctl start_app
常用命令:
关闭启动mq
/etc/init.d/rabbitmq-server stop
/etc/init.d/rabbitmq-server start
检测集群状态
/usr/local/rabbitmq/sbin/rabbitmqctl cluster_status
删除节点
/usr/local/rabbitmq/sbin/rabbitmqctl forget_cluster_node rabbit@rabbitmq241
-----------------------------------------------------------------------------------------------------------
vip配置如下:
/etc/rc.d/init.d/realserver
#!/bin/bash VIPS="192.168.15.1 192.168.15.1" . /etc/rc.d/init.d/functions stop() {
exit 0 |
执行sh checkvip.sh
realserver_num=$(/sbin/ip a |grep inet |grep lo: |grep brd |wc -l) if [ ! -f /etc/init.d/realserver ];then
|
设置定时任务
*/5 * * * * sh /home/scottbing/tools/checkvip.sh
来源:CSDN
作者:scott_bing
链接:https://blog.csdn.net/scott_bing/article/details/104053095