使用pcsshell配置cor osync & pa cemak er集
Pac emake r
Pac emake r,即Cl uster Reso urceManag er(CR M),管理整个HA,客户端通过pacem aker管理监控整个集。
CRM支持ocf和l sb两种资源类型:
ocf格式的启动脚本在/us r/lib/ocf/resou rce.d/下面。
lsb的脚本一般在/etc/r c.d/i nit.d/下面。
1、常用的集管理工具:
(1)基于命令行
crm s hell/pcs
(2)基于图形化
p ygui/hawk/lcmc/pcs
2、相关的资源文件:
(1)/usr/lib/o cf/re sourc e.d,p acema ker资源库文件位置,可安装资源包:re sourc e-age nts 获取更多oc f格式的资源。
(2)/usr/sbin/fenc e_***,Fenc ing设备的执行脚本名称,可安装资源包:fence-agen ts 获取更多Fen cing设备资源。
3、查看使用说明:
[sh ell]# manocf_h eartb eat_*** ## 查看OCF资源说明,ma n
ocf_hear tbeat_apac he
[shell]# ma n fen ce_*** ## 查看Fenci ng设备说明,man fenc e_vmw are
4、参考文档
htt ps://githm/Clus terLa bs
ht tp://clust erlag/doc/
http://ww w.lin ux-ha.org/doc/m an-pa ges/m an-pa ges.h tml
h ttps://acc ess.r edhat/docum entat ion/e n-
US/Red_H at_En terpr ise_L inux/6/htm l/Con figur ing_t he_Re d_Hat_High_Avai labil ity_A d d-On_with_Pace maker/inde x.htm l
在集配置过程中参考了互联网上众多优秀文章,在此感谢原作者!!!
以下记录整理了在vmwar e esx i5.5+ cen tos6.6环境中使用PCS命令配置co rosyn c & p acema ker集的一些操作,由于本人水平有限,仅供参考:
--------------------------------------------------
1.安装集软件:
[she ll]#yum -y ins tallcoros ync p acema ker p cs
[shell]# yu m -yinsta ll fe nce-a gents reso urce-agent s
2.拷贝配置文件、启动脚本
[s hell]# mkd ir -p /etc/clus ter/
[she ll]#ln -s /etc/rc.d/init.d/co rosyn c /et c/rc.d/ini t.d/c man
[shel l]# l n -s/usr/sbin/coros ync-c mapct l /us r/sbi n/cor osync-objc tl
[shell]# cp /etc/coro sync/coros ync.c onf.e xampl e /et c/cor osync/coro sync.conf
注意:集需要严格的时间同步机制,如果启用了防火墙需要开放相应的端口。
--------------------------------------------------
PCS(Pacem aker/Coros ync c onfig urati on sy stem)命令配置集示例:
一、建立集:
1、配置集节点的认证asthe h aclus ter u ser:
[she ll]#pcs c luste r aut h nod e11 n ode12
2、创建一个二个节点的集
[sh ell]# pcsclust er se tup --name mycl uster node11 no de12
[she ll]#pcs c luste r sta rt --all ## 启动集
3、设置资源默认粘性(防止资源回切)
[s hell]# pcs reso urcedefau lts r esour ce-st ickin ess=100
[shell]# pc s res ource defa ults
4、设置资源超时时间
[s hell]# pcs reso urceop de fault s tim eout=90s
[shel l]# p cs re sourc e opdefau lts
5、二个节点时,忽略节点quo rum功能
[sh ell]# pcsprope rty s et no-quor um-po licy=ignor e
6、没有 Fe ncing设备时,禁用STON ITH 组件功能
在 ston ith-e nable d="fa lse"的情况下,分布式锁管理器 (D LM) 等资源以及依赖DLM的所有服务(例如c LVM2、GFS2和 OCF S2)都将无法启动。
[sh ell]# pcsprope rty s et st onith-enab led=f alse
[she ll]#crm_v erify -L -V ## 验证集配置信息
二、建立集资源
1、查看可用资源
[shel l]# p cs re sourc e lis t ##查看支持资源列表,p cs re sourc e lis t ocf:hear tbeat
[sh ell]# pcsresou rce d escri be ag ent_n ame ##查看资源使用参数,pcs r esour ce de scrib e ocf:hear tbeat:IPad dr2
2、配置虚拟IP
[shel l]# p cs re sourc e cre ate C luste rIP o cf:he artbe at:IP addr2 \
ip="192.168.10.15" c idr_n etmas k=32nic=e th0 o p mon itorinter val=30s
3、配置A pache(http d)
[shell]# pc s res ource crea te We bServ er oc f:hea rtbea t:apa che \
ht tpd="/usr/sbin/httpd" con figfi le="/etc/h ttpd/conf/httpd.conf" \
stat usurl="htt p://l ocalh ost/s erver-stat us" o p mon itorinter val=1min
4、配置N ginx
[she ll]#pcs r esour ce cr eateWebSe rverocf:h eartb eat:n ginx\
h ttpd="/usr/sbin/ngin x" co nfigf ile="/etc/nginx/ngin f" \
sta tusur l="ht tp://local host/ngx_s tatus" opmonit or in terva l=30s
5.1、配置Fi leSys tem
[shel l]# p cs re sourc e cre ate W ebFSocf:h eartb eat:F ilesy stem\
d evice="/de v/sdb1" di recto ry="/var/w ww/ht ml" f stype="ext4"
[shel l]# p cs re sourc e cre ate W ebFSocf:h eartb eat:F ilesy stem\
d evice="-U32937d65eb" dir ector y="/v ar/ww w/htm l" fs type="ext4"
5.2、配置F ileSy stem-NFS
[shel l]# p cs re sourc e cre ate W ebFSocf:h eartb eat:F ilesy stem\
d evice="192.168.10.18:/mys qldat a" di recto ry="/var/l ib/my sql"fstyp e="nf s" \
opt ions="-o u serna me=yo ur_na me,pa sswor d=you r_pas sword" \
op s tarttimeo ut=60s opstoptimeo ut=60s opmonit or in terva l=20s time out=60s
6、配置Is csi
[shel l]# p cs re sourc e cre ate W ebDat a ocf:hear tbeat:iscs i \
port al="192.168.10.18" t arget="iqn.2008-08.c om.st arwin dsoft ware:" \
cf烟雾头设置 op m onito r dep th="0" tim eout="30"inter val="120"
[sh ell]# pcsresou rce c reate WebF S ocf:hear tbeat:File syste m \
devi ce="-U 32937d65eb" d irect ory="/var/www/h tml"fstyp e="ex t4" o ption s="_n etdev" 7、配置DRB D
[s hell]# pcs reso urcecreat e Web Dataocf:l inbit:drbd \
drbd_resou rce=w wwdat a opmonit or in terva l=60s
[s hell]# pcs reso urcemaste r Web DataC loneWebDa ta \
mas ter-m ax=1maste r-nod e-max=1 cl one-m ax=2clone-node-max=1 not ify=t rue
[she ll]#pcs r esour ce cr eateWebFS ocf:heart beat:Files ystem \
devic e="/d ev/dr bd1"direc tory="/var/www/html" fsty pe="e xt4"
8、配置MySQL
[sh ell]# pcsresou rce c reate MySQ L ocf:hear tbeat:mysq l \
bina ry="/usr/b in/my sqld_safe" conf ig="/etc/m yf" dat adir="/var/lib/mysql" \
pid="/var/run/mysql d/mys ql.pi d" so cket="/tmp/mysq l.soc k" \
opstart time out=180s o p sto p tim eout=180sop mo nitor inte rval=20s t imeou t=60s
9、配置Ping d,检测节点与目标的连接有效性
[sh ell]# pcsresou rce c reate Ping Check ocf:heart beat:pingd \
dampe n=5smulti plier=100host_list="192.168.10.1 r outer" \
op m onito r int erval=30stimeo ut=10s
10、创建资源clone,克隆的资源会在全部节点启动
[she ll]#pcs r esour ce cl one P ingCh eck
[shel l]# p cs re sourc e clo ne Cl uster IP cl one-m ax=2clone-node-max=2 glo bally-
uniq ue=tr ue ##clone-max=2,数据包分成2路
[she ll]#pcs r esour ce up dateClust erIPclust erip_hash=sourc eip ##指定响应请求的分配策略为:s ource ip
三、调整集资源
1、配置资源约束
[she ll]#pcs r esour ce gr oup a dd We bSrvs Clus terIP##配置资源组,组中资源会在同一节点运行
[shel l]# p cs re sourc e gro up re moveWebSr vs Cl uster IP ##移除组中的指定资源
[sh ell]# pcsresou rce m aster WebD ataCl one W ebDat a ## 配置具有多个状态的资源,如 DR BD ma ster/slave状态
[shell]# pc s con strai nt co locat ion a dd We bServ er Cl uster IP IN FINIT Y ## 配置资源捆绑关系
[sh ell]# pcsconst raint colo catio n rem ove W ebSer ver ## 移除资源捆绑关系约束中资源
[shell]# pc s con strai nt or der C luste rIP t hen W ebSer ver ##配置资源启动顺序
[she ll]#pcs c onstr aintorder remo ve Cl uster IP ## 移除资源启动顺序约束中资源
[s hell]# pcs cons train t ## 查看资源约束关系, pcs cons train t --f ull
2、配置资源位置
[shel l]# p cs co nstra int l ocati on We bServ er pr efers node11 ## 指定资源默认某个节点,n ode=50 指定增加的 sc ore
[shel l]# p cs co nstra int l ocati on We bServ er av oidsnode11 ##指定资源避开某个节点,nod e=50指定减少的 scor e
[s hell]# pcs cons train t loc ation remo ve lo catio n-Web Serve r ##移除资源节点位置约束中资源I D,可用p cs co nfig获取
[s hell]# pcs cons train t loc ation WebS erver pref ers n ode11=INFI NITY##手工移动资源节点,指定节点资源的 sc ore o f INF INITY
[sh ell]# crm_simul ate -sL ##验证节点资源sco re 值
3、修改资源配置
[she ll]#pcs r esour ce up dateWebFS## 更新资源配置
[shel l]# p cs re sourc e del ete W ebFS##删除指定资源
4、管理集资源
[shell]# pc s res ource disa ble C luste rIP ## 禁用资源
[shel l]# p cs re sourc e ena ble C luste rIP ## 启用资源
[shel l]# p cs re sourc e fai lcoun t sho w Clu sterI P ## 显示指定资源的错误计数
[sh ell]# pcsresou rce f ailco unt r esetClust erIP##清除指定资源的错误计数
[shel l]# p cs re sourc e cle anupClust erIP##清除指定资源的状态与错误计数
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论