CentOS 6.6 上使用 luci/ricci 安装配置 RHCS 集群

前端之家收集整理的这篇文章主要介绍了CentOS 6.6 上使用 luci/ricci 安装配置 RHCS 集群前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


1.配置 RHCS 集群的前提:

  1. 时间同步

  2. 名称解析,这里使用修改/etc/hosts 文件

  3. 配置好 yum 源,CentOS 6 的默认的就行

  4. 关闭防火墙(或者开放集群所需通信端口),和selinux

  5. 关闭 NetworkManager 服务


2. RHCS 所需要的主要软件包为cman rgmanager

cman: 是集群基础信息层,在 CentOS 6中依赖 corosync

rgmanager: 是集群资源管理器, 类似于pacemaker 功能

luci: 提供了管理 rhcs 集群的 web 界面,luci 管理集群主要是通过跟 ricci 通信来完成的。

ricci: 安装在集群的节点的接收来自 luci 管理请求的代理。

luci ricci 的关系就好像 ambari-server ambari-agent 一样。


3.环境说明:

luci:192.168.6.31cent1.test.com
ricci:192.168.6.32cent2.test.com
ricci:192.168.6.33cent3.test.com
ricci:192.168.6.34cent4.test.com

我这里已经配好了主机名了,但是其他的如时间同步,配置/etc/hosts/ 等都没执行,为了方便,所以写了个 playbook 来进行初始化一下

---
-hosts:hdpservers
remote_user:root
vars:
tasks:
-name:addsynctimecron
cron:name='synctime'minute='*/5'job='/usr/sbin/ntpdate192.168.6.31'
-name:shutdowniptables
service:name={{item.name}}state={{item.state}}enabled={{item.enabled}}
with_items:
-{name:iptables,state:stopped,enabled:no}
-{name:NetworkManager,enabled:no}
tags:stopservice
-name:copyselinuxconffile
copy:src={{item.src}}dest={{item.dest}}owner={{item.owner}}group={{item.group}}mode={{item.mode}}
with_items:
-{src=\'#\'" /etc/selinux/config',dest:/etc/selinux/config,owner:root,group:root,mode:'0644'}
-{src=\'#\'" /etc/hosts',dest:/etc/hosts,mode:'0644'}
-name:cmdoffselinux
shell:setenforce0

执行这个 playbook,进行初始化

[root@cent1yaml]#ansible-playbookbase.yml

4. cent1 上安装 luci,luci 是一个 python 程序,依赖很多python

[root@cent1~]#yuminstallluci

启动 luci

[root@cent3~]#/etc/init.d/lucistart
Addingfollowingauto-detectedhostIDs(IPaddresses/domainnames),correspondingto`cent3'address,totheconfigurationofself-managedcertificate`/var/lib/luci/etc/cacert.config'(youcanchangethembyediting`/var/lib/luci/etc/cacert.config',removingthegeneratedcertificate`/var/lib/luci/certs/host.pem'andrestartingluci):
(nonesuitablefound,youcanstilldoitmanuallyasmentionedabove)

Generatinga2048bitRSAprivatekey
writingnewprivatekeyto'/var/lib/luci/certs/host.pem'
正在启动saslauthd:[确定]
Startluci...[确定]
Pointyourwebbrowsertohttps://cent1.hfln.com:8084(orequivalent)toaccessluci

现在可以在前台登录luci 了,看清是 https

wKiom1hyEoyzMOQgAACbKZtlLzM010.png-wh_50

账号密码就是这台主机的账号和密码

wKioL1hyEsGBvBTUAACQpOagIiI054.png-wh_50

登录成功啦,现在来配置 rhcs 的集群,这个只是用来管理集群的,真正的集群还没开始装呢。

5. cnet2,cent3,cent4 中安装 ricci,ricci 也依赖很多软件,这里使用 ansible 直接在三个节点上装, 当然我已经配好了 cent1 其他节点的免密钥登录

[root@cent1~]#ansiblerhcs-myum-a"name=ricci"

装好ricci 之后还要在 node 节点上给 ricci 用户设置密码,ricci用户就是运行 ricci进程的用户,这个密码一会要用,这里就简单粗暴了,这个密码还可以用 ccs命令来进行设置

[root@cent1~]#ansiblerhcs-mshell-a"echo'123456'|passwd--stdinricci"

启动 ricci

[root@cent1~]#ansiblerhcs-mservice-a"name=riccistate=startedenabled=yes"
[root@cent2~]#ss-tunlp|grepricci
tcpLISTEN05:::11111:::*users:(("ricci",3237,3))

ricci 监听在 11111 端口,像这种操作当然也是可以写到 playbook 当中的


6. 现在可以在web 界面上配置集群了,比如创建/添加/删除一个集群,管理node,resource,fence device,servicegroups,Failover Domains 等等集群的全生命周期都可以在这里完成。


这里演示一个关于 web服务的高可用服务

Manage Clusters--> Create 是创建一个集群

wKioL1hyFQ7xT45yAADbD9J-0DI383.png-wh_50

这个界面还算简单吧;

wKioL1hyFZ7wiKFQAADMU6p_c2A753.png-wh_50

Create Cluster 之后,那么就开始尝试安装集群软件了.

在任意一个node上可以看到 ricci 的工作进程:

[root@cent2~]#psaux|grepricci
ricci34530.10.42136644400?S<s17:180:00ricci-uricci
ricci34890.00.1549121908?S<s17:220:00/usr/libexec/ricci/ricci-worker-f/var/lib/ricci/queue/1500004777
root34900.20.5485525136?S17:220:00ricci-modrpm
root35670.00.0103252880pts/0S+17:240:00grepricci

/var/lib/ricci/queue/目录下存放的是 luci 发给 ricci 的任务文件 XML 格式的

[root@cent2~]#file/var/lib/ricci/queue/1500004777
/var/lib/ricci/queue/1500004777:XMLdocumenttext

7. 安装成功了

wKioL1hyFj2g6fBUAADptWp3XSk187.png-wh_50

可以点任何一个node 进去看看

wKiom1hyFl-iji5ZAABejjAPvnA610.png-wh_50

如果这底下的服务没启动的话,可以尝试手动起一下,一般来说是OK的。


8.添加资源


这里没有 fence 设备,不关注这个,添加两个公共资源,并添加一个服务,然后来启动服务

Resources -->Add : 添加一个资源

wKiom1hyFp6gPQcQAABHuqot2Z4055.png-wh_50

添加一个虚拟IP,这里的 mask 要写成上面这样,不能写成 255.255.255.0 这种,否则会导致无法添加IP

rgmanagerStartingstoppedserviceservice:web1
rgmanagerstartonip"192.168.6.100/255.255.255.0"returned1(genericerror)
rgmanager#68:Failedtostartservice:web1;returnvalue:1

添加一个script资源

wKioL1hyFvCgVf2kAAAvcOMojQQ397.png-wh_50


9.添加 Service

这里的资源是共公的,假如这个集群内有多个服务,那么都可以使用这些资源,也可以在

Service Groups 添加一个私有的资源。

现在添加一个Service:


Service Groups--> Add : 添加一个 Service,

wKiom1hyF62x9i_rAACcvdyoeb0068.png-wh_50

Add Resource 将刚才建立的两个资源添加进来;

wKioL1hyF_3BN0Y-AAC6KjlqtDs615.png-wh_50

现在在集群的节点上用命令查看一下,集群内的任何节点都可以

[root@cent3~]#clustat
ClusterStatusforha1@SunJan817:47:402017
MemberStatus:Quorate

MemberNameIDStatus
--------------------
cent2.test.com1Online,rgmanager
cent3.test.com2Online,Local,rgmanager
cent4.test.com3Online,rgmanager

ServiceNameOwner(Last)State
---------------------------
service:web1cent2.test.comstarted

cent2 ip httpd 服务都已经起来了

[root@cent2~]#ipa
1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWN
link/loopback00:00:00:00:00:00brd00:00:00:00:00:00
inet127.0.0.1/8scopehostlo
inet6::1/128scopehost
valid_lftforeverpreferred_lftforever
2:eth0:<BROADCAST,MULTICAST,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000
link/ether00:0c:29:91:b3:11brdff:ff:ff:ff:ff:ff
inet192.168.6.32/24brd192.168.6.255scopeglobaleth0
inet192.168.6.100/24scopeglobalsecondaryeth0
inet6fe80::20c:29ff:fe91:b311/64scopelink
valid_lftforeverpreferred_lftforever
[root@cent2~]#netstat-tunlp|grep80
tcp00:::80:::*LISTEN34901/httpd

10.测试故障转移:


关于 rhcs service 的健康状态检测,可以通过 /var/log/cluster/rgmanager.log 日志来查看

Jan0818:56:59rgmanager[ip]Checking192.168.6.100/24,Level10
Jan0818:56:59rgmanager[ip]192.168.6.100/24presentoneth0
Jan0818:56:59rgmanager[ip]Linkforeth0:Detected
Jan0818:56:59rgmanager[ip]Linkdetectedoneth0
Jan0818:56:59rgmanager[ip]Localpingto192.168.6.100succeeded

这里可以看到他会尝试查看和 ping 192.168.6.100 ,这是针对 IP 资源的检测方式

Jan0818:55:49rgmanager[script]Executing/etc/rc.d/init.d/httpdstatus

上面是 script 资源的检测方式则是仅仅去用脚本来执行 status 参数。

在我尝试将/etc/init.d/httpd/ stop 后,日志出现了如下:

Jan0818:56:59rgmanager[script]Executing/etc/rc.d/init.d/httpdstatus
Jan0818:56:59rgmanager[script]script:http1:statusof/etc/rc.d/init.d/httpdFailed(returned3)
#这里发现检测失败了
Jan0818:56:59rgmanagerstatusonscript"http1"returned1(genericerror)
Jan0818:56:59rgmanagerStoppingserviceservice:web1
Jan0818:56:59rgmanager[script]Executing/etc/rc.d/init.d/httpdstop
Jan0818:56:59rgmanager[ip]RemovingIPv4address192.168.6.100/24frometh0
#以上几步在这个节点停止了web1服务
Jan0818:57:09rgmanagerServiceservice:web1isrecovering
Jan0818:57:14rgmanagerServiceservice:web1isnowrunningonmember2
#将web1服务在member2上恢复了,member2也就是cent3.test.com

查看转移后的集群状态:

[root@cent3~]#clustat
ClusterStatusforha1@SunJan820:25:262017
MemberStatus:Quorate

MemberNameIDStatus
--------------------
cent2.test.com1Online,rgmanager

ServiceNameOwner(Last)State
---------------------------
service:web1cent3.test.comstarted



如果这种 script 的资源不符合你的需求,那么可以尝试 apache 资源。即使你认为这种 script 的资源检查方式过于简单,也可以在脚本里添加功能来达到你的目的。


11.尝试关闭节点,查看 Service 转移情况:

在关掉 cent3 之后,service 转移到了 cent4

[root@cent2~]#clustat
ClusterStatusforha1@SunJan820:35:422017
MemberStatus:Quorate

MemberNameIDStatus
--------------------
cent2.test.com1Online,rgmanager
cent3.test.com2Offline
cent4.test.com3Online,rgmanager

ServiceNameOwner(Last)State
---------------------------
service:web1cent4.test.comstarted

接着关掉了 cent4,Service 又转移到了 cent2

[root@cent2~]#clustat
ClusterStatusforha1@SunJan820:36:272017
MemberStatus:Quorate

MemberNameIDStatus
--------------------
cent2.test.com1Online,rgmanager
cent3.test.com2Offline
cent4.test.com3Online

ServiceNameOwner(Last)State
---------------------------
service:web1cent2.test.comstarted

这里的 cent4.test.com 仍然显示 Online 是因为正在关机当中,尚未真正关闭

过了几秒,弹出了以下提示信息:

[root@cent2~]#
Messagefromsyslogd@cent2atJan820:36:42...
rgmanager[5685]:#1:QuorumDissolved

日志里显示

Jan0820:35:01rgmanagerMember2shuttingdown

Jan0820:36:18rgmanagerMember3shuttingdown
Jan0820:36:18rgmanagerStartingstoppedserviceservice:web1
Jan0820:36:18rgmanager[ip]Linkforeth0:Detected
Jan0820:36:19rgmanager[ip]AddingIPv4address192.168.6.100/24toeth0
Jan0820:36:19rgmanager[ip]Pingingaddr192.168.6.100fromdeveth0
Jan0820:36:21rgmanager[ip]SendinggratuitousARP:192.168.6.10000:0c:29:91:b3:11brdff:ff:ff:ff:ff:ff
Jan0820:36:22rgmanager[script]Executing/etc/rc.d/init.d/httpdstart
Jan0820:36:22rgmanagerServiceservice:web1started
Jan0820:36:42rgmanager#1:QuorumDissolved

Messagefromsyslogd@cent2atJan820:36:42...
rgmanager[5685]:#1:QuorumDissolved
Jan0820:36:42rgmanager[script]Executing/etc/rc.d/init.d/httpdstop
Jan0820:36:42rgmanager[ip]RemovingIPv4address192.168.6.100/24frometh0

服务停止了,这是因为 法定票数不足的原因

[root@cent2~]#clustat
Servicestatesunavailable:Operationrequiresquorum
ClusterStatusforha1@SunJan820:37:002017
MemberStatus:Inquorate

MemberNameIDStatus
--------------------
cent2.test.com1Online,Local
cent3.test.com2Offline
cent4.test.com3Offline
原文链接:https://www.f2er.com/centos/379127.html

猜你在找的CentOS相关文章