RHCS集群(ricci,luci)的搭建并实现图像化管理及添加fence及实现高可用性集群(httpd为例)

集群套件的作用

  • 集群中luci的作用:

    luci是用来配置和管理集群,监听在8084上

  • 集群中ricci的作用:
    ricci是安装在每个后端的每个节点上的,luci管理集群上的各个节点就是通过和节点上的ricci进行通信,ricci监听在11111上

  • 集群中fence的作用:
    当意外原因导致主机异常或者宕机时,备机会首先调用FENCE设备,然后通过FENCE设备将异常主机重启或者从网络隔离,当FENCE操作成功执行后,返回信息给备机,备机在接到FENCE成功的信息后,开始接管主机的服务和资源。这样通过FENCE设备,将异常节点占据的资源进行了释放,保证了资源和服务始终运行在一个节点上。并且有效的阻止了“脑裂"的发生。

实验环境:
rhel6.5 selinux and iptables disabled

主机环境:

主机名IP服务
hetoto1172.25.12.1ricci,luci,httpd
hetoto2172.25.12.2ricci,httpd
foundation12172.25.12.250fence

搭建RHCS环境

一、 配置主机和hetoto1,hetoto2的环境环境
1.首先在hetoto1和hetoto2搭建高级的yum源

vim /etc/yum.repo//rhel-source.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=http://172.25.79.250/rhel6.5
enabled=1
gpgcheck=0

[HighAvailability]    ##高可用安装包
name=HighAvailability
baseurl=http://172.25.12.250/rhel6.5/HighAvailability
enabled=1
gpgcheck=0

[LoadBalancer]        ##负载均衡安装包
name=LoadBalancer
baseurl=http://172.25.12.250/rhel6.5/LoadBalancer
enabled=1
gpgcheck=0

[ResilientStorage]    ##弹性存储安装包
name=ResilientStorage
baseurl=http://172.25.12.250/rhel6.5/ResilientStorage
enabled=1
gpgcheck=0

[ScalableFileSystem]  ##文件系统类安装包
name=ScalableFileSystem
baseurl=http://172.25.12.250/rhel6.5/ScalableFileSystem
enabled=1
gpgcheck=0

查看yum源是否正常,添加的安装包是否添加进去

[root@hetoto1 ~]# yum clean all  ##清除yum缓存
[root@hetoto1 ~]# yum repolist	 ##看添加的包是否被检测到

在这里插入图片描述
在这里插入图片描述
配置hetoto2同上

2.添加解析(物理机,hetoto1和hetoto2上都要做)

[root@foundation12 images]# vim /etc/hosts
[root@foundation12 images]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.254.250 content.example.com foundation0.ilt.example.com
172.25.12.1	hetoto1
172.25.12.2	hetoto2
172.25.12.3	hetoto3
172.25.12.4	hetoto4
172.25.12.5	hetoto5
172.25.12.6	hetoto6

hetoto1和hetoto2同上配置

3.在hetoto1安装rhcs的图形网页管理工具

  • ricci(图形里的集群管理)

  • luci(图形界面)

  • 修改ricci用户密码

  • 开启ricci和luci

  • 并设置开机自启

[root@hetoto1 ~]# yum install ricci luci -y
[root@hetoto1 ~]# yum install httpd -y
[root@hetoto1 ~]# passwd ricci

在这里插入图片描述
开启ricci和luci

[root@hetoto1 ~]# /etc/init.d/ricci start
[root@hetoto1 ~]# /etc/init.d/luci start

在这里插入图片描述
设置开机自启

[root@hetoto1 ~]# chkconfig ricci on
[root@hetoto1 ~]# chkconfig luci on
[root@hetoto1 ~]# chkconfig httpd on

在这里插入图片描述

4.在hetoto2上安装ricci,其余同hetoto1上设置

[root@hetoto2 ~]# yum install ricci -y
[root@hetoto2 ~]# passwd ricci
    [root@hetoto2 ~]# /etc/init.d/ricci start

在这里插入图片描述

[root@hetoto2 ~]# chkconfig ricci on
[root@hetoto2 ~]# chkconfig httpd on

在这里插入图片描述

二、创建集群

(1)在浏览器中输入https://172.25.12.1:8084/

  • 因为是https访问,所以需要添加信任网络,点击Advanced …
    在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

(2)登陆帐号和密码是hetoto1中的系统用户和密码,普通用户需要经过超级用户的审核才能登陆,所以一般选择超级用户登陆
在这里插入图片描述在这里插入图片描述

在这里插入图片描述
(3)点击集群管理(Manager Clusters),然后点击create出现以下页面,创建一个集群westos_ha

在这里插入图片描述

在这里插入图片描述

  • 然后点击(CreateCluster),进入等待页面,此时hetoto1和hetoto2会重启,然后在重新连接hetoto1和hetoto2

注:如果没有设定luci和ricci开机自启动,则需要在等待过程中重启虚拟机之后,再次开起服务,才能完成hetoto1和hetoto2集群节点的添加。

节点添加成功如下图
在这里插入图片描述

(4)hetoto1和hetoto2上集群信息的查看

chkconfig --list                     ##查看开机会自启动的服务
cat /etc/cluster/cluster.conf ##发现该文件之中已有hetoto1和hetoto2的集群
clustat                                   ##也会看见集群

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

三、配置fence

