REDHAT6.4搭建RHCSHA1.安装前准备(1)主机环境:2台装有redhat6.4虚拟机每台虚拟机2块网卡,一块用作业务,一块用作心跳Redhat6.4的ISO镜像(2)地址对应的主机名规划节点1:业务IP:192.168.200.128/24wed1心跳IP:172.16.2.1/24node1hb节点2:业务IP:192.168.200.129/24web2心跳IP:172.16.2.2/24node2hb漂移ip:192.168.200.130webvip2.集群软件安装(1)hosts文件配置,文件内容添加如下,两台机器均做同样操作192.168.200.128web1192.168.200.129web2172.16.2.1node1hb172.16.2.2node2hb192.168.200.130webvip(2)配置yum本地安装,两台机器均做同样操作先把ISO挂载到本地mount/dev/cdrom/mnt编辑yum配置文件如下,习惯应该先把文件备份vi/etc/yum.repos.d/rhel-source.repo内容改成如下即可[rhel-source]name=RedHatEnterpriseLinux$releasever-$basearch-Sourcebaseurl=file:///mnt/enabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[rhel-source-HA]name=RedHatEnterpriseLinux$releasever-$basearch-Sourcebaseurl=file:///mnt/HighAvailabilityenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[rhel-source-LB]name=RedHatEnterpriseLinux$releasever-$basearch-Sourcebaseurl=file:///mnt/LoadBalancerenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[rhel-source-RS]name=RedHatEnterpriseLinux$releasever-$basearch-Sourcebaseurl=file:///mnt/ResilientStorageenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[rhel-source-beta]name=RedHatEnterpriseLinux$releaseverBeta-$basearch-Sourcebaseurl==0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release(3)集群软件包安装,,两台机器均做同样操作yumcleanall(如果安装时报时间错误,可以使用此命令)yuminstallcluster-glueresource-agentspacemakeryuminstallluciriccicmanopenaisrgmanagerlvm2-clustergfs2-utils(4)集群软件启动以及设置自启动,两台机器均做同样操作servicelucistartservicericcistartservicergmanagerstartservicecmanstartchkconfigriccionchkconfiglucionchkconfigcmanonchkconfigrgmanageron(5)修改ricci用户密码,两台机器均做同样操作使用passwdricci将密码设成和root一样,设置好重启ricci服务3.集群配置(1)登录HA配置页面,进行配置,在其中一个节点操作即可我使用的是谷歌浏览器在浏览器输入地址用户名root密码为root密码(2)添加clusters,点击create如下图,输入clustername,nodename和password(3)添加FailoverDomain添加failoverdomain,填写name,勾选prioritized和restricted勾选member,并为两个节点填写优先级,值越小优先级越高(4)添加Resouces本次实验测试httpd的HA,所以添加一个IPADDRESS资源和一个httpd脚本资源添加IPADDRESS资源添加httpdscripts资源(5)添加servicegroups填写ServiceName,勾选AutomaticallyStartThisService,选择刚才添加的FailoverDomain,还没结束,还要AddResource点击AddResource,选择192.168.200.130/24在弹出的IPAddress下点击AddChildResources选择之前添加的httpd,最后点击SubmitConfig里主要配置仲裁盘和心跳多播的,本次实验没有仲裁盘,默认即可,至此HA配置完成4.集群的测试(1)手动切换节点查看集群状态切换至节点2切回节点1(2)杀掉httpd进程我在两个节点的/var/目录下建立index.html文件Kill掉主节点的httpd进程此时访问漂移地址的网页在节点2同样执行此命令此时访问漂移地址的网页(3)断开主节点网线此时主节点在node1上,断开节点1业务网的网线此时查看节点的状态,发现已切换到节点2恢复节点1的业务网线,断开节点2的业务网线,发现一切换到节点1(4)对主节点关电源操作切断节点1的电源,把虚拟机的电源直接关掉节点2一直起不来,看日志应该是没有配置fence设备导致