目录
1. 安装环境 ................................................................................................................................... 1 2. 配置步骤 ................................................................................................................................... 2
2.1 创建集群并加入节点 ........................................................................................................ 3
2.1.1简单集群的配置 ...................................................................................................... 3 2.1.2多心跳网卡集群的配置 .......................................................................................... 4 2.2 在pacemaker中加入stonith设备 .................................................................................... 4
2.2.1 简单的stonith设备的创建 .................................................................................... 4 2.2.2 基于ISCSI的stonith设备的创建 ........................................................................ 5 2.2.3 基于IPMI接口的stonith设备的创建 .................................................................. 5 2.3 在pacemaker中加入DLM和CLVM资源..................................................................... 6 2.4 在pacemaker中加入共享存储资源................................................................................. 6
2.4.1 共享存储设备的类型 ............................................................................................. 6 2.4.2 Pacemaker中共享存储资源的设置 ....................................................................... 9 2.5 安装配置Postgres ........................................................................................................... 10 2.6在pacemaker中创建pgsql资源 ..................................................................................... 10 2.7 在pacemaker中配置master的VIP .............................................................................. 11
2.7.1 配置一个VIP ....................................................................................................... 11 2.7.2 配置多个VIP ....................................................................................................... 11 2.8 在pacemaker中配置Slave的VIP ................................................................................ 12
2.8.1 共享一个VIP ....................................................................................................... 12 2.8.2 每个Slave一个单独的VIP................................................................................. 12
3. 问题如何调试 ......................................................................................................................... 13
1. 安装环境
假设目前我们的安装环境有4个nodes: Node1: 192.168.199.191 Node2: 192.168.199.192 Node3: 192.168.199.193 Node4: 192.168.199.194
这些节点的VIP地址: Master:192.168.199.189 Slave1:192.168.199.188 Slave2:192.168.199.187 Slave3:192.168.199.186
执行下列步骤:
? 在这四个节点上安装CENTOS7或者REDHAT7 Linux操作系统(Minimal安装)
? 首先要保证这四个节点网络互通,时钟同步。
? 在每个节点的/etc/hosts文件中加入节点名和IP的对应。集群间会通过下列配置的地址
进行心跳消息的传递。
192.168.199.191 node1 192.168.199.192 node2 192.168.199.193 node3 192.168.199.194 node4
? 在每个节点上关闭防火墙
systemctl stop firewalld;chkconfig firewalld off;
? 在每个节点上安装pacemaker和PAF的软件包
yum install -y corosync pacemaker pcs gfs2-utils lvm2-cluster *scsi* python-clufter;
yum install -y resource-agents-paf-2.1.0-1.noarch.rpm;
说明:如果是redhat7,需要配置yum源
# mkdir -p /media/rhel
# mount -t iso9660 /dev/sr0 /media/rhel
[root@db1 ~]# cat /etc/yum.repos.d/rhel.repo
[rhel]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug baseurl=file:///media/rhel enabled=1 gpgcheck=1
gpgkey=file:///media/rhel/RPM-GPG-KEY-redhat-release [repo-ha] gpgcheck=0 enabled=1
baseurl=file:///media/rhel/addons/HighAvailability name=repo-ha
[repo-storage] gpgcheck=0 enabled=1
baseurl=file:///media/rhel/addons/ResilientStorage name=repo-storage
# yum clean all # yum list
resource-agents-paf-2.2.0-1.noarch.r
? 在每个节点上启动pacemaker, 设置集群的访问密码为12345,并开启LVM支持集群功
能。
systemctl start pcsd; systemctl enable pcsd;
echo 12345 |passwd --stdin hacluster; /sbin/lvmconf --enable-cluster;
2. 配置步骤
下面创建一个pacemaker集群,在集群中加入4个节点(node1, node2, node3, node4),并依次
加入stonith, DLM,CLVM,GFS2,PGSQL,VIP资源。在运行过程中,这些资源会按照以上顺序依次执行。即如果一个资源没有启动,排在此资源之后的所有资源都不会启动。当所有的配置完成后,我们期望通过pcs status命令看到的集群状态类似下面是一个3节点的配置:
以下集群操作是在某一个节点上以root的用户执行。
2.1 创建集群并加入节点 2.1.1简单集群的配置
例如集群名字为cluster_pgsql:
pcs cluster auth node1 node2 node3 node4 -u hacluster;
pcs cluster setup --name cluster_pgsql node1 node2 node3 node4; pcs cluster start --all;
pcs property set no-quorum-policy=freeze; pcs property set stonith-enabled=true;
说明:
? ? ? ?
首先对四个节点进行鉴权,确定这四个节点配置了pacemaker并且心跳网络可以连通。 然后将四个节点加入集群中。
启动pacemaker.此时运行”pcs status”命令可以看到集群中有四个节点,没有资源。
设置no quorumpolicy。Quorom 机制,是一种分布式系统中常用的,用来保证数据冗余和最终一致性的投票算法。该算法可以保证同一份数据对象的多份拷贝不会被超过两个访问对象读写。
no-quorum-policy参数表示当没有quorum时集群应该如何,缺省值stop,取值范围如下。我们这里设置
freeze是为了防止主节点频繁的迁移(例如,主节点node1故障之后,另一个备节点node2被提升为主节点。当node1恢复后,我们希望node2仍是主节点,node1变成备节点。而不是主节点又迁移回node1)。 ? ? ? ? ?
ignore - continue all resource management
freeze - continue resource management, but don't recover resources from nodes not in the affected partition stop - stop all resources in the affected cluster parition suicide - fence all nodes in the affected cluster partition
设置系统支持stonith设备。我们之所以加入stonith设备的支持是共享存储资源(dlm,clvm)的要求。stonith是“shoot the other node in the head”的首字母简写。运行pacemaker的服务器可以通过串口线或网线向stonith设备发送命令,该设备控制对其他服务器的电力供应。当pacemker无法停止集群中出现故障的节点或者资源时,stonith设备负责将机器重启。当我们将stonith-enabled(缺省值true)参数设为true时,集群中必须配置stonith资源,否则集群不会启动任何资源(如dlm,clvm,pgsql,vip)。
2.1.2多心跳网卡集群的配置
pcs cluster auth node1 node2 node3 node4 -u hacluster;
pcs cluster setup --name cluster_pgsql node1,node10 node2,node20 node3,node30 node4,node40;
说明:
?
假设node1有两个心跳网卡,在etc/hosts中的配置如下,其他node的配置类似。 192.168.199.191 node1 192.168.10.191 node10 ?
多心跳的实现是通过rrp即路由冗余协议。同一个节点的多个IP用逗号隔开。
2.2 在pacemaker中加入stonith设备
Stonith设备有很多种,通过”pcs stonith show”命令可以查看系统支持的stonith种类。下面介绍3种stonith设备的配置,我们可以任选其中的一种进行配置。
2.2.1 简单的stonith设备的创建
pcs stonith create scsi-stonith-device fence_scsi devices=/dev/mapper/fence pcmk_monitor_action=metadata pcmk_reboot_action=off pcmk_host_list=\node2 node3 node4\
说明:
? ?
scsi-stonith-device是我们起的资源的名字。可以起任意名字。
在我们的开发环境中,我们只是希望stonith资源是start状态,并不期望他真正的重启机器。所以在这里我们使用pcmk_monitor_action=metadata,它意味着该stonith资源的monior操作并不真正检查stonith设备是否存在,而是打印一个XML meta然后返回succeed。
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库基于pacemaker的共享存储集群配置在线全文阅读。
相关推荐: