ricci+luic+fence实现HA

来源:互联网 发布:同方软件股份有限公司 编辑:程序博客网 时间:2024/06/05 04:07

[server5]

[root@server5 ~]# cat /etc/hosts   #解析127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4::1         localhost localhost.localdomain localhost6 localhost6.localdomain6172.25.66.1 server1172.25.66.2 server2172.25.66.3 server3172.25.66.4 server4172.25.66.5 server5172.25.66.6 server6[root@server5 ~]# vim /etc/yum.repos.d/yum.repo #配置YUM.....[server]name=Server     #默认读取的是Serverbaseurl=http://172.25.66.250/rhel6.5/Servergpgcheck=0[HighAvailability]name=HighAvailabilitybaseurl=http://172.25.66.250/rhel6.5/HighAvailabilitygpgcheck=0[LoadBalancer ]name=LoadBalancer baseurl=http://172.25.66.250/rhel6.5/LoadBalancer gpgcheck=0[ResilientStorage]name=ResilientStoragebaseurl=http://172.25.66.250/rhel6.5/ResilientStoragegpgcheck=0[ScalableFileSystem]name=ScalableFileSystembaseurl=http://172.25.66.250/rhel6.5/ScalableFileSystemgpgcheck=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 wordBAD PASSWORD: is too simpleRetype new password: passwd: all authentication tokens updated successfully.[root@server5 ~]# /etc/init.d/ricci restartShutting 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=Serverbaseurl=http://172.25.66.250/rhel6.5/Servergpgcheck=0[HighAvailability]name=HighAvailabilitybaseurl=http://172.25.66.250/rhel6.5/HighAvailabilitygpgcheck=0[LoadBalancer ]name=LoadBalancer baseurl=http://172.25.66.250/rhel6.5/LoadBalancer gpgcheck=0[ResilientStorage]name=ResilientStoragebaseurl=http://172.25.66.250/rhel6.5/ResilientStoragegpgcheck=0[ScalableFileSystem]name=ScalableFileSystembaseurl=http://172.25.66.250/rhel6.5/ScalableFileSystemgpgcheck=0.....[root@server6 ~]# yum install ricci -y[root@server6 ~]# /etc/init.d/ricci startStarting system message bus:                               [  OK  ]Starting oddjobd:                                          [  OK  ]generating SSL certificates...  doneGenerating NSS database...  doneStarting ricci:                                            [  OK  ][root@server6 ~]# passwd ricci         #修改 ricci 密码Changing password for user ricci.New password: BAD PASSWORD: it is based on a dictionary wordBAD PASSWORD: is too simpleRetype new password: passwd: all authentication tokens updated successfully.[root@server6 ~]# /etc/init.d/ricci statusricci (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 fencelibxshmfence-1.2-1.el7.x86_64fence-virtd-multicast-0.3.2-2.el7.x86_64fence-virtd-libvirt-0.3.2-2.el7.x86_64fence-virtd-serial-0.3.2-2.el7.x86_64fence-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    #用随机数生成key1+0 records in1+0 records out128 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)? yesWarning: 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掉server6fence server6 success[root@server5 cluster]#clustat  #查看集群状态

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

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

[root@server5 ~]# clustat Cluster Status for wuxie @ Tue May 23 20:32:04 2017Member 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 ~]#
原创粉丝点击