Skip to content

Resource agent for postgresql 9.2 cascade

t-matsuo edited this page Dec 10, 2012 · 7 revisions

considering RA for cascade replication (experimental)

figure figure

sample setting of crm

property \
    no-quorum-policy="ignore" \
    stonith-enabled="false" \
    startup-fencing="false" \
    stonith-timeout="710s" \
    crmd-transition-delay="2"

rsc_defaults \
    resource-stickiness="INFINITY" \
    migration-threshold="1"

ms msPostgresql pgsql \
    meta \
        master-max="1" \
        master-node-max="1" \
        clone-max="4" \
        clone-node-max="1" \
        notify="true"

### Group Configuration ###

group master-group \
    vip-master \
    meta \
        ordered="false"

### Clone Configuration ###
clone clnPingd \
    pingCheck

primitive vip-master ocf:heartbeat:IPaddr2 \
    params \
        ip="192.168.0.202" \
        nic="eth0" \
        cidr_netmask="24" \
    op start   timeout="60s" interval="0s"  on-fail="restart" \
    op monitor timeout="60s" interval="10s" on-fail="restart" \
    op stop    timeout="60s" interval="0s"  on-fail="block"

primitive vip-for-02-sl6 ocf:heartbeat:IPaddr2 \
    params \
        ip="192.168.3.202" \
        nic="eth3" \
        cidr_netmask="24" \
    meta \
        migration-threshold="0" \
        resource-stickiness="1" \
    op start   timeout="60s" interval="0s"  on-fail="stop" \
    op monitor timeout="60s" interval="10s" on-fail="restart" \
    op stop    timeout="60s" interval="0s"  on-fail="block"

primitive vip-for-03-sl6 ocf:heartbeat:IPaddr2 \
    params \
        ip="192.168.3.203" \
        nic="eth3" \
        cidr_netmask="24" \
    meta \
        migration-threshold="0" \
        resource-stickiness="1" \
    op start   timeout="60s" interval="0s"  on-fail="stop" \
    op monitor timeout="60s" interval="10s" on-fail="restart" \
    op stop    timeout="60s" interval="0s"  on-fail="block"

primitive vip-for-04-sl6 ocf:heartbeat:IPaddr2 \
    params \
        ip="192.168.3.204" \
        nic="eth3" \
        cidr_netmask="24" \
    meta \
        migration-threshold="0" \
        resource-stickiness="1" \
    op start   timeout="60s" interval="0s"  on-fail="stop" \
    op monitor timeout="60s" interval="10s" on-fail="restart" \
    op stop    timeout="60s" interval="0s"  on-fail="block"

primitive vip-for-05-sl6 ocf:heartbeat:IPaddr2 \
    params \
        ip="192.168.3.205" \
        nic="eth3" \
        cidr_netmask="24" \
    meta \
        migration-threshold="0" \
        resource-stickiness="1" \
    op start   timeout="60s" interval="0s"  on-fail="stop" \
    op monitor timeout="60s" interval="10s" on-fail="restart" \
    op stop    timeout="60s" interval="0s"  on-fail="block"

primitive pgsql ocf:heartbeat:pgsql \
    params \
        pgctl="/usr/pgsql-9.2/bin/pg_ctl" \
        psql="/usr/pgsql-9.2/bin/psql" \
        pgdata="/var/lib/pgsql/9.2/data/" \
        start_opt="-p 5432" \
        rep_mode="sync" \
        cascade="true" \
        xlog_check_count="2" \
        node_list="02-sl6 03-sl6 04-sl6 05-sl6" \
        restore_command="cp /var/lib/pgsql/9.2/data/pg_archive/%f %p" \
        master_ip="192.168.3.202 192.168.3.203 192.168.3.204 192.168.3.205" \
        primary_conninfo_opt="keepalives_idle=60 keepalives_interval=5 keepalives_count=5" \
        stop_escalate="0" \
        restart_on_promote="true" \
    op start   timeout="60s" interval="0s"  on-fail="restart" \
    op monitor timeout="60s" interval="10s" on-fail="restart" \
    op monitor timeout="60s" interval="9s"  on-fail="restart" role="Master" \
    op promote timeout="60s" interval="0s"  on-fail="block" \
    op demote  timeout="60s" interval="0s"  on-fail="block" \
    op stop    timeout="60s" interval="0s"  on-fail="block" \
    op notify  timeout="60s" interval="0s"

primitive pingCheck ocf:pacemaker:pingd \
    params \
        name="default_ping_set" \
        host_list="192.168.0.1" \
        multiplier="100" \
    op start   timeout="60s" interval="0s"  on-fail="restart" \
    op monitor timeout="60s" interval="10s" on-fail="restart" \
    op stop    timeout="60s" interval="0s"  on-fail="ignore"

### Resource Location ###
location rsc_location-1 msPostgresql \
    rule -inf: not_defined default_ping_set or default_ping_set lt 100

location rsc_location-2 vip-for-02-sl6 \
    rule -inf: #uname eq 02-sl6 \
    rule 200: #uname eq 05-sl6 \
    rule -inf: not_defined pgsql-status \
	rule -inf: pgsql-status ne HS:cascade and pgsql-status ne HS:sync and pgsql-status ne PRI \
    rule 10: pgsql-status eq PRI \
    rule 50: pgsql-status eq HS:cascade \
    rule 100: pgsql-status eq HS:sync
location rsc_location-3 vip-for-03-sl6 \
    rule -inf: #uname eq 03-sl6 \
    rule 200: #uname eq 02-sl6 \
    rule -inf: not_defined pgsql-status \
	rule -inf: pgsql-status ne HS:cascade and pgsql-status ne HS:sync and pgsql-status ne PRI \
    rule 10: pgsql-status eq PRI \
    rule 50: pgsql-status eq HS:cascade \
    rule 100: pgsql-status eq HS:sync
location rsc_location-4 vip-for-04-sl6 \
    rule -inf: #uname eq 04-sl6 \
    rule 200: #uname eq 03-sl6 \
    rule -inf: not_defined pgsql-status \
	rule -inf: pgsql-status ne HS:cascade and pgsql-status ne HS:sync and pgsql-status ne PRI \
    rule 10: pgsql-status eq PRI \
    rule 50: pgsql-status eq HS:cascade \
    rule 100: pgsql-status eq HS:sync
location rsc_location-5 vip-for-05-sl6 \
    rule -inf: #uname eq 05-sl6 \
    rule 200: #uname eq 04-sl6 \
    rule -inf: not_defined pgsql-status \
	rule -inf: pgsql-status ne HS:cascade and pgsql-status ne HS:sync and pgsql-status ne PRI \
    rule 10: pgsql-status eq PRI \
    rule 50: pgsql-status eq HS:cascade \
    rule 100: pgsql-status eq HS:sync

### Resource Colocation ###
colocation rsc_colocation-1 inf: msPostgresql clnPingd
colocation rsc_colocation-4 inf: master-group msPostgresql:Master

### Resource Order ###
order rsc_order-1 0: clnPingd              msPostgresql         symmetrical=false
order rsc_order-4 inf: msPostgresql:promote  master-group:start symmetrical=false
order rsc_order-5 0: msPostgresql:demote   master-group:stop    symmetrical=false

crm_mon -Af

============
Last updated: Fri Nov 16 16:16:16 2012
Stack: Heartbeat
Current DC: 05-sl6 (d730b973-b0bd-4f84-be2e-f95862aaaa) - partition with quorum
Version: 1.0.12-066152e
4 Nodes configured, unknown expected votes
7 Resources configured.
============

Online: [ 05-sl6 02-sl6 04-sl6 03-sl6 ]

 vip-for-02-sl6 (ocf::heartbeat:IPaddr2):       Started 05-sl6
 vip-for-03-sl6 (ocf::heartbeat:IPaddr2):       Started 02-sl6
 vip-for-04-sl6 (ocf::heartbeat:IPaddr2):       Started 03-sl6
 vip-for-05-sl6 (ocf::heartbeat:IPaddr2):       Started 04-sl6
 Resource Group: master-group
     vip-master (ocf::heartbeat:IPaddr2):       Started 05-sl6
 Master/Slave Set: msPostgresql
     Masters: [ 05-sl6 ]
     Slaves: [ 02-sl6 04-sl6 03-sl6 ]
 Clone Set: clnPingd
     Started: [ 05-sl6 02-sl6 04-sl6 03-sl6 ]

Node Attributes:
* Node 05-sl6:
    + default_ping_set                  : 100
    + master-pgsql:0                    : 1000
    + pgsql-children                    : 02-sl6
    + pgsql-data-status                 : LATEST
    + pgsql-master-baseline             : 000000000A000410
    + pgsql-status                      : PRI
* Node 02-sl6:
    + default_ping_set                  : 100
    + master-pgsql:1                    : 100
    + pgsql-children                    : 03-sl6
    + pgsql-data-status                 : STREAMING|SYNC
    + pgsql-status                      : HS:sync
* Node 04-sl6:
    + default_ping_set                  : 100
    + master-pgsql:2                    : -INFINITY
    + pgsql-data-status                 : STREAMING|ASYNC
    + pgsql-status                      : HS:cascade
* Node 03-sl6:
    + default_ping_set                  : 100
    + master-pgsql:3                    : -INFINITY
    + pgsql-children                    : 04-sl6
    + pgsql-data-status                 : STREAMING|ASYNC
    + pgsql-status                      : HS:cascade

Migration summary:
* Node 05-sl6:
* Node 04-sl6:
* Node 03-sl6:
* Node 02-sl6: