我正在尝试使用一些自定义资源代理(由Bitnine https://github.com/bitnine-oss编写)为HA Postgres-XL使用Pacemaker资源。
我的过程是: 1.创建原始资源“ data1”,其中包括启动/停止/升级/删除功能。 2.创建控制原语实例的主/从资源。
在这里,我希望在节点t2上启动主节点,在节点t4上启动从节点。 我正在尝试使用以下位置评分来控制主/从资源的位置。
@ubuntu:~$ sudo pcs -f data1.xml create resource data1 ocf:bitnine:postgres-xl-data datadir=/var/lib/postgresql/DATA/pgxl/nodes/data1 port=15432 nodename=data1
@ubuntu:~$ sudo pcs -f data1.xml resource master data1-ha data1 master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 target-role="Started" notify="True"
@ubuntu:~$ sudo pcs constraint location data1-ha prefers t2=1000 t4=10
但是,出现以下错误。因为我的代理人描述性不是很高,所以我通过实验发现它试图将两个节点都作为主节点而不是主节点/从节点启动。
@ubuntu:~$ sudo pcs status
[sudo] password for michaelscott:
Cluster name: xl-cluster
WARNINGS:
No stonith devices and stonith-enabled is not false
Stack: corosync
Current DC: t4 (version 1.1.18-2b07d5c5a9) - partition with quorum
Last updated: Thu Mar 28 18:19:32 2019
Last change: Thu Mar 28 17:48:48 2019 by root via crm_resource on t1
5 nodes configured
2 resources configured
Online: [ t1 t2 t3 t4 t5 ]
Full list of resources:
Master/Slave Set: data1-ha [data1]
data1 (ocf::bitnine:postgres-xl-data): FAILED Master t4
Masters: [ t2 ]
Stopped: [ t1 t3 t5 ]
Failed Actions:
* data1_monitor_11000 on t4 'master' (8): call=22610, status=complete, exitreason='',
last-rc-change='Thu Mar 28 18:19:32 2019', queued=0ms, exec=107ms
Daemon Status:
corosync: active/disabled
pacemaker: active/disabled
pcsd: active/enabled
如果我更改“ master-max = 2”,则会得到以下信息:
@ubuntu:~$ sudo pcs status
[sudo] password for michaelscott:
Cluster name: xl-cluster
WARNINGS:
No stonith devices and stonith-enabled is not false
Stack: corosync
Current DC: t4 (version 1.1.18-2b07d5c5a9) - partition with quorum
Last updated: Thu Mar 28 18:19:32 2019
Last change: Thu Mar 28 17:48:48 2019 by root via crm_resource on t1
5 nodes configured
2 resources configured
Online: [ t1 t2 t3 t4 t5 ]
Full list of resources:
Master/Slave Set: data1-ha [data1]
data1 (ocf::bitnine:postgres-xl-data):
Masters: [ t2 t4 ]
Daemon Status:
corosync: active/disabled
pacemaker: active/disabled
pcsd: active/enabled
我的问题是:如何强制在t2上启动Master实例,在t4上启动Slave?我花了几天的时间来阅读有关Pacemaker中位置/共置的文档/示例(我很直觉可以找到答案),但是到目前为止还没有任何东西可以工作。
谢谢
编辑:
今天,进一步尝试通过将约束添加到CIB中来限制位置,以将母版推到t2,如下所示。同样的错误。
<constraints>
<rsc_location id="location-data1-ha-t1--INFINITY" node="t1" rsc="data1-ha" score="-INFINITY"/>
<rsc_location id="location-data1-ha-t3--INFINITY" node="t3" rsc="data1-ha" score="-INFINITY"/>
<rsc_location id="location-data1-ha-t5--INFINITY" node="t5" rsc="data1-ha" score="-INFINITY"/>
<rsc_location id="location-data1-ha" rsc="data1-ha">
<rule id="location-data1-ha-rule" role="master" score="INFINITY">
<expression attribute="#uname" id="location-data1-ha-rule-expr" operation="eq" value="t2"/>
</rule>
</rsc_location>
<rsc_location id="location-data1-ha-1" rsc="data1-ha">
<rule id="location-data1-ha-1-rule" role="slave" score="INFINITY">
<expression attribute="#uname" id="location-data1-ha-1-rule-expr" operation="eq" value="t4"/>
</rule>
</rsc_location>
</constraints>