高可用集羣是指以減少服務中斷時間爲目的的服務器集羣技術。它通過保護用戶的業務程序對外不間斷提供的服務,把因軟件/硬件/人爲造成的故障對業務的影響降低到最小程度。高可用集羣的應用系統有多樣化發展趨勢,用途也越來越多樣化,同時帶來了配置及可操作性方面的複雜性,因此選擇好的高可用軟件至關重要。
實驗環境:真機:172.25.254.29
server4:172.25.29.4
server5:172.25.29.5
server6:172.25.29.6
一.首先配置好高可用集羣yum源;每臺實驗服務器一樣;相互解析。
[root@server4 ~]# vim /etc/yum.repos.d/yum.repo
[base]
name=Instructor Server Repository
baseurl=http://172.25.29.450/rhel6.5
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
# HighAvailability rhel6.5
[HighAvailability]
name=Instructor HighAvailability Repository
baseurl=http://172.25.29.450/rhel6.5/HighAvailability
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
# LoadBalancer packages
[LoadBalancer]
name=Instructor LoadBalancer Repository
baseurl=http://172.25.29.450/rhel6.5/LoadBalancer
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
# LoadBalancer packages
[LoadBalancer]
name=Instructor LoadBalancer Repository
baseurl=http://172.25.29.450/rhel6.5/LoadBalancer
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
# ResilientStorage
[ResilientStorage]
name=Instructor ResilientStorage Repository
baseurl=http://172.25.29.450/rhel6.5/ResilientStorage
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
# ScalableFileSystem
[ScalableFileSystem]
name=Instructor ScalableFileSystem Repository
baseurl=http://172.25.29.450/rhel6.5/ScalableFileSystem
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@server4 ~]# yum clean all
[root@server4 ~]# yum repolist
[root@server4 ~]#vim /etc/hosts
172.25.29.4 server4.example.com
172.25.29.5 server5.example.com
172.25.29.6 server6.example.com
172.25.254.29
二.server4和server5作爲高可用服務器;server6安裝lici用作圖形界面
[root@server4 ~]# yum install -y ricci
[root@server4 ~]# passwd ricci
更改用戶 ricci 的密碼 。
新的 密碼:
無效的密碼: 它基於字典單詞
無效的密碼: 過於簡單
重新輸入新的 密碼:
passwd: 所有的身份驗證令牌已經成功更新。
[root@server4 ~]# /etc/init.d/ricci start
[root@server4 ~]# chkconfig ricci on
[root@server5 ~]# yum install -y ricci
[root@server5 ~]# passwd ricci
更改用戶 ricci 的密碼 。
新的 密碼:
無效的密碼: 它基於字典單詞
無效的密碼: 過於簡單
重新輸入新的 密碼:
passwd: 所有的身份驗證令牌已經成功更新。
[root@server5 ~]# /etc/init.d/ricci start
[root@server5 ~]# chkconfig ricci on
[root@server6 ~]# yum install luci -y
[root@server6 ~]# /etc/init.d/luci start
Start luci... [確定]
Point your web browser to https://server6.example.com:8084 (or equivalent) to access luci
三.真機安裝fence
[root@foundation29 ~]# rpm -qa|grep fence
fence-virtd-serial-0.3.2-1.el7.x86_64
fence-virtd-0.3.2-1.el7.x86_64
fence-virtd-libvirt-0.3.2-1.el7.x86_64
fence-virtd-multicast-0.3.2-1.el7.x86_64
[root@foundation29 ~]# yum install -y fence-virtd*
[root@foundation29 ~]# fence_virtd -c
Module search path [/usr/lib64/fence-virt]:
Listener module [multicast]:
Multicast IP Address [225.0.0.12]:
Multicast IP Port [1229]:
Interface [br0]:
Key File [/etc/cluster/fence_xvm.key]:
Backend module [libvirt]:
Replace /etc/fence_virt.conf with the above [y/N]? y
[root@foundation29 ~]# systemctl restart fence_virtd
[root@foundation29 ~]# systemctl status fence_virtd
[root@foundation29 ~]# netstat -anulp |grep 1229
udp 0 0 0.0.0.0:1229 0.0.0.0:* 205
[root@foundation29 ~]# cd /etc/
[root@foundation29 etc]# mkdir cluster/
[root@foundation29 etc]# dd if=/dev/random of=/etc/cluster/fence_xvm.key bs=128 count=1
[root@foundation29 cluster]# ls
fence_xvm.key
[root@foundation29 cluster]# file fence_xvm.key
fence_xvm.key: data
[root@foundation29 cluster]# systemctl restart fence_virtd
[root@foundation29 cluster]# vim /etc/fence_virt.conf
[root@foundation29 cluster]# scp fence_xvm.key [email protected]:/etc/cluster/
[email protected]'s password:
fence_xvm.key 100% 128 0.1KB/s 00:00
[root@foundation29 cluster]# scp fence_xvm.key [email protected]:/etc/cluster/
[email protected]'s password:
fence_xvm.key 100% 128 0.1KB/s 00:00
四.對集羣進行設置;讓集羣統一管理服務器
[root@server4 ~]# clustat 查看狀態
Cluster Status for www @ Sat Sep 17 18:56:42 2016
Member Status: Quorate
Member Name ID Status
------ ---- ---- ------
server4.example.com 1 Online
server5.example.com 2 Online, Local
[root@server4 ~]#fence_node server5.example.com
@@@@@用server4把server5 (fence)server5重啓
[root@server4 ~]# yum install httpd -y (安裝httpd不要開啓;讓組幫助開啓)
[root@server4 ~]# cd /var/www/html
[root@server4 html]# vim index.html (添加發布內容方便驗證)
[root@server4 cluster]#echo c > /proc/sysrq-trigger (當server4損壞時組會把server4 踢出去server5接手;server4重啓後又會自動加入組中等待)
[root@server5 cluster]#/etc/init.d/httpd stop (當關掉server5的httpd時組會自動把server5踢出去;server4接手;server5重器後又會自動加入組中)