集群架构:

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.

如何使用pgpool failover_stream.sh自己控制选择指定的master节点的更多相关文章

  1. Oracle 函数 “数据控制,指定某些人只能查看他权限范围内的信息”

    create or replace function work_plan_mask (p_schema VARCHAR2,p_table VARCHAR2) return Varchar2 AS -- ...

  2. jquery选择指定元素之外的所有元素

    最近的项目中有这么一个需求,点击一排图片中的任意一张后底部弹出一个对话框,要求点击任意地方隐藏对话框 这个时候用not()显然是不现实的,用closest()可以实现差不多的功能 <!DOCTY ...

  3. 选择指定的MySQL数据库

    <?php /******************************** *** 功能:选择指定的MySQL数据库 *********************************/ ? ...

  4. 黑马程序员——C语言基础 流程控制 选择结构和循环结构

    ---恢复内容开始--- Java培训.Android培训.iOS培训..Net培训.期待与您交流! (以下内容是对黑马苹果入学视频的个人知识点总结) (一)流程控制 1> 顺序结构:默认的流程 ...

  5. WdatePicker 控制选择范围

    1. 跨无限级框架显示 无论你把日期控件放在哪里,你都不需要担心会被外层的iframe所遮挡进而影响客户体验,因为My97日期控件是可以跨无限级框架显示的 示例2-7 跨无限级框架演示 可无限跨越框架 ...

  6. ElementUI DatePicker 日期选择器控制选择时间范围

    选择今天以及今天之后的日期 <el-date-picker v-model="value1" type="date" placeholder=" ...

  7. UGUI 用手柄或者键盘控制选择Scroll View中的游戏对象时,滚动条跟着移动

    原预制体以及脚本的下载地址:https://download.csdn.net/download/qq_15017279/10404010 1.新建一个Scroll View,删掉横向的滚动条,并且把 ...

  8. input accept属性控制选择文件类型

    <form> <input type="file" name="pic" id="pic" accept="im ...

  9. 打印机设置(PrintDialog)、页面设置(PageSetupDialog) 及 RDLC报表如何选择指定打印机

    如果一台电脑同时连接多个打印机,而且每个打印机使用的纸张大小各不相同(比如:票据打印钱用的小票专用张,办公打印机用的是A4标准纸),在处理打印类的需求时,如果不用代码干预,用户必须每次打印时,都必须在 ...

随机推荐

  1. C#操作Oracle数据库中文乱码问题解决

    最近公司有一个对外项目,采用的是oracle数据库,以前做的项目基本都是SQLserver,有和oracle对接的也就一些简单的增删查改. 还巧合的遇到乱码问题,网上各种查找,筛选,总算是把问题解决了 ...

  2. 杭电1003 Max Sum TLE

    这一题目是要求连续子序列的最大和,所以在看到题目的一瞬间就想到的是把所有情况列举出来,再两个两个的比较,取最大的(即为更新最大值的意思),这样的思路很简单,但是会超时,时间复杂度为O(n^3),因为有 ...

  3. UVa 1583 Digit Generator WA

    #include<stdio.h> int main() { long int n,i,s=0; while(scanf("%d",&n)!=EOF) { in ...

  4. 还是UVa340

    #include<stdio.h> #define maxn 1010 int main() { int num,a[maxn],i,j,b[maxn]; ; &&num) ...

  5. box-shadow 阴影剖析

    box-shadow的四个值分别是左右偏移,上下偏移,向四周模糊扩算,距离四周边缘的距离,最后一个是阴影的颜色值,如图示例: 上代码,复制代码,就可以看到上图的效果 <!DOCTYPE html ...

  6. PhotoZoom Classic 7怎么样?对电脑和系统要求高不高?

    PhotoZoom Classic 7怎么样?对电脑和系统要求高不高? 相较于更专业PhotoZoom Pro,标准版本的PhotoZoom Classic 7更适用于日常工作中的图片放大处理,例如在 ...

  7. input[type=radio]选中的样式变化

    input[type=radio]:hover{ border: 2px solid #D0D0D0; } input[type=radio]:focus{ border: 2px solid #1B ...

  8. VS Code中编写html(4) 标签的宽高颜色背景设置

    1  <!+Tab键--> <!--有两个div标签时,分别设置style,有两种方法--> <div id="div1">第一个div标签:& ...

  9. luogu P2634 [国家集训队]聪聪可可 点分治

    Description 聪聪和可可是兄弟俩,他们俩经常为了一些琐事打起来,例如家中只剩下最后一根冰棍而两人都想吃.两个人都想玩儿电脑(可是他们家只有一台电脑)……遇到这种问题,一般情况下石头剪刀布就好 ...

  10. 路飞学城Python-Day152

    爬取搜狗首页页面数据 import urllib.request # 1.指定url url = r'https://www.sogou.com/' # 2.发起请求 # urlopen()参数内部可 ...