zoukankan      html  css  js  c++  java
  • 如何使用pgpool failover_stream.sh自己控制选择指定的master节点

    集群架构:

    h236:master

    h237:standby sync

    h238:standby sync

    h239:stadnby async

    h240:standby async

    h241:standby async

    pool.conf

    failover_command = '/etc/kingbasecluster/failover_stream.sh %H %P %d'

    failover_stream.sh

    #!/bin/sh
    h238=172.19.33.238
    h239=172.19.33.239
    h240=172.19.33.240
    h241=172.19.33.241
    h236=172.19.33.236
    h237=172.19.33.237
    trigger_command="pg_ctl promote -D /data/pgdata"
    fix_rec="sed -i 's/172.19.33.236./172.19.33.237/' /data/pgdata/recovery.conf;
    pg_ctl -D /data/pgdata/ stop -m fast;pg_ctl -D /data/pgdata/ start"

    #primary down
    #236(node 0) , 237(node1)
    if [$2 -eq $3 ];then
            #node 236 down          
            if [ $2 -eq 0 ];then
                    /usr/bin/ssh -T $h237 $trigger_command
            fi
            #node 237 down #236手动修复称为standby之后
            if [ $2 -eq 1 ];then
                    $fix_rec="sed -i 's/172.19.33.237./172.19.33.236/' /data/pgdata/recovery.conf;
                    pg_ctl -D /data/pgdata/ stop -m fast;pg_ctl -D /data/pgdata/ start"
                    /usr/bin/ssh -T $h236 $trigger_command
            fi

            #238-241 follow new primary
            /usr/bin/ssh -T $h238 $fix_rec &
            /usr/bin/ssh -T $h239 $fix_rec &
            /usr/bin/ssh -T $h240 $fix_rec &
            /usr/bin/ssh -T $h241 $fix_rec &

    #do nothing for other  standby down
    fi
    exit 0;

    ==============================================================================

    failover命令中的参数使用描述

    failover_command

    This parameter specifies a command to run when a node is detached. pgpool-II replaces the following special characters with backend specific information.

    Special character Description
    %d Backend ID of a detached node.
    %h Hostname of a detached node.
    %p Port number of a detached node.
    %D Database cluster directory of a detached node.
    %M Old master node ID.
    %m New master node ID.
    %H Hostname of the new master node.
    %P Old primary node ID.
    %% '%' character

    You need to reload pgpool.conf if you change failover_command.

    When a failover is performed, pgpool kills all its child processes, which will in turn terminate all active sessions to pgpool. Then pgpool invokes the failover_command and waits for its completion. After this, pgpool starts new child processes and is ready again to accept connections from clients.

    failback_command

    This parameter specifies a command to run when a node is attached. pgpool-II replaces special the following characters with backend specific information.

    Special character Description
    %d Backend ID of an attached node.
    %h Hostname of an attached node.
    %p Port number of an attached node.
    %D Database cluster path of an attached node.
    %M Old master node
    %m New master node
    %H Hostname of the new master node.
    %P Old primary node ID.
    %% '%' character

    You need to reload pgpool.conf if you change failback_command.

  • 相关阅读:
    邮件系列3 --- 安全传输
    配置postfix支持虚拟域和虚拟用户
    Postfix+Sasl+Courier-authlib+Dovecot+MySQL+extmail 邮件系统部署
    在switch中的case语句中声明变量编译出错的解决方案
    关于自控力
    PUTTY使用Ctrl+s僵死的问题
    sqlite3里类似top的用法
    二维数组、行指针、指针数组、二级指针
    sqlite3_exec函数的使用
    基于s5pv210嵌入式linux使用其他动态、静态库文件程序的交叉编译
  • 原文地址:https://www.cnblogs.com/songyuejie/p/7054923.html
Copyright © 2011-2022 走看看