Skip to content

Resource agent for postgresql 9.2 cascade

t-matsuo edited this page Nov 16, 2012 · 7 revisions

considering RA for cascade replication

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