server1:
yum install luci ricci -y
echo westos | passwd -stdin ricci
/etc/init.d/ricci start
chkconfig --list ricci
chkconfig ricci on
/etc/init.d/luci start
chkconfig luci on
server4:
yum install ricci -y
echo westos | passwd --stdin ricci
/etc/init.d/ricci start
yum install luci ricci -y
echo westos | passwd -stdin ricci
/etc/init.d/ricci start
chkconfig --list ricci
chkconfig ricci on
/etc/init.d/luci start
chkconfig luci on
server4:
yum install ricci -y
echo westos | passwd --stdin ricci
/etc/init.d/ricci start
编辑:
Failover Domains
添加:
Resources
添加:
Service Groups
添加
测试:
server4:
clustat ##查看正在运行的节点
clustat ##查看正在运行的节点
clusvcadm -r web -m server4 ##切换至server4
clustat
clustat
clusvcadm -d web ##关闭服务
clusvcadm -e web ##开启服务
/etc/init.d/httpd stop
当一台apache服务停止,会自动切换另外一台服务器继承服务
当一台apache服务停止,会自动切换另外一台服务器继承服务
物理机
yum install fence-virtd-0.3.2-5.el7.x86_64
yum install fence-virtd-libvirt.x86_64
yum install fence-virtd-multicast.x86_64
fence_virtd -c
mkdir /etc/cluster/
dd if=/dev/urandom of=/etc/cluster/fence_xvm.key bs=128 count=1
systemctl restart fence_virtd.service ##开启dence服务
yum install fence-virtd-0.3.2-5.el7.x86_64
yum install fence-virtd-libvirt.x86_64
yum install fence-virtd-multicast.x86_64
fence_virtd -c
mkdir /etc/cluster/
dd if=/dev/urandom of=/etc/cluster/fence_xvm.key bs=128 count=1
systemctl restart fence_virtd.service ##开启dence服务
scp fence_xvm.key server1:/etc/cluster/ ##将配置好的文件分发给server1和server4
scp fence_xvm.key server4:/etc/cluster/
在server2,3:
cd /etc/cluster/
ls
[root@server1 cluster]# ls
cluster.conf cman-notify.d fence_xvm.key
cd /etc/cluster/
ls
[root@server1 cluster]# ls
cluster.conf cman-notify.d fence_xvm.key
页面配置
Fence Devices
NOde
server1:
server4:
此时当server1或server4中任何一台机子挂掉的话,另一台会接管服务,并自动重启挂掉的那台服务器。
实现轮循:
开启server2,server3
开启httpd服务
在eth0上添加虚拟ip
ip addr add 172.25.8.100/32 dev eth0
yum install arptables_jf
arptables -A IN -d 172.25.8.100 -j DROP
arptables -A OUT -s 172.25.8.100 -j mangle --mangle-ip-s 172.25.8.2
/etc/init.d/arptables_jf save
/etc/init.d/arptables_jf start
添加策略(如果已添加开启服务即可)
开启server2,server3
开启httpd服务
在eth0上添加虚拟ip
ip addr add 172.25.8.100/32 dev eth0
yum install arptables_jf
arptables -A IN -d 172.25.8.100 -j DROP
arptables -A OUT -s 172.25.8.100 -j mangle --mangle-ip-s 172.25.8.2
/etc/init.d/arptables_jf save
/etc/init.d/arptables_jf start
添加策略(如果已添加开启服务即可)
server1:
yum install ldirectord-3.9.5-3.1.x86_64.rpm -y
clusvcadm -d web
cd /etc/ha.d/
vim ldirectord.cf
yum install ldirectord-3.9.5-3.1.x86_64.rpm -y
clusvcadm -d web
cd /etc/ha.d/
vim ldirectord.cf
server4:
yum install ldirectord-3.9.5-3.1.x86_64.rpm -y
yum install ldirectord-3.9.5-3.1.x86_64.rpm -y
server1:
scp ldirectord.cf server4:/etc/ha.d
scp ldirectord.cf server4:/etc/ha.d
页面操作:
Resources
Service Groups
将ld脚本加入web
Resources
Service Groups
将ld脚本加入web
server1:
clusvcadm -e web
ipvsadm -l
clusvcadm -e web
ipvsadm -l
测试:
出现2和3的轮循效果
出现2和3的轮循效果