FENCE的原理:

  • 当意外原因导致主机异常或者宕机时,备机会首先调用FENCE设备,然后通过FENCE设备将异常主机重启或者从网络隔离,当FENCE操作成功执行后,返回信息给备机,备机在接到FENCE成功的信息后,开始接管主机的服务和资源。这样通过FENCE设备,将异常节点占据的资源进行了释放,保证了资源和服务始终运行在一个节点上。

配置过程:

1.在主机上安装fence
在这里插入图片描述

2.生成fence的加密文件

  • 因为本身配置的文件中没有fence的加密文件,所以要自己生成加密文件,然后再配置fence的配置文件
[root@foundation12 ~]# mkdir /etc/cluster
[root@foundation12 ~]# cd /etc/cluster/
[root@foundation12 cluster]# dd if=/dev/urandom of=/etc/cluster/fence_xvm.key bs=128 count=1
[root@foundation12 cluster]# ls

在这里插入图片描述

3.编辑fence的配置文件

[root@foundation12 ~]# fence_virtd -c

在这里插入图片描述
除了修改此处,其余回车即可
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
4.将修改好的密钥文件发送给节点hetoto1和hetoto2,保证hetoto1和hetoto2利用的是同一个密钥

[root@foundation12 cluster]# scp fence_xvm.key root@172.25.12.1:/etc/cluster/   ##发送给hetoto1
[root@foundation12 cluster]# scp fence_xvm.key root@172.25.12.2:/etc/cluster/   ##发送给hetoto2

在这里插入图片描述

  • 查看hetoto1是否收到密钥
    在这里插入图片描述
    5.打开fence服务
[root@foundation12 cluster]# systemctl start fence_virtd.service 
[root@foundation12 cluster]# systemctl status fence_virtd.service 
[root@foundation12 cluster]# netstat -autnlp | grep 1229

在这里插入图片描述

添加fence设备

1.点击Fence Devices,再点击Add

在这里插入图片描述

  • 选择多播模式的fence

在这里插入图片描述在这里插入图片描述

2.绑定节点(两个节点都要进行以下操作)
(1)hetoto1

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
UUID可以在虚拟机的管理截面看到
在这里插入图片描述

(2)hetoto2同理
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.两个节点都绑定后配置文件内容应该如下:
在这里插入图片描述
4.fence设备的测试

  • 在hetoto1上通过fence干掉节点hetoto2,使hetoto2断电重启则为成功

    [root@hetoto1 cluster]# fence_node hetoto2
    fence hetoto2 success
    在这里插入图片描述

  • 能ssh连接hetoto2,说明hetoto2已经重启成功
    在这里插入图片描述

四、高可用服务配置(httpd为例)

1.添加故障转移域
在这里插入图片描述

  • 将hetoto1和hetoto2添加在域中,即hetoto1或hetoto2出现故障时,切换到正常的那一个上,集群打开后,服务落在优先级高的节点上。(数字越小优先级越高)
    在这里插入图片描述

2.添加服务中所要用到的资源(以httpd高可用为例)
在这里插入图片描述

  • 添加IP Address(集群对外VIP) ,点击Submit提交

5 : 切换主机之间的时间

在这里插入图片描述

  • 再点击Resources,点击Add,选择模式Script,添加启动httpd服务的脚本

在这里插入图片描述
在这里插入图片描述

3.向集群中添加上一步添加的资源(IP Address 和script)

  • 第一步是创建一个资源组(服务中要用到资源的集合)apache
    在这里插入图片描述
  • 接着将资源添加进去
    在这里插入图片描述在这里插入图片描述
    在这里插入图片描述

在hetoto1 和hetoto2上安装httpd服务,并编写默认测试页面内容

[root@hetoto1 ~]# yum install httpd -y
[root@hetoto1 ~]# cd /var/www/html
[root@hetoto1 html]# vim index.html
[root@hetoto1 html]# cat index.html 
hetoto1
[root@hetoto1 html]# /etc/init.d/httpd start

hetoto2上配置同理

[root@hetoto2 ~]# yum install httpd -y
[root@hetoto2 ~]# cd /var/www/html
[root@hetoto2 html]# vim index.html
[root@hetoto2 html]# cat index.html 
hetoto2
[root@hetoto2 html]# /etc/init.d/httpd start
  • 刷新页面,显示httpd服务运行在hetoto2上(优先级高)

在这里插入图片描述

在这里插入图片描述
并且在hetoto2上可以看到添加上的VIP

在这里插入图片描述
4.测试
(1)在物理机访问两台节点,正常
在这里插入图片描述

出现下图这样的报错先看看hetoto1和hetoto2上的httpd服务是否打开?没打开则打开

在这里插入图片描述
(2)在物理机访问VIP——>hetoto2

在这里插入图片描述
(3)测试高可用

  • 在hetoto2中,输入echo c> /proc/sysrq-trigger ,手动宕掉服务器

在这里插入图片描述

  • 再次访问VIP,会发现访问切换到hetoto1上,等hetoto2重启成功之后,则又会切换到hetoto2
    在这里插入图片描述
    注意:
    一般在企业中,需要勾选 No Failback (故障不回切) 、即当hetoto2挂掉后,服务自动转到hetoto1上,并且VIP也会自动飘过来,即使hetoto2重启成功了,服务也不会再转回去

  • 当关掉hetoto2上的httpd,服务会自动转移到hetoto1上
    在这里插入图片描述
    在这里插入图片描述在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值