Corosync+Pacemaker高可用集群构建过程详解

Corosync+Pacemaker高可用集群构建过程详解

注意:使用LSB资源类型的不能开机自动运行
OCF(open cluster framework):/usr/lib/ocf/resource.d/provider/,类似于LSB的脚本,但仅支持start,stop,status,monitor,meta-data

注意:必须设置enable,设置为开机自动启动

二、corosync安装及其配置
安装:

要求:1.基于主机名之间进行相互解析 2.各个节点之间时间需同步
安装:yum -y install pacemaker (CentOS7)

corosync配置详解:corosync的主要配置分为totem、logging、quorum、nodelist配置段

totem { #定义各个节点之间的通信方式、加密与否,
version: 2 #指明totem的版本信息
cluster_name:myclusters #定义集群名称
crypto_cipher: aes128 #定义加密算法
crypto_hash: sha1 #定义hash算法
interface { #心跳及其事务传递接口
ringnumber: 0 #环接口
bindnetaddr: 10.1.0.0 #绑定的 段
mcastaddr: 239.25.102.1 #多播地址
mcastport: 5405 #多播端口
ttl: 1 #生存时间,防止发生环路
}
}
logging { #日志模块
fileline: off
to_stderr: no #标准错误输出
to_logfile: yes
logfile: /var/log/cluster/corosync.log #日志存放路径
to_syslog: no
debug: off
timestamp: on
logger_subsys {
subsys: QUORUM
debug: off
}
}
quorum { #投票系统
provider: corosync_votequorum #开启投票机制
}
nodelist { #节点列表
node {
ring0_addr: 10.1.10.65 #节点IP地址
nodeid: 1 #节点编
}
node {
ring0_addr: 10.1.10.66 #节点列表
nodeid: 2 #节点编
}
}

三、corosync+pacemaker+nfs实现高可用案例
此实验需将另一台服务器启动nfs服务并挂载至两节点上配置同样的页面文件

node 167840321: node1.alren.com #默认设置,此在corosync配置文件中定义
attributes standby=on
node 167840322: node2.alren.com
attributes standby=off
primitive webip IPaddr #定义webip
params ip=10.1.10.80
meta target-role=Started
primitive webserver systemd:httpd #定义webserver
primitive webstore Filesystem #定义webstore
params device=”10.1.10.67:/www/html” directory=”/var/www/html” fstype=nfs
op start timeout=60s interval=0 #附加选项为超时时间、时间间隔
op stop timeout=60s interval=0
group webservice webip webstore webserver #将webip、webserver、webstore加入到webservice组
location cli-prefer-webservice webservice role=Started inf: node1.alren.com
property cib-bootstrap-options:
have-watchdog=false
dc-version=1.1.13-10.el7-44eb2dd
cluster-infrastructure=corosync
cluster-name=myclusters
stonith-enabled=false
symmetric-cluster=true

vim: set filetype=pcmk:

这里写图片描述

crm(live)configure# show
node 167840321: node1.alren.com
attributes standby=on
node 167840322: node2.alren.com
attributes standby=off
primitive webip IPaddr
params ip=10.1.10.80
meta target-role=Started
primitive webserver systemd:httpd
primitive webstore Filesystem
params device=”10.1.10.67:/www/html” directory=”/var/www/html” fstype=nfs
op start timeout=60s interval=0
op stop timeout=60s interval=0
colocation webip_webserver_with_webstore inf: webip webserver webstore #设定排列约束
order webip_before_webstore_before_webserver Mandatory: webip webstore webserver #设定顺序约束,此时启动顺序为:webip,webstore,webserver
property cib-bootstrap-options:
have-watchdog=false
dc-version=1.1.13-10.el7-44eb2dd
cluster-infrastructure=corosync
cluster-name=myclusters
stonith-enabled=false
symmetric-cluster=true
default-resource-stickiness=200

定义资源监控配置如下:当httpd服务停止时,将自动重启httpd,如重启失败则将资源转移至可用的节点
crm(live)configure# show
node 167840321: node1.alren.com
attributes standby=off
node 167840322: node2.alren.com
attributes standby=on
primitive webip IPaddr
params ip=10.1.10.80
meta target-role=Started
primitive webserver systemd:httpd
op start timeout=15s interval=0 #定义资源启动间隔及其超时时间
op stop timeout=15s interval=0 #定义资源停止时间间隔及其超时时间
op monitor interval=15s timeout=15s #定义资源监控的时间间隔及其超时时间
primitive webstore Filesystem
params device=”10.1.10.67:/www/html” directory=”/var/www/html” fstype=nfs
op start timeout=60s interval=0
op stop timeout=60s interval=0
colocation webip_webserver_with_webstore inf: webstore webip webserver
order webip_before_webstore_before_webserver Mandatory: webip webstore webserver
property cib-bootstrap-options:
have-watchdog=false
dc-version=1.1.13-10.el7-44eb2dd
cluster-infrastructure=corosync
cluster-name=myclusters
stonith-enabled=false
symmetric-cluster=true
default-resource-stickiness=200
no-quorum-policy=ignore
last-lrm-refresh=1479180221

总结:综合上诉的配置总体感觉corosync+pacemaker的方式实现高可用比lvs略微复杂,corosync同样可实现对RS的健康状态检测,可借助ldirectory实现自动生成ipvs规则

文章知识点与官方知识档案匹配,可进一步学习相关知识CS入门技能树Linux入门初识Linux24720 人正在系统学习中

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2017年2月9日
下一篇 2017年2月9日

相关推荐