1.部署实验环境
- 此实验中需要3台rhel6版本的虚拟机,分别是server1 server2 server3。
- 配好同一网段的ip地址,提前写好解析。
- 在server1和server2搭建高级的yum源:
2.搭建RHCS环境
- ricci—图形里的集群管理
- luci—图形界面
- 在server1中安装:
- 给ricci设置密码:
- 启动ricci luci:
注意:企业6没有systemctl命令,所以启动关闭服务等操作需要用脚本来实现
- 设置开机自启
- 在server2中安装:
- 给ricci设置密码:
- 启动ricci:
3.创建集群
- 在网页中输入网址:https://172.25.58.1:8084 即https://server1的ip:8084
- 登陆:
- 创建集群:
- 此时server1和server2会重启,然后再重新连接server1和server2
- 查看集群信息:
4.配置fence
- FENCE的原理:
当意外原因导致主机异常或者宕机时,备机会首先调用FENCE设备,然后通过FENCE设备将异常主机重启或者从网络隔离,当FENCE操作成功执行后,返回信息给备机,备机在接到FENCE成功的信息后,开始接管主机的服务和资源。这样通过FENCE设备,将异常节点占据的资
源进行了释放,保证了资源和服务始终运行在一个节点上。
- 在真机中安装fence:
yum search fence
yum install fence-virtd.x86_64 fence-virtd-libvirt.x86_64 fence-virtd-multicast.x86_64 -y
systemctl start fence_virtd.service
systemctl status fence_virtd.service
- 编辑fence的配置文件:
[root@foundation58 ~]# fence_virtd -c
Module search path [/usr/lib64/fence-virt]:
Available backends:
libvirt 0.1
Available listeners:
multicast 1.2
Listener modules are responsible for accepting requests
from fencing clients.
Listener module [multicast]:
The multicast listener module is designed for use environments
where the guests and hosts may communicate over a network using
multicast.
The multicast address is the address that a client will use to
send fencing requests to fence_virtd.
Multicast IP Address [225.0.0.12]:
Using ipv4 as family.
Multicast IP Port [1229]:
Setting a preferred interface causes fence_virtd to listen only
on that interface. Normally, it listens on all interfaces.
In environments where the virtual machines are using the host
machine as a gateway, this *must* be set (typically to virbr0).
Set to 'none' for no interface.
Interface [virbr0]: br0 #除了此处为br0,其余全部按回车选择默认
The key file is the shared key information which is used to
authenticate fencing requests. The contents of this file must
be distributed to each physical host and virtual machine within
a cluster.
Key File [/etc/cluster/fence_xvm.key]:
Backend modules are responsible for routing requests to
the appropriate hypervisor or management layer.
Backend module [libvirt]:
Configuration complete.
=== Begin Configuration ===
backends {
libvirt {
uri = "qemu:///system";
}
}
listeners {
multicast {
port = "1229";
family = "ipv4";
interface = "br0";
address = "225.0.0.12";
key_file = "/etc/cluster/fence_xvm.key";
}
}
fence_virtd {
module_path = "/usr/lib64/fence-virt";
backend = "libvirt";
listener = "multicast";
}
=== End Configuration ===
Replace /etc/fence_virt.conf with the above [y/N]? y
[root@foundation58 ~]#
- 截取密钥:
将截取好的密钥文件发送给节点server1和server2:
保证server1和server2利用的是同一个密钥
scp fence_xvm.key root@172.25.58.1:/etc/cluster/
scp fence_xvm.key root@172.25.58.2:/etc/cluster/
- 添加fence设备:
- 绑定节点:
- server2同上面的步骤。两个节点都要绑定
- 两个节点都绑定后配置文件内容应该如下:
- 设置火墙:
systemctl stop firewalld
- 测试:
在server1上通过fence干掉节点server2,使server2断电重启则为成功