ricci+luic+fence实现HA

[server5]

[root@server5 ~]# cat /etc/hosts   #解析
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.66.1 server1
172.25.66.2 server2
172.25.66.3 server3
172.25.66.4 server4
172.25.66.5 server5
172.25.66.6 server6

[root@server5 ~]# vim /etc/yum.repos.d/yum.repo #配置YUM
.....
[server]
name=Server     #默认读取的是Server
baseurl=http://172.25.66.250/rhel6.5/Server
gpgcheck=0

[HighAvailability]
name=HighAvailability
baseurl=http://172.25.66.250/rhel6.5/HighAvailability
gpgcheck=0

[LoadBalancer ]
name=LoadBalancer 
baseurl=http://172.25.66.250/rhel6.5/LoadBalancer 
gpgcheck=0

[ResilientStorage]
name=ResilientStorage
baseurl=http://172.25.66.250/rhel6.5/ResilientStorage
gpgcheck=0

[ScalableFileSystem]
name=ScalableFileSystem
baseurl=http://172.25.66.250/rhel6.5/ScalableFileSystem
gpgcheck=0

.....
[root@server5 yum.repos.d]# yum clean all
[root@server5 yum.repos.d]# yum repolist
[root@server5 ~]# yum install ricci -y #安装ricci|给生成的ricci用户设定passwd
[root@server5 ~]# yum install luci -y  #安装luci|luci是HA客户端管理软件
[root@server5 ~]# /etc/init.d/ricci start
[root@server5 ~]# passwd ricci     #设置ricci用户的密码
Changing password for user ricci.
New password: 
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@server5 ~]# /etc/init.d/ricci restart
Shutting down ricci:                                       [  OK  ]
Starting ricci:                                            [  OK  ]
[root@server5 ~]# chkconfig ricci on   #设置开机自起
[root@server5 ~]# /etc/init.d/iptables stop    #关闭防火墙

[server6]

[root@server6 ~]# vim /etc/yum.repos.d/yum.repo 
.....
[server]
name=Server
baseurl=http://172.25.66.250/rhel6.5/Server
gpgcheck=0


[HighAvailability]
name=HighAvailability
baseurl=http://172.25.66.250/rhel6.5/HighAvailability
gpgcheck=0

[LoadBalancer ]
name=LoadBalancer 
baseurl=http://172.25.66.250/rhel6.5/LoadBalancer 
gpgcheck=0

[ResilientStorage]
name=ResilientStorage
baseurl=http://172.25.66.250/rhel6.5/ResilientStorage
gpgcheck=0

[ScalableFileSystem]
name=ScalableFileSystem
baseurl=http://172.25.66.250/rhel6.5/ScalableFileSystem
gpgcheck=0

.....
[root@server6 ~]# yum install ricci -y
[root@server6 ~]# /etc/init.d/ricci start
Starting system message bus:                               [  OK  ]
Starting oddjobd:                                          [  OK  ]
generating SSL certificates...  done
Generating NSS database...  done
Starting ricci:                                            [  OK  ]
[root@server6 ~]# passwd ricci         #修改 ricci 密码
Changing password for user ricci.
New password: 
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@server6 ~]# /etc/init.d/ricci status
ricci (pid  1326) is running...
[root@server3 ~]#

*浏览器访问
https://172.25.66.5:8084

这里写图片描述

[物理机]
*安装fence
作用:当意外原因导致主机异常或宕机时,备用机会首先调用fence设备,然后通过fence设备将异常的主机重启或从网络上隔离,释放异常主机占据的资源,当隔离操作成功后,返回信息给备用机,备用机在接到信息后,开始接管主机的服务和资源。

[root@foundation66 Desktop]# yum install fence-virtd-multicast.x86_64 -y 
[root@foundation66 Desktop]# yum install fence-virtd-libvirt.x86_64 -y
[root@foundation66 Desktop]# yum install fence-virtd-serial.x86_64 -y
[root@foundation66 Desktop]# rpm -aq | grep fence
libxshmfence-1.2-1.el7.x86_64
fence-virtd-multicast-0.3.2-2.el7.x86_64
fence-virtd-libvirt-0.3.2-2.el7.x86_64
fence-virtd-serial-0.3.2-2.el7.x86_64
fence-virtd-0.3.2-2.el7.x86_64
[root@foundation66 Desktop]# fence_virtd -c
.....
Interface [virbr0]: br0
.....
[root@foundation66 Desktop]# mkdir /etc/cluster
[root@foundation66 Desktop]# touch /etc/cluster/fence_xvm.key
[root@foundation66 Desktop]# dd if=/dev/urandom of=/etc/cluster/fence_xvm.key bs=128 count=1    #用随机数生成key
1+0 records in
1+0 records out
128 bytes (128 B) copied, 0.000484055 s, 264 kB/s
[root@foundation66 Desktop]# file /etc/cluster/fence_xvm.key 
/etc/cluster/fence_xvm.key: data
[root@foundation66 Desktop]# 
[root@foundation66 cluster]# scp fence_xvm.key root@172.25.66.5:/etc/cluster/
root@172.25.66.5's password: 
fence_xvm.key                                 100%  128     0.1KB/s   00:00    
[root@foundation66 cluster]# scp fence_xvm.key root@172.25.66.6:/etc/cluster/       #将钥匙纷发给各节点
The authenticity of host '172.25.30.3 (172.25.30.3)' can't be established.
RSA key fingerprint is a7:af:72:48:a0:35:7a:da:a1:7a:03:62:47:b0:11:b6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.25.30.3' (RSA) to the list of known hosts.
root@172.25.30.3's password: 
fence_xvm.key                                 100%  128     0.1KB/s   00:00    
[root@foundation66 cluster]#
[root@foundation66 cluster]# systemctl start fence_virtd.service 
[root@foundation66 cluster]# systemctl status fence_virtd.service 
[[root@foundation66 cluster]# virsh list
 Id    Name                           State
----------------------------------------------------
 18    vm5                            running
 20    vm5                            running
[root@foundation66 cluster]#

*在浏览器刚做的集群中
添加fence等…
这里写图片描述
这里写图片描述

down掉其中一个

[root@server5 cluster]# fence_node server6#down掉server6
fence server6 success
[root@server5 cluster]#clustat  #查看集群状态

[VIP]
*vip是一个不存在的ip,当访问此ip是,会通过自己的设置,按照优先级开启优先级高的服务器的Apache服务

这里写图片描述
这里写图片描述
这里写图片描述

[root@server5 ~]# clustat 
Cluster Status for wuxie @ Tue May 23 20:32:04 2017
Member Status: Quorate

 Member Name                                   ID   Status
 ------ ----                                   ---- ------
 server5                                           1 Online, Local, rgmanager
 server6                                           2 Online, rgmanager

 Service Name                         Owner (Last)                         State         
 ------- ----                         ----- ------                         -----         
 service:Apache                       server5                              started       
[root@server5 ~]#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值