{"id":16570,"date":"2025-04-18T23:02:20","date_gmt":"2025-04-18T15:02:20","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/16570.html"},"modified":"2025-04-18T23:02:20","modified_gmt":"2025-04-18T15:02:20","slug":"pgpool%e9%85%8d%e7%bd%ae%e5%ae%89%e8%a3%85%e4%b9%8b%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/16570.html","title":{"rendered":"pgpool\u914d\u7f6e\u5b89\u88c5\u4e4b\u670d\u52a1\u5668\u7684\u914d\u7f6e"},"content":{"rendered":"<h2>\u7b2c 1 \u7ae0.\u670d\u52a1\u5668\u914d\u7f6e<\/h2>\n<h3>1.1. \u8bbe\u7f6e\u53c2\u6570<\/h3>\n<h4>1.1.1. \u53c2\u6570\u540d\u79f0\u548c\u503c<\/h4>\n<p>\u6240\u6709\u53c2\u6570\u540d\u79f0\u5747\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u6bcf\u4e2a\u53c2\u6570\u90fd\u91c7\u7528 \u503c\u4e3a\u4ee5\u4e0b\u4e94\u79cd\u7c7b\u578b\u4e4b\u4e00&#xff1a;boolean\u3001string\u3001integer\u3001floating point\u3001 \u6216\u679a\u4e3e &#xff08;enum&#xff09;\u3002\u7c7b\u578b\u51b3\u5b9a\u4e86\u8bbe\u7f6e \u53c2\u6570&#xff1a;<\/p>\n<p>\u5e03\u5c14&#xff1a;\u503c\u53ef\u4ee5\u5199\u6210 on\u3001off\u3001true\u3001false\u3001yes\u3001no\u30011\u30010&#xff08;\u5168\u90e8\u4e0d\u533a\u5206\u5927\u5c0f\u5199&#xff09;\u6216\u5176\u4e2d\u4e4b\u4e00\u7684\u4efb\u4f55\u660e\u786e\u524d\u7f00\u3002<\/p>\n<p>\u5b57\u7b26\u4e32&#xff1a;\u901a\u5e38&#xff0c;\u5c06\u503c\u62ec\u5728\u5355\u5f15\u53f7\u4e2d&#xff0c;\u5c06\u4efb\u4f55\u5355\u4e2a \u503c\u5185\u7684 quotes \u4e2d\u3002\u5982\u679c\u503c \u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6570\u5b57\u6216\u6807\u8bc6\u7b26\u3002<\/p>\n<p>\u6570\u5b57 &#xff08;\u6574\u6570\u548c\u6d6e\u70b9&#xff09; &#xff1a;\u4ec5\u5141\u8bb8\u6d6e\u70b9\u53c2\u6570\u4f7f\u7528\u5c0f\u6570\u70b9\u3002 \u4e0d\u8981\u4f7f\u7528\u5343\u4f4d\u5206\u9694\u7b26\u3002\u4e0d\u9700\u8981\u62a5\u4ef7\u3002<\/p>\n<p>\u5e26\u5355\u4f4d\u7684\u6570\u503c&#xff1a;\u63cf\u8ff0 quant \u7684\u6570\u503c\u53c2\u6570 memory \u6216 time \u5177\u6709\u9690\u542b\u5355\u4f4d\u3002 \u5355\u4f4d\u53ef\u4ee5\u662f\u5343\u5b57\u8282\u3001\u5146\u5b57\u8282\u3001\u6beb\u79d2\u3001 \u79d2\u6216\u5206\u949f\u3002 \u4f8b\u5982&#xff1a;<\/p>\n<p>  search_primary_node_timeout &#061; 6min<br \/>\n  memqcache_total_size &#061; 64MB<\/p>\n<p>\u8fd9\u4e9b\u8bbe\u7f6e\u4e4b\u4e00\u7684\u672a\u4fee\u9970\u6570\u503c\u5c06\u4f7f\u7528 \u53c2\u6570\u7684\u9ed8\u8ba4\u5355\u4f4d\u3002<\/p>\n<p>\u5355\u4f4d\u540d\u79f0\u533a\u5206\u5927\u5c0f\u5199&#xff0c;\u5e76\u4e14\u6570\u503c\u548c\u5355\u4f4d\u4e4b\u95f4\u53ef\u4ee5\u6709\u7a7a\u683c\u3002<\/p>\n<p>\u6709\u6548\u7684\u5185\u5b58\u5355\u4f4d\u4e3a kB &#xff08;KB&#xff09;\u3001MB &#xff08;\u5146\u5b57\u8282&#xff09;\u3001GB &#xff08;\u5343\u5146\u5b57\u8282&#xff09; \u548c TB &#xff08;TB&#xff09;\u3002<\/p>\n<p>\u6709\u6548\u7684\u65f6\u95f4\u5355\u4f4d\u4e3a ms&#xff08;\u6beb\u79d2&#xff09;\u3001s&#xff08;\u79d2&#xff09;\u3001min&#xff08;\u5206\u949f&#xff09;\u3001h&#xff08;\u5c0f\u65f6&#xff09;\u548c d&#xff08;\u5929&#xff09;\u3002<\/p>\n<p>\u679a\u4e3e&#xff1a;\u679a\u4e3e\u7c7b\u578b\u53c2\u6570\u7684\u7f16\u5199\u65b9\u5f0f\u4e0e string \u76f8\u540c \u53c2\u6570&#xff0c;\u4f46\u4ec5\u9650\u4e8e\u5177\u6709\u4e00\u7ec4\u6709\u9650\u7684 \u503c\u3002\u679a\u4e3e\u53c2\u6570\u503c\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002<\/p>\n<h4>1.1.2. \u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u53c2\u6570\u4ea4\u4e92<\/h4>\n<p>\u8bbe\u7f6e\u8fd9\u4e9b\u53c2\u6570\u6700\u57fa\u672c\u7684\u65b9\u6cd5\u662f\u7f16\u8f91\u6587\u4ef6 pgpool.conf&#xff0c; \u5b83\u4f4d\u4e8e $prefix\/etc\/pgpool.conf \u4e2d&#xff0c;\u5982\u679c\u5b83 \u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\u3002\u6b64\u6587\u4ef6\u53ef\u80fd\u5982\u4e0b\u6240\u793a\u7684\u793a\u4f8b\u5982\u4e0b&#xff1a;<\/p>\n<p> # This is a comment<br \/>\n listen_addresses &#061; &#039;localhost&#039;<br \/>\n port &#061; 9999<br \/>\n serialize_accept &#061; off<br \/>\n reset_query_list &#061; &#039;ABORT; DISCARD ALL&#039;<\/p>\n<p>\u6bcf\u884c\u6307\u5b9a\u4e00\u4e2a\u53c2\u6570\u3002name \u548c \u4e4b\u95f4\u7684\u7b49\u53f7 value \u662f\u53ef\u9009\u7684\u3002\u7a7a\u683c\u65e0\u5173\u7d27\u8981&#xff08;\u9664\u975e\u5728\u5e26\u5f15\u53f7\u7684 parameter \u503c&#xff09;\u548c\u7a7a\u884c\u4e3a \u5ffd\u89c6\u3002\u54c8\u5e0c\u6807\u8bb0 &#xff08;#&#xff09; \u6307\u5b9a\u4f59\u6570 \u4f5c\u4e3a\u6ce8\u91ca\u3002\u4e0d\u7b80\u5355\u7684\u53c2\u6570\u503c \u6807\u8bc6\u7b26\u6216\u6570\u5b57\u5fc5\u987b\u7528\u5355\u5f15\u53f7\u5f15\u8d77\u6765\u3002\u8981\u5d4c\u5165\u5355\u4e2a quote \u5728\u53c2\u6570\u503c\u4e2d&#xff0c;\u5199\u5165\u4e24\u4e2a\u5f15\u53f7 &#xff08;preferred&#xff09; \u6216\u53cd\u659c\u6760\u5f15\u53f7\u3002<\/p>\n<p>\u4ee5\u8fd9\u79cd\u65b9\u5f0f\u8bbe\u7f6e\u7684\u53c2\u6570\u4e3a\u96c6\u7fa4\u63d0\u4f9b\u9ed8\u8ba4\u503c\u3002 \u6d3b\u52a8\u4f1a\u8bdd\u770b\u5230\u7684\u8bbe\u7f6e\u5c06\u662f\u8fd9\u4e9b\u503c&#xff0c;\u9664\u975e\u5b83\u4eec \u88ab\u8986\u76d6\u3002\u4ee5\u4e0b\u90e8\u5206\u4ecb\u7ecd\u4e86 \u7ba1\u7406\u5458\u6216\u7528\u6237\u53ef\u4ee5\u8986\u76d6\u8fd9\u4e9b\u9ed8\u8ba4\u503c\u3002<\/p>\n<p>\u6bcf\u5f53\u4e3b\u670d\u52a1\u5668\u8fdb\u7a0b \u63a5\u6536 SIGHUP \u4fe1\u53f7;\u8fd9\u4e2a\u4fe1\u53f7\u6700\u5bb9\u6613 \u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884c pgpool reload \u53d1\u9001\u3002\u4e3b\u8981\u7684 pgpool \u8fdb\u7a0b\u4e5f\u4f1a\u5c06\u6b64\u4fe1\u53f7\u4f20\u64ad\u5230\u5b83\u7684\u6240\u6709\u5b50\u8fdb\u7a0b \u8fdb\u7a0b&#xff0c;\u4ee5\u4fbf Next Session \u4e5f\u91c7\u7528\u65b0\u503c\u3002 \u67d0\u4e9b\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e;\u5bf9\u5176 \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u6761\u76ee\u5c06\u88ab\u5ffd\u7565&#xff0c;\u76f4\u5230\u670d\u52a1\u5668\u91cd\u65b0\u542f\u52a8\u3002 \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u65e0\u6548\u53c2\u6570\u8bbe\u7f6e\u540c\u6837 \u5728 SIGHUP \u5904\u7406\u671f\u95f4\u88ab\u5ffd\u7565&#xff08;\u4f46\u88ab\u8bb0\u5f55&#xff09;\u3002<\/p>\n<h4>1.1.3. \u7ba1\u7406\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9<\/h4>\n<p>Pgpool-II \u63d0\u4f9b\u4e86\u4e00\u4e2a\u5c06 pgpool.conf \u6587\u4ef6\u5206\u89e3\u4e3a\u5b50\u6587\u4ef6\u7684\u529f\u80fd\u3002\u6b64\u529f\u80fd\u662f \u5728\u7ba1\u7406\u591a\u4e2a\u670d\u52a1\u5668\u6216\u6309\u529f\u80fd\u5212\u5206\u65f6\u7279\u522b\u6709\u7528\u3002include \u6307\u4ee4\u53ef\u4ee5\u50cf\u8fd9\u6837\u4f7f\u7528&#xff1a;<\/p>\n<p> include &#061; &#039;filename&#039;<\/p>\n<p>\u5982\u679c\u6587\u4ef6\u540d\u4e0d\u662f\u7edd\u5bf9\u8def\u5f84&#xff0c;\u5219\u5c06\u5176\u89c6\u4e3a\u76f8\u5bf9\u8def\u5f84 \u6dfb\u52a0\u5230\u5305\u542b\u5f15\u7528\u914d\u7f6e\u6587\u4ef6\u7684\u76ee\u5f55\u4e2d\u3002 \u5305\u542b\u7269\u53ef\u4ee5\u5d4c\u5957\u3002<\/p>\n<h4>1.1.4. \u901a\u8fc7 SQL \u5ba2\u6237\u7aef\u8fdb\u884c\u53c2\u6570\u4ea4\u4e92<\/h4>\n<p>Pgpool-II \u8fd8\u63d0\u4f9b\u4e86\u4e24\u79cd SQL \u98ce\u683c \u547d\u4ee4\u4e0e\u4f1a\u8bdd\u672c\u5730\u914d\u7f6e\u8bbe\u7f6e\u4ea4\u4e92\u3002<\/p>\n<p>PGPOOL SHOW \u547d\u4ee4\u5141\u8bb8\u68c0\u67e5 \u6240\u6709\u53c2\u6570\u7684\u5f53\u524d\u503c\u3002<\/p>\n<p>PGPOOL SET \u547d\u4ee4\u5141\u8bb8\u4fee\u6539 \u5f53\u524d\u503c&#xff0c;\u8fd9\u4e9b\u53c2\u6570\u53ef\u4ee5\u5728\u672c\u5730\u8bbe\u7f6e\u4e3a \u4f1a\u671f;\u5b83\u5bf9\u5176\u4ed6\u4f1a\u8bdd\u6ca1\u6709\u5f71\u54cd\u3002<\/p>\n<h3>1.2. \u8fde\u63a5\u548c\u8eab\u4efd\u9a8c\u8bc1<\/h3>\n<h4>1.2.1. \u8fde\u63a5\u8bbe\u7f6e<\/h4>\n<p>listen_addresses &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u670d\u52a1\u5668\u6240\u5728\u7684 TCP\/IP \u5730\u5740 \u4fa6\u542c\u6765\u81ea\u5ba2\u6237\u7aef\u5e94\u7528\u7a0b\u5e8f\u7684\u8fde\u63a5\u3002 \u8be5\u503c\u91c7\u7528\u9017\u53f7\u5206\u9694\u7684\u4e3b\u673a\u540d\u5217\u8868\u7684\u5f62\u5f0f \u548c\/\u6216\u6570\u5b57 IP \u5730\u5740\u3002\u7279\u6b8a\u6761\u76ee * \u5bf9\u5e94\u4e8e\u6240\u6709\u53ef\u7528\u7684 IP \u63a5\u53e3\u3002\u6761\u76ee 0.0.0.0 \u5141\u8bb8\u4fa6\u542c\u6240\u6709 IPv4 \u5730\u5740&#xff0c;\u800c &#xff1a;&#xff1a; \u5141\u8bb8\u4fa6\u542c\u6240\u6709 IPv6 \u5730\u5740\u3002 \u5982\u679c\u5217\u8868\u4e3a\u7a7a&#xff0c;\u5219\u670d\u52a1\u5668\u4e0d\u4fa6\u542c\u4efb\u4f55 IP \u63a5\u53e3 \u5b8c\u5168&#xff0c;\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u53ea\u80fd\u4f7f\u7528 Unix \u57df\u5957\u63a5\u5b57\u6765\u8fde\u63a5 \u5230\u5b83\u3002 \u9ed8\u8ba4\u503c \u662f localhost&#xff0c;\u5b83 \u4ec5\u5141\u8bb8\u672c\u5730 TCP\/IP\u201c\u73af\u56de\u201d\u8fde\u63a5\u5230 \u88ab\u5236\u9020\u3002\u5f53\u5ba2\u6237\u7aef\u8eab\u4efd\u9a8c\u8bc1 &#xff08;\u7b2c 6.1 \u8282&#xff09;\u5141\u8bb8\u7cbe\u7ec6\u7684 \u63a7\u5236\u8c01\u53ef\u4ee5\u8bbf\u95ee server&#xff0c; listen_addresses \u63a7\u5236\u54ea\u4e9b \u63a5\u53e3\u63a5\u53d7\u8fde\u63a5\u5c1d\u8bd5&#xff0c;\u8fd9\u6709\u52a9\u4e8e\u9632\u6b62 \u5728\u4e0d\u5b89\u5168\u7684\u7f51\u7edc\u4e0a\u91cd\u590d\u6076\u610f\u8fde\u63a5\u8bf7\u6c42 \u63a5\u53e3\u3002\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>port &#xff08;\u6574\u6570) \u4f7f\u7528\u7684\u7aef\u53e3\u53f7 \u7531 Pgpool-II \u76d1\u542c \u8fde\u63a5\u3002\u9ed8\u8ba4\u503c\u4e3a 9999\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>unix_socket_directories &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u63a5\u53d7 Pgpool-II \u8fde\u63a5\u7684 UNIX \u57df\u5957\u63a5\u5b57\u5c06\u88ab\u521b\u5efa\u7684\u76ee\u5f55\u3002\u591a\u4e2a\u5957\u63a5\u5b57 \u53ef\u4ee5\u901a\u8fc7\u5217\u51fa\u591a\u4e2a\u76ee\u5f55&#xff08;\u4ee5\u9017\u53f7\u5206\u9694&#xff09;\u6765\u521b\u5efa\u3002\u8fdd\u7ea6 \u662f \/tmp\u3002\u8bf7\u6ce8\u610f&#xff0c;\u6b64\u5957\u63a5\u5b57\u53ef\u80fd\u4f1a\u88ab\u5220\u9664 \u901a\u8fc7 cron \u4f5c\u4e1a\u3002\u6211\u4eec\u5efa\u8bae\u5c06\u6b64\u503c\u8bbe\u7f6e\u4e3a \/var\/run \u6216\u6b64\u7c7b\u76ee\u5f55\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>unix_socket_group &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u8bbe\u7f6e Unix \u57df\u5957\u63a5\u5b57\u7684\u62e5\u6709\u7ec4\u3002&#xff08;\u7684\u62e5\u6709\u7528\u6237 sockets \u59cb\u7ec8\u662f\u542f\u52a8 server \u7684\u7528\u6237\u3002\u7ec4\u5408 \u4f7f\u7528\u53c2\u6570 unix_socket_permissions \u53ef\u4ee5\u662f \u7528\u4f5c Unix \u57df\u8fde\u63a5\u7684\u9644\u52a0\u8bbf\u95ee\u63a7\u5236\u673a\u5236\u3002 \u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;\u8fd9\u662f\u7a7a\u5b57\u7b26\u4e32&#xff0c;\u5b83\u4f7f\u7528 server \u7528\u6237\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>unix_socket_permissions &#xff08;\u6574\u6570&#xff09;) \u8bbe\u7f6e Unix \u57df\u5957\u63a5\u5b57\u7684\u8bbf\u95ee\u6743\u9650\u3002Unix \u57df \u5957\u63a5\u5b57\u4f7f\u7528\u901a\u5e38\u7684 Unix \u6587\u4ef6\u7cfb\u7edf\u6743\u9650\u96c6\u3002\u53c2\u6570\u503c \u5e94\u4e3a\u4ee5 chmod \u548c umask \u7cfb\u7edf\u8c03\u7528\u3002&#xff08;\u8981\u4f7f\u7528\u60ef\u7528\u7684\u516b\u8fdb\u5236\u683c\u5f0f&#xff0c;\u8bf7\u5c06\u6570\u5b57 \u5fc5\u987b\u4ee5 0&#xff08;\u96f6&#xff09;\u5f00\u5934\u3002<\/p>\n<p>\u9ed8\u8ba4\u6743\u9650\u4e3a 0777&#xff0c;\u8fd9\u610f\u5473\u7740\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5 \u8fde\u63a5\u3002\u5408\u7406\u7684\u66ff\u4ee3\u65b9\u6848\u662f 0770 &#xff08;only user \u548c group&#xff0c;\u53e6\u8bf7\u53c2\u9605 unix_socket_group&#xff09; \u548c 0700 &#xff08;\u4ec5\u7528\u6237&#xff09;\u3002&#xff08;\u8bf7\u6ce8\u610f&#xff0c;\u5bf9\u4e8e Unix \u57df\u5957\u63a5\u5b57&#xff0c; \u53ea\u6709\u5199\u5165\u6743\u9650\u624d\u91cd\u8981&#xff0c;\u56e0\u6b64\u8bbe\u7f6e\u6216\u64a4\u9500\u6ca1\u6709\u610f\u4e49 \u8bfb\u53d6\u6216\u6267\u884c\u6743\u9650\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>pcp_listen_addresses &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a pcp \u670d\u52a1\u5668\u6240\u5728\u7684 TCP\/IP \u5730\u5740 \u4fa6\u542c\u6765\u81ea\u5ba2\u6237\u7aef\u5e94\u7528\u7a0b\u5e8f\u7684\u8fde\u63a5\u3002 \u8be5\u503c\u91c7\u7528\u9017\u53f7\u5206\u9694\u7684\u4e3b\u673a\u540d\u5217\u8868\u7684\u5f62\u5f0f \u548c\/\u6216\u6570\u5b57 IP \u5730\u5740\u3002\u7279\u6b8a\u6761\u76ee * \u5bf9\u5e94\u4e8e\u6240\u6709\u53ef\u7528\u7684 IP \u63a5\u53e3\u3002\u6761\u76ee 0.0.0.0 \u5141\u8bb8\u4fa6\u542c\u6240\u6709 IPv4 \u5730\u5740&#xff0c;\u800c &#xff1a;&#xff1a; \u5141\u8bb8\u4fa6\u542c\u6240\u6709 IPv6 \u5730\u5740\u3002 \u5982\u679c\u5217\u8868\u4e3a\u7a7a&#xff0c;\u5219\u670d\u52a1\u5668\u4e0d\u4fa6\u542c\u4efb\u4f55 IP \u63a5\u53e3 \u5b8c\u5168&#xff0c;\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u53ea\u80fd\u4f7f\u7528 Unix \u57df\u5957\u63a5\u5b57\u6765\u8fde\u63a5 \u5230\u5b83\u3002 \u9ed8\u8ba4\u503c \u662f localhost&#xff0c;\u5b83 \u4ec5\u5141\u8bb8\u672c\u5730 TCP\/IP\u201c\u73af\u56de\u201d\u8fde\u63a5\u5230 \u88ab\u5236\u9020\u3002\u5f53\u5ba2\u6237\u7aef\u8eab\u4efd\u9a8c\u8bc1 &#xff08;\u7b2c 6.1 \u8282&#xff09;\u5141\u8bb8\u7cbe\u7ec6\u7684 \u63a7\u5236\u8c01\u53ef\u4ee5\u8bbf\u95ee server&#xff0c; pcp_listen_addresses \u63a7\u5236\u54ea\u4e9b \u63a5\u53e3\u63a5\u53d7\u8fde\u63a5\u5c1d\u8bd5&#xff0c;\u8fd9\u6709\u52a9\u4e8e\u9632\u6b62 \u5728\u4e0d\u5b89\u5168\u7684\u7f51\u7edc\u4e0a\u91cd\u590d\u6076\u610f\u8fde\u63a5\u8bf7\u6c42 \u63a5\u53e3\u3002\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>pcp_port &#xff08;\u6574\u6570&#xff09;) PCP \u4f7f\u7528\u7684\u7aef\u53e3\u53f7 process \u6765\u76d1\u542c\u8fde\u63a5\u3002\u9ed8\u8ba4\u503c\u4e3a 9898\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>pcp_socket_dir &#xff08;\u5b57\u7b26\u4e32&#xff09;) UNIX \u57df\u5957\u63a5\u5b57\u63a5\u53d7 \u5c06\u521b\u5efa PCP \u8fdb\u7a0b\u7684\u8fde\u63a5\u3002\u591a\u4e2a\u5957\u63a5\u5b57 \u53ef\u4ee5\u901a\u8fc7\u5217\u51fa\u591a\u4e2a\u76ee\u5f55&#xff08;\u4ee5\u9017\u53f7\u5206\u9694&#xff09;\u6765\u521b\u5efa\u3002 \u9ed8\u8ba4\u503c\u4e3a \/tmp\u3002\u8bf7\u6ce8\u610f&#xff0c;\u6b64 socket \u53ef\u80fd\u4f1a\u88ab cron \u4f5c\u4e1a\u5220\u9664\u3002\u6211\u4eec\u5efa\u8bae\u5c06\u6b64\u9879 \u503c\u8bbe\u7f6e\u4e3a \/var\/run \u6216\u6b64\u7c7b\u76ee\u5f55\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>num_init_children &#xff08;\u6574\u6570) \u7684 \u9884\u5206\u53c9\u7684 Pgpool-II \u670d\u52a1\u5668 \u8fc7\u7a0b\u3002\u9ed8\u8ba4\u503c\u4e3a 32\u3002num_init_children \u4e5f\u662f \u5e76\u53d1\u8fde\u63a5\u6570\u9650\u5236 \u5230 Pgpool-II\u3002\u5982\u679c \u8d85\u8fc7 num_init_children \u4e2a\u5ba2\u6237\u7aef\u5c1d\u8bd5\u8fde\u63a5\u5230 Pgpool-II&#xff0c;\u5b83\u4eec \u5df2\u963b\u6b62&#xff08;\u672a\u56e0\u9519\u8bef\u800c\u88ab\u62d2\u7edd&#xff0c; \u5982 PostgreSQL&#xff09;&#xff0c;\u76f4\u5230 \u9664\u975e\u8bbe\u7f6e\u4e86 reserved_connections&#xff0c;\u5426\u5219\u4e0e\u4efb\u4f55 Pgpool-II \u8fdb\u7a0b\u7684\u8fde\u63a5\u90fd\u662f\u5173\u95ed\u7684 \u8bbe\u7f6e\u4e3a 1 \u6216\u66f4\u591a\u3002\u6700\u9ad8 listen_backlog_multiplier* num_init_children\u53ef\u4ee5\u6392\u961f\u3002<\/p>\n<p>\u8be5\u961f\u5217\u4f4d\u4e8e\u5185\u6838\u5185\u90e8&#xff0c;\u79f0\u4e3a \u201clisten queue\u201d\u3002\u8fd9 \u4fa6\u542c\u961f\u5217\u7684\u957f\u5ea6\u79f0\u4e3a \u201cbacklog\u201d\u3002\u6709 \u67d0\u4e9b\u7cfb\u7edf\u4e2d\u79ef\u538b\u7684\u4e0a\u9650&#xff0c;\u5982\u679c num_init_children*listen_backlog_multiplier\u8d85\u8fc7\u8be5\u6570\u91cf&#xff0c;\u5219\u9700\u8981\u5c06\u79ef\u538b\u5de5\u4f5c\u8bbe\u7f6e\u5f97\u66f4\u9ad8\u3002 \u5426\u5219&#xff0c;\u5728\u91cd\u8d1f\u8f7d\u7cfb\u7edf\u4e2d\u53ef\u80fd\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u95ee\u9898&#xff1a;<\/p>\n<p>\u8fde\u63a5\u5230 Pgpool-II \u5931\u8d25<\/p>\n<p>\u8fde\u63a5\u5230 Pgpool-II \u662f \u7531\u4e8e\u5185\u6838\u4e2d\u7684\u91cd\u8bd5\u800c\u53d8\u6162\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528 \u201cnetstat -s\u201d \u547d\u4ee4\u3002\u5982\u679c\u60a8\u53d1\u73b0\u7c7b\u4f3c\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p>535 times the listen queue of a socket overflowed<\/p>\n<p>\u90a3\u4e48 listen \u961f\u5217\u80af\u5b9a\u662f\u6ea2\u51fa\u7684\u3002\u4f60 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u5e94\u8be5\u4f1a\u589e\u52a0\u79ef\u538b&#xff08;\u60a8\u5c06 \u9700\u8981\u8d85\u7ea7\u7528\u6237\u6743\u9650&#xff09;\u3002<\/p>\n<p># sysctl net.core.somaxconn<br \/>\nnet.core.somaxconn &#061; 128<br \/>\n# sysctl -w net.core.somaxconn &#061; 256<\/p>\n<p>\u4f60\u53ef\u4ee5\u5c06\u4ee5\u4e0b\u5185\u5bb9\u6dfb\u52a0\u5230 \/etc\/sysctl.conf \u4e2d\u3002<\/p>\n<p>net.core.somaxconn &#061; 256<\/p>\n<p>\u5230 \u7684\u8fde\u63a5\u6570 \u6bcf\u4e2a PostgreSQL \u5927\u81f4\u662f max_pool*num_init_children\u3002<\/p>\n<p>\u4f46\u662f&#xff0c;\u53d6\u6d88\u67e5\u8be2\u4f1a\u521b\u5efa\u53e6\u4e00\u4e2a \u8fde\u63a5\u5230\u540e\u7aef;\u56e0\u6b64&#xff0c;\u5982\u679c\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6&#xff0c;\u5219\u65e0\u6cd5\u53d6\u6d88\u67e5\u8be2 \u6240\u6709\u8fde\u63a5\u90fd\u5728\u4f7f\u7528\u4e2d\u3002\u5982\u679c\u8981\u786e\u4fdd\u67e5\u8be2\u53ef\u4ee5 be canceled&#xff0c;\u8bf7\u5c06\u6b64\u503c\u8bbe\u7f6e\u4e3a\u9884\u671f\u8fde\u63a5\u6570\u7684\u4e24\u500d\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;PostgreSQL \u5141\u8bb8\u5e76\u53d1 \u975e\u8d85\u7ea7\u7528\u6237\u6700\u591a max_connections \u7684\u8fde\u63a5 &#8211; superuser_reserved_connections\u3002<\/p>\n<p>\u603b\u4e4b&#xff0c;max_pool\u3001num_init_children\u3001max_connections\u3001 superuser_reserved_connections\u5fc5\u987b\u6ee1\u8db3\u4ee5\u4e0b\u516c\u5f0f&#xff1a;<\/p>\n<p>   max_pool*num_init_children &lt;&#061; (max_connections &#8211; superuser_reserved_connections) (no query canceling needed)<br \/>\n   max_pool*num_init_children*2 &lt;&#061; (max_connections &#8211; superuser_reserved_connections) (query canceling needed)<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>reserved_connections &#xff08;\u6574\u6570&#xff09;) \u5f53\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a 1 \u6216\u66f4\u5927\u65f6&#xff0c;\u4f20\u5165 \u4e0d\u63a5\u53d7\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8fde\u63a5&#xff0c;\u5e76\u663e\u793a\u9519\u8bef \u6d88\u606f \u201cSorry&#xff0c; too many clients already\u201d&#xff0c;\u800c\u4e0d\u662f \u5982\u679c\u5f53\u524d\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u6570 \u5927\u4e8e &#xff08;num_init_children &#8211; reserved_connections&#xff09;\u3002\u4f8b\u5982 \u5982\u679c reserved_connections &#061; 1 \u548c num_init_children &#061; 32&#xff0c;\u5219 \u6765\u81ea\u5ba2\u6237\u7aef\u7684\u7b2c 32 \u4e2a\u8fde\u63a5\u5c06\u88ab\u62d2\u7edd\u3002\u8fd9 \u884c\u4e3a\u76f8\u4f3c \u5230 PostgreSQL \u5e76\u4e14\u9002\u5408 \u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u6570\u4e3a large \u4e14\u6bcf\u4e2a\u4f1a\u8bdd\u53ef\u80fd\u9700\u8981\u5f88\u957f\u65f6\u95f4\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b \u4fa6\u542c\u961f\u5217\u7684\u957f\u5ea6\u53ef\u80fd\u5f88\u957f&#xff0c;\u5e76\u4e14\u53ef\u80fd\u4f1a \u5bfc\u81f4\u7cfb\u7edf\u4e0d\u7a33\u5b9a\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u8bbe\u7f6e\u6b64 parameter \u8bbe\u7f6e\u4e3a\u975e 0 \u662f\u9632\u6b62\u76d1\u542c\u7684\u597d\u4e3b\u610f \u961f\u5217\u53d8\u5f97\u5f88\u957f\u3002<\/p>\n<p>\u5982\u679c\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a 0&#xff0c;\u5219\u6ca1\u6709\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8fde\u63a5 \u5c06\u88ab\u62d2\u7edd\u3002\u9ed8\u8ba4\u503c\u4e3a 0\u3002 \u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.2.2. \u8eab\u4efd\u9a8c\u8bc1\u8bbe\u7f6e<\/h4>\n<p>enable_pool_hba &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5982\u679c\u4e3a true&#xff0c;\u5219 Pgpool-II \u5c06\u4f7f\u7528 pool_hba.conf \u4f5c\u4e3a\u5ba2\u6237\u7aef \u8ba4\u8bc1\u3002\u6709\u5173\u5982\u4f55\u914d\u7f6e pool_hba.conf \u8fdb\u884c\u5ba2\u6237\u7aef\u8eab\u4efd\u9a8c\u8bc1\u7684\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u89c1Section 6.1\u3002 \u9ed8\u8ba4\u503c\u4e3a false\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<p>pool_passwd &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a \u7684\u5bc6\u7801\u6587\u4ef6\u7684\u8def\u5f84&#xff08;\u7edd\u5bf9\u6216\u76f8\u5bf9&#xff09; \u8ba4\u8bc1\u3002\u9ed8\u8ba4\u503c\u4e3a \u201cpool_passwd\u201d\u3002 \u5c06\u76f8\u5bf9\u4e8e\u76ee\u5f55\u89e3\u91ca\u76f8\u5bf9\u8def\u5f84 \u914d\u7f6e\u6587\u4ef6\u7684\u653e\u7f6e\u4f4d\u7f6e\u3002 \u6307\u5b9a \u2018\u2019 &#xff08;\u7a7a&#xff09; \u5c06\u7981\u7528 \u7684\u5bc6\u7801\u6587\u4ef6\u3002<\/p>\n<p>\u5bc6\u7801\u53ef\u4ee5\u4f7f\u7528\u4e09\u79cd\u683c\u5f0f\u5b58\u50a8\u5728 pool_passwd \u6587\u4ef6\u4e2d\u3002 AES256 \u52a0\u5bc6\u683c\u5f0f\u3001\u7eaf\u6587\u672c\u683c\u5f0f\u548c md5 \u683c\u5f0f\u3002Pgpool-II \u6807\u8bc6\u5bc6\u7801\u683c\u5f0f\u7c7b\u578b \u901a\u8fc7\u5b83\u7684\u524d\u7f00&#xff0c;\u56e0\u6b64 pool_passwd \u4e2d\u7684\u6bcf\u4e2a\u5bc6\u7801\u6761\u76ee\u90fd\u5fc5\u987b\u5e26\u6709\u524d\u7f00 \u6839\u636e\u5bc6\u7801\u683c\u5f0f\u3002<\/p>\n<p>\u8981\u4ee5\u7eaf\u6587\u672c\u683c\u5f0f\u5b58\u50a8\u5bc6\u7801&#xff0c;\u8bf7\u4f7f\u7528 TEXT \u524d\u7f00\u3002 \u4f8b\u5982\u3002\u8981\u5728 pool_passwd \u4e2d\u5b58\u50a8\u660e\u6587\u5bc6\u7801\u5b57\u7b26\u4e32 \u201cmypassword\u201d&#xff0c;\u8bf7\u5728\u5bc6\u7801\u5b57\u7b26\u4e32\u524d\u9762\u52a0\u4e0a TEXT \u524d\u7f00\u3002 \u4f8b\u5982 TEXTmypassword<\/p>\n<p>\u540c\u6837&#xff0c;MD5 \u54c8\u5e0c\u5bc6\u7801\u5fc5\u987b\u4ee5 MD5 \u548c AES256 \u52a0\u5bc6\u7684\u5bc6\u7801\u7c7b\u578b\u53ef\u4ee5\u4f7f\u7528 AES \u524d\u7f00\u8fdb\u884c\u5b58\u50a8\u3002 \u6709\u5173\u4f7f\u7528 AES256 \u52a0\u5bc6\u5bc6\u7801\u3002<\/p>\n<p>\u5728\u6ca1\u6709\u6709\u6548\u524d\u7f00\u7684\u60c5\u51b5\u4e0b&#xff0c;Pgpool-II \u5c06 \u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u7eaf\u6587\u672c\u5bc6\u7801\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>allow_clear_text_frontend_auth &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5982\u679c PostgreSQL \u540e\u7aef\u670d\u52a1\u5668\u9700\u8981 md5 \u6216 SCRAM \u8eab\u4efd\u9a8c\u8bc1&#xff0c;\u5219\u67d0\u4e9b \u7528\u6237\u7684\u8eab\u4efd\u9a8c\u8bc1&#xff0c;\u4f46\u8be5\u7528\u6237\u7684\u5bc6\u7801\u6ca1\u6709\u51fa\u73b0\u5728 \u201cpool_passwd\u201d \u6587\u4ef6\u4e2d&#xff0c;\u90a3\u4e48\u542f\u7528 allow_clear_text_frontend_auth \u5c06\u5141\u8bb8 Pgpool-II \u4f7f\u7528\u660e\u6587\u5bc6\u7801 \u4f7f\u7528\u524d\u7aef\u5ba2\u6237\u7aef\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1&#xff0c;\u4ee5\u7eaf\u6587\u672c\u5f62\u5f0f\u83b7\u53d6\u5bc6\u7801 \u5e76\u5c06\u5176\u7528\u4e8e\u540e\u7aef\u8eab\u4efd\u9a8c\u8bc1\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a false\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; allow_clear_text_frontend_auth\u4ec5\u5728\u672a\u542f\u7528 enable_pool_hba \u65f6\u6709\u6548<\/p>\n<p>authentication_timeout &#xff08;\u6574\u6570) \u6307\u5b9a\u8d85\u65f6&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09; \u7528\u4e8e Pgpool-II \u8eab\u4efd\u9a8c\u8bc1\u3002\u6307\u5b9a 0 \u5c06\u7981\u7528\u8d85\u65f6\u3002 \u9ed8\u8ba4\u503c\u4e3a 60\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<h3>1.3. \u6d41\u7a0b\u7ba1\u7406<\/h3>\n<p>process_management_mode &#xff08;\u679a\u4e3e&#xff09;) \u6307\u5b9a Pgpool-II \u5b50\u8fdb\u7a0b\u7684\u7a7a\u95f2\u8fdb\u7a0b\u7ba1\u7406\u65b9\u6cd5\u3002 \u6709\u6548\u9009\u9879&#xff1a;<\/p>\n<p>\u8868 1-1.\u53ef\u80fd\u7684\u8fdb\u7a0b\u7ba1\u7406\u6a21\u5f0f<\/p>\n<table>\n<tr>\u72b6\u6001\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>\u9759\u6001\u7684<\/td>\n<td>\u6240\u6709\u5b50\u8282\u70b9\u5728\u542f\u52a8\u65f6\u90fd\u662f pre-forked \u7684\u3002 \u5b50\u8fdb\u7a0b\u7684\u6570\u91cf\u662f\u56fa\u5b9a\u7684 &#xff08;num_init_children&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u52a8\u6001<\/td>\n<td>\u5b50\u8fdb\u7a0b\u6309\u9700\u751f\u6210&#xff0c;\u6700\u591a num_init_children\u3002 \u4efb\u4f55\u65f6\u5019\u7a7a\u95f2\u7684\u5b50\u8fdb\u7a0b\u6570\u53d6\u51b3\u4e8e min_spare_children \u548c max_spare_children<\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u4e3a static&#xff0c;\u4e0e V4.4 \u4e4b\u524d\u7684\u7248\u672c\u517c\u5bb9\u3002<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>process_management_mode \u5728 Pgpool-II V4.4 \u4e4b\u524d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u6709\u5173\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u9605 Section 3.3.3 \u3002<\/p>\n<p>process_management_strategy &#xff08;enum) \u6307\u5b9a\u8fdb\u7a0b\u7ba1\u7406\u7b56\u7565\u4ee5\u6ee1\u8db3\u5907\u7528&#xff08;\u7a7a\u95f2&#xff09;\u8fdb\u7a0b\u8ba1\u6570 \u6709\u6548\u9009\u9879&#xff1a;<\/p>\n<p>\u8868 1-2.\u53ef\u80fd\u7684\u6d41\u7a0b\u7ba1\u7406\u7b56\u7565<\/p>\n<table>\n<tr>\u7b56\u7565\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>lazy<\/td>\n<td>\u4f7f\u7528\u6b64\u7b56\u7565&#xff0c;\u5c06\u9010\u6b65\u6267\u884c\u7f29\u51cf \u5e76\u4e14\u4ec5\u5728\u5197\u4f59\u8fdb\u7a0b\u8ba1\u6570\u8fc7\u591a\u65f6\u89e6\u53d1 \u4fdd\u6301\u9ad8\u4f4d\u8d85\u8fc7 5 \u5206\u949f<\/td>\n<\/tr>\n<tr>\n<td>gentle<\/td>\n<td>\u4f7f\u7528\u6b64\u7b56\u7565&#xff0c;\u5c06\u9010\u6b65\u6267\u884c\u7f29\u51cf \u5e76\u4e14\u4ec5\u5728\u5197\u4f59\u8fdb\u7a0b\u8ba1\u6570\u8fc7\u591a\u65f6\u89e6\u53d1 \u4fdd\u6301\u9ad8\u4f4d\u8d85\u8fc7 2 \u5206\u949f<\/td>\n<\/tr>\n<tr>\n<td>aggressive<\/td>\n<td>\u4f7f\u7528\u6b64\u7b56\u7565&#xff0c;\u5c06\u79ef\u6781\u6267\u884c\u7f29\u51cf &#xff0c;\u5e76\u4e14\u5728\u5907\u7528\u8fdb\u7a0b\u8f83\u9ad8\u7684\u60c5\u51b5\u4e0b\u4f1a\u66f4\u9891\u7e41\u5730\u89e6\u53d1\u3002 \u6b64\u6a21\u5f0f\u4f7f\u7528\u66f4\u5feb\u4e14\u667a\u80fd\u7a0b\u5ea6\u7a0d\u4f4e\u7684\u8fdb\u7a0b\u9009\u62e9\u6807\u51c6 \u786e\u5b9a\u53ef\u4ee5\u63d0\u4f9b\u670d\u52a1\u4ee5\u6ee1\u8db3 max_spare_children<\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u503c\u4e3a gentle\u3002<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>process_management_strategy \u5728 Pgpool-II V4.4 \u4e4b\u524d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>min_spare_children &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u8981\u4fdd\u7559\u7684\u5907\u7528 &#xff08;\u7a7a\u95f2&#xff09; \u5b50\u8fdb\u7a0b\u7684\u6700\u5c0f\u6570\u91cf\u3002 \u5982\u679c\u7a7a\u95f2\u8fdb\u7a0b\u8ba1\u6570\u4f4e\u4e8e min_spare_children&#xff0c; Pgpool-II \u5c06\u4ea7\u751f\u65b0\u7684\u5b50\u8fdb\u7a0b&#xff0c;\u9664\u975e\u5b83\u8fbe\u5230\u5141\u8bb8\u7684\u5b50\u8fdb\u7a0b\u603b\u4e0a\u9650 &#xff08;num_init_children&#xff09;\u3002 \u9ed8\u8ba4\u503c\u4e3a 5\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<p>\u8be5\u53c2\u6570\u4ec5\u9002\u7528\u4e8e\u52a8\u6001\u6d41\u7a0b\u7ba1\u7406\u6a21\u5f0f\u3002<\/p>\n<p>max_spare_children &#xff08;\u6574\u6570) \u6307\u5b9a\u8981\u4fdd\u7559\u7684\u5907\u7528 &#xff08;\u7a7a\u95f2&#xff09; \u5b50\u8fdb\u7a0b\u7684\u6700\u5927\u6570\u91cf\u3002 \u5982\u679c\u7a7a\u95f2\u8fdb\u7a0b\u6570\u4ece max_spare_children \u5f00\u59cb\u589e\u52a0&#xff0c;Pgpool-II \u5c06\u6740\u6b7b\u8fc7\u591a\u7684\u5b50\u8fdb\u7a0b\u3002 \u9009\u62e9\u6807\u51c6\u662f\u9009\u62e9\u5177\u6709\u6700\u5c11\u6c60\u8fde\u63a5\u6570\u7684\u8fdb\u7a0b\u3002 \u9ed8\u8ba4\u503c\u4e3a 10\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<p>\u8be5\u53c2\u6570\u4ec5\u9002\u7528\u4e8e\u52a8\u6001\u6d41\u7a0b\u7ba1\u7406\u6a21\u5f0f\u3002<\/p>\n<h3>1.4. \u96c6\u7fa4\u6a21\u5f0f<\/h3>\n<p>backend_clustering_mode &#xff08;\u679a\u4e3e&#xff09;) \u96c6\u7fa4\u6a21\u5f0f\u662f\u540c\u6b65 PostgreSQL \u670d\u52a1\u5668\u7684\u65b9\u6cd5\u3002\u8bbe\u7f6e\u805a\u7c7b \u6a21\u5f0f&#xff0c;\u53ef\u4ee5\u4f7f\u7528 backend_clustering_mode\u3002\u5728 \u672c\u8282\u8ba8\u8bba\u5982\u4f55\u8bbe\u7f6e clustering mode\u3002\u6709\u5173\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u9605 Section 2.1.1 \u3002<\/p>\n<h4>1.4.1. \u6d41\u5f0f\u590d\u5236\u6a21\u5f0f<\/h4>\n<p>\u6b64\u6a21\u5f0f\u662f\u6700\u5e38\u7528\u548c\u63a8\u8350\u7684\u7fa4\u96c6\u6a21\u5f0f\u3002\u5728\u8fd9\u4e2a mode PostgreSQL \u8d1f\u8d23 \u590d\u5236\u6bcf\u4e2a\u670d\u52a1\u5668\u3002\u8981\u542f\u7528\u6b64\u6a21\u5f0f&#xff0c;\u8bf7\u4f7f\u7528 backend_clustering_mode \u7684 \u2018streaming_replication\u2019 \u8868\u793a\u3002<\/p>\n<p>backend_clustering_mode &#061; &#039;streaming_replication&#039;<\/p>\n<p>\u5728\u6b64\u6a21\u5f0f\u4e0b&#xff0c;\u60a8\u6700\u591a\u53ef\u4ee5\u62e5\u6709 127 \u4e2a Streaming Replication \u5907\u7528\u670d\u52a1\u5668\u3002 \u6b64\u5916&#xff0c;\u53ef\u80fd\u6839\u672c\u6ca1\u6709\u5907\u7528\u670d\u52a1\u5668\u3002<\/p>\n<p>\u8fd9\u79cd\u6a21\u5f0f\u7684\u7f3a\u70b9\u662f&#xff0c;\u9700\u8981\u8003\u8651 \u5206\u53d1\u8bfb\u53d6\u67e5\u8be2\u65f6\u7684\u590d\u5236\u5ef6\u8fdf\u3002\u53ef\u89c1\u6027 \u8282\u70b9\u4e4b\u95f4\u7684\u4e00\u81f4\u6027\u4e5f\u65e0\u6cd5\u4fdd\u8bc1\u3002\u7f13\u89e3\u8fd9\u4e9b \u95ee\u9898 \u51c6\u5907\u4e86\u8bb8\u591a\u989d\u5916\u7684\u53c2\u6570&#xff0c;\u4f46\u5b83\u53ef\u80fd\u4f1a\u4f7f \u7ba1\u7406\u4efb\u52a1\u66f4\u96be\u3002\u6b64\u5916&#xff0c;\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u65f6\u95f4 \u5f53\u4e3b\u670d\u52a1\u5668\u5b95\u673a\u65f6\u6267\u884c\u6545\u969c\u8f6c\u79fb&#xff0c;\u5e76\u4e14 Standbys \u5df2\u5347\u7ea7\u3002\u5982\u679c\u8981\u907f\u514d\u8fd9\u4e9b\u95ee\u9898&#xff0c;\u8bf7\u8003\u8651\u5feb\u7167\u9694\u79bb \u6a21\u5f0f\u3002<\/p>\n<p>\u53c2\u89c1 Section 1.12 \u6d41\u590d\u5236\u6a21\u5f0f\u7684\u5176\u4ed6\u53c2\u6570\u3002<\/p>\n<h4>1.4.2. \u539f\u751f\u590d\u5236\u6a21\u5f0f<\/h4>\n<p>\u8fd9\u79cd\u6a21\u5f0f\u4f7f Pgpool-II \u80fd\u591f \u5728 PostgreSQL \u540e\u7aef\u4e4b\u95f4\u590d\u5236\u6570\u636e\u3002\u8981\u542f\u7528\u6b64\u6a21\u5f0f&#xff0c;\u8bf7\u4f7f\u7528 \u2018native_replication\u2019 \u4f5c\u4e3a backend_clustering_mode\u3002<\/p>\n<p>backend_clustering_mode &#061; &#039;native_replication&#039;<\/p>\n<p>\u5728\u6b64\u6a21\u5f0f\u4e0b&#xff0c;\u60a8\u6700\u591a\u53ef\u4ee5\u6709 127 \u4e2a\u5907\u7528\u590d\u5236\u670d\u52a1\u5668\u3002 \u6b64\u5916&#xff0c;\u53ef\u80fd\u6839\u672c\u6ca1\u6709\u5907\u7528\u670d\u52a1\u5668\u3002<\/p>\n<p>\u8d1f\u8f7d\u5e73\u8861&#xff08;\u8bf7\u53c2\u9605 Section 1.8 &#xff09;\u53ef\u4ee5 \u8fd8\u53ef\u4ee5\u4e0e\u590d\u5236\u6a21\u5f0f\u4e00\u8d77\u4f7f\u7528&#xff0c;\u4ee5\u5c06\u8d1f\u8f7d\u5206\u914d\u5230 \u9644\u52a0\u7684\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u8fd9\u79cd\u6a21\u5f0f\u7684\u7f3a\u70b9\u662f&#xff0c;\u8282\u70b9\u4e4b\u95f4\u7684\u53ef\u89c1\u6027\u4e00\u81f4\u6027\u662f \u4e0d\u4fdd\u8bc1\u3002\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8282\u70b9\u548c\u8bfb\u53d6\u4e0d\u4e00\u81f4 \u4e0d\u4e00\u81f4\u7684\u6570\u636e\u3002\u5982\u679c\u8981\u907f\u514d\u8fd9\u4e9b\u95ee\u9898&#xff0c;\u8bf7\u8003\u8651\u5feb\u7167\u9694\u79bb \u6a21\u5f0f\u3002<\/p>\n<p>\u4ee5\u4e0b\u9009\u9879\u4f1a\u5f71\u54cd Pgpool-II \u5728\u590d\u5236\u6a21\u5f0f\u4e0b\u7684\u884c\u4e3a\u3002<\/p>\n<p>replication_stop_on_mismatch &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;\u5e76\u4e14\u6240\u6709\u8282\u70b9\u90fd\u4e0d\u56de\u590d\u76f8\u540c\u7684 packet kind \u6dfb\u52a0\u5230\u53d1\u9001\u5230 \u6240\u6709 PostgreSQL \u540e\u7aef\u8282\u70b9&#xff0c; \u5219 reply \u4e0e \u591a\u6570 \u88ab Pgpool-II. \u5982\u679c\u8bbe\u7f6e\u4e86 replication_stop_on_mismatch \u8bbe\u7f6e\u4e3a off \u5e76\u53d1\u751f\u7c7b\u4f3c\u7684\u60c5\u51b5 Pgpool-II \u4ec5\u7ec8\u6b62 \u5f53\u524d\u7528\u6237\u4f1a\u8bdd&#xff0c;\u4f46\u4e0d\u4f1a\u9000\u5316\u540e\u7aef \u8282\u70b9\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; Pgpool-II \u4e0d\u68c0\u67e5 \u540e\u7aef\u8fd4\u56de\u7684\u6570\u636e\u5e76\u505a\u51fa\u51b3\u7b56 \u4ec5\u901a\u8fc7\u6bd4\u8f83\u7ed3\u679c\u6570\u636e\u5305\u7c7b\u578b\u3002<\/p>\n<p>\u542f\u7528 replication_stop_on_mismatch\u662f \u9632\u6b62\u540e\u7aef\u4e4b\u95f4\u7684\u6570\u636e\u4e0d\u4e00\u81f4 \u8282\u70b9\u3002\u4f8b\u5982&#xff0c;\u60a8\u53ef\u80fd\u5e0c\u671b\u9000\u5316\u540e\u7aef node \u5982\u679c UPDATE \u8bed\u53e5\u5728\u4e00\u4e2a\u540e\u7aef\u8282\u70b9\u4e0a\u5931\u8d25 \u540c\u65f6\u4f20\u9012\u4ed6\u4eba\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<p>failover_if_affected_tuples_mismatch &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;\u5e76\u4e14\u6240\u6709\u8282\u70b9\u90fd\u4e0d\u56de\u590d\u76f8\u540c\u7684 INSERT\/UPDATE\/DELETE \u53d7\u5f71\u54cd\u7684\u5143\u7ec4\u6570 query \u4e2d&#xff0c;\u5219\u5176\u56de\u590d\u4e0e \u591a\u6570 \u88ab Pgpool-II. \u5982\u679c failover_if_affected_tuples_mismatch \u8bbe\u7f6e\u4e3a off \u5e76\u4e14\u53d1\u751f\u7c7b\u4f3c\u60c5\u51b5&#xff0c;\u5219 Pgpool-II \u4ec5\u7ec8\u6b62 \u5f53\u524d\u7528\u6237\u4f1a\u8bdd&#xff0c;\u4f46\u4e0d\u4f1a\u9000\u5316\u540e\u7aef \u8282\u70b9\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5728\u5e73\u5c40\u7684\u60c5\u51b5\u4e0b&#xff0c;\u5f53\u4e24\u4e2a\u6216\u591a\u4e2a\u7ec4\u5177\u6709\u76f8\u540c\u7684 number of nodes&#xff0c;\u5219\u5305\u542b\u4e3b\u8282\u70b9\u7684\u7ec4 node&#xff08;\u5177\u6709\u6700\u5c0f\u8282\u70b9 ID \u7684\u540e\u7aef\u8282\u70b9&#xff09;\u83b7\u53d6 \u4f18\u5148\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>replicate_select &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;Pgpool-II \u542f\u7528 SELECT \u67e5\u8be2\u590d\u5236\u6a21\u5f0f\u3002\u5373\u53d1\u9001 SELECT \u67e5\u8be2 \u6dfb\u52a0\u5230\u6240\u6709\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u8868 1-3.\u5bf9 SELECT \u8def\u7531load_balance_mode\u5f71\u54cd\u7684 replicate_select <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418150219-6802697b92514.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>insert_lock &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;Pgpool-II \u5c06 \u81ea\u52a8\u9501\u5b9a\u8868 \u5728 PostgreSQL \u4e0a\u7684 INSERT \u4e4b\u524d \u4e3a\u6b64\u53d1\u5e03\u4e86\u58f0\u660e\u3002<\/p>\n<p>\u590d\u5236 SERIAL \u6570\u636e\u7c7b\u578b\u7684\u8868\u65f6&#xff0c;SERIAL column \u503c\u53ef\u80fd\u4f1a\u5728\u4e0d\u540c\u7684 backends \u7684\u6b64\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6cd5\u662f\u663e\u5f0f \u5728\u53d1\u51fa INSERT \u4e4b\u524d\u9501\u5b9a table\u3002<\/p>\n<p>\u56e0\u6b64&#xff0c;\u4e3a\u4e86\u81ea\u52a8\u9501\u5b9a \u8868 Pgpool-II \u6267\u884c \u4ee5\u4e0b\u8f6c\u6362&#xff1a;<\/p>\n<p>   INSERT INTO &#8230;<\/p>\n<p>\u81ea<\/p>\n<p>   BEGIN;<br \/>\n   LOCK TABLE &#8230;<br \/>\n   INSERT INTO &#8230;<br \/>\n   COMMIT;<\/p>\n<p>\u8c28\u614e&#xff1a;\u8fd9\u79cd\u65b9\u6cd5\u4e25\u91cd\u964d\u4f4e\u4e86\u4ea4\u6613\u7684 \u6392\u6bd4<\/p>\n<p>Pgpool-II V2.2 \u6216\u66f4\u9ad8\u7248\u672c&#xff0c;\u81ea\u52a8\u68c0\u6d4b\u8868\u662f\u5426\u5177\u6709 SERIAL \u5217&#xff0c;\u56e0\u6b64\u5982\u679c \u6ca1\u6709 SERIAL \u5217\u3002<\/p>\n<p>Pgpool-II V3.0 \u5230 Pgpool-II V3.0.4 \u90fd\u4f7f\u7528\u9488\u5bf9\u5e8f\u5217\u5173\u7cfb\u7684\u884c\u9501&#xff0c;\u800c\u4e0d\u662f \u8868\u9501\u3002\u8fd9\u662f\u4e3a\u4e86\u6700\u5927\u9650\u5ea6\u5730\u51cf\u5c11\u9501\u51b2\u7a81 \u4f7f\u7528 VACUUM&#xff08;\u5305\u62ec autovacuum&#xff09;\u3002 \u4f46\u662f&#xff0c;\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u53e6\u4e00\u4e2a\u95ee\u9898\u3002\u540e \u4e8b\u52a1\u56de\u7ed5\u53d1\u751f&#xff0c;\u9488\u5bf9 sequence \u5173\u7cfb\u5bfc\u81f4 PostgreSQL \u5185\u90e8\u9519\u8bef&#xff08;\u66f4\u591a \u51c6\u786e\u5730\u8bf4&#xff0c;pg_clog \u4e0a\u7684 Access \u9519\u8bef&#xff0c;\u5b83\u4f7f \u4ea4\u6613\u72b6\u6001&#xff09;\u3002\u4e3a\u4e86\u9632\u6b62 this&#xff0c;PostgreSQL \u6838\u5fc3 \u5f00\u53d1\u4eba\u5458\u51b3\u5b9a\u7981\u6b62\u5bf9 \u5e8f\u5217&#xff0c;\u8fd9\u574f\u4e86 \u5f53\u7136\u662f Pgpool-II&#xff08; PostgreSQL \u7684\u201c\u56fa\u5b9a\u201d\u7248\u672c\u4f5c\u4e3a 9.0.5 \u53d1\u5e03&#xff0c; 8.4.9\u30018.3.16 \u548c 8.2.22&#xff09;\u3002<\/p>\n<p>Pgpool-II V3.0.5 \u6216\u66f4\u9ad8\u7248\u672c\u4f7f\u7528\u884c\u9501 \u9488\u5bf9 pgpool_catalog.insert_lock \u8868&#xff0c;\u56e0\u4e3a\u65b0\u7684 PostgreSQL \u4e0d\u5141\u8bb8\u5bf9 \u5e8f\u5217\u5173\u7cfb\u3002\u56e0\u6b64insert_lock \u4e2d\u521b\u5efa\u8868 \u6240\u6709\u4e8b\u5148\u901a\u8fc7 Pgpool-II \u8bbf\u95ee\u7684\u6570\u636e\u5e93\u90fd\u662f \u5fc5\u586b\u3002\u6709\u5173\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u9605 Section 2.8 \u3002\u5982\u679c\u4e0d\u5b58\u5728 insert_lock table \u4e2d&#xff0c;Pgpool-II \u4f1a\u9501\u5b9a Insert Target Table.\u6b64\u884c\u4e3a\u662f\u76f8\u540c\u7684 \u4f5c\u4e3a Pgpool-II V2.2 \u548c V2.3 \u7cfb\u5217\u3002<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u4f7f\u7528 insert_lock \u54ea\u4e2a \u4e0e\u65e7\u7248\u672c\u517c\u5bb9&#xff0c;\u60a8\u53ef\u4ee5\u6307\u5b9a LOCK \u65b9\u6cd5\u3002 \u6709\u5173\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u9605 Section 2.5 \u3002<\/p>\n<p>\u5bf9\u4e8e\u7cbe\u7ec6 &#xff08;\u6bcf\u4e2a\u8bed\u53e5&#xff09; \u63a7\u5236&#xff1a;<\/p>\n<p>\u5c06 insert_lock \u8bbe\u7f6e\u4e3a true&#xff0c;\u5e76\u5728 \u60a8\u6267\u884c\u7684 INSERT \u8bed\u53e5\u7684\u5f00\u5934 \u4e0d\u60f3\u83b7\u53d6 table lock\u3002<\/p>\n<p>\u5c06 insert_lock \u8bbe\u7f6e\u4e3a false&#xff0c;\u5e76\u5728 INSERT \u8bed\u53e5\u7684\u5f00\u5934&#xff0c;\u60a8\u4e3a\u5176 \u60f3\u8981\u83b7\u53d6\u8868\u9501\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c\u542f\u7528\u4e86 insert_lock&#xff0c;\u5219 PostgreSQL 8.0 \u5728\u4e8b\u52a1\u3001\u6743\u9650\u3001 rules \u548c alter_table\u3002<\/p>\n<p>\u8fd9\u6837\u505a\u7684\u539f\u56e0\u662f Pgpool-II \u5c1d\u8bd5 LOCK \u7684 VIEW \u8fdb\u884c\u89c4\u5219\u6d4b\u8bd5&#xff0c;\u5e76\u751f\u6210\u4ee5\u4e0b\u5185\u5bb9 \u9519\u8bef\u4fe1\u606f&#xff1a;<\/p>\n<p>! ERROR: current transaction is aborted, commands ignored until<br \/>\nend of transaction block<\/p>\n<p>\u4f8b\u5982&#xff0c;transactions \u6d4b\u8bd5\u5c1d\u8bd5\u5c06 INSERT \u63d2\u5165 \u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u8868\u683c&#xff0c; \u800c Pgpool-II \u4f7f PostgreSQL \u83b7\u53d6 \u8868\u7684\u9501\u3002\u5f53\u7136&#xff0c;\u8fd9\u4f1a\u5bfc\u81f4 \u9519\u8bef\u3002\u4e8b\u52a1\u5c06\u88ab\u4e2d\u6b62&#xff0c;\u5e76\u4e14 \u4ee5\u4e0b INSERT \u8bed\u53e5\u4ea7\u751f\u4e0a\u8ff0\u9519\u8bef \u6d88\u606f\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a on\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<p>lobj_lock_table &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u5927\u578b\u5bf9\u8c61\u590d\u5236\u63a7\u5236\u7684\u8868\u540d\u3002 \u5982\u679c\u6307\u5b9a&#xff0c;Pgpool-II \u5c06\u9501\u5b9a lobj_lock_table \u6307\u5b9a\u7684\u8868\u5e76\u751f\u6210 \u901a\u8fc7\u67e5\u770b\u7cfb\u7edf\u76ee\u5f55pg_largeobject\u7136\u540e\u8c03\u7528 lo_create \u6765\u521b\u5efa\u5927\u578b\u5bf9\u8c61 ID \u5927\u578b\u7269\u4f53\u3002 \u6b64\u8fc7\u7a0b\u4fdd\u8bc1 Pgpool-II \u5728\u590d\u5236\u6a21\u5f0f\u4e0b\u7684\u6240\u6709 DB \u8282\u70b9\u4e2d\u5c06\u83b7\u5f97\u76f8\u540c\u7684\u5927\u5bf9\u8c61 ID\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; PostgreSQL 8.0 \u53ca\u66f4\u65e9\u7248\u672c\u53ef\u4ee5 \u6ca1\u6709lo_create&#xff0c;\u6240\u4ee5\u8fd9\u4e2a\u529f\u80fd \u4e0d\u9002\u7528\u4e8e PostgreSQL 8.0 \u53ca\u66f4\u65e9\u7248\u672c\u3002<\/p>\n<p>\u8c03\u7528 libpq \u51fd\u6570 lo_creat&#xff08;&#xff09; \u4f1a\u89e6\u53d1\u6b64 \u7279\u5f81\u3002\u8fd8\u53ef\u4ee5\u521b\u5efa\u5927\u578b\u5bf9\u8c61 \u901a\u8fc7 Java API &#xff08;JDBC \u9a71\u52a8\u7a0b\u5e8f&#xff09;\u3001PHP API &#xff08;pg_lo_create \u6216\u7c7b\u4f3c API PHP \u5e93&#xff08;\u5982 PDO&#xff09;\u548c\u5404\u79cd API \u4e2d\u7684\u76f8\u540c API \u5df2\u77e5\u7f16\u7a0b\u8bed\u8a00\u4f7f\u7528\u7c7b\u4f3c\u7684\u534f\u8bae \u56e0\u6b64\u5e94\u8be5\u6709\u6548\u3002<\/p>\n<p>\u6b64\u529f\u80fd\u4e0d\u9002\u7528\u4e8e\u5bf9\u5927\u578b\u5bf9\u8c61\u7684\u4ee5\u4e0b\u64cd\u4f5c\u3002<\/p>\n<p>\u6240\u6709\u4f7f\u7528 lo_create\u3001lo_import_with_oid.<\/p>\n<p>lo_import SELECT \u4e2d\u8c03\u7528\u7684\u540e\u7aef\u51fd\u6570\u3002<\/p>\n<p>lo_create SELECT \u4e2d\u8c03\u7528\u7684\u540e\u7aef\u51fd\u6570\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u6240\u6709 PostgreSQL \u7528\u6237\u90fd\u5fc5\u987b \u5177\u6709\u5199\u5165\u8bbf\u95ee\u6743\u9650 lobj_lock_table\u4e0a&#xff0c;\u5b83\u53ef\u4ee5\u662f \u5728\u4efb\u4f55 schema \u4e2d\u521b\u5efa\u3002<\/p>\n<p>\u521b\u5efa\u5927\u578b\u5bf9\u8c61\u9501\u5b9a\u8868\u7684\u793a\u4f8b&#xff1a;<\/p>\n<p>   CREATE TABLE public.my_lock_table ();<br \/>\n   GRANT ALL ON public.my_lock_table TO PUBLIC;<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a \u2018\u2019&#xff08;empty&#xff09;&#xff0c;\u8fd9\u5c06\u7981\u7528\u8be5\u529f\u80fd\u3002<\/p>\n<h4>1.4.3. \u5feb\u7167\u9694\u79bb\u6a21\u5f0f<\/h4>\n<p>\u6b64\u6a21\u5f0f\u7c7b\u4f3c\u4e8e\u672c\u673a\u590d\u5236\u6a21\u5f0f&#xff0c;\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u5b83\u6dfb\u52a0\u4e86 \u8282\u70b9\u4e4b\u95f4\u7684\u53ef\u89c1\u6027\u4e00\u81f4\u6027\u3002\u5b9e\u73b0\u57fa\u4e8e \u5728\u7814\u7a76\u8bba\u6587 Pangea \u4e0a&#xff1a;\u4e00\u4e2a Eager \u6570\u636e\u5e93\u590d\u5236\u4e2d\u95f4\u4ef6\u4fdd\u8bc1\u5feb\u7167 \u65e0\u9700\u4fee\u6539\u6570\u636e\u5e93\u670d\u52a1\u5668\u5373\u53ef\u8fdb\u884c\u9694\u79bb\u3002 \u8981\u542f\u7528\u6b64\u6a21\u5f0f&#xff0c;\u8bf7\u4f7f\u7528 \u2018snapshot_isolation\u2019 \u4f5c\u4e3a backend_clustering_mode\u3002<\/p>\n<p>backend_clustering_mode &#061; \u2018snapshot_isolation\u2019<\/p>\n<p>\u4f8b\u5982&#xff0c;\u60a8\u53ef\u4ee5\u907f\u514d\u7531 \u53ef\u89c1\u6027\u4e0d\u4e00\u81f4\u3002\u8fd9\u91cc S1 \u548c S2 \u8868\u793a\u4f1a\u8bdd&#xff0c;\u800c N1 N2 \u5206\u522b\u8868\u793a PostgreSQL \u670d\u52a1\u5668 1 \u548c 2\u3002<\/p>\n<p>S1\/N1: BEGIN;<br \/>\nS1\/N2: BEGIN;<br \/>\nS1\/N1: UPDATE t1 SET i &#061; i &#043; 1;&#8211; i &#061; 1<br \/>\nS1\/N2: UPDATE t1 SET i &#061; i &#043; 1; &#8212; i &#061; 1<br \/>\nS1\/N1: COMMIT;<br \/>\nS2\/N1: BEGIN;<br \/>\nS2\/N2: BEGIN;<br \/>\nS2\/N2: DELETE FROM t1 WHERE i &#061; 1; &#8212; delete 1 row since S1\/N2 is not committed yet<br \/>\nS2\/N1: DELETE FROM t1 WHERE i &#061; 1; &#8212; delete no row since S1\/N1 is committed and i is not 1 anymore<br \/>\nS1\/N2: COMMIT;<br \/>\nS2\/N1: COMMIT;<br \/>\nS2\/N2: COMMIT;<\/p>\n<p>\u5728\u5feb\u7167\u9694\u79bb\u6a21\u5f0f\u4e0b&#xff0c;\u7ed3\u679c\u5c06\u662f\u4ee5\u4e0b\u4efb\u4e00 \u5b83\u4eec&#xff0c;\u5b83\u6c38\u8fdc\u4e0d\u4f1a\u7834\u574f\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u6570\u636e\u4e00\u81f4\u6027 \u8282\u70b9\u3002<\/p>\n<p>S1\/N1: BEGIN;<br \/>\nS1\/N2: BEGIN;<br \/>\nS1\/N1: UPDATE t1 SET i &#061; i &#043; 1;&#8211; i &#061; 1<br \/>\nS1\/N2: UPDATE t1 SET i &#061; i &#043; 1; &#8212; i &#061; 1<br \/>\nS2\/N1: BEGIN;<br \/>\nS2\/N2: BEGIN;<br \/>\nS1\/N1: COMMIT;<br \/>\nS1\/N2: COMMIT;<br \/>\nS2\/N1: DELETE FROM t1 WHERE i &#061; 1; &#8212; delete no row since S1\/N1 is committed and i is not 1 anymore<br \/>\nS2\/N2: DELETE FROM t1 WHERE i &#061; 1; &#8212; delete no row since S1\/N2 is committed and i is not 1 anymore<br \/>\nS2\/N1: COMMIT;<br \/>\nS2\/N2: COMMIT;<\/p>\n<p>S1\/N1: BEGIN;<br \/>\nS1\/N2: BEGIN;<br \/>\nS1\/N1: UPDATE t1 SET i &#061; i &#043; 1;&#8211; i &#061; 1<br \/>\nS1\/N2: UPDATE t1 SET i &#061; i &#043; 1; &#8212; i &#061; 1<br \/>\nS2\/N1: BEGIN;<br \/>\nS2\/N2: BEGIN;<br \/>\nS2\/N1: DELETE FROM t1 WHERE i &#061; 1; &#8212; delete 1 row since S1\/N1 is not committed yet<br \/>\nS2\/N2: DELETE FROM t1 WHERE i &#061; 1; &#8212; delete 1 row since S1\/N2 is not committed yet<br \/>\nS1\/N1: COMMIT;<br \/>\nS1\/N2: COMMIT;<br \/>\nS2\/N1: COMMIT;<br \/>\nS2\/N2: COMMIT;<\/p>\n<p>\u9700\u8981\u5c06\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u8bbe\u7f6e\u4e3a \u53ef\u91cd\u590d\u8bfb\u53d6\u3002\u8fd9\u610f\u5473\u7740\u60a8\u9700\u8981\u5728 postgresql.conf \u4e2d\u8bbe\u7f6e\u5b83&#xff0c;\u5982\u4e0b\u6240\u793a&#xff1a;<\/p>\n<p>default_transaction_isolation &#061; &#039;repeatable read&#039;<\/p>\n<h4>1.4.4. \u903b\u8f91\u590d\u5236\u6a21\u5f0f<\/h4>\n<p>\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b&#xff0c;PostgreSQL \u8d1f\u8d23\u590d\u5236 \u6bcf\u4e2a\u670d\u52a1\u5668\u3002\u8981\u542f\u7528\u6b64\u6a21\u5f0f&#xff0c;\u8bf7\u4f7f\u7528 \u2018logical_replication\u2019 \u4f5c\u4e3a backend_clustering_mode\u3002<\/p>\n<p>backend_clustering_mode &#061; &#039;logical_replication&#039;<\/p>\n<p>\u5728\u6b64\u6a21\u5f0f\u4e0b&#xff0c;\u6700\u591a\u53ef\u4ee5\u6709 127 \u4e2a\u903b\u8f91\u590d\u5236\u5907\u7528\u670d\u52a1\u5668\u3002 \u6b64\u5916&#xff0c;\u53ef\u80fd\u6839\u672c\u6ca1\u6709\u5907\u7528\u670d\u52a1\u5668\u3002<\/p>\n<p>\u8fd9\u79cd\u6a21\u5f0f\u7684\u7f3a\u70b9\u662f&#xff0c;\u9700\u8981\u8003\u8651 \u5206\u53d1\u8bfb\u53d6\u67e5\u8be2\u65f6\u7684\u590d\u5236\u5ef6\u8fdf\u3002\u53ef\u89c1\u6027 \u8282\u70b9\u4e4b\u95f4\u7684\u4e00\u81f4\u6027\u4e5f\u65e0\u6cd5\u4fdd\u8bc1\u3002\u4e5f\u80af\u5b9a \u7c7b\u578b\u7684\u5bf9\u8c61&#xff08;\u5982 DDL \u548c\u5927\u578b\u5bf9\u8c61&#xff09;\u4e0d\u4f1a\u88ab\u590d\u5236\u3002<\/p>\n<h4>1.4.5. Slony \u6a21\u5f0f<\/h4>\n<p>\u6b64\u6a21\u5f0f\u7528\u4e8e\u5c06 Pgpool-II \u4e0e Slony-I \u8026\u5408\u3002Slony-I \u8d1f\u8d23 \u5b9e\u9645\u6570\u636e\u590d\u5236\u3002\u8981\u542f\u7528\u6b64\u6a21\u5f0f&#xff0c;\u8bf7\u4f7f\u7528 \u2018slony\u2019 \u4f5c\u4e3a backend_clustering_mode\u3002<\/p>\n<p>backend_clustering_mode &#061; &#039;slony&#039;<\/p>\n<p>\u5728\u6b64\u6a21\u5f0f\u4e0b&#xff0c;\u60a8\u6700\u591a\u53ef\u4ee5\u6709 127 \u4e2a\u526f\u672c\u670d\u52a1\u5668\u3002\u5b83\u4e5f\u662f \u53ef\u80fd\u6839\u672c\u6ca1\u6709\u526f\u672c\u670d\u52a1\u5668\u3002<\/p>\n<p>\u8fd9\u79cd\u6a21\u5f0f\u7684\u7f3a\u70b9\u662f&#xff0c;\u9700\u8981\u8003\u8651 \u5206\u53d1\u8bfb\u53d6\u67e5\u8be2\u65f6\u7684\u590d\u5236\u5ef6\u8fdf\u3002\u53ef\u89c1\u6027 \u8282\u70b9\u4e4b\u95f4\u7684\u4e00\u81f4\u6027\u4e5f\u65e0\u6cd5\u4fdd\u8bc1\u3002\u4e5f\u80af\u5b9a \u7c7b\u578b\u7684\u5bf9\u8c61&#xff08;\u5982 DDL \u548c\u5927\u578b\u5bf9\u8c61&#xff09;\u4e0d\u4f1a\u88ab\u590d\u5236\u3002<\/p>\n<p>\u5f15\u5165\u6d41\u5f0f\u590d\u5236\u548c\u903b\u8f91\u590d\u5236\u540e&#xff0c; \u4f7f\u7528 Slony-I \u7684\u7cfb\u7edf\u5f88\u5c11\u3002\u5982\u679c\u6ca1\u6709 \u7279\u522b\u7684\u539f\u56e0&#xff0c;\u4e0d\u5efa\u8bae\u4f7f\u7528\u8fd9\u79cd\u6a21\u5f0f\u3002<\/p>\n<h4>1.4.6. Raw \u6a21\u5f0f<\/h4>\n<p>\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b&#xff0c;Pgpool-II \u4e0d\u5173\u5fc3\u6570\u636e\u5e93\u540c\u6b65\u3002 \u7528\u6237\u6709\u8d23\u4efb\u8ba9\u6574\u4e2a\u7cfb\u7edf\u505a\u6709\u610f\u4e49\u7684\u4e8b\u60c5\u3002 \u5728\u8be5\u6a21\u5f0f\u4e0b\u65e0\u6cd5\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002 \u8981\u542f\u7528\u6b64\u6a21\u5f0f&#xff0c;\u8bf7\u4f7f\u7528 \u2018raw\u2019 \u4f5c\u4e3a backend_clustering_mode\u3002<\/p>\n<p>backend_clustering_mode &#061; &#039;raw&#039;<\/p>\n<h3>1.5. \u540e\u7aef\u8bbe\u7f6e<\/h3>\n<h4>1.5.1. \u540e\u7aef\u8fde\u63a5\u8bbe\u7f6e<\/h4>\n<p>backend_hostname &#xff08;\u5b57\u7b26\u4e32&#xff09;) backend_hostname \u6307\u5b9a PostgreSQL \u540e\u7aef\u4e3a connected to \u7684 .\u5b83\u88ab\u4f7f\u7528 \u7531 Pgpool-II \u8fdb\u884c\u901a\u4fe1 \u4e0e\u670d\u52a1\u5668\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<p>\u5bf9\u4e8e TCP\/IP \u901a\u4fe1&#xff0c;\u6b64\u53c2\u6570\u53ef\u4ee5\u91c7\u7528 hostname \u6216 IP \u5730\u5740\u3002\u5982\u679c\u6b64 URL \u4ee5 slash&#xff08;\/&#xff09;&#xff0c;\u5b83\u6307\u5b9a Unix \u57df \u901a\u4fe1\u800c\u4e0d\u662f TCP\/IP;\u8be5\u503c\u662f \u5b58\u50a8\u5957\u63a5\u5b57\u6587\u4ef6\u7684\u76ee\u5f55\u3002\u8fd9 backend_hostname\u4e3a\u7a7a\u65f6\u7684\u9ed8\u8ba4\u884c\u4e3a &#xff08;\u2018\u2019&#xff09; \u7528\u4e8e\u8fde\u63a5\u5230 Unix \u57df \u5957\u63a5\u5b57\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u5728 \u53c2\u6570\u540d\u79f0 &#xff08;e.g.backend_hostname0&#xff09; \u7684\u7ed3\u5c3e\u3002\u8fd9 number \u79f0\u4e3a \u201cDB node ID\u201d&#xff0c;\u5b83\u4ece 0. \u6570\u636e\u5e93\u8282\u70b9 ID \u4e3a 0 \u7684\u540e\u7aef\u5c06\u4e3a \u79f0\u4e3a \u201c\u4e3b\u8282\u70b9\u201d\u3002\u5b9a\u4e49\u591a\u4e2a\u540e\u7aef\u65f6&#xff0c; \u5373\u4f7f\u4e3b\u8282\u70b9\u5df2\u5173\u95ed&#xff08;\u4e0d\u662f true \u5728\u67d0\u4e9b\u6a21\u5f0f\u4e0b&#xff09;\u3002\u5728\u672c\u4f8b\u4e2d&#xff0c;\u4e3a\u6700\u5e74\u8f7b\u7684\u6570\u636e\u5e93\u8282\u70b9 ID alive \u5c06\u6210\u4e3a\u65b0\u7684\u4e3b\u8282\u70b9\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f&#xff0c;id \u4e3a 0 \u7684 DB \u8282\u70b9\u6ca1\u6709\u7279\u6b8a\u7684 \u8fd9\u610f\u5473\u7740\u5982\u679c\u5728 Streaming Replication \u6a21\u5f0f\u4e0b\u8fd0\u884c\u3002\u800c \u60a8\u5e94\u8be5\u5173\u5fc3\u6570\u636e\u5e93\u8282\u70b9\u662f \u201c\u4e3b\u8282\u70b9\u201d \u8fd8\u662f \u4e0d\u3002\u6709\u5173\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u89c1 Section 1.8&#xff0c; Section 1.10&#xff0c; Section 1.12 \u3002<\/p>\n<p>\u5982\u679c\u60a8\u6253\u7b97\u4ec5\u4f7f\u7528 \u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668&#xff0c;\u6307\u5b9a \u5b83\u7531 backend_hostname0\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u53c2\u6570\u884c\u548c \u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u3002\u4f46\u662f&#xff0c;\u73b0\u6709\u7684 \u503c\u65e0\u6cd5\u66f4\u65b0&#xff0c;\u56e0\u6b64\u60a8\u5fc5\u987b \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u91cd\u542f Pgpool-II\u3002<\/p>\n<p>backend_port &#xff08;\u6574\u6570&#xff09;) backend_port \u6307\u5b9a\u7aef\u53e3\u53f7 \u7684\u540e\u7aef\u3002\u591a\u4e2a\u540e\u7aef\u53ef\u4ee5\u7531 \u5728\u53c2\u6570\u540d\u79f0\u7684\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u6570\u5b57 &#xff08;\u4f8b\u5982 backend_port0&#xff09;\u3002\u5982\u679c\u60a8\u8ba1\u5212\u4ec5\u4f7f\u7528 1 \u4e2a PostgreSQL \u670d\u52a1\u5668&#xff0c;\u8bf7\u901a\u8fc7 backend_port0 \u6307\u5b9a\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u53c2\u6570\u884c\u6765\u6dfb\u52a0\u65b0\u7684\u540e\u7aef\u7aef\u53e3 \u5e76\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u3002\u4f46\u662f&#xff0c;\u73b0\u6709\u7684 \u503c\u65e0\u6cd5\u66f4\u65b0&#xff0c;\u56e0\u6b64\u60a8\u5fc5\u987b \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u91cd\u542f Pgpool-II\u3002<\/p>\n<p>backend_weight &#xff08;\u6d6e\u70b9\u6570&#xff09;) backend_weight \u6307\u5b9a\u8d1f\u8f7d\u5747\u8861 \u7684\u6bd4\u7387\u3002\u5b83\u53ef\u4ee5\u8bbe\u7f6e\u4e3a\u4efb\u4f55\u6574\u6570\u6216 \u6d6e\u70b9\u503c\u5927\u4e8e\u6216\u7b49\u4e8e\u96f6\u3002 \u591a\u4e2a\u540e\u7aef\u53ef\u4ee5\u7531 \u5728\u53c2\u6570\u540d\u79f0\u7684\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u6570\u5b57 &#xff08;\u4f8b\u5982 backend_weight0&#xff09;\u3002\u5982\u679c\u60a8\u8ba1\u5212\u53ea\u4f7f\u7528\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668&#xff0c;\u901a\u8fc7 backend_weight0 \u6307\u5b9a\u3002<\/p>\n<p>\u65b0backend_weight\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5728\u6b64\u53c2\u6570\u4e2d\u6dfb\u52a0 \u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u3002\u4f46\u662f&#xff0c;\u8fd9\u5c06\u9700\u8981 \u4ec5\u5bf9\u65b0\u5efa\u7acb\u7684\u5ba2\u6237\u7aef\u4f1a\u8bdd\u6709\u6548\u3002Pgpool-II V2.2.6&#xff0c; V2.3 \u6216\u66f4\u9ad8\u7248\u672c\u5141\u8bb8\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d \u914d\u7f6e\u6587\u4ef6\u3002\u5982\u679c\u60a8\u60f3\u9632\u6b62 \u53d1\u9001\u5230 standbys \u4ee5\u6267\u884c\u67d0\u4e9b\u7ba1\u7406\u7684\u4efb\u4f55\u67e5\u8be2 \u5728 Streaming Replication Mode\u3001Logical Replication Mode \u548c Slony \u6a21\u5f0f\u4e0b\u5de5\u4f5c\u3002<\/p>\n<h4>1.5.2. \u540e\u7aef\u6570\u636e\u8bbe\u7f6e<\/h4>\n<p>backend_data_directory &#xff08;\u5b57\u7b26\u4e32&#xff09;) backend_data_directory \u6307\u5b9a database cluster \u76ee\u5f55\u4e0b\u3002\u591a\u4e2a\u540e\u7aef\u53ef\u4ee5\u662f \u901a\u8fc7\u5728\u53c2\u6570\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u6570\u5b57\u6765\u6307\u5b9a \u540d\u79f0&#xff08;\u4f8b\u5982 backend_data_directory0&#xff09;\u3002\u5982\u679c\u60a8\u8ba1\u5212\u4f7f\u7528 \u53ea\u6709\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668&#xff0c;\u901a\u8fc7 backend_data_directory0\u3002\u6b64\u53c2\u6570\u7531\u5728\u7ebf\u6062\u590d\u4f7f\u7528\u3002 \u5982\u679c\u60a8\u4e0d\u4f7f\u7528\u5728\u7ebf\u6062\u590d&#xff0c;\u5219\u65e0\u9700\u8bbe\u7f6e\u5b83\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u53c2\u6570data_directory\u884c\u5e76\u91cd\u65b0\u52a0\u8f7d \u914d\u7f6e\u6587\u4ef6\u3002\u4f46\u662f&#xff0c;\u73b0\u6709\u503c\u65e0\u6cd5\u66f4\u65b0&#xff0c;\u56e0\u6b64 \u4f60\u5fc5\u987b\u5728 \u90a3\u4e2a\u6848\u5b50\u3002<\/p>\n<p>backend_flag &#xff08;\u5b57\u7b26\u4e32&#xff09;) backend_flag \u63a7\u5236\u5404\u79cd\u540e\u7aef \u884c\u4e3a\u3002\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0 \u53c2\u6570\u540d\u79f0\u672b\u5c3e\u7684 number &#xff08;\u4f8b\u5982 backend_flag0&#xff09;\u3002\u5982\u679c\u60a8\u8ba1\u5212\u53ea\u4f7f\u7528\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668&#xff0c;\u8bf7\u901a\u8fc7 backend_flag0 \u6307\u5b9a\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u53c2\u6570\u884c\u5e76\u91cd\u65b0\u52a0\u8f7d \u914d\u7f6e\u6587\u4ef6\u3002\u76ee\u524d\u5141\u8bb8\u4ee5\u4e0b\u64cd\u4f5c\u3002\u591a\u4e2a\u6807\u5fd7\u53ef\u4ee5 \u4f7f\u7528 \u201c|\u201d \u6307\u5b9a\u3002<\/p>\n<p>\u8868 1-4.\u540e\u7aef\u6807\u5fd7<\/p>\n<table>\n<tr>Flag\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>ALLOW_TO_FAILOVER<\/td>\n<td>\u5141\u8bb8\u6545\u969c\u8f6c\u79fb\u6216\u5206\u79bb\u540e\u7aef\u3002\u8fd9 \u662f\u9ed8\u8ba4\u503c\u3002\u4e0d\u80fd\u6307\u5b9a \u540c\u65f6DISALLOW_TO_FAILOVER\u3002<\/td>\n<\/tr>\n<tr>\n<td>DISALLOW_TO_FAILOVER<\/td>\n<td>\u4e0d\u5141\u8bb8\u6545\u969c\u8f6c\u79fb\u6216\u5206\u79bb\u540e\u7aef \u5f53\u60a8\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u4fdd\u62a4\u540e\u7aef\u65f6&#xff0c;\u8fd9\u975e\u5e38\u6709\u7528 \u4f7f\u7528 HA &#xff08;High Availability&#xff09; \u8f6f\u4ef6&#xff0c;\u4f8b\u5982 Heartbeat \u6216 Pacemaker\u3002\u4e0d\u80fd\u6307\u5b9a ALLOW_TO_FAILOVER\u540c\u65f6\u3002<\/td>\n<\/tr>\n<tr>\n<td>ALWAYS_PRIMARY<\/td>\n<td>\u8fd9\u4ec5\u5728\u6d41\u5f0f\u590d\u5236\u4e2d\u6709\u7528 \u6a21\u5f0f\u3002\u5173\u4e8e \u6d41\u5f0f\u590d\u5236\u6a21\u5f0f\u3002\u5982\u679c\u6b64\u6807\u5fd7\u8bbe\u7f6e\u4e3a \u5176\u4e2d\u4e4b\u4e00 backends&#xff0c;Pgpool-II \u5c06 \u672a\u901a\u8fc7\u68c0\u67e5\u627e\u5230\u4e3b\u8282\u70b9 backend \u7684\u76f8\u53cd&#xff0c;\u8bf7\u59cb\u7ec8\u5c06 flag \u8bbe\u7f6e\u4e3a\u4e3b\u8282\u70b9\u3002\u8fd9\u9002\u7528\u4e8e \u5305\u62ec Amazon Aurora \u5728\u5185\u7684\u7cfb\u7edf PostgreSQL \u517c\u5bb9\u6027&#xff0c;\u5b83 \u56fa\u5b9a\u4e3b\u670d\u52a1\u5668\u540d\u79f0\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>backend_application_name &#xff08;\u5b57\u7b26\u4e32&#xff09;) backend_application_name \u6307\u5b9a \u63a5\u6536 WAL \u65e5\u5fd7\u7684 walreceiver \u7684\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0 \u4ece\u4e3b\u8282\u70b9\u3002\u56e0\u6b64&#xff0c;\u5728\u6d41\u5f0f\u4e4b\u5916 replication \u6a21\u5f0f&#xff0c;\u5219\u65e0\u9700\u8bbe\u7f6e\u8be5\u53c2\u6570\u3002 \u5982\u679c\u60a8\u60f3\u663e\u793a \u201creplication_state\u201d\u548c\u201creplication_sync_state\u201d\u5217 \u5728 SHOW POOL NODES \u548c pcp_node_info \u547d\u4ee4\u4e2d\u3002 \u6b64\u5916&#xff0c;delay_threshold_by_time \u8981\u6c42 \u8fd9\u4e2a\u53c2\u6570\u4e5f\u662f\u5982\u6b64\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u5047\u8bbe\u4e3b\u8282\u70b9\u662f backend0&#xff08;\u5176\u4e3b\u673a\u540d \u662f \u201chost0\u201d&#xff09;&#xff0c;\u5219\u6709\u95ee\u9898\u7684\u5907\u7528\u8282\u70b9\u662f backend1&#xff0c;\u800c backend_application_name backend1 \u662f \u201cserver1\u201d&#xff0c;\u5219 postgresql.conf \u7684primary_conninfo\u53c2\u6570\u5e94\u5982\u4e0b\u6240\u793a&#xff1a;<\/p>\n<p>primary_conninfo &#061; &#039;host&#061;host0 port&#061;5432 user&#061;postgres application_name&#061;&#039;server1&#039;&#039;<\/p>\n<p>recovery_1st_stage_command \u5e94\u8be5 \u751f\u6210 Parameter\u3002\u6709\u5173\u4ee5\u4e0b\u5185\u5bb9&#xff0c;\u8bf7\u53c2\u89c1 Section 8.2.7.8 \u547d\u4ee4\u7684\u5b8c\u6574\u793a\u4f8b\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<h3>1.6. \u8fde\u63a5\u6c60<\/h3>\n<p>Pgpool-II \u7ef4\u62a4\u5df2\u5efa\u7acb\u7684 \u8fde\u63a5\u5230 PostgreSQL \u670d\u52a1\u5668&#xff0c;\u5e76\u5728 \u5177\u6709\u76f8\u540c\u5c5e\u6027\u7684\u65b0\u8fde\u63a5&#xff08;\u5373\u7528\u6237\u540d\u3001\u6570\u636e\u5e93\u3001 protocol version&#xff09;\u7684\u5b83\u51cf\u5c11\u4e86\u8fde\u63a5\u5f00\u9500&#xff0c; \u5e76\u63d0\u9ad8\u7cfb\u7edf\u7684\u6574\u4f53\u541e\u5410\u91cf\u3002<\/p>\n<p>1.6.1. \u8fde\u63a5\u6c60\u8bbe\u7f6e connection_cache &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on \u65f6\u7f13\u5b58\u5230\u540e\u7aef\u7684\u8fde\u63a5\u3002\u9ed8\u8ba4\u503c\u4e3a on\u3002\u4f46\u662f&#xff0c;\u5373\u4f7f connection_cache \u5904\u4e8e\u6253\u5f00\u72b6\u6001&#xff0c;\u4e5f\u4e0d\u4f1a\u7f13\u5b58\u4e0e template0\u3001template1\u3001postgres \u548c regression \u6570\u636e\u5e93\u7684\u8fde\u63a5\u3002<\/p>\n<p>\u5982\u679c\u4f60\u66f4\u6539\u4e86\u8fd9\u4e2a\u503c&#xff0c;\u4f60\u9700\u8981\u91cd\u542f Pgpool-II\u3002<\/p>\n<p>max_pool &#xff08;\u6574\u6570&#xff09;) \u7f13\u5b58\u8fde\u63a5\u7684\u6700\u5927\u6570\u91cf \u5728\u6bcf\u4e2a Pgpool-II \u5b50\u7ea7\u4e2d \u8fc7\u7a0b\u3002Pgpool-II \u91cd\u7528\u4e86 cached connection&#xff08;\u5982\u679c\u4f20\u5165\u8fde\u63a5\u6b63\u5728\u8fde\u63a5&#xff09; \u6dfb\u52a0\u5230\u5177\u6709\u76f8\u540c\u7528\u6237\u540d\u548c\u76f8\u540c \u8fd0\u884c\u65f6\u53c2\u6570\u3002\u5982\u679c\u6ca1\u6709&#xff0c;Pgpool-II \u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 \u8fde\u63a5\u5230\u540e\u7aef\u3002\u5982\u679c\u7f13\u5b58\u7684 \u8fde\u63a5\u6570\u8d85\u8fc7 max_pool&#xff0c;\u5219\u6700\u65e9\u7684\u8fde\u63a5\u5c06 \u88ab\u4e22\u5f03&#xff0c;\u5e76\u5c06\u8be5\u69fd\u7528\u4e8e\u65b0\u8fde\u63a5\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a 4\u3002\u8bf7\u6ce8\u610f&#xff0c;\u6570\u91cf \u4ece Pgpool-II \u8fdb\u7a0b\u5230\u540e\u7aef\u7684\u8fde\u63a5\u53ef\u80fd\u8fbe\u5230 num_init_children * max_pool \u603b\u8ba1\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>listen_backlog_multiplier &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u4ece\u524d\u7aef\u5230 Pgpool-II \u7684\u8fde\u63a5\u961f\u5217\u957f\u5ea6\u3002\u961f\u5217\u957f\u5ea6&#xff08;\u5b9e\u9645\u4e0a\u662f listen&#xff08;&#xff09; \u7cfb\u7edf\u8c03\u7528\u7684 \u201cbacklog\u201d \u53c2\u6570&#xff09;\u5b9a\u4e49\u4e3a listen_backlog_multiplier * num_init_children\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u67d0\u4e9b\u7cfb\u7edf\u5177\u6709 listen&#xff08;&#xff09; \u7cfb\u7edf\u8c03\u7528\u7684 backlog \u53c2\u6570\u7684\u4e0a\u9650\u3002 \u6709\u5173\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u9605 num_init_children\u3002 \u9ed8\u8ba4\u503c\u4e3a 2\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>serialize_accept &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;Pgpool-II \u542f\u7528\u5e8f\u5217\u5316 \u5728\u4f20\u5165\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u4e0a\u3002 \u5728\u6ca1\u6709\u5e8f\u5217\u5316\u7684\u60c5\u51b5\u4e0b&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u4f1a\u5524\u9192\u6240\u6709 Pgpool-II \u5b50\u8fdb\u7a0b\u6765\u6267\u884c accept&#xff08;&#xff09; \u548c\u5176\u4e2d\u4e00\u4e2a \u5b9e\u9645\u83b7\u53d6\u4f20\u5165\u8fde\u63a5\u3002\u8fd9\u91cc\u7684\u95ee\u9898\u662f&#xff0c;\u56e0\u4e3a\u6211\u7684\u5b69\u5b50 \u8fdb\u7a0b\u5524\u9192\u65f6&#xff0c;\u4f1a\u53d1\u751f\u5927\u91cf\u7684\u4e0a\u4e0b\u6587\u5207\u6362&#xff0c;\u5e76\u4e14 \u6027\u80fd\u53d7\u5230\u5f71\u54cd\u3002<\/p>\n<p>\u8fd9\u79cd\u73b0\u8c61\u662f\u4e00\u4e2a\u4f17\u6240\u5468\u77e5\u7684\u7ecf\u5178\u95ee\u9898&#xff0c;\u79f0\u4e3a \u201c\u96f7\u9706\u7fa4\u95ee\u9898\u201d\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7 \u5e8f\u5217\u5316 accept&#xff08;&#xff09; \u8c03\u7528&#xff0c;\u8fd9\u6837\u53ea\u6709\u4e00\u4e2a Pgpool-II \u8fdb\u7a0b\u88ab\u5524\u9192 \u5bf9\u4e8e\u4f20\u5165\u8fde\u63a5&#xff0c;\u8981\u6267\u884c accept&#xff08;&#xff09; \u3002<\/p>\n<p>\u4f46\u662f\u5e8f\u5217\u5316\u6709\u5176\u81ea\u8eab\u7684\u5f00\u9500&#xff0c;\u5efa\u8bae\u4f7f\u7528 \u4ec5\u7528\u4e8e\u8f83\u5927\u7684 num_init_children \u503c\u3002 \u5bf9\u4e8e\u5c11\u6570num_init_children&#xff0c; serialize accept \u53ef\u80fd\u4f1a\u964d\u4f4e\u6027\u80fd&#xff0c;\u56e0\u4e3a \u5e8f\u5217\u5316\u5f00\u9500\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5efa\u8bae\u5728\u51b3\u5b9a\u662f\u5426\u4f7f\u7528 serialize_accept \u4e4b\u524d\u5148\u505a\u4e00\u4e2a\u57fa\u51c6\u6d4b\u8bd5&#xff0c;\u56e0\u4e3a\u76f8\u5173\u6027 num_init_children \u548c serialize_accept \u5728\u4e0d\u540c\u7684\u73af\u5883\u4e2d\u53ef\u80fd\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<p>\u4f8b 1-1.\u4f7f\u7528 pgbench \u51b3\u5b9a\u662f\u5426\u5e94\u4f7f\u7528 serialize_accept<\/p>\n<p>\u8981\u8fd0\u884c pgbench&#xff0c;\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u5185\u5bb9 \u547d\u4ee4\u3002<\/p>\n<p>pgbench -n -S -p 9999 -c 32 -C -S -T 300 test<\/p>\n<p>\u8fd9\u91cc&#xff0c;-C \u544a\u8bc9 pgbench \u8fde\u63a5 \u5230\u6570\u636e\u5e93\u3002-c 32 \u6307\u5b9a\u5230 Pgpool-II \u7684\u5e76\u53d1\u4f1a\u8bdd\u6570\u3002 \u60a8\u5e94\u8be5\u6839\u636e\u7cfb\u7edf\u7684\u8981\u6c42\u8fdb\u884c\u66f4\u6539\u3002 pgbench \u5b8c\u6210\u540e&#xff0c;\u68c0\u67e5 \u201c\u5305\u62ec\u5efa\u7acb\u7684\u8054\u7cfb\u201d\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u542f\u7528 child_life_time \u540e&#xff0c;serialize_accept \u4e0d\u8d77\u4f5c\u7528\u3002\u5982\u679c\u9700\u8981&#xff0c;\u8bf7\u786e\u4fdd\u5c06 child_life_time \u8bbe\u7f6e\u4e3a 0 \u4ee5\u6253\u5f00 serialize_accept\u3002 \u5982\u679c\u4f60\u62c5\u5fc3 Pgpool-II \u8fdb\u7a0b\u5185\u5b58\u6cc4\u6f0f \u6216\u8005\u4efb\u4f55\u6f5c\u5728\u7684\u95ee\u9898&#xff0c;\u4f60\u53ef\u4ee5\u6539\u7528 child_max_connections\u3002 \u8fd9\u7eaf\u7cb9\u662f\u4e00\u4e2a\u5b9e\u73b0\u9650\u5236&#xff0c;\u5c06\u6765\u53ef\u80fd\u4f1a\u5220\u9664\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>child_life_time &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a Pgpool-II \u5b50\u8fdb\u7a0b\u5728\u7a7a\u95f2\u65f6\u7ec8\u6b62\u5b83\u7684\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;\u3002\u65b0\u7684\u5b50\u8fdb\u7a0b \u5f53 Pgpool-II \u7acb\u5373\u751f\u6210\u65f6 \u56e0 child_life_time \u800c\u7ec8\u6b62\u3002child_life_time \u662f\u4e00\u79cd\u9632\u6b62 Pgpool-II \u5b50\u9879\u4e2d\u7684\u5185\u5b58\u6cc4\u6f0f\u548c\u5176\u4ed6\u610f\u5916\u9519\u8bef\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; child_life_time \u4e0d\u9002\u7528\u4e8e \u5c1a\u672a\u63a5\u53d7\u4efb\u4f55\u8fde\u63a5\u7684\u8fdb\u7a0b\u3002<\/p>\n<p>\u6ce8&#xff1a; \u542f\u7528 child_life_time \u540e&#xff0c;serialize_accept \u5c06\u5931\u6548\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a 300&#xff08;5 \u5206\u949f&#xff09;&#xff0c;\u5c06\u5176\u8bbe\u7f6e\u4e3a 0 \u5c06\u7981\u7528\u8be5\u529f\u80fd\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>client_idle_limit &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u5728\u5ba2\u6237\u7aef\u4fdd\u6301\u7a7a\u95f2\u72b6\u6001\u65f6\u65ad\u5f00\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09; \u81ea\u4e0a\u6b21\u67e5\u8be2\u4ee5\u6765\u3002 \u8fd9\u5bf9\u4e8e\u9632\u6b62 Pgpool-II \u7684\u5b50\u8282\u70b9\u88ab\u61d2\u60f0\u7684\u5ba2\u6237\u7aef\u6216\u635f\u574f\u7684 TCP\/IP \u5360\u7528\u5f88\u6709\u7528 \u5ba2\u6237\u7aef\u548c Pgpool-II \u4e4b\u95f4\u7684\u8fde\u63a5\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; client_idle_limit \u5728 \u5728\u7ebf\u6062\u590d\u7684\u7b2c\u4e8c\u9636\u6bb5\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a 0&#xff0c;\u8fd9\u5c06\u5173\u95ed\u8be5\u529f\u80fd\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>child_max_connections &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a Pgpool-II \u5b50\u8fdb\u7a0b\u7684\u751f\u547d\u5468\u671f&#xff0c;\u6839\u636e\u5b83\u53ef\u4ee5\u63a5\u6536\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u6570\u3002Pgpool-II \u5c06\u7ec8\u6b62\u5b50\u8fdb\u7a0b \u5728\u670d\u52a1child_max_connections\u5ba2\u6237\u7aef\u4e4b\u540e connections&#xff0c;\u5e76\u7acb\u5373\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u5b50\u8fdb\u7a0b\u6765\u53d6\u4ee3\u5b83\u3002<\/p>\n<p>child_max_connections \u5728\u975e\u5e38\u7e41\u5fd9\u7684\u670d\u52a1\u5668\u4e0a\u5f88\u6709\u7528&#xff0c; \u5176\u4e2d child_life_time \u548c connection_life_time \u6c38\u8fdc\u4e0d\u4f1a\u89e6\u53d1\u3002\u9632\u6b62 PostgreSQL \u670d\u52a1\u5668\u83b7\u53d6 \u592a\u5927\u4e86\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a 0&#xff0c;\u8fd9\u5c06\u5173\u95ed\u8be5\u529f\u80fd\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>connection_life_time &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u7ec8\u6b62\u7f13\u5b58\u8fde\u63a5\u7684\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09; \u6dfb\u52a0\u5230 PostgreSQL \u540e\u7aef\u3002\u6b64\u65f6\u95f4\u7528\u4f5c\u7f13\u5b58\u8fde\u63a5\u8fc7\u671f\u65f6\u95f4\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a 0&#xff0c;\u8fd9\u610f\u5473\u7740\u4e0d\u4f1a\u65ad\u5f00\u7f13\u5b58\u7684\u8fde\u63a5\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>reset_query_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u53d1\u9001\u7684 SQL \u547d\u4ee4&#xff0c;\u7528\u4e8e\u91cd\u7f6e\u540e\u7aef\u8fde\u63a5 \u9000\u51fa\u7528\u6237\u4f1a\u8bdd\u65f6\u3002\u53ef\u4ee5\u901a\u8fc7\u5206\u9694\u6bcf\u4e2a\u547d\u4ee4\u6765\u6307\u5b9a\u591a\u4e2a\u547d\u4ee4 \u901a\u8fc7 \u201c;\u201d\u3002<\/p>\n<p>\u53ef\u7528\u7684\u547d\u4ee4\u56e0 PostgreSQL \u7248\u672c\u800c\u5f02\u3002 \u4ee5\u4e0b\u662f\u5728\u4e0d\u540c PostgreSQL \u7248\u672c\u4e0areset_query_list\u7684\u4e00\u4e9b\u63a8\u8350\u8bbe\u7f6e\u3002 \u4f46\u662f\u8bf7\u6ce8\u610f&#xff0c;\u5e94\u59cb\u7ec8\u5305\u542b ABORT \u547d\u4ee4\u3002<\/p>\n<p>\u8868 1-5.\u5728\u4e0d\u540c PostgreSQL \u7248\u672c\u4e0areset_query_list\u7684\u63a8\u8350\u8bbe\u7f6e<\/p>\n<table>\n<tr>PostgreSQL versionreset_query_list<\/tr>\n<tbody>\n<tr>\n<td>7.1 or earlier<\/td>\n<td>\u2018ABORT\u2019<\/td>\n<\/tr>\n<tr>\n<td>7.2 to 8.2<\/td>\n<td>\u2018ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT\u2019<\/td>\n<\/tr>\n<tr>\n<td>8.3 or later<\/td>\n<td>\u2018ABORT; DISCARD ALL\u2019<\/td>\n<\/tr>\n<tr>\n<td>\u6ce8\u610f&#xff1a;\u5f53\u4e0d\u5728 7.4 \u6216\u66f4\u9ad8\u7248\u672c\u7684 PostgreSQL \u7248\u672c\u7684\u4e8b\u52a1\u5757\u4e2d\u65f6&#xff0c;\u4e0d\u4f1a\u53d1\u51fa \u201cABORT\u201d\u3002<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9ed8\u8ba4\u503c\u4e3a &#039;ABORT;\u5168\u90e8\u4e22\u5f03\u201d\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<h3>1.7. \u9519\u8bef\u62a5\u544a\u548c\u65e5\u5fd7\u8bb0\u5f55<\/h3>\n<h4>1.7.1. \u8bb0\u5f55\u4f4d\u7f6e<\/h4>\n<p>log_destination &#xff08;\u5b57\u7b26\u4e32&#xff09;) Pgpool-II \u652f\u6301\u4e24\u4e2a\u76ee\u7684\u5730 \u7528\u4e8e\u8bb0\u5f55 Pgpool-II \u6d88\u606f\u3002 \u652f\u6301\u7684\u65e5\u5fd7\u76ee\u6807\u662f stderr \u548c syslog\u3002\u60a8\u4e5f\u53ef\u4ee5\u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a\u5217\u8868 \u7684\u6240\u9700\u65e5\u5fd7\u76ee\u6807&#xff0c;\u5982\u679c\u9700\u8981\u65e5\u5fd7\u6d88\u606f&#xff0c;\u8bf7\u7528\u9017\u53f7\u5206\u9694 \u5728\u591a\u4e2a\u76ee\u7684\u5730\u4e0a\u3002<\/p>\n<p>   #for example to log on both syslog and stderr<br \/>\n   log_destination &#061; &#039;syslog,stderr&#039;<\/p>\n<p>\u9ed8\u8ba4\u662f\u4ec5\u8bb0\u5f55\u5230 stderr \u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5728\u67d0\u4e9b\u7cfb\u7edf\u4e0a&#xff0c;\u60a8\u9700\u8981\u66f4\u6539 \u7cfb\u7edf\u7684 syslog \u5b88\u62a4\u8fdb\u7a0b&#xff0c;\u4ee5\u4fbf\u4f7f\u7528 syslog \u9009\u9879 \u4e3a\u4e86log_destination\u3002Pgpool-II \u53ef\u4ee5\u8bb0\u5f55\u5230 syslog \u8bbe\u65bd LOCAL0 \u5230 LOCAL7 &#xff08;\u8bf7\u53c2\u9605syslog_facility&#xff09;&#xff0c;\u4f46\u5927\u591a\u6570\u5e73\u53f0\u4e0a\u7684\u9ed8\u8ba4 syslog \u914d\u7f6e\u5c06\u4e22\u5f03\u6240\u6709\u6b64\u7c7b\u6d88\u606f\u3002 \u60a8\u9700\u8981\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p> local0.*    \/var\/log\/pgpool.log<\/p>\n<p>\u5230 syslog \u5b88\u62a4\u7a0b\u5e8f\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d&#xff0c;\u4f7f\u5176\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>logging_collector &#xff08;\u5e03\u5c14\u503c&#xff09;) \u6b64\u53c2\u6570\u542f\u7528\u65e5\u5fd7\u8bb0\u5f55\u6536\u96c6\u5668&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b&#xff0c;\u7528\u4e8e\u6355\u83b7 \u8bb0\u5f55\u53d1\u9001\u5230 stderr \u7684\u6d88\u606f&#xff0c;\u5e76\u5c06\u5176\u91cd\u5b9a\u5411\u5230\u65e5\u5fd7\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u53ef\u4ee5\u5728\u4e0d\u4f7f\u7528\u65e5\u5fd7\u8bb0\u5f55\u6536\u96c6\u5668\u7684\u60c5\u51b5\u4e0b\u8bb0\u5f55\u5230 stderr;\u65e5\u5fd7\u6d88\u606f\u5c06 \u53ea\u9700\u8f6c\u5230\u670d\u52a1\u5668\u7684 stderr \u6307\u5411\u7684\u4efb\u4f55\u4f4d\u7f6e\u5373\u53ef\u3002\u4f46\u662f&#xff0c;\u8be5\u65b9\u6cd5\u4ec5\u9002\u7528\u4e8e \u5bf9\u4e8e\u4f4e\u65e5\u5fd7\u91cf&#xff0c;\u56e0\u4e3a\u5b83\u6ca1\u6709\u63d0\u4f9b\u8f6e\u6362\u65e5\u5fd7\u6587\u4ef6\u7684\u4fbf\u6377\u65b9\u6cd5\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ea\u80fd\u5728 Pgpool-II \u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>logging_collector \u5728 Pgpool-II V4.2 \u4e4b\u524d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>log_directory &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u542f\u7528 logging_collector \u540e&#xff0c;\u6b64\u53c2\u6570\u5c06\u786e\u5b9a \u5c06\u5728\u5176\u4e2d\u521b\u5efa\u65e5\u5fd7\u6587\u4ef6\u7684\u76ee\u5f55\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a \/tmp\/pgpool_logs\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ea\u80fd\u5728 Pgpool-II \u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>log_filename &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u542f\u7528 logging_collector \u540e&#xff0c;\u6b64\u53c2\u6570\u4f1a\u8bbe\u7f6e \u521b\u5efa\u7684\u65e5\u5fd7\u6587\u4ef6\u7684\u6587\u4ef6\u540d\u3002\u8be5\u503c\u88ab\u89c6\u4e3a strftime \u6a21\u5f0f&#xff0c;\u56e0\u6b64 %-escapes \u53ef\u7528\u4e8e\u6307\u5b9a\u65f6\u53d8 \u6587\u4ef6\u540d\u3002 \u652f\u6301\u7684 %-escapes \u7c7b\u4f3c\u4e8e Open Group \u7684 strftime\u89c4\u8303\u4e2d\u5217\u51fa\u7684 %-escapes\u3002<\/p>\n<p>\u5982\u679c\u6307\u5b9a\u4e0d\u5e26\u8f6c\u4e49\u7b26\u7684\u6587\u4ef6\u540d&#xff0c;\u5219\u5e94\u8ba1\u5212\u4f7f\u7528\u65e5\u5fd7\u8f6e\u6362 \u5b9e\u7528\u7a0b\u5e8f&#xff0c;\u4ee5\u907f\u514d\u6700\u7ec8\u586b\u6ee1\u6574\u4e2a\u78c1\u76d8\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a pgpool-%Y-%m-%d_%H%M%S.log\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ea\u80fd\u5728 Pgpool-II \u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>log_file_mode &#xff08;\u6574\u6570&#xff09;) \u6b64\u53c2\u6570\u8bbe\u7f6e\u542f\u7528 logging_collector \u65f6\u65e5\u5fd7\u6587\u4ef6\u7684\u6743\u9650\u3002\u53c2\u6570\u503c\u5e94\u4e3a\u4ee5 \u63a5\u53d7 chmod \u548c umask \u7cfb\u7edf\u8c03\u7528\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u8981\u4f7f\u7528\u60ef\u7528\u7684\u516b\u8fdb\u5236\u683c\u5f0f&#xff0c;\u6570\u5b57\u5fc5\u987b\u4ee5 0&#xff08;\u96f6&#xff09;\u5f00\u5934\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ea\u80fd\u5728 Pgpool-II \u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>log_rotation_age &#xff08;\u6574\u6570&#xff09;) \u542f\u7528 logging_collector \u540e&#xff0c;\u6b64\u53c2\u6570\u5c06\u786e\u5b9a \u4f7f\u7528\u5355\u4e2a\u65e5\u5fd7\u6587\u4ef6\u7684\u6700\u957f\u65f6\u95f4&#xff0c;\u4e4b\u540e\u4f1a\u51fa\u73b0\u65b0\u65e5\u5fd7 \u6587\u4ef6\u3002\u5982\u679c\u6307\u5b9a\u6b64\u503c\u65f6\u6ca1\u6709\u5355\u4f4d&#xff0c;\u5219 \u5b83\u4ee5\u5206\u949f\u4e3a\u5355\u4f4d\u3002\u9ed8\u8ba4\u503c\u4e3a 24 \u5c0f\u65f6\u3002<\/p>\n<p>\u8bbe\u7f6e\u4e3a 0 \u53ef\u7981\u7528\u57fa\u4e8e\u65f6\u95f4\u521b\u5efa\u65b0\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ea\u80fd\u5728 Pgpool-II \u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>log_rotation_size &#xff08;\u6574\u6570) \u542f\u7528 logging_collector \u540e&#xff0c;\u6b64\u53c2\u6570\u5c06\u786e\u5b9a \u5355\u4e2a\u65e5\u5fd7\u6587\u4ef6\u7684\u6700\u5927\u5927\u5c0f\u3002\u5728\u8fd9\u4e48\u591a KB \u4e4b\u540e \u53d1\u51fa\u5230\u65e5\u5fd7\u6587\u4ef6\u4e2d&#xff0c;\u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<p>\u8bbe\u7f6e\u4e3a 0 \u53ef\u7981\u7528\u57fa\u4e8e\u5927\u5c0f\u521b\u5efa\u65b0\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ea\u80fd\u5728 Pgpool-II \u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>log_truncate_on_rotation &#xff08;\u5e03\u5c14\u503c&#xff09;) \u542f\u7528 logging_collector \u540e&#xff0c; \u8fd9\u4e2a\u53c2\u6570\u4f1a\u5bfc\u81f4 Pgpool-II \u622a\u65ad&#xff08;\u8986\u76d6&#xff09;&#xff0c; \u800c\u4e0d\u662f\u9644\u52a0\u5230\u4efb\u4f55\u540c\u540d\u7684\u73b0\u6709\u65e5\u5fd7\u6587\u4ef6\u3002 \u4f46\u662f&#xff0c;\u4ec5\u5f53\u6253\u5f00\u65b0\u6587\u4ef6\u65f6\u624d\u4f1a\u53d1\u751f\u622a\u65ad&#xff0c;\u56e0\u4e3a \u57fa\u4e8e\u65f6\u95f4\u7684\u8f6e\u6362&#xff0c;\u800c\u4e0d\u662f\u5728 startup \u6216\u57fa\u4e8e\u5927\u5c0f\u7684\u8f6e\u6362\u671f\u95f4\u3002 \u5173\u95ed\u65f6&#xff0c;\u5728\u6240\u6709\u60c5\u51b5\u4e0b\u90fd\u5c06\u9644\u52a0\u9884\u5148\u5b58\u5728\u7684\u6587\u4ef6\u3002 \u4f8b\u5982&#xff0c;\u5c06\u6b64\u8bbe\u7f6e\u4e0epgpool-%H.log\u7b49log_filename\u7ed3\u5408\u4f7f\u7528\u5c06\u5bfc\u81f4\u751f\u6210 24 \u5c0f\u65f6\u65e5\u5fd7 \u6587\u4ef6&#xff0c;\u7136\u540e\u5faa\u73af\u8986\u76d6\u5b83\u4eec\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ea\u80fd\u5728 Pgpool-II \u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>syslog_facility &#xff08;\u679a\u4e3e&#xff09;) \u53e6\u8bf7\u53c2\u9605\u7cfb\u7edf\u7684 syslog \u5b88\u62a4\u7a0b\u5e8f\u7684\u6587\u6863\u3002 \u542f\u7528\u65e5\u5fd7\u8bb0\u5f55\u5230 syslog \u540e&#xff0c; \u6b64\u53c2\u6570\u786e\u5b9a\u8981\u4f7f\u7528\u7684 syslog \u201cfacility\u201d\u3002 \u60a8\u53ef\u4ee5\u9009\u62e9 LOCAL0\u3001LOCAL1\u3001LOCAL2\u3001LOCAL3\u3001LOCAL4\u3001LOCAL5\u3001LOCAL6\u3001LOCAL7; \u9ed8\u8ba4\u503c\u4e3a LOCAL0\u3002 \u53e6\u8bf7\u53c2\u9605\u7cfb\u7edf\u7684 syslog \u5b88\u62a4\u7a0b\u5e8f\u7684\u6587\u6863\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>syslog_ident &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u542f\u7528\u65e5\u5fd7\u8bb0\u5f55\u5230 syslog \u540e&#xff0c;\u6b64\u53c2\u6570\u5c06\u786e\u5b9a \u7528\u4e8e\u8bc6\u522b syslog \u65e5\u5fd7\u4e2d Pgpool-II \u6d88\u606f\u7684\u7a0b\u5e8f\u540d\u79f0\u3002\u9ed8\u8ba4\u4e3a pgpool\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>1.7.2. \u4f55\u65f6\u8bb0\u5f55 client_min_messages &#xff08;enum) \u63a7\u5236\u53d1\u9001\u5230\u5ba2\u6237\u7aef\u7684\u6700\u5c0f\u6d88\u606f\u7ea7\u522b\u3002 \u6709\u6548\u503c\u4e3a DEBUG5\u3001DEBUG4\u3001DEBUG3\u3001DEBUG2\u3001DEBUG1\u3001LOG\u3001NOTICE\u3001WARNING \u548c ERROR\u3002\u6bcf\u4e2a\u7ea7\u522b\u5305\u62ec \u5b83\u4e4b\u540e\u7684\u6240\u6709\u7ea7\u522b\u3002\u9ed8\u8ba4\u503c\u4e3a NOTICE\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>log_min_messages &#xff08;\u679a\u4e3e&#xff09;) \u9ed8\u8ba4\u503c\u4e3a WARNING\u3002 \u63a7\u5236\u5411 log \u53d1\u51fa\u7684\u6700\u5c0f\u6d88\u606f\u7ea7\u522b\u3002 \u6709\u6548\u503c\u4e3a DEBUG5\u3001DEBUG4\u3001DEBUG3\u3001DEBUG2\u3001DEBUG1\u3001INFO\u3001NOTICE\u3001WARNING\u3001ERROR\u3001LOG\u3001FATAL\u548c \u548c PANIC\u3002 \u6bcf\u4e2a\u7ea7\u522b\u90fd\u5305\u542b\u5176\u540e\u7684\u6240\u6709\u7ea7\u522b\u3002 \u9ed8\u8ba4\u503c\u4e3a WARNING\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>5.7.3. \u8bb0\u5f55\u4ec0\u4e48 log_statement &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on&#xff0c;\u5c06\u6240\u6709 SQL \u8bed\u53e5\u6253\u5370\u5230\u65e5\u5fd7\u4e2d\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>log_per_node_statement &#xff08;\u5e03\u5c14\u503c&#xff09;) \u4e0e log_statement \u7c7b\u4f3c&#xff0c;\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u5b83\u4f1a\u6253\u5370 logs \u7684\u65e5\u5fd7\u3002\u786e\u4fdd \u590d\u5236\u6216\u8d1f\u8f7d\u5e73\u8861\u6b63\u5728\u8fd0\u884c\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>notice_per_node_statement &#xff08;\u5e03\u5c14\u503c&#xff09;) \u4e0e log_per_node_statement \u7c7b\u4f3c&#xff0c;\u4f46 \u5b83\u5c06\u6bcf\u4e2a\u6570\u636e\u5e93\u8282\u70b9\u7684\u8bed\u53e5\u65e5\u5fd7\u5206\u522b\u6253\u5370\u4e3a \u4e00\u6761 NOTICE \u6d88\u606f\u3002\u4f7f\u7528 default client_min_messages \u8bbe\u7f6e&#xff08;\u5373 \u662f NOTICE&#xff09;&#xff0c;\u65e5\u5fd7\u6d88\u606f\u5c06\u6253\u5370\u5728\u5ba2\u6237\u7aef\u7684\u7ec8\u7aef\u4e0a \u4e5f\u3002\u8fd9\u5bf9\u5ba2\u6237\u6765\u8bf4\u5f88\u65b9\u4fbf&#xff0c;\u56e0\u4e3a\u5b83\u4e0d\u9700\u8981 \u8bbf\u95ee Pgpool-II \u65e5\u5fd7\u6587\u4ef6\u3002\u6ce8\u610f \u90a3 \u4e0e log_per_node_statement \u4e0d\u540c&#xff0c;notice_per_node_statement \u4e0d\u6253\u5370\u5185\u90e8\u67e5\u8be2&#xff08;\u4f8b\u5982&#xff0c;\u7cfb\u7edf\u76ee\u5f55\u67e5\u8be2&#xff09;\u3002 \u8fd9\u662f\u56e0\u4e3a\u6b64\u529f\u80fd\u65e8\u5728\u7528\u4e8e\u6d4b\u8bd5 \u4e5f\u3002\u7531\u4e8e\u5185\u90e8\u67e5\u8be2\u5f80\u5f80\u662f\u4e0d\u786e\u5b9a\u7684&#xff0c;\u56e0\u6b64 \u5728\u6d4b\u8bd5\u4e2d\u6253\u5370\u5b83\u4eec\u6ca1\u6709\u5e2e\u52a9\u3002\u51fa\u4e8e\u540c\u6837\u7684\u539f\u56e0&#xff0c; \u4e0d\u6253\u5370\u540e\u7aef\u8fdb\u7a0b ID\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>log_client_messages &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on&#xff0c;\u5c06\u5ba2\u6237\u7aef\u6d88\u606f\u6253\u5370\u5230\u65e5\u5fd7\u4e2d\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>log_hostname &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on&#xff0c;\u5219\u6253\u5370\u4e3b\u673a\u540d\u800c\u4e0d\u662f IP \u5730\u5740 \u5728 ps \u547d\u4ee4\u7ed3\u679c\u548c\u8fde\u63a5\u65e5\u5fd7\u4e2d &#xff08;\u5f53 log_connections \u5904\u4e8e\u6253\u5f00\u72b6\u6001\u65f6&#xff09;\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>log_connections &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on&#xff0c;\u5219\u6253\u5370\u4ece\u65e5\u5fd7\u5230\u65e5\u5fd7\u7684\u6240\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>log_disconnections &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on&#xff0c;\u5219\u5c06\u6240\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u7ec8\u6b62\u6253\u5370\u5230\u65e5\u5fd7\u4e2d\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>log_pcp_processes &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on&#xff0c;\u542f\u7528\u6709\u5173\u6b63\u5e38 PCP \u8fdb\u7a0b\u7684\u65e5\u5fd7\u8bb0\u5f55 fork \u548c exit \u72b6\u6001\u3002\u9ed8\u8ba4\u503c\u4e3a on\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>log_error_verbosity &#xff08;enum) \u63a7\u5236\u4e3a\u8bb0\u5f55\u7684\u6bcf\u6761\u6d88\u606f\u53d1\u51fa\u7684\u8be6\u7ec6\u4fe1\u606f\u91cf\u3002 \u6709\u6548\u503c\u4e3a TERSE\u3001DEFAULT \u548c VERBOSE\u3002 \u6bcf\u4e2a\u6dfb\u52a0\u66f4\u591a\u5b57\u6bb5 \u6dfb\u52a0\u5230\u663e\u793a\u7684\u6d88\u606f\u4e2d\u3002TERSE \u4e0d\u5305\u62ec DETAIL\u3001HINT\u3001QUERY \u548c CONTEXT \u9519\u8bef\u4fe1\u606f\u7684\u65e5\u5fd7\u8bb0\u5f55\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>log_line_prefix &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u8fd9\u662f\u4e00\u4e2a -style \u5b57\u7b26\u4e32&#xff0c;\u5728 \u6bcf\u4e2a\u5bf9\u6570\u884c\u3002% \u5b57\u7b26\u5f00\u59cb\u88ab\u66ff\u6362\u7684 \u201c\u8f6c\u4e49\u5e8f\u5217\u201d \u4fe1\u606f\u6982\u8ff0\u5982\u4e0b\u3002 \u6240\u6709\u65e0\u6cd5\u8bc6\u522b\u7684\u8f6c\u4e49\u90fd\u5c06\u88ab\u5ffd\u7565\u3002\u5176\u4ed6\u5b57\u7b26\u5c06\u76f4\u63a5\u590d\u5236\u5230 Log \u884c\u3002\u9ed8\u8ba4\u503c\u4e3a &#039;%m&#xff1a; %a pid %p&#xff1a; &#039;&#xff0c;\u5b83\u6253\u5370\u65f6\u95f4\u6233\u3001\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u548c\u8fdb\u7a0b ID\u3002printf<\/p>\n<p>\u8868 1-6.log_line_prefix \u8f6c\u4e49\u9009\u9879<\/p>\n<table>\n<tr>EscapeEffect<\/tr>\n<tbody>\n<tr>\n<td>%a<\/td>\n<td>Application name. The initial value for child (session process) is \u201cchild\u201d. If Clients set application name (either in the startup message or by using SET command), application name will be changed accordingly. In other types of process, application name is a hard coded string.<\/td>\n<\/tr>\n<tr>\n<td>%p<\/td>\n<td>Process ID (PID)<\/td>\n<\/tr>\n<tr>\n<td>%P<\/td>\n<td>Process name<\/td>\n<\/tr>\n<tr>\n<td>%t<\/td>\n<td>Time stamp without milliseconds<\/td>\n<\/tr>\n<tr>\n<td>%m<\/td>\n<td>Time stamp with milliseconds<\/td>\n<\/tr>\n<tr>\n<td>%d<\/td>\n<td>Database name<\/td>\n<\/tr>\n<tr>\n<td>%u<\/td>\n<td>User name<\/td>\n<\/tr>\n<tr>\n<td>%l<\/td>\n<td>Log line number for each process<\/td>\n<\/tr>\n<tr>\n<td>%%<\/td>\n<td>\u2018%\u2019 character<\/td>\n<\/tr>\n<tr>\n<td>\u8868 1-7.\u5404\u79cd\u8fdb\u7a0b\u4e2d\u7684\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<tr>Process typeapplication name<\/tr>\n<tbody>\n<tr>\n<td>main<\/td>\n<td>main<\/td>\n<\/tr>\n<tr>\n<td>child<\/td>\n<td>child<\/td>\n<\/tr>\n<tr>\n<td>streaming replication delay check worker<\/td>\n<td>sr_check_worker<\/td>\n<\/tr>\n<tr>\n<td>watchdog heart beat sender<\/td>\n<td>heart_beat_sender<\/td>\n<\/tr>\n<tr>\n<td>watchdog heart beat receiver<\/td>\n<td>heart_beat_receiver<\/td>\n<\/tr>\n<tr>\n<td>watchdog<\/td>\n<td>watchdog<\/td>\n<\/tr>\n<tr>\n<td>watchdog life check<\/td>\n<td>life_check<\/td>\n<\/tr>\n<tr>\n<td>follow primary child<\/td>\n<td>follow_child<\/td>\n<\/tr>\n<tr>\n<td>watchdog utility<\/td>\n<td>watchdog_utility<\/td>\n<\/tr>\n<tr>\n<td>pcp main<\/td>\n<td>pcp_main<\/td>\n<\/tr>\n<tr>\n<td>pcp child<\/td>\n<td>pcp_child<\/td>\n<\/tr>\n<tr>\n<td>health check process<\/td>\n<td>health_check%d (%d is replaced with backend node id)<\/td>\n<\/tr>\n<tr>\n<td>logger process<\/td>\n<td>logger (Note that the application name \u201clogger\u201d will not be output to the log file managed by logger process)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<h3>1.8. \u8d1f\u8f7d\u5747\u8861<\/h3>\n<p>SELECT \u67e5\u8be2\u7684 Pgpool-II \u8d1f\u8f7d\u5747\u8861 \u9002\u7528\u4e8e\u9664 Raw \u6a21\u5f0f\u4e4b\u5916\u7684\u4efb\u4f55\u7fa4\u96c6\u6a21\u5f0f\u3002\u5f53\u542f\u7528\u65f6&#xff0c;Pgpool-II \u5c06\u5199\u5165\u67e5\u8be2\u53d1\u9001\u5230\u672c\u5730\u590d\u5236\u6a21\u5f0f\u4e0b\u7684\u4e3b\u8282\u70b9&#xff0c;\u6240\u6709 Replication \u6a21\u5f0f\u4e0b\u7684\u540e\u7aef\u8282\u70b9&#xff0c;\u5176\u4ed6\u67e5\u8be2\u4f1a\u83b7\u5f97 load \u5728\u6240\u6709\u540e\u7aef\u8282\u70b9\u4e4b\u95f4\u4fdd\u6301\u5e73\u8861\u3002\u8d1f\u8f7d\u5230\u54ea\u4e2a\u8282\u70b9 \u5e73\u8861\u673a\u5236\u53d1\u9001\u8bfb\u53d6\u67e5\u8be2\u662f\u5728\u4f1a\u8bdd\u4e2d\u51b3\u5b9a\u7684 Start time \u7684 a \u503c&#xff0c;\u9664\u975e\u6307\u5b9a\u4e86 statement_level_load_balance&#xff0c;\u5426\u5219\u5728\u4f1a\u8bdd\u7ed3\u675f\u4e4b\u524d\u4e0d\u4f1a\u66f4\u6539\u3002\u7136\u800c \u4f46\u4e5f\u6709\u4e00\u4e9b\u4f8b\u5916\u3002\u6709\u5173\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u9605\u4e0b\u6587\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u53d1\u9001\u5230\u4e3b\u8282\u70b9\u6216\u7531\u4e8e\u65e0\u6cd5\u5e73\u8861\u800c\u590d\u5236\u7684\u67e5\u8be2\u662f \u4e5f\u8003\u8651\u5728\u8d1f\u8f7d\u5e73\u8861\u7b97\u6cd5\u4e2d\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u60a8\u53ef\u4ee5\u68c0\u67e5\u54ea\u4e2a\u6570\u636e\u5e93\u8282\u70b9\u88ab\u5206\u914d\u4e3a\u8d1f\u8f7d\u5747\u8861 node \u7684 SET POOL NODES \u8fdb\u884c\u5206\u914d\u3002<\/p>\n<h4>1.8.1. \u8d1f\u8f7d\u5747\u8861\u7684\u6761\u4ef6<\/h4>\n<p>\u5bf9\u4e8e\u8981\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u7684\u67e5\u8be2&#xff0c;\u4ee5\u4e0b\u6240\u6709\u8981\u6c42 \u5fc5\u987b\u6ee1\u8db3&#xff1a;<\/p>\n<p>PostgreSQL \u7248\u672c 7.4 \u6216\u66f4\u9ad8\u7248\u672c<\/p>\n<p>\u4e5f \u5728\u6d41\u5f0f\u590d\u5236\u6a21\u5f0f\u3001\u672c\u673a\u590d\u5236\u6a21\u5f0f\u6216\u5feb\u7167\u9694\u79bb\u6a21\u5f0f\u4e0b<\/p>\n<p>\u67e5\u8be2\u4e0d\u5f97\u4f4d\u4e8e\u663e\u5f0f\u58f0\u660e\u7684\u4e8b\u52a1\u4e2d &#xff08;\u5373\u4e0d\u5728 BEGIN ~ END \u5757\u4e2d&#xff09;<\/p>\n<p>\u4f46\u662f&#xff0c;\u5982\u679c\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6&#xff0c;\u5219\u53ef\u4ee5\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861 \u5373\u4f7f\u5728\u663e\u5f0f\u4e8b\u52a1\u4e2d<\/p>\n<p>\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u4e0d\u662f SERIALIZABLE<\/p>\n<p>\u4e8b\u52a1\u5c1a\u672a\u53d1\u51fa\u5199\u5165\u67e5\u8be2&#xff08;\u76f4\u5230\u5199\u5165 query \u7684 intent \u8bf7\u6c42&#xff0c;\u5219\u53ef\u4ee5\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002\u8fd9\u91cc \u201cwrite query\u201d \u8868\u793a\u975e SELECT DML \u6216 DDL\u3002\u5728 Pgpool-II 4.1 \u4e4b\u524d&#xff0c; \u5177\u6709 write \u6216 read_only\u51fd\u6570\u5217\u8868\u4e0d\u88ab\u89c6\u4e3a\u5199\u5165\u67e5\u8be2\u3002<\/p>\n<p>\u5982\u679c write \u4e14 read_only function list \u4e3a\u7a7a&#xff0c;\u5219 SELECT \u5177\u6709 \u975e volatile \u7684\u51fd\u6570\u88ab\u89c6\u4e3a\u53ea\u8bfb\u67e5\u8be2\u3002<\/p>\n<p>\u5b83\u4e0d\u662f SELECT INTO<\/p>\n<p>\u5b83\u4e0d\u662f SELECT FOR UPDATE \u4e5f\u4e0d\u662f FOR SHARE<\/p>\n<p>\u5b83\u4ee5 \u201cSELECT\u201d \u6216 COPY TO STDOUT\u3001EXPLAIN\u3001 \u89e3\u91ca \u5206\u6790 \u9009\u62e9\u2026ignore_leading_white_space &#061; true \u5c06\u5ffd\u7565\u524d\u5bfc\u7a7a\u683c\u3002 &#xff08;\u4f7f\u7528 write_function_list \u6216 read_only_function_list \u4e2d\u6307\u5b9a\u7684\u5199\u5165\u51fd\u6570\u7684 SELECT \u9664\u5916)<\/p>\n<p>\u5728\u6d41\u590d\u5236\u6a21\u5f0f\u4e0b&#xff0c;\u9664\u4e0a\u8ff0\u6761\u4ef6\u5916&#xff0c;\u8fd8\u5fc5\u987b\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6&#xff1a;<\/p>\n<p>\u4e0d\u4f7f\u7528\u4e34\u65f6\u8868&#xff08;\u4e0d\u590d\u5236\u4e34\u65f6\u8868&#xff09;<\/p>\n<p>\u4e0d\u4f7f\u7528 unlogged \u8868&#xff08;\u4e0d\u590d\u5236 unlogged \u8868&#xff09;<\/p>\n<p>\u4e0d\u4f7f\u7528\u7cfb\u7edf\u76ee\u5f55&#xff08;\u7cfb\u7edf\u76ee\u5f55\u4fe1\u606f\u4e3a important \u4e14\u6700\u597d\u907f\u514d\u590d\u5236\u5ef6\u8fdf&#xff09;<\/p>\n<p>\u6ce8\u610f&#xff1a; \u60a8\u53ef\u4ee5\u901a\u8fc7\u63d2\u5165\u4efb\u610f comments \u7684 SELECT \u67e5\u8be2&#xff1a;<\/p>\n<p>\/REPLICATION\/ SELECT \u2026<\/p>\n<p>\u5982\u679c\u8981\u5728\u4e0d\u6291\u5236\u8d1f\u8f7d\u5747\u8861\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u6ce8\u91ca&#xff0c;\u53ef\u4ee5\u5c06 allow_sql_comments \u8bbe\u7f6e\u4e3a on\u3002 \u53e6\u8bf7\u53c2\u9605replicate_select\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; JDBC \u9a71\u52a8\u7a0b\u5e8f\u5177\u6709 autocommit \u9009\u9879\u3002\u5982\u679c autocommit \u4e3a false&#xff0c;\u5219 JDBC \u9a71\u52a8\u7a0b\u5e8f\u81ea\u884c\u53d1\u9001 \u201cBEGIN\u201d \u548c \u201cCOMMIT\u201d\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b \u5c06\u5e94\u7528\u4e0a\u8ff0\u6709\u5173\u8d1f\u8f7d\u5747\u8861\u7684\u76f8\u540c\u9650\u5236\u3002<\/p>\n<h4>1.8.2. \u7f16\u5199\u67e5\u8be2\u53ef\u80fd\u4f1a\u5f71\u54cd\u8d1f\u8f7d\u5747\u8861<\/h4>\n<p>\u901a\u5e38&#xff0c;\u5982\u679c\u6ee1\u8db3\u67d0\u4e9b\u6761\u4ef6&#xff0c;\u5219\u8bfb\u53d6\u67e5\u8be2\u4f1a\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861 \u90fd\u6ee1\u8db3\u4e86\u3002\u4f46\u662f&#xff0c;\u7f16\u5199\u67e5\u8be2\u53ef\u80fd\u4f1a\u5f71\u54cd\u8d1f\u8f7d \u5e73\u8861\u3002\u8fd9\u91cc\u7684 \u201cwriting queries\u201d \u662f\u6307\u9664 \u4e0b\u9762&#xff1a;<\/p>\n<p>SELECT\/WITH&#xff0c;\u800c\u65e0\u9700\u7f16\u5199\u51fd\u6570\u3002 volatile \u51fd\u6570\u88ab\u89c6\u4e3a\u5199\u5165\u51fd\u6570\u3002 \u60a8\u53ef\u4ee5\u4f7f\u7528 write_function_list \u6216 read_only_function_list \u5b9a\u4e49\u81ea\u5df1\u7684\u7f16\u5199\u51fd\u6570\u3002<\/p>\n<p>SELECT\/WITH \u4e0d\u5e26 FOR UPDATE\/SHARE<\/p>\n<p>\u4e0d\u5e26 DML \u8bed\u53e5\u7684 WITH<\/p>\n<p>\u590d\u5236\u5230 STDOUT<\/p>\n<p>\u89e3\u91ca<\/p>\n<p>EXPLAIN ANALYZE \u4e14\u67e5\u8be2\u4e3a SELECT \u4e0d\u5305\u62ec\u5199\u5165\u51fd\u6570<\/p>\n<p>\u663e\u793a<\/p>\n<p>\u5982\u679c\u51fa\u73b0\u5199\u5165\u67e5\u8be2&#xff0c;\u5219\u540e\u7eed\u8bfb\u53d6\u67e5\u8be2\u53ef\u80fd\u4e0d\u662f \u8d1f\u8f7d\u5747\u8861\u3002\u5373\u53d1\u9001\u5230\u4e3b\u8282\u70b9&#xff08;\u5728 streaming \u4e2d replication \u6a21\u5f0f&#xff09;\u6216\u4e3b\u8282\u70b9&#xff08;\u5728\u5176\u4ed6\u6a21\u5f0f\u4e0b&#xff09;&#xff0c;\u5177\u4f53\u53d6\u51b3\u4e8e disable_load_balance_on_write\u7684\u8bbe\u7f6e\u3002<\/p>\n<h4>1.8.3. \u6d41\u5f0f\u590d\u5236\u4e2d\u7684\u8d1f\u8f7d\u5747\u8861<\/h4>\n<p>\u4f7f\u7528\u6d41\u590d\u5236\u548c\u70ed\u5907\u7528\u65f6&#xff0c;\u8bf7\u52a1\u5fc5 \u786e\u5b9a\u54ea\u4e2a\u67e5\u8be2\u53ef\u4ee5\u53d1\u9001\u5230\u4e3b\u6570\u636e\u5e93\u6216\u5907\u7528\u6570\u636e\u5e93&#xff0c; \u4ee5\u53ca\u54ea\u4e00\u4e2a\u4e0d\u5e94\u8be5\u88ab\u9001\u5230\u5907\u7528\u6570\u636e\u5e93\u3002\u4ed4\u7ec6\u7684 Pgpool-II \u7684 Streaming Replication \u6a21\u5f0f \u5904\u7406\u8fd9\u4e2a\u3002<\/p>\n<p>\u6211\u4eec\u901a\u8fc7\u67e5\u770b\u6765\u533a\u5206\u54ea\u4e2a\u67e5\u8be2\u5e94\u8be5\u53d1\u9001\u5230\u54ea\u4e2a\u8282\u70b9 \u5728\u67e5\u8be2\u672c\u8eab\u3002<\/p>\n<p>\u8fd9\u4e9b\u67e5\u8be2\u5e94\u4ec5\u53d1\u9001\u5230\u4e3b\u8282\u70b9<\/p>\n<p>\u63d2\u5165\u3001\u66f4\u65b0\u3001\u5220\u9664\u3001\u590d\u5236\u81ea\u3001\u622a\u65ad\u3001\u521b\u5efa\u3001\u5220\u9664\u3001\u66f4\u6539\u3001\u6ce8\u91ca<\/p>\n<p>\u9009\u62e9\u3002\u3002\u3002\u7528\u4e8e\u5206\u4eab |\u66f4\u65b0<\/p>\n<p>\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b SERIALIZABLE \u4e2d\u7684 SELECT<\/p>\n<p>LOCK \u547d\u4ee4\u6bd4 ROW EXCLUSIVE MODE \u66f4\u4e25\u683c<\/p>\n<p>DECLARE, FETCH, CLOSE<\/p>\n<p>\u663e\u793a<\/p>\n<p>\u4e00\u4e9b\u4e8b\u52a1\u6027\u547d\u4ee4&#xff1a;<\/p>\n<p>BEGIN READ WRITE\u3001START TRANSACTION \u8bfb\u5199<\/p>\n<p>\u8bbe\u7f6e\u4e8b\u52a1\u8bfb\u5199&#xff0c;\u5c06\u4f1a\u8bdd\u7279\u5f81\u8bbe\u7f6e\u4e3a\u4e8b\u52a1\u8bfb\u5199<\/p>\n<p>\u8bbe\u7f6e transaction_read_only &#061; \u5173\u95ed<\/p>\n<p>\u4e24\u9636\u6bb5\u63d0\u4ea4\u547d\u4ee4&#xff1a;PREPARE TRANSACTION\u3001COMMIT PREPARED\u3001ROLLBACK PREPARED<\/p>\n<p>\u503e\u542c\u3001\u53d6\u6d88\u503e\u542c\u3001\u901a\u77e5<\/p>\n<p>\u771f\u7a7a<\/p>\n<p>\u4e00\u4e9b\u5e8f\u5217\u51fd\u6570&#xff08;nextval \u548c setval&#xff09;<\/p>\n<p>\u5927\u578b\u5bf9\u8c61\u521b\u5efa\u547d\u4ee4<\/p>\n<p>\u591a\u8bed\u53e5\u67e5\u8be2&#xff08;\u5355\u884c\u4e0a\u6709\u591a\u4e2a SQL \u547d\u4ee4&#xff09;<\/p>\n<p>\u8fd9\u4e9b\u67e5\u8be2\u53ef\u4ee5\u53d1\u9001\u5230\u4e3b\u8282\u70b9\u548c\u5907\u7528\u8282\u70b9\u3002 \u5982\u679c\u542f\u7528\u4e86\u8d1f\u8f7d\u5747\u8861&#xff0c;\u5219\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u7c7b\u578b\u7684\u67e5\u8be2\u53d1\u9001\u5230\u5907\u7528\u8282\u70b9\u3002 \u4f46\u662f&#xff0c;\u5982\u679c\u8bbe\u7f6e\u4e86 delay_threshold \u5e76\u4e14\u590d\u5236\u5ef6\u8fdf\u9ad8\u4e8e delay_threshold&#xff0c;\u5219\u4f1a\u5c06\u67e5\u8be2\u53d1\u9001\u5230\u4e3b\u8282\u70b9\u3002<\/p>\n<p>\u4e0a\u9762\u672a\u5217\u51fa SELECT<\/p>\n<p>\u590d\u5236\u5230 STDOUT<\/p>\n<p>\u89e3\u91ca<\/p>\n<p>EXPLAIN ANALYZE \u4e14\u67e5\u8be2\u4e3a SELECT \u4e0d\u5305\u62ec\u5199\u5165\u51fd\u6570<\/p>\n<p>\u663e\u793a<\/p>\n<p>\u8fd9\u4e9b\u67e5\u8be2\u5c06\u540c\u65f6\u53d1\u9001\u5230\u4e3b\u8282\u70b9\u548c\u5907\u7528\u8282\u70b9<\/p>\n<p>\u8bbe\u7f6e<\/p>\n<p>\u4e22\u5f03<\/p>\n<p>\u5168\u90e8\u89e3\u9664\u5206\u914d<\/p>\n<p>SAVEPOINT&#xff08;\u4ee5\u53ca\u76f8\u5173\u547d\u4ee4&#xff0c;\u4f8b\u5982 RELEASE SAVEPOINT&#xff09;<\/p>\n<p>\u5728\u663e\u5f0f\u4e8b\u52a1\u4e2d&#xff1a;<\/p>\n<p>\u4e8b\u52a1\u542f\u52a8\u547d\u4ee4&#xff08;\u5982 BEGIN&#xff09;\u5c06\u53d1\u9001\u5230\u4e3b\u8282\u70b9 \u548c\u5907\u7528\u8282\u70b9\u3002<\/p>\n<p>\u9075\u5faa SELECT \u548c\u4e00\u4e9b\u53ef\u4ee5\u53d1\u9001\u5230\u4e24\u8005\u7684\u5176\u4ed6\u67e5\u8be2 primary \u6216 standby \u5728\u4e8b\u52a1\u4e2d\u6216\u5728 standby \u8282\u70b9\u4e0a\u6267\u884c\u3002<\/p>\n<p>\u53d1\u9001\u65e0\u6cd5\u5728\u5907\u7528\u6570\u636e\u5e93\u4e0a\u6267\u884c\u7684\u547d\u4ee4&#xff0c;\u4f8b\u5982 INSERT \u5230\u4e3b\u8282\u70b9\u3002 \u5728\u5176\u4e2d\u4e00\u4e2a\u547d\u4ee4\u4e4b\u540e&#xff0c;\u751a\u81f3 SELECT \u4e5f\u4f1a\u88ab\u53d1\u9001\u5230\u4e3b\u8282\u70b9 \u8fd9\u662f\u56e0\u4e3a\u8fd9\u4e9b SELECT \u53ef\u80fd\u5e0c\u671b\u7acb\u5373\u770b\u5230 INSERT \u7684\u7ed3\u679c\u3002 \u6b64\u884c\u4e3a\u4e00\u76f4\u6301\u7eed\u5230\u4e8b\u52a1\u5173\u95ed\u6216\u4e2d\u6b62\u3002<\/p>\n<p>\u5728\u6269\u5c55\u534f\u8bae\u4e2d&#xff0c;\u53ef\u4ee5\u786e\u5b9a\u67e5\u8be2\u662f\u5426\u53ef\u4ee5 \u5728\u89e3\u6790\u67e5\u8be2\u65f6\u53d1\u9001\u5230 standby \u6216\u4e0d\u5904\u4e8e\u8d1f\u8f7d\u5747\u8861\u6a21\u5f0f\u3002 \u89c4\u5219\u4e0e\u975e\u6269\u5c55\u534f\u8bae\u7684\u89c4\u5219\u76f8\u540c\u3002 \u4f8b\u5982&#xff0c;\u5c06 INSERT \u53d1\u9001\u5230\u4e3b\u8282\u70b9\u3002 \u63a5\u4e0b\u6765\u7684 bind\u3001describe \u548c execute \u4e5f\u5c06\u88ab\u53d1\u9001\u5230\u4e3b\u8282\u70b9\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c SELECT \u8bed\u53e5\u7684\u89e3\u6790\u56e0\u8d1f\u8f7d\u800c\u53d1\u9001\u5230\u5907\u8282\u70b9 \u5e73\u8861&#xff0c;\u7136\u540e\u4e00\u4e2a DML \u8bed\u53e5&#xff0c;\u6bd4\u5982 INSERT&#xff0c;\u88ab\u53d1\u9001\u5230 Pgpool-II&#xff0c; \u90a3\u4e48\u89e3\u6790\u7684 SELECT \u5fc5\u987b\u5728\u4e3b\u8282\u70b9\u4e0a\u6267\u884c\u3002 \u56e0\u6b64&#xff0c;\u6211\u4eec\u5728\u4e3b\u8282\u70b9\u4e0a\u91cd\u65b0\u89e3\u6790 SELECT\u3002<\/p>\n<p>\u6700\u540e&#xff0c;Pgpool-II \u7684\u89e3\u6790\u5668\u8ba4\u4e3a\u662f \u9519\u8bef\u53d1\u9001\u5230\u4e3b\u8282\u70b9\u3002<\/p>\n<h4>1.8.4. \u8d1f\u8f7d\u5747\u8861\u8bbe\u7f6e<\/h4>\n<p>load_balance_mode &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;Pgpool-II \u542f\u7528 \u5bf9\u4f20\u5165\u7684 SELECT \u67e5\u8be2\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002 \u5373\u6765\u81ea\u5ba2\u6237\u7aef\u7684 SELECT \u67e5\u8be2\u88ab\u5206\u53d1\u5230 \u914d\u7f6e\u7684 PostgreSQL \u540e\u7aef\u3002 \u9ed8\u8ba4\u503c\u4e3a on\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ignore_leading_white_space &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;Pgpool-II \u4f1a\u5ffd\u7565 \u8d1f\u8f7d\u5747\u8861\u4e2d SQL \u67e5\u8be2\u5f00\u5934\u7684\u7a7a\u683c\u3002 \u5982\u679c\u4e0e DBI\/DBD&#xff1a;Pg \u7b49 API \u4e00\u8d77\u4f7f\u7528&#xff0c;\u5219\u975e\u5e38\u6709\u7528&#xff0c;\u5176\u4e2d\u6dfb\u52a0\u4e86 \u7a7a\u683c\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>read_only_function_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u4e0d\u66f4\u65b0\u6570\u636e\u5e93\u7684\u51fd\u6570\u540d\u79f0\u7684\u9017\u53f7\u5206\u9694\u5217\u8868\u3002SELECT \u5305\u62ec \u6b64\u5217\u8868\u4e2d\u672a\u6307\u5b9a\u7684\u51fd\u6570\u4e0d\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002 \u8fd9\u4e9b\u5c06\u5728\u590d\u5236\u6a21\u5f0f\u4e0b\u7684\u6240\u6709\u6570\u636e\u5e93\u8282\u70b9\u4e4b\u95f4\u590d\u5236\u3002 \u4ec5\u5728 Other \u6a21\u5f0f\u4e0b\u53d1\u9001\u5230\u4e3b\u8282\u70b9\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u5339\u914d\u51fd\u6570\u540d\u79f0&#xff0c; \u5176\u4e2d ^ \u548c $ \u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230\u5176\u4e2d\u3002<\/p>\n<p>\u4f8b 1-2.\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/p>\n<p>\u5982\u679c\u60a8\u5df2\u4e3a\u6240\u6709\u53ea\u8bfb\u51fd\u6570\u6dfb\u52a0\u524d\u7f00 \u4f7f\u7528 \u2018get_\u2019 \u6216 \u2018select_\u2019 \u65f6&#xff0c;\u60a8\u53ef\u4ee5 \u6309\u5982\u4e0b\u65b9\u5f0f\u8bbe\u7f6eread_only_function_list&#xff1a;<\/p>\n<p>read_only_function_list &#061; &#039;get_.*,select_.*&#039;<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c\u67e5\u8be2\u53ef\u4ee5\u5f15\u7528\u5177\u6709\u548c\u4e0d\u5177\u6709\u67b6\u6784\u7684\u51fd\u6570 qualification \u65f6&#xff0c;\u60a8\u5fc5\u987b\u6dfb\u52a0\u4e24\u4e2a\u6761\u76ee&#xff08;\u5e26\u548c\u4e0d\u5e26 Schema name&#xff09; \u7684 Schema \u540d\u79f0&#xff09;\u3002<\/p>\n<p>#For example:<br \/>\n#If the queries sometime use &#034;f1()&#034; and other times &#034;public.f1()&#034;<br \/>\n#to refer the function f1 then the read_only_function_list<br \/>\n#would be configured as follows.<\/p>\n<p>read_only_function_list &#061; &#034;f1,public.f1&#034;<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c\u6b64\u53c2\u6570\u548c write_function_list \u4e3a\u7a7a\u5b57\u7b26\u4e32&#xff0c;\u5219\u5c06\u68c0\u67e5\u51fd\u6570\u7684 volatile \u5c5e\u6027\u3002\u5982\u679c \u5c5e\u6027\u662f volatile \u7684&#xff0c;\u51fd\u6570\u88ab\u89c6\u4e3a\u5199\u5165 \u529f\u80fd\u3002\u8fd9\u662f\u65b9\u4fbf\u4e14\u63a8\u8350\u7684\u65b9\u6cd5\u3002\u7136\u800c&#xff0c;\u8fd9\u4e2a \u7b2c\u4e00\u6b21\u9700\u8981\u5bf9 System Catalog \u8fdb\u884c\u4e00\u6b21\u989d\u5916\u67e5\u8be2 time &#xff08;\u5728\u4e0b\u6b21\u4f7f\u7528\u7f13\u5b58\u7684\u67e5\u8be2\u7ed3\u679c\u65f6&#xff0c;\u5e76\u4e14\u6ca1\u6709\u989d\u5916\u7684 \u67e5\u8be2&#xff09;\u3002\u5982\u679c\u60a8\u4e0d\u60f3\u53d1\u9001\u6b64\u7c7b\u67e5\u8be2&#xff0c;\u8bf7 \u53ef\u4ee5\u7ee7\u7eed\u4f7f\u7528\u8fd9\u4e2a\u53c2\u6570\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>write_function_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u4ee5\u9017\u53f7\u5206\u9694\u7684\u51fd\u6570\u540d\u79f0\u5217\u8868&#xff0c;\u8fd9\u4e9b\u51fd\u6570\u540d\u79f0\u5c06\u66f4\u65b0\u6570\u636e\u5e93\u3002 \u5305\u542b\u6b64\u5217\u8868\u4e2d\u6307\u5b9a\u51fd\u6570\u7684 SELECT \u4e3a \u672a\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002 \u8fd9\u4e9b\u5c06\u5728\u590d\u5236\u6a21\u5f0f\u4e0b\u7684\u6240\u6709\u6570\u636e\u5e93\u8282\u70b9\u4e4b\u95f4\u590d\u5236\u3002 \u4ec5\u5728 Other \u6a21\u5f0f\u4e0b\u53d1\u9001\u5230\u4e3b\u8282\u70b9\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u5339\u914d\u51fd\u6570\u540d\u79f0&#xff0c; \u5176\u4e2d ^ \u548c $ \u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230\u5176\u4e2d\u3002<\/p>\n<p>\u4f8b 1-3.\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/p>\n<p>\u5982\u679c\u60a8\u5df2\u4e3a\u6240\u6709\u66f4\u65b0\u51fd\u6570\u6dfb\u52a0\u524d\u7f00 \u4f7f\u7528 \u2018set_\u2019&#xff0c; \u2018update_\u2019&#xff0c; \u2018delete_\u2019 \u6216 \u2018insert_\u2019&#xff0c;\u60a8\u53ef\u4ee5 \u8bbe\u7f6ewrite_function_list\u5982\u4e0b&#xff1a;<\/p>\n<p>write_function_list &#061; &#039;nextval,setval,set_.*,update_.*,delete_.*,insert_.*&#039;<\/p>\n<p>\u6ce8\u610f&#xff1a; \u67e5\u8be2\u662f\u5426\u53ef\u4ee5\u5f15\u7528\u5177\u6709\u548c\u4e0d\u5177\u6709\u67b6\u6784\u7684\u51fd\u6570 qualification \u90a3\u4e48\u4f60\u5fc5\u987b\u6dfb\u52a0\u4e24\u4e2a\u6761\u76ee&#xff08;\u5e26\u548c\u4e0d\u5e26 Schema name&#xff09; \u7684 Schema \u540d\u79f0&#xff09;\u3002<\/p>\n<p>#For example:<br \/>\n#If the queries sometime use &#034;f1()&#034; and other times &#034;public.f1()&#034;<br \/>\n#to refer the function f1 then the write_function_list<br \/>\n#would be configured as follows.<\/p>\n<p>write_function_list &#061; &#034;f1,public.f1&#034;<\/p>\n<p>\u6ce8\u610f&#xff1a; write_function_list \u548c read_only_function_list \u662f\u4e92\u65a5\u7684&#xff0c;\u5728\u914d\u7f6e\u4e2d\u53ea\u80fd\u8bbe\u7f6e\u4e24\u4e2a\u5217\u8868\u4e2d\u7684\u4e00\u4e2a\u3002<\/p>\n<p>\u4f8b 1-4.\u4f7f\u7528 nextval&#xff08;&#xff09; \u548c setval&#xff08;&#xff09; \u8fdb\u884c\u914d\u7f6e\u4ee5\u8fdb\u5165\u6b63\u786e\u7684\u540e\u7aef<\/p>\n<p>\u5728 Pgpool-IIV3.0 \u4e4b\u524d&#xff0c;nextval&#xff08;&#xff09; \u548c setval&#xff08;&#xff09; \u88ab\u79f0\u4e3a\u5199\u5165\u6570\u636e\u5e93\u7684\u51fd\u6570\u3002 \u60a8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e write_function_list \u548c read_only_function_list \u6765\u914d\u7f6e\u5b83&#xff0c;\u5982\u4e0b\u6240\u793a<\/p>\n<p>read_only_function_list &#061; &#039;&#039;<br \/>\nwrite_function_list &#061; &#039;nextval,setval,lastval,currval&#039;<\/p>\n<p>\u6ce8\u610f&#xff1a; \u9664\u4e86 nextval&#xff08;&#xff09; \u548c setval&#xff08;&#xff09; \u4e4b\u5916&#xff0c;PostgreSQL \u8fd8\u5305\u542b lastval&#xff08;&#xff09; \u548c currval&#xff08;&#xff09;\u3002 \u867d\u7136 lastval&#xff08;&#xff09; \u548c currval&#xff08;&#xff09; \u4e0d\u662f\u5199\u5165\u51fd\u6570\u7c7b\u578b&#xff0c;\u4f46\u5efa\u8bae\u5c06 lastval&#xff08;&#xff09; \u548c currval&#xff08;&#xff09; \u89c6\u4e3a\u5199\u5165\u51fd\u6570&#xff0c;\u4ee5\u907f\u514d\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\u53d1\u751f\u9519\u8bef \u8fd9\u4e9b\u51fd\u6570\u88ab\u610f\u5916\u5730\u8fdb\u884c\u4e86\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c\u6b64\u53c2\u6570\u548c read_only_function_list \u4e3a\u7a7a\u5b57\u7b26\u4e32&#xff0c;\u5219\u5c06\u68c0\u67e5\u51fd\u6570\u7684 volatile \u6b63\u786e\u6027\u3002\u5982\u679c \u5c5e\u6027\u662f volatile \u7684&#xff0c;\u51fd\u6570\u88ab\u89c6\u4e3a\u5199\u5165 \u529f\u80fd\u3002\u8fd9\u662f\u65b9\u4fbf\u4e14\u63a8\u8350\u7684\u65b9\u6cd5\u3002\u7136\u800c&#xff0c;\u8fd9\u4e2a \u7b2c\u4e00\u6b21\u9700\u8981\u5bf9 System Catalog \u8fdb\u884c\u4e00\u6b21\u989d\u5916\u67e5\u8be2 time &#xff08;\u5728\u4e0b\u6b21\u4f7f\u7528\u7f13\u5b58\u7684\u67e5\u8be2\u7ed3\u679c\u65f6&#xff0c;\u5e76\u4e14\u6ca1\u6709\u989d\u5916\u7684 \u67e5\u8be2&#xff09;\u3002\u5982\u679c\u60a8\u4e0d\u60f3\u53d1\u9001\u6b64\u7c7b\u67e5\u8be2&#xff0c;\u8bf7 \u53ef\u4ee5\u7ee7\u7eed\u4f7f\u7528\u8fd9\u4e2a\u53c2\u6570\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>primary_routing_query_pattern_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u4ee5\u5206\u53f7\u5206\u9694\u7684 SQL \u6a21\u5f0f\u5217\u8868&#xff0c;\u8be5 SQL \u6a21\u5f0f\u4e3a \u5e94\u53d1\u9001\u5230\u4e3b\u8282\u70b9\u3002 \u4e0e\u6b64\u5217\u8868\u4e2d\u6307\u5b9a\u7684\u6a21\u5f0f\u5339\u914d\u7684 SQL \u4e3a \u672a\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002 \u9664 Only Native Replication \u6a21\u5f0f\u5916\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u5339\u914d SQL \u6a21\u5f0f&#xff0c; \u5176\u4e2d ^ \u548c $ \u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230\u5176\u4e2d\u3002 \u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u7279\u6b8a\u5b57\u7b26\u65f6 &#xff08;\u5982 \u201c&#039;\u201d\u3001\u201c \u201d;\u201c\u3001 \u201d*\u201c\u3001\u201d \u201c&#xff08;\u201d\u3001 \u201c&#xff09;\u201d\u3001 \u201c|\u201d\u3001 \u201c&#043;\u201d\u3001 \u201c.\u201d\u3001 \u201c\\\\\u201d\u3001 \u201c&#xff1f;\u201d\u3001 \u201c^\u201d\u3001 \u201c$\u201d\u3001 \u201c{\u201d\u3001\u201c}\u201d\u3001\u201c{\u201d\u6216\u201c}\u201d\u7b49&#xff09; \u5728 SQL \u6a21\u5f0f\u4e2d&#xff0c;\u60a8\u9700\u8981\u4f7f\u7528 \u201c\\\\\u201d \u5bf9\u5b83\u4eec\u8fdb\u884c\u8f6c\u4e49\u3002 \u6b64\u53c2\u6570\u4e2d\u6307\u5b9a\u7684 SQL \u6a21\u5f0f\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002<\/p>\n<p>\u4f8b 1-5.\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/p>\n<p>\u5982\u679c\u4ee5\u4e0b SQL \u53ea\u5e94\u53d1\u9001\u5230\u4e3b\u8282\u70b9&#xff0c;\u60a8\u53ef\u4ee5 \u6309\u5982\u4e0b\u65b9\u5f0f\u8bbe\u7f6eprimary_routing_query_pattern_list&#xff1a;<\/p>\n<p>SELECT * FROM table_name1;<\/p>\n<p>\u4ece table_name2\u4e2d\u9009\u62e9 col1&#xff0c; col2 \u5176\u4e2d col1 LIKE \u2018%a%\u2019;<\/p>\n<p>SQL \u5305\u62ec table_name3<\/p>\n<p>primary_routing_query_pattern_list &#061; &#039;SELECT \\\\* FROM table_name1\\\\;;SELECT col1, col2 FROM table_name2 WHERE col1 LIKE \\\\&#039;%a%\\\\&#039;\\\\;;.*table_name3.*&#039;<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c SQL \u540c\u65f6\u5339\u914d write_function_list \u548c read_only_function_list&#xff0c;\u5219\u5ffd\u7565read_only_function_list\u8bbe\u7f6e&#xff0c;\u5e76\u4e14\u5e94\u4ec5\u5c06 SQL \u53d1\u9001\u5230\u4e3b\u8282\u70b9\u3002<\/p>\n<p>\u6839\u636e SQL \u6a21\u5f0f&#xff0c;\u4f7f\u7528\u6b64\u529f\u80fd\u65f6&#xff0c;\u6027\u80fd\u53ef\u80fd\u4f1a\u964d\u4f4e 1-2%\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>user_redirect_preference_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a \u201cuser-name&#xff1a;node id &#xff08;ratio&#xff09;\u201d \u5bf9\u7684\u5217\u8868 \u5c06 SELECT \u67e5\u8be2\u53d1\u9001\u5230\u7279\u5b9a\u540e\u7aef \u8282\u70b9\u3002 \u8d1f\u8f7d\u5747\u8861\u6bd4\u7387\u6307\u5b9a\u4e00\u4e2a\u4ecb\u4e8e 0 \u548c 1 \u4e4b\u95f4\u7684\u503c\u3002\u9ed8\u8ba4\u503c\u4e3a 1.0\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u901a\u8fc7\u6307\u5b9a \u201cuser1&#xff1a;1&#xff08;0.5&#xff09;\u201d&#xff0c;Pgpool-II \u4f1a\u5c06 50% \u7684 SELECT \u67e5\u8be2\u91cd\u5b9a\u5411\u5230 ID \u4e3a 1 \u7684\u540e\u7aef\u8282\u70b9 \u7528\u6237 user1 \u7684\u8fde\u63a5\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a \u201cuser-name&#xff1a;node id &#xff08;ratio&#xff09;\u201d \u5bf9 \u4f7f\u7528\u9017\u53f7 &#xff08;&#xff0c;&#xff09; \u5206\u9694\u5b83\u4eec\u3002<\/p>\n<p>\u7528\u6237\u540d\u4e5f\u63a5\u53d7\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 \u60a8\u53ef\u4ee5\u4f7f\u7528\u7279\u6b8a\u5173\u952e\u5b57\u4f5c\u4e3a\u8282\u70b9 ID\u3002 \u5982\u679c\u6307\u5b9a\u4e86 \u201cprimary\u201d&#xff0c;\u5219\u67e5\u8be2\u5c06\u53d1\u9001\u5230\u4e3b\u8282\u70b9&#xff0c;\u5e76\u4e14 \u5982\u679c\u6307\u5b9a\u4e86 \u201cstandby\u201d&#xff0c;\u5219\u968f\u673a\u9009\u62e9\u5176\u4e2d\u4e00\u4e2a\u5907\u7528\u8282\u70b9 \u57fa\u4e8e\u8d1f\u8f7d\u5747\u8861\u6bd4\u7387\u3002<\/p>\n<p>\u4f8b 1-6.\u4f7f\u7528 user_redirect_preference_list<\/p>\n<p>\u5982\u679c\u8981\u914d\u7f6e\u4ee5\u4e0b SELECT \u67e5\u8be2\u8def\u7531\u89c4\u5219&#xff1a;<\/p>\n<p>\u4ece\u8fde\u63a5\u8def\u7531\u6240\u6709 SELECT \u67e5\u8be2 \u4f7f\u7528\u7528\u6237 postgres \u5230\u4e3b\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u4ece\u8fde\u63a5\u4e2d\u8def\u7531 30% \u7684 SELECT \u67e5\u8be2 \u4f7f\u7528\u7528\u6237 user0 \u6216 user1 \u5230 ID \u4e3a 1 \u7684\u540e\u7aef\u8282\u70b9\u3002 \u5176\u4ed6 70% \u7684 SELECT \u67e5\u8be2\u5c06\u53d1\u9001\u5230\u5176\u4ed6\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u4ece\u8fde\u63a5\u8def\u7531\u6240\u6709 SELECT \u67e5\u8be2 \u4f7f\u7528\u7528\u6237 user2 \u5230\u5907\u7528\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u7136\u540euser_redirect_preference_list\u5c06\u914d\u7f6e\u5982\u4e0b&#xff1a;<\/p>\n<p>user_redirect_preference_list &#061; &#039;postgres:primary,user[01]:1(0.3),user2:standby&#039;<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>database_redirect_preference_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a \u201cdatabase-name&#xff1a;node id&#xff08;ratio&#xff09;\u201d \u5bf9\u7684\u5217\u8868 \u5c06 SELECT \u67e5\u8be2\u53d1\u9001\u5230\u7279\u5b9a\u540e\u7aef \u8282\u70b9\u3002 \u8d1f\u8f7d\u5747\u8861\u6bd4\u7387\u6307\u5b9a\u4e00\u4e2a\u4ecb\u4e8e 0 \u548c 1 \u4e4b\u95f4\u7684\u503c\u3002\u9ed8\u8ba4\u503c\u4e3a 1.0\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u901a\u8fc7\u6307\u5b9a \u201ctest&#xff1a;1&#xff08;0.5&#xff09;\u201d&#xff0c;Pgpool-II \u4f1a\u5c06 50% \u7684 SELECT \u67e5\u8be2\u91cd\u5b9a\u5411\u5230 ID \u4e3a 1 \u7684\u540e\u7aef\u8282\u70b9 \u4e0e test \u6570\u636e\u5e93\u7684\u8fde\u63a5\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a \u201cdatabase-name&#xff1a;node id&#xff08;ratio&#xff09;\u201d \u5bf9 \u4f7f\u7528\u9017\u53f7 &#xff08;&#xff0c;&#xff09; \u5206\u9694\u5b83\u4eec\u3002<\/p>\n<p>\u6570\u636e\u5e93\u540d\u79f0\u4e5f\u63a5\u53d7\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 \u60a8\u53ef\u4ee5\u4f7f\u7528\u7279\u6b8a\u5173\u952e\u5b57\u4f5c\u4e3a\u8282\u70b9 ID\u3002 \u5982\u679c\u6307\u5b9a\u4e86 \u201cprimary\u201d&#xff0c;\u5219\u67e5\u8be2\u5c06\u53d1\u9001\u5230\u4e3b\u8282\u70b9&#xff0c;\u5e76\u4e14 \u5982\u679c\u6307\u5b9a\u4e86 \u201cstandby\u201d&#xff0c;\u5219\u968f\u673a\u9009\u62e9\u5176\u4e2d\u4e00\u4e2a\u5907\u7528\u8282\u70b9 \u57fa\u4e8e\u8d1f\u8f7d\u5747\u8861\u6bd4\u7387\u3002<\/p>\n<p>\u4f8b 1-7.\u4f7f\u7528 database_redirect_preference_list<\/p>\n<p>\u5982\u679c\u8981\u914d\u7f6e\u4ee5\u4e0b SELECT \u67e5\u8be2\u8def\u7531\u89c4\u5219&#xff1a;<\/p>\n<p>\u5c06 postgres \u6570\u636e\u5e93\u4e0a\u7684\u6240\u6709 SELECT \u67e5\u8be2\u8def\u7531\u5230\u4e3b\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u5c06 mydb0 \u6216 mydb1 \u6570\u636e\u5e93\u4e0a\u7684 30% SELECT \u67e5\u8be2\u8def\u7531\u5230 ID \u4e3a 1 \u7684\u540e\u7aef\u8282\u70b9\u3002 \u5176\u4ed6 70% \u7684 SELECT \u67e5\u8be2\u5c06\u53d1\u9001\u5230\u5176\u4ed6\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u5c06 mydb2 \u6570\u636e\u5e93\u4e0a\u7684\u6240\u6709 SELECT \u67e5\u8be2\u8def\u7531\u5230\u5907\u7528\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u7136\u540edatabase_redirect_preference_list\u5c06\u914d\u7f6e\u5982\u4e0b&#xff1a;<\/p>\n<p>database_redirect_preference_list &#061; &#039;postgres:primary,mydb[01]:1(0.3),mydb2:standby&#039;<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>app_name_redirect_preference_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a \u201capplication-name&#xff1a;node id&#xff08;ratio&#xff09;\u201d \u5bf9\u7684\u5217\u8868 \u5c06 SELECT \u67e5\u8be2\u53d1\u9001\u5230\u7279\u5b9a\u540e\u7aef \u8282\u70b9\u3002 \u8d1f\u8f7d\u5747\u8861\u6bd4\u7387\u6307\u5b9a\u4e00\u4e2a\u4ecb\u4e8e 0 \u548c 1 \u4e4b\u95f4\u7684\u503c\u3002\u9ed8\u8ba4\u503c\u4e3a 1.0\u3002 \u60a8\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a \u201capplication-name&#xff1a;node id&#xff08;ratio&#xff09;\u201d \u5bf9 \u4f7f\u7528\u9017\u53f7 &#xff08;&#xff0c;&#xff09; \u5206\u9694\u5b83\u4eec\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5728 PostgreSQL V9.0 \u6216\u66f4\u9ad8\u7248\u672c\u4e2d&#xff0c;\u201c\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u201d\u662f\u6307\u5b9a\u7684\u540d\u79f0 \u7531 Client \u7aef\u8fde\u63a5\u5230 Database \u65f6\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;psql \u547d\u4ee4\u7684\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u4e3a \u201cpsql\u201d\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; Pgpool-II \u53ef\u4ee5\u8bc6\u522b\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0 \u4ec5\u5728 start-up \u6570\u636e\u5305\u4e2d\u6307\u5b9a\u3002 \u5c3d\u7ba1\u5ba2\u6237\u7aef\u53ef\u4ee5\u63d0\u4f9b\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0 \u4f46\u662f Pgpool-II \u4e0d\u4f1a\u8003\u8651\u8fdb\u884c\u67e5\u8be2\u8def\u7531\u3002<\/p>\n<p>\u6570\u636e\u5e93\u540d\u79f0\u4e5f\u63a5\u53d7\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 \u60a8\u53ef\u4ee5\u4f7f\u7528\u7279\u6b8a\u5173\u952e\u5b57\u4f5c\u4e3a\u8282\u70b9 ID\u3002 \u5982\u679c\u6307\u5b9a\u4e86 \u201cprimary\u201d&#xff0c;\u5219\u67e5\u8be2\u5c06\u53d1\u9001\u5230\u4e3b\u8282\u70b9&#xff0c;\u5e76\u4e14 \u5982\u679c\u6307\u5b9a\u4e86 \u201cstandby\u201d&#xff0c;\u5219\u968f\u673a\u9009\u62e9\u5176\u4e2d\u4e00\u4e2a\u5907\u7528\u8282\u70b9 \u57fa\u4e8e\u8d1f\u8f7d\u5747\u8861\u6bd4\u7387\u3002<\/p>\n<p>\u4f8b 1-8.\u4f7f\u7528 app-name_redirect_preference_list<\/p>\n<p>\u5982\u679c\u8981\u914d\u7f6e\u4ee5\u4e0b SELECT \u67e5\u8be2\u8def\u7531\u89c4\u5219&#xff1a;<\/p>\n<p>\u5c06\u6240\u6709 SELECT \u4ece psql \u5ba2\u6237\u7aef\u8def\u7531\u5230\u4e3b\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u5c06 30% \u7684 SELECT \u67e5\u8be2\u4ece myapp1 \u5ba2\u6237\u7aef\u8def\u7531\u5230 ID \u4e3a 1 \u7684\u540e\u7aef\u8282\u70b9\u3002\u5176\u4ed6 70% \u7684 SELECT \u67e5\u8be2\u5c06\u53d1\u9001\u5230\u5176\u4ed6\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u5c06\u6240\u6709 SELECT \u67e5\u8be2\u4ece myapp2 \u5ba2\u6237\u7aef\u8def\u7531\u5230\u5907\u7528\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u7136\u540e app_name_redirect_preference_list \u5c06\u6309\u5982\u4e0b\u65b9\u5f0f\u914d\u7f6e&#xff1a;<\/p>\n<p>app_name_redirect_preference_list &#061; &#039;psql:primary,myapp1:1(0.3),myapp2:standby&#039;<\/p>\n<p>\u6ce8\u610f&#xff1a; user_redirect_preference_list\u3001database_redirect_preference_list \u548c app_name_redirect_preference_list \u7684\u4f18\u5148\u7ea7\u662f&#xff1a;<\/p>\n<p>app_name_redirect_preference_list &gt; database_redirect_preference_list &gt; user_redirect_preference_list<\/p>\n<p>\u4f8b\u5982&#xff0c;\u5982\u679c\u60a8\u8bbe\u7f6e database_redirect_preference_list &#061; \u2018postgres&#xff1a;standby&#xff08;1.0&#xff09;\u2019 \u548c app_name_redirect_preference_list &#061; \u2018myapp1&#xff1a;primary&#xff08;1.0&#xff09;\u2019&#xff0c; \u6765\u81ea postgres \u6570\u636e\u5e93\u4e0a\u5e94\u7528\u7a0b\u5e8f myapp1 \u7684\u6240\u6709 SELECT \u90fd\u5c06\u53d1\u9001\u5230\u4e3b\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u901a\u8fc7\u6307\u5b9a user_redirect_preference_list\u3001database_redirect_preference_list \u548c app_name_redirect_preference_list&#xff0c; \u5f53\u591a\u4e2a\u6570\u636e\u5e93\u540d\u79f0\u548c\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u5339\u914d\u65f6&#xff0c; \u5c06\u4f7f\u7528\u7b2c\u4e00\u4e2a\u8bbe\u7f6e\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u5982\u679c\u60a8\u8bbe\u7f6e database_redirect_preference_list &#061; \u2018postgres&#xff1a;primary&#xff0c;postgres&#xff1a;standby\u2019&#xff0c;\u5219\u5c06\u4f7f\u7528 \u201cpostgres&#xff1a; primary\u201d\u3002<\/p>\n<p>\u8c28\u614e JDBC \u9a71\u52a8\u7a0b\u5e8f PostgreSQL-9.3 \u53ca\u66f4\u65e9\u7248\u672c \u4e0d\u4f1a\u5728\u542f\u52a8\u6570\u636e\u5305\u4e2d\u53d1\u9001\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0&#xff0c;\u5373\u4f7f \u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u662f\u4f7f\u7528 JDBC \u9a71\u52a8\u7a0b\u5e8f\u9009\u9879 \u201cApplicationName\u201d \u548c \u201cassumeMinServerVersion&#061;9.0\u201d \u6307\u5b9a\u7684\u3002 \u56e0\u6b64&#xff0c;\u5982\u679c\u60a8\u60f3\u901a\u8fc7 JDBC \u4f7f\u7528 app_name_redirect_preference_list \u529f\u80fd&#xff0c;\u8bf7\u4f7f\u7528 PostgreSQL-9.4 \u6216\u66f4\u9ad8\u7248\u672c\u7684\u9a71\u52a8\u7a0b\u5e8f\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>allow_sql_comments &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;Pgpool-II \u5728\u8bc6\u522b\u8d1f\u8f7d\u5747\u8861\u65f6\u5ffd\u7565 SQL \u6ce8\u91ca \u6216\u67e5\u8be2\u7f13\u5b58\u3002 \u5f53\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a off \u65f6&#xff0c;SQL \u6ce8\u91ca \u53ef\u4ee5\u6709\u6548\u5730\u9632\u6b62\u67e5\u8be2 \u8d1f\u8f7d\u5747\u8861\u6216\u7f13\u5b58&#xff08;Pgpool-II V3.4 \u4e4b\u524d\u7684\u884c\u4e3a&#xff09;\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>disable_load_balance_on_write &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5199\u5165\u67e5\u8be2\u51fa\u73b0\u540e\u7684\u8d1f\u8f7d\u5747\u8861\u884c\u4e3a\u3002 \u6b64\u53c2\u6570\u5728\u6d41\u5f0f\u590d\u5236\u4e2d\u7279\u522b\u6709\u7528 \u6a21\u5f0f\u3002\u5f53\u5199\u5165\u67e5\u8be2\u53d1\u9001\u5230\u4e3b\u670d\u52a1\u5668\u65f6&#xff0c; \u66f4\u6539\u5c06\u5e94\u7528\u4e8e\u5907\u7528\u670d\u52a1\u5668&#xff0c;\u4f46\u6709\u65f6\u95f4 \u6ede\u540e\u3002\u56e0\u6b64&#xff0c;\u5982\u679c\u5ba2\u6237\u7aef\u5728\u5199\u5165\u540e\u7acb\u5373\u8bfb\u53d6\u540c\u4e00\u884c \u67e5\u8be2\u4e2d&#xff0c;\u5ba2\u6237\u7aef\u53ef\u80fd\u65e0\u6cd5\u770b\u5230 \u6392\u3002\u5982\u679c\u8fd9\u662f\u95ee\u9898\u6240\u5728&#xff0c;\u5219 Client \u7aef\u5e94\u59cb\u7ec8\u8bfb\u53d6\u6570\u636e \u4ece\u4e3b\u670d\u52a1\u5668\u3002\u4f46\u662f&#xff0c;\u8fd9\u5b9e\u9645\u4e0a\u4f1a\u7981\u7528 \u8d1f\u8f7d\u5e73\u8861&#xff0c;\u8fd9\u4f1a\u5bfc\u81f4\u6027\u80fd\u964d\u4f4e\u3002\u8fd9 \u53c2\u6570\u5141\u8bb8\u5bf9 not-clustering-aware \u5e94\u7528\u7a0b\u5e8f\u517c\u5bb9\u6027\u548c \u6027\u80fd\u3002<\/p>\n<p>\u5982\u679c\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a off&#xff0c;\u5219\u8bfb\u53d6 \u5373\u4f7f\u51fa\u73b0\u5199\u5165\u67e5\u8be2&#xff0c;\u67e5\u8be2\u4e5f\u4f1a\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002\u8fd9 \u63d0\u4f9b\u6700\u4f73\u7684\u8d1f\u8f7d\u5e73\u8861\u6027\u80fd&#xff0c;\u4f46\u5ba2\u6237\u7aef\u53ef\u80fd\u4f1a\u770b\u5230 \u8f83\u65e7\u7684\u6570\u636e\u3002\u8fd9\u5bf9\u4e8e PostgreSQL \u53c2\u6570 synchronous_commit &#061; \u2018remote_apply\u2019&#xff0c;\u6216 \u5728\u672c\u673a\u590d\u5236\u6a21\u5f0f\u4e0b&#xff0c;\u56e0\u4e3a\u6ca1\u6709\u590d\u5236 \u5ef6\u8fdf\u3002<\/p>\n<p>\u5982\u679c\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a transaction&#xff0c;\u5e76\u4e14\u5199\u5165\u67e5\u8be2\u51fa\u73b0\u5728\u663e\u5f0f\u4e8b\u52a1\u4e2d&#xff0c; \u540e\u7eed\u8bfb\u53d6\u67e5\u8be2\u4e0d\u4f1a\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861&#xff0c;\u76f4\u5230 \u4ea4\u6613\u7ed3\u675f\u3002\u8bf7\u6ce8\u610f&#xff0c;\u8bfb\u53d6\u67e5\u8be2\u4e0d\u5728 explicit transaction \u4e0d\u53d7 parameter \u7684\u5f71\u54cd\u3002\u8fd9 \u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b&#xff0c;\u8bbe\u7f6e\u4f1a\u63d0\u4f9b\u6700\u4f73\u5e73\u8861&#xff0c;\u60a8\u5e94\u8be5 \u4ece\u8fd9\u91cc\u5f00\u59cb\u3002\u8fd9\u662f Pgpool-II 3.7 \u6216\u66f4\u65e9\u7248\u672c\u4e2d\u7684\u9ed8\u8ba4\u548c\u76f8\u540c\u7684\u884c\u4e3a\u3002<\/p>\n<p>\u5982\u679c\u8bbe\u7f6e\u4e86\u8be5\u53c2\u6570 trans_transaction\u548c\u7f16\u5199\u67e5\u8be2 \u51fa\u73b0\u5728\u663e\u5f0f\u4e8b\u52a1\u4e2d&#xff0c;\u540e\u7eed\u8bfb\u53d6\u67e5\u8be2 \u5728\u4e8b\u52a1\u548c\u540e\u7eed\u4e8b\u52a1\u4e2d\u4e0d\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861 explicit \u4e8b\u52a1&#xff0c;\u76f4\u5230\u4f1a\u8bdd\u7ed3\u675f\u3002\u6240\u4ee5\u8fd9\u4e2a \u53c2\u6570\u5bf9\u4e8e\u8f83\u65e7\u7684\u5e94\u7528\u7a0b\u5e8f\u66f4\u5b89\u5168&#xff0c;\u4f46\u63d0\u4f9b\u7684\u66f4\u5c11 \u6027\u80fd\u6bd4\u4ea4\u6613\u3002\u8bf7\u6ce8\u610f \u4e0d\u5728\u663e\u5f0f\u4e8b\u52a1\u4e2d\u7684\u8bfb\u53d6\u67e5\u8be2\u4e0d\u662f \u53d7 parameter \u5f71\u54cd\u3002<\/p>\n<p>\u5982\u679c\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a always \u4e14 \u5199\u5165\u67e5\u8be2\u51fa\u73b0&#xff0c;\u540e\u7eed\u8bfb\u53d6\u67e5\u8be2\u4e0d\u52a0\u8f7d \u65e0\u8bba\u4ed6\u4eec\u5904\u4e8e \u663e\u5f0f\u4e8b\u52a1\u3002\u8fd9\u7ed9\u51fa\u4e86\u6700\u9ad8\u7684 \u4e0e\u975e\u96c6\u7fa4\u611f\u77e5\u5e94\u7528\u7a0b\u5e8f\u7684\u517c\u5bb9\u6027\u4ee5\u53ca \u6700\u4f4e\u6027\u80fd\u3002<\/p>\n<p>\u5982\u679c\u8fd9\u4e2a\u53c2\u6570\u88ab\u8bbe\u7f6e\u4e3a dml_adaptive Pgpool-II \u8ddf\u8e2a WRITE \u8bed\u53e5\u4e2d\u5f15\u7528\u7684\u6bcf\u4e2a TABLE\u3002 \u663e\u5f0f\u4e8b\u52a1&#xff0c;\u5e76\u4e14\u4e0d\u4f1a\u5bf9\u540e\u7eed\u7684 READ \u67e5\u8be2\u5b83\u4eec\u6b63\u5728\u8bfb\u53d6\u7684 TABLE \u662f\u5426\u4e4b\u524d\u88ab\u4fee\u6539\u8fc7 \u5728\u540c\u4e00\u7b14\u4ea4\u6613\u4e2d\u3002 \u53ef\u4ee5\u914d\u7f6e\u8868\u4e0a\u7684\u4f9d\u8d56\u51fd\u6570\u3001\u89e6\u53d1\u5668\u548c\u89c6\u56fe \u4f7f\u7528 dml_adaptive_object_relationship_list<\/p>\n<p>dml_adaptive_object_relationship_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u4e3a\u4e86\u9632\u6b62 READ \u4f9d\u8d56\u5bf9\u8c61\u7684\u8d1f\u8f7d\u5747\u8861&#xff0c;\u60a8\u53ef\u4ee5\u6307\u5b9a\u5bf9\u8c61\u540d\u79f0 \u540e\u8ddf\u5192\u53f7 &#xff08;&#xff1a;&#xff09; \u548c\u9017\u53f7 &#xff08;&#xff0c;&#xff09; \u5206\u9694\u7684\u4f9d\u8d56\u5bf9\u8c61\u540d\u79f0\u5217\u8868\u3002\u201c[\u5bf9\u8c61]&#xff1a;[\u4f9d\u8d56\u5bf9\u8c61]\u201d\u5728 WRITE \u8bed\u53e5\u53d1\u51fa\u540e\u7684\u663e\u5f0f\u4e8b\u52a1\u5757\u4e2d&#xff0c;\u8fd9\u5c06\u963b\u6b62 \u5bf9\u5305\u542b\u4f9d\u8d56\u5bf9\u8c61\u5f15\u7528\u7684\u4efb\u4f55 READ \u8bed\u53e5\u8fdb\u884c\u8d1f\u8f7d\u5e73\u8861\u3002<\/p>\n<p>\u4f8b 1-9.\u914d\u7f6e dml \u81ea\u9002\u5e94\u5bf9\u8c61\u5173\u7cfb<\/p>\n<p>\u5982\u679c\u60a8\u5728 table_1 \u4e0a\u5b89\u88c5\u4e86\u89e6\u53d1\u5668&#xff0c;\u8be5\u89e6\u53d1\u5668\u5bf9\u6bcf\u4e2a\u89e6\u53d1\u5668\u6267\u884c table_2 INSERT \u5728 table_1\u3002\u7136\u540e&#xff0c;\u60a8\u9700\u8981\u786e\u4fdd \u8bfb\u53d6table_2\u4e0d\u5f97\u5728\u540c\u4e00\u4e8b\u52a1\u4e2d\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861 \u5728 INSERT \u540e\u8f6c\u6362\u4e3a table_1\u3002 \u5bf9\u4e8e\u6b64\u914d\u7f6e&#xff0c;\u60a8\u53ef\u4ee5\u8bbe\u7f6e<\/p>\n<p>dml_adaptive_object_relationship_list &#061; \u2018table_1:table_2\u2019<\/p>\n<p>\u6b64\u53c2\u6570\u4ec5\u5bf9 disable_load_balance_on_write&#061;\u2018dml_adaptive\u2019 \u6709\u6548 \u6ce8\u610f&#xff1a; \u8981\u914d\u7f6e\u5bf9\u51fd\u6570\u7684\u4f9d\u8d56\u5173\u7cfb&#xff0c; \u8be5\u51fd\u6570\u5fc5\u987b\u5b58\u5728\u4e8e write_function_list<\/p>\n<p>statement_level_load_balance &#xff08;\u5e03\u5c14\u503c) \u5f53\u8bbe\u7f6e\u4e3a on \u4e14 load_balance_mode \u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;\u5c06\u4e3a\u6bcf\u4e2a\u8bfb\u53d6\u67e5\u8be2\u786e\u5b9a\u8d1f\u8f7d\u5747\u8861\u8282\u70b9\u3002 \u5f53\u8bbe\u7f6e\u4e3a off \u65f6&#xff0c;\u8d1f\u8f7d\u5747\u8861\u8282\u70b9\u5728\u4f1a\u8bdd\u5f00\u59cb\u65f6\u51b3\u5b9a &#xff0c;\u5e76\u4e14\u5728\u4f1a\u8bdd\u7ed3\u675f\u4e4b\u524d\u4e0d\u4f1a\u66f4\u6539\u3002 \u4f8b\u5982&#xff0c;\u5728\u4f7f\u7528\u8fde\u63a5\u6c60\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d&#xff0c;\u4fdd\u6301\u8fde\u63a5 \u5bf9\u540e\u7aef\u670d\u52a1\u5668\u5f00\u653e&#xff0c;\u56e0\u4e3a\u4f1a\u8bdd\u53ef\u80fd\u4f1a\u957f\u65f6\u95f4\u4fdd\u6301&#xff0c; \u8d1f\u8f7d\u5747\u8861\u8282\u70b9\u5728\u4f1a\u8bdd\u7ed3\u675f\u4e4b\u524d\u4e0d\u4f1a\u66f4\u6539\u3002 \u5728\u6b64\u7c7b\u5e94\u7528\u7a0b\u5e8f\u4e2d&#xff0c;\u542f\u7528 statement_level_load_balance \u65f6&#xff0c; \u53ef\u4ee5\u51b3\u5b9a\u6bcf\u4e2a\u67e5\u8be2\u7684\u8d1f\u8f7d\u5747\u8861\u8282\u70b9&#xff0c;\u800c\u4e0d\u662f\u6bcf\u4e2a\u4f1a\u8bdd\u7684\u8d1f\u8f7d\u5747\u8861\u8282\u70b9\u3002 \u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5728\u6d41\u5f0f\u590d\u5236\u6a21\u5f0f\u4e0b&#xff0c;\u67d0\u4e9b\u7c7b\u578b\u7684\u67e5\u8be2&#xff08;\u5982 BEGIN\/END\/COMMIT\/ABORT\/SET\/SAVEPOINT\/RELEASE SAVEPOINT\/DEALLOCATE ALL\/DISCARD \u53d1\u9001\u5230 \u4e3b\u8282\u70b9\u548c\u8d1f\u8f7d\u5747\u8861\u8282\u70b9\u3002\u5982\u679c statement_level_load_balance \u5904\u4e8e\u6253\u5f00\u72b6\u6001&#xff0c;\u5219 \u67e5\u8be2\u4e5f\u4f1a\u53d1\u9001\u5230\u6240\u6709\u5907\u7528\u8282\u70b9\u3002\u8fd9\u4e0d\u662f \u901a\u5e38\u662f\u4e2a\u95ee\u9898\u3002\u4f46\u662f&#xff0c;\u5f53\u5176\u4e2d\u4e00\u4e2a\u5907\u7528\u6570\u636e\u5e93\u5904\u4e8e\u8fdc\u7a0b\u72b6\u6001\u65f6 \u7f51\u7edc&#xff0c;\u5219\u7f51\u7edc\u5ef6\u8fdf\u53ef\u80fd\u4f1a\u5bfc\u81f4 \u6848\u4f8b\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<h3>1.9. \u5065\u5eb7\u68c0\u67e5<\/h3>\n<p>Pgpool-II \u5b9a\u671f\u8fde\u63a5\u5230\u914d\u7f6e\u7684 PostgreSQL \u540e\u7aef\u6765\u68c0\u6d4b\u670d\u52a1\u5668\u6216\u7f51\u7edc\u4e0a\u7684\u4efb\u4f55\u9519\u8bef\u3002 \u6b64\u9519\u8bef\u68c0\u67e5\u8fc7\u7a0b\u79f0\u4e3a \u201c\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u201d\u3002<\/p>\n<p>\u5982\u679c\u542f\u7528\u4e86 SSL&#xff0c;\u5219\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5 \u8fdb\u7a0b\u53ef\u80fd\u4f1a\u4f7f\u7528 SSL \u8fde\u63a5\u3002<\/p>\n<p>\u5982\u679c\u68c0\u6d4b\u5230\u9519\u8bef&#xff0c;Pgpool-II \u6267\u884c\u6545\u969c\u8f6c\u79fb \u6216\u9000\u5316&#xff0c;\u5177\u4f53\u53d6\u51b3\u4e8e\u914d\u7f6e\u3002<\/p>\n<p>\u8c28\u614e \u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u9700\u8981\u4e0e\u6bcf\u4e2a\u540e\u7aef\u8282\u70b9\u5efa\u7acb\u4e00\u4e2a\u989d\u5916\u7684\u8fde\u63a5&#xff0c; \u56e0\u6b64&#xff0c;\u9700\u8981\u76f8\u5e94\u5730\u8c03\u6574 postgresql.conf \u4e2d\u7684 max_connections\u3002<\/p>\n<p>\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u8fc7\u7a0b\u4f1a\u6536\u96c6\u5404\u79cd\u7edf\u8ba1\u6570\u636e&#xff0c;\u4f8b\u5982 \u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u603b\u6570\u3002\u68c0\u67e5\u7edf\u8ba1\u4fe1\u606f data \u4e2d&#xff0c;\u8bf7\u4f7f\u7528 SHOW POOL_HEALTH_CHECK_STATS \u547d\u4ee4\u3002\u8bf7\u6ce8\u610f&#xff0c;\u6570\u636e\u5b58\u50a8\u5728\u5171\u4eab\u5185\u5b58\u4e2d area \u7684 API \u4e2d&#xff0c;\u5b83\u5c06\u5728 Pgpool-II \u542f\u52a8\u65f6\u521d\u59cb\u5316\u3002<\/p>\n<p>\u4ee5\u4e0b\u53c2\u6570\u540d\u79f0\u7684\u672b\u5c3e\u4e5f\u53ef\u4ee5\u6709\u6570\u5b57\u540e\u7f00 \u6bcf\u4e2a\u540d\u5b57\u3002\u540e\u7f00\u5bf9\u5e94\u540e\u7aef id&#xff0c;\u5373 \u5728 backend information \u4e2d\u5b9a\u4e49&#xff0c;\u4f8b\u5982 \u4f5c\u4e3a backend_hostname\u3002 \u4f8b\u5982&#xff0c;health_check_timeout0 \u5e94\u7528\u4e8e backend 0 \u7684 health_check_timeout \u503c\u3002<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u5e26 suffix \u7684\u53c2\u6570&#xff0c;\u5219 backend \u7684\u503c \u53d6\u81ea\u6ca1\u6709\u540e\u7f00\u7684\u53c2\u6570\u540d\u79f0\u3002\u5728 \u4ece\u8fd9\u4e2a\u610f\u4e49\u4e0a\u8bf4&#xff0c;\u6ca1\u6709\u540e\u7f00\u7684\u53c2\u6570\u540d\u79f0\u7684\u5de5\u4f5c\u65b9\u5f0f\u7c7b\u4f3c\u4e8e \u201cglobal \u53d8\u91cf\u201d\u3002<\/p>\n<p>health_check_timeout &#xff08;\u6574\u6570) \u6307\u5b9a\u5982\u679c TCP \u8fde\u63a5\u5728\u6b64\u65f6\u95f4\u5185\u672a\u6210\u529f&#xff0c;\u5219\u653e\u5f03\u8fde\u63a5\u5230\u540e\u7aef PostgreSQL \u7684\u8d85\u65f6\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u7528\u4e8e\u9632\u6b62\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u7b49\u5f85 \u62d4\u4e0b\u7f51\u7ebf\u7684\u65f6\u95f4\u5f88\u957f\u3002 \u9ed8\u8ba4\u503c\u4e3a 20\u3002\u5c06\u5176\u8bbe\u7f6e\u4e3a 0 \u5c06\u7981\u7528\u8d85\u65f6&#xff08;\u7b49\u5f85 TCP\/IP \u8d85\u65f6&#xff09;\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>health_check_period &#xff08;\u6574\u6570) \u6307\u5b9a\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u4e4b\u95f4\u7684\u95f4\u9694&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;\u3002 \u9ed8\u8ba4\u503c\u4e3a 0&#xff0c;\u8fd9\u610f\u5473\u7740\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u5df2\u7981\u7528\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>health_check_user &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u6267\u884c\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u7684 PostgreSQL \u7528\u6237\u540d\u3002 \u6240\u6709 PostgreSQL \u540e\u7aef\u4e2d\u5fc5\u987b\u5b58\u5728\u540c\u4e00\u7528\u6237\u3002 \u5426\u5219&#xff0c;\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>health_check_password &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5728 health_check_user \u4e2d\u914d\u7f6e\u7684\u7528\u4e8e\u6267\u884c\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u7684 PostgreSQL \u7528\u6237\u540d\u7684\u5bc6\u7801\u3002 \u7528\u6237\u548c\u5bc6\u7801\u5728\u6240\u6709 PostgreSQL \u540e\u7aef\u4e2d\u5fc5\u987b\u76f8\u540c\u3002 \u5426\u5219&#xff0c;\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002<\/p>\n<p>\u5982\u679c health_check_password \u4e3a\u7a7a&#xff0c;Pgpool-II \u5c06\u9996\u5148\u5c1d\u8bd5\u4ece\u6587\u4ef6\u4e2d\u83b7\u53d6 health_check_user \u7684\u5bc6\u7801pool_passwd\u7136\u540e\u518d\u4f7f\u7528\u7a7a\u5bc6\u7801\u3002<\/p>\n<p>Pgpool-II \u63a5\u53d7\u4ee5\u4e0b\u5f62\u5f0f \u7684\u5bc6\u7801health_check_password \u6216 pool_passwd \u6587\u4ef6\u4e2d&#xff1a;<\/p>\n<p>AES256-CBC \u52a0\u5bc6\u5bc6\u7801 \u6700\u5b89\u5168\u548c\u63a8\u8350\u7684\u5bc6\u7801\u5b58\u50a8\u65b9\u5f0f\u3002\u8fd9 \u5bc6\u7801\u5b57\u7b26\u4e32\u5fc5\u987b\u5e26\u6709\u524d\u7f00 \u4f7f\u7528 AES\u3002 \u60a8\u53ef\u4ee5\u4f7f\u7528 pg_enc \u5b9e\u7528\u7a0b\u5e8f\u521b\u5efa\u683c\u5f0f\u6b63\u786e\u7684 AES \u52a0\u5bc6\u5bc6\u7801\u5b57\u7b26\u4e32\u3002Pgpool-II \u9700\u8981\u4e00\u4e2a\u4f4d\u4e8e startup \u4ee5\u4f7f\u7528\u52a0\u5bc6\u7684\u5bc6\u7801\u3002 \u6709\u5173\u63d0\u4f9b Pgpool-II \u7684\u89e3\u5bc6\u5bc6\u94a5<\/p>\n<p>MD5 \u54c8\u5e0c\u5bc6\u7801 \u4e0d\u5982 AES256 \u5b89\u5168&#xff0c;\u4f46\u4ecd\u7136\u6bd4 clear \u597d text \u5bc6\u7801\u3002\u5bc6\u7801\u5b57\u7b26\u4e32\u5fc5\u987b\u5e26\u6709\u524d\u7f00 \u4f7f\u7528 MD5\u3002\u8bf7\u6ce8\u610f&#xff0c;\u540e\u7aef \u8fd8\u5fc5\u987b\u8bbe\u7f6e MD5 \u8eab\u4efd\u9a8c\u8bc1\u3002\u60a8\u53ef\u4ee5 \u4f7f\u7528 pg_md5 \u5b9e\u7528\u7a0b\u5e8f\u521b\u5efa \u683c\u5f0f\u6b63\u786e\u7684 MD5 \u54c8\u5e0c\u5bc6\u7801\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u7eaf\u6587\u672c\u5bc6\u7801 \u672a\u52a0\u5bc6&#xff0c;\u660e\u6587\u5bc6\u7801\u3002\u4f60\u5e94\u8be5\u907f\u514d \u4ee5\u5c3d\u53ef\u80fd\u4f7f\u7528\u5b83\u3002\u5bc6\u7801\u5b57\u7b26\u4e32\u5fc5\u987b\u4e3a \u524d\u7f00\u4e3a TEXT\u3002\u4f8b\u5982&#xff0c;\u5982\u679c \u60a8\u5e0c\u671b\u5c06 myPass \u8bbe\u7f6e\u4e3a password \u7684 Password&#xff0c;\u60a8\u5e94\u8be5 \u5728\u5bc6\u7801\u4e2d\u6307\u5b9a TEXTmypass \u7530\u3002\u5728\u6ca1\u6709\u6709\u6548\u7684 \u524d\u7f00&#xff0c;Pgpool-II \u5c06 \u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u7eaf\u6587\u672c\u5bc6\u7801\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>health_check_database &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u6267\u884c\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u7684 PostgreSQL \u6570\u636e\u5e93\u540d\u79f0\u3002 \u9ed8\u8ba4\u503c\u4e3a \u2018\u2019&#xff08;empty&#xff09;&#xff0c;\u5b83\u9996\u5148\u5c1d\u8bd5 \u201cpostgres\u201d \u6570\u636e\u5e93&#xff0c;\u7136\u540e\u5c1d\u8bd5 \u201ctemplate1\u201d \u6570\u636e\u5e93&#xff0c;\u76f4\u5230\u6210\u529f<\/p>\n<p>health_check_database \u662f\u5728 Pgpool-II V3.5 \u4e2d\u5f15\u5165\u7684\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>health_check_max_retries &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u5728\u653e\u5f03\u4e4b\u524d\u8981\u6267\u884c\u7684\u6700\u5927\u91cd\u8bd5\u6b21\u6570&#xff0c;\u5e76\u4e14 \u5728\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u5931\u8d25\u65f6\u542f\u52a8\u6545\u969c\u8f6c\u79fb\u3002<\/p>\n<p>\u63d0\u793a&#xff1a; \u6b64\u8bbe\u7f6e\u5728\u53c2\u5dee\u4e0d\u9f50\u7684\u7f51\u7edc\u4e2d\u975e\u5e38\u6709\u7528&#xff0c;\u56e0\u4e3a\u9884\u8ba1 \u5373\u4f7f\u4e3b\u8282\u70b9\u6b63\u5e38&#xff0c;\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u5076\u5c14\u4e5f\u4f1a\u5931\u8d25\u3002<\/p>\n<p>\u63d0\u793a&#xff1a; \u5efa\u8bae\u5fc5\u987b\u7981\u7528 failover_on_backend_error&#xff0c; \u5982\u679c\u8981\u542f\u7528 health_check_max_retries\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a 0&#xff0c;\u8fd9\u610f\u5473\u7740\u4e0d\u91cd\u8bd5\u3002 \u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>health_check_retry_delay &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u5728\u4e24\u6b21\u5931\u8d25\u4e4b\u95f4\u4f11\u7720\u7684\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09; \u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u91cd\u8bd5&#xff08;\u9664\u975e health_check_max_retries &gt; 0&#xff0c;\u5426\u5219\u4e0d\u4f7f\u7528&#xff09;\u3002 \u5982\u679c\u4e3a 0&#xff0c;\u5219\u7acb\u5373\u91cd\u8bd5&#xff0c;\u4e0d\u4f1a\u5ef6\u8fdf\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>connect_timeout &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u653e\u5f03\u8fde\u63a5\u4e4b\u524d\u7684\u65f6\u95f4\u91cf&#xff08;\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d&#xff09; \u5230\u540e\u7aef\u3002 \u9ed8\u8ba4\u503c\u4e3a 10000 \u6beb\u79d2&#xff08;10 \u79d2&#xff09;\u3002\u6d6e\u70b9\u7f51\u7edc\u7528\u6237\u53ef\u80fd\u5e0c\u671b\u589e\u52a0\u8be5\u503c\u3002 0 \u8868\u793a\u65e0\u8d85\u65f6\u3002connect()<\/p>\n<p>\u6ce8\u610f&#xff1a; connect_timeout\u503c\u4e0d\u4ec5\u7528\u4e8e\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5&#xff0c; \u4f46\u4e5f\u7528\u4e8e\u521b\u5efa\u666e\u901a\u8fde\u63a5\u6c60\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<h3>1.10. \u6545\u969c\u8f6c\u79fb\u548c\u6545\u969c\u6062\u590d<\/h3>\n<p>\u6545\u969c\u8f6c\u79fb\u610f\u5473\u7740\u81ea\u52a8\u5206\u79bb PostgreSQL \u540e\u7aef\u8282\u70b9&#xff0c;\u800c PostgreSQL\u540e\u7aef\u8282\u70b9\u4e0d\u662f \u53ef\u901a\u8fc7 Pgpool-II \u8bbf\u95ee\u3002\u8fd9\u79cd\u60c5\u51b5 \u65e0\u8bba\u914d\u7f6e\u53c2\u6570\u8bbe\u7f6e\u5982\u4f55&#xff0c;\u90fd\u4f1a\u81ea\u52a8\u8fdb\u884c&#xff0c;\u5e76\u4e14 \u6240\u8c13\u7684\u81ea\u52a8\u6545\u969c\u8f6c\u79fb\u8fc7\u7a0b\u3002Pgpool-II \u786e\u8ba4 PostgreSQL \u540e\u7aef\u8282\u70b9\u65e0\u6cd5\u8bbf\u95ee \u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5&#xff1a;<\/p>\n<p>\u5e38\u89c4\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u6d41\u7a0b &#xff08;\u6709\u5173\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u89c1 Section 1.9 \u8be6\u7ec6\u4fe1\u606f&#xff09;\u3002\u5065\u5eb7\u68c0\u67e5\u8fc7\u7a0b\u5c1d\u8bd5\u8fde\u63a5 \u4ece Pgpool-II \u5230 PostgreSQL \u8282\u70b9\u786e\u8ba4 \u5b83\u7684\u5065\u5eb7\u3002\u5982\u679c\u8fde\u63a5\u5931\u8d25&#xff0c;\u5219\u6709\u53ef\u80fd \u7f51\u7edc\u8fde\u63a5\u6709\u95ee\u9898 \u5728 Pgpool-II \u548c PostgreSQL \u4e4b\u95f4&#xff0c; \u548c\/\u6216 PostgreSQL \u4e0d\u8d77\u4f5c\u7528 \u9002\u5f53\u5730\u3002Pgpool-II \u4e0d\u4f1a \u533a\u5206\u6bcf\u79cd\u60c5\u51b5&#xff0c;\u5e76\u53ea\u51b3\u5b9a \u7279\u5b9a PostgreSQL \u8282\u70b9\u662f \u5982\u679c\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u5931\u8d25&#xff0c;\u5219\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u8fde\u63a5\u65f6\u51fa\u9519 \u66f4\u6539\u4e3a PostgreSQL \u6216\u7f51\u7edc\u7ea7\u522b \u4e0e IT \u901a\u4fe1\u65f6\u53d1\u751f\u9519\u8bef\u3002Pgpool-II \u5c06\u65ad\u5f00\u8fde\u63a5 \u5230 Client \u7aef\u7684\u4f1a\u8bdd \u5982\u679c failover_on_backend_error \u5728 \u7136\u800c&#xff0c;\u90a3\u4e2a\u6848\u4f8b\u3002<\/p>\n<p>\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b&#xff1a;\u5f53\u5ba2\u6237\u7aef\u5df2\u8fde\u63a5\u65f6 \u5230 Pgpool-II \u5e76\u4e14 PostgreSQL \u5df2\u5173\u95ed &#xff08;\u8bf7\u6ce8\u610f&#xff0c;\u5982\u679c\u6ca1\u6709\u5ba2\u6237\u7aef\u8fde\u63a5 \u5230 Pgpool-II&#xff0c;\u5173\u95ed PostgreSQL \u7684 down \u4e0d\u4f1a \u89e6\u53d1\u6545\u969c\u8f6c\u79fb&#xff09;\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u5728\u6d41\u5f0f\u590d\u5236\u6a21\u5f0f\u4e0b&#xff0c;\u5173\u95ed \u7684 PostgreSQL \u4e0d\u4f1a\u89e6\u53d1 \u6545\u969c\u8f6c\u79fb&#xff08;\u5982\u679c\u8282\u70b9\u662f\u5907\u7528\u8282\u70b9\u4e14\u4e0d\u662f\u8d1f\u8f7d&#xff09; \u5e73\u8861\u8282\u70b9\u5076\u6570 \u5982\u679c failover_on_backend_shutdown \u5904\u4e8e\u6253\u5f00\u72b6\u6001\u3002<\/p>\n<p>\u5982\u679c\u914d\u7f6e\u4e86 failover_command \u5e76\u4e14 \u53d1\u751f\u6545\u969c\u8f6c\u79fb&#xff0c;failover_command \u6267\u884c\u3002\u5e94\u63d0\u4f9bfailover_command \u6309\u7528\u6237\u3002\u4ece 4.1 \u5f00\u59cb&#xff0c;\u63d0\u4f9b\u4e86\u6545\u969c\u8f6c\u79fb\u547d\u4ee4\u7684\u793a\u4f8b\u811a\u672c \u4f5c\u4e3a failover.sh.sample&#xff0c;\u8fd9\u53ef\u80fd\u662f\u4e00\u4e2a\u5f88\u597d\u7684 \u8d77\u70b9\u3002<\/p>\n<p>failover \u547d\u4ee4\u7684\u4e3b\u8981\u4f5c\u7528\u662f\u9009\u62e9\u65b0\u7684\u4e3b\u670d\u52a1\u5668 \u4ece\u73b0\u6709\u7684\u5907\u7528\u670d\u52a1\u5668\u8fdb\u884c\u63a8\u5e7f\u3002\u53e6\u4e00\u4e2a \u4f8b\u5982&#xff0c;\u8ba9\u7ba1\u7406\u5458\u77e5\u9053\u53d1\u751f\u4e86\u6545\u969c\u8f6c\u79fb \u901a\u8fc7\u53d1\u9001\u90ae\u4ef6\u3002<\/p>\n<p>\u867d\u7136\u53d1\u751f\u6545\u969c\u65f6\u53ef\u80fd\u4f1a\u53d1\u751f\u6545\u969c\u8f6c\u79fb&#xff0c;\u4f46\u786e\u5b9e\u5982\u6b64 \u53ef\u4ee5\u624b\u52a8\u89e6\u53d1\u5b83\u3002\u8fd9\u79f0\u4e3a switch \u7ed3\u675f\u3002\u4f8b\u5982&#xff0c;\u5207\u6362 \u4e00\u4e2a PostgreSQL \u8fdb\u884c\u5907\u4efd \u662f\u53ef\u80fd\u7684\u3002\u8bf7\u6ce8\u610f&#xff0c;\u5207\u6362\u53ea\u4f1a\u5c06 status \u8bbe\u7f6e\u4e3a \u5b95\u673a&#xff0c;\u5e76\u4e14\u6c38\u8fdc\u4e0d\u4f1a\u4f7f PostgreSQL \u5b95\u673a\u3002\u5207\u6362\u53ef\u7531 using pcp_detach_node \u547d\u4ee4\u3002<\/p>\n<p>\u901a\u8fc7\u6545\u969c\u8f6c\u79fb\u5206\u79bb\u7684 PostgreSQL \u8282\u70b9&#xff0c;\u6216\u8005 switch over \u5c06\u6c38\u8fdc\u4e0d\u4f1a\u8fd4\u56de\u5230\u4e4b\u524d\u7684\u72b6\u6001 &#xff08;attached state&#xff09; \u5728\u9ed8\u8ba4\u8bbe\u7f6e\u4e2d\u81ea\u52a8\u663e\u793a\u3002\u4f7f\u7528 -D \u9009\u9879\u91cd\u542f Pgpool-II \u6216\u8fd0\u884c pcp_attach_node \u4f1a\u4f7f\u5176\u518d\u6b21\u8fdb\u5165 attached \u72b6\u6001\u3002\u5b83 \u5efa\u8bae\u5728\u6267\u884c\u6b64\u64cd\u4f5c\u4e4b\u524d\u786e\u8ba4 SHOW POOL NODES \u7684 replication_state \u662f \u201cstreaming\u201d\u3002\u8fd9 state \u8868\u793a\u5907\u7528\u670d\u52a1\u5668\u5df2\u6b63\u786e\u8fde\u63a5\u5230 \u901a\u8fc7\u6d41\u590d\u5236\u7684\u4e3b\u670d\u52a1\u5668\u548c\u4e24\u4e2a\u6570\u636e\u5e93\u90fd\u662f \u540c\u6b65\u3002<\/p>\n<p>\u4ece 4.1 \u5f00\u59cb&#xff0c;\u65b0\u53c2\u6570auto_failback\u53ef\u4ee5\u662f \u8fc7\u53bb\u4f1a\u81ea\u52a8\u6267\u884c\u4e0a\u8ff0\u64cd\u4f5c\u3002\u6709\u5173\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u9605 auto_failback\u3002<\/p>\n<h4>1.10.1. \u6545\u969c\u8f6c\u79fb\u548c\u6545\u969c\u6062\u590d\u8bbe\u7f6e<\/h4>\n<p>failover_command &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5728 PostgreSQL \u540e\u7aef\u8282\u70b9\u5206\u79bb\u65f6\u8981\u8fd0\u884c\u7684\u7528\u6237\u547d\u4ee4\u3002Pgpool-II \u66ff\u6362\u4e86\u4ee5\u4e0b\u7279\u6b8a\u5b57\u7b26 \u66ff\u6362\u4e3a\u540e\u7aef\u7279\u5b9a\u4fe1\u606f\u3002<\/p>\n<p>\u8868 1-8.failover \u547d\u4ee4\u9009\u9879<\/p>\n<table>\n<tr>\u7279\u6b8a\u5b57\u7b26\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>%d<\/td>\n<td>\u5df2\u5206\u79bb\u8282\u70b9\u7684\u6570\u636e\u5e93\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%h<\/td>\n<td>\u5206\u79bb\u8282\u70b9\u7684\u4e3b\u673a\u540d<\/td>\n<\/tr>\n<tr>\n<td>%p<\/td>\n<td>\u5df2\u5206\u79bb\u8282\u70b9\u7684\u7aef\u53e3\u53f7<\/td>\n<\/tr>\n<tr>\n<td>%D<\/td>\n<td>\u5df2\u5206\u79bb\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>%m<\/td>\n<td>\u65b0\u7684\u4e3b\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%H<\/td>\n<td>\u65b0\u4e3b\u8282\u70b9\u7684\u4e3b\u673a\u540d<\/td>\n<\/tr>\n<tr>\n<td>%M<\/td>\n<td>\u65e7\u7684\u4e3b\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%P<\/td>\n<td>\u65e7\u7684\u4e3b\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%r<\/td>\n<td>\u65b0\u4e3b\u8282\u70b9\u7684\u7aef\u53e3\u53f7<\/td>\n<\/tr>\n<tr>\n<td>%R<\/td>\n<td>\u65b0\u4e3b\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>%N<\/td>\n<td>\u65e7\u4e3b\u8282\u70b9\u7684\u4e3b\u673a\u540d&#xff08;Pgpool-II 4.1 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>%S<\/td>\n<td>\u65e7\u4e3b\u8282\u70b9\u7684\u7aef\u53e3\u53f7 &#xff08;Pgpool-II 4.1 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>%%<\/td>\n<td>\u2018%\u2019 \u5b57\u7b26<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6ce8\u610f \u6ce8\u610f&#xff1a; \u201c\u4e3b\u8282\u70b9\u201d\u662f\u6307\u5177\u6709 \u201c\u6700\u5e74\u8f7b&#xff08;\u6216\u6700\u5c0f&#xff09;\u8282\u70b9 ID\u201d \u6570\u636e\u5e93\u8282\u70b9\u3002\u5728\u6d41\u5f0f\u5904\u7406\u4e2d \u590d\u5236\u6a21\u5f0f&#xff0c;\u8fd9\u53ef\u80fd\u4e0d\u540c\u4e8e \u4e3b\u8282\u70b9\u3002\u5728\u8868 1-8 \u4e2d&#xff0c; %m \u662f\u9009\u5b9a\u7684\u65b0\u4e3b\u8282\u70b9 \u7531 Pgpool-II \u63d0\u4f9b\u3002\u5b83\u662f\u8282\u70b9 \u88ab\u5206\u914d\u4e86\u6700\u5c0f&#xff08;\u6700\u5c0f&#xff09;\u7684\u8282\u70b9 ID&#xff0c;\u5373 \u6d3b \u7740\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u60a8\u6709 3 \u4e2a\u8282\u70b9&#xff0c;\u5373\u8282\u70b9 0\u30011\u3001 2. \u5047\u8bbe\u8282\u70b9 1 \u662f\u4e3b\u8282\u70b9&#xff0c;\u5e76\u4e14\u6240\u6709\u8282\u70b9\u90fd\u8fd0\u884c\u72b6\u51b5\u826f\u597d &#xff08;\u65e0\u5b95\u673a\u8282\u70b9&#xff09;\u3002\u5982\u679c\u8282\u70b9 1 \u53d1\u751f\u6545\u969c&#xff0c;\u5219failover_command \u4f7f\u7528 %m &#061; 0 \u8c03\u7528\u3002\u5e76\u4e14&#xff0c;\u5982\u679c\u6240\u6709\u5907\u7528\u8282\u70b9\u90fd\u5df2\u5173\u95ed&#xff0c;\u5e76\u4e14\u4e3b\u8282\u70b9 \u53d1\u751f\u6545\u969c\u5207\u6362&#xff0c;failover_command\u4f7f\u7528 %m &#061; -1 \u548c %H&#xff0c;%R&#xff0c;$r &#061; \u201c\u201d \u8c03\u7528\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u6267\u884c\u6545\u969c\u8f6c\u79fb\u65f6&#xff0c; \u57fa\u672c\u4e0a Pgpool-II \u6740\u6b7b\u4e86\u6240\u6709 \u5176\u5b50\u8fdb\u7a0b&#xff0c;\u8be5\u5b50\u8fdb\u7a0b\u5c06\u53cd\u8fc7\u6765\u7ec8\u6b62\u6240\u6709 \u5230 Pgpool-II \u7684 active sessions \u6765\u8bbf\u95ee\u3002\u4e4b\u540e Pgpool-II \u8c03\u7528 failover_command \u5e76\u5728\u547d\u4ee4\u5b8c\u6210\u540e Pgpool-II \u542f\u52a8\u65b0\u7684\u5b50\u8fdb\u7a0b \u8fd9\u5c06\u4f7f\u5b83\u518d\u6b21\u51c6\u5907\u597d\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5\u3002<\/p>\n<p>\u7136\u800c&#xff0c;\u4ece Pgpool-II 3.6 \u5f00\u59cb&#xff0c;\u5728 steaming \u590d\u5236\u6a21\u5f0f&#xff0c;\u5ba2\u6237\u7aef\u4f1a\u8bdd\u5c06\u4e0d\u4f1a \u5982\u679c\u4f1a\u8bdd \u4e0d\u4f7f\u7528\u5931\u8d25\u7684\u5907\u7528\u670d\u52a1\u5668\u3002\u8bf7\u6ce8\u610f&#xff0c;\u5982\u679c \u67e5\u8be2&#xff0c;\u5219\u4f1a\u8bdd\u5c06\u4e3a \u65ad\u5f00\u3002\u5982\u679c\u4e3b\u670d\u52a1\u5668\u5b95\u673a&#xff0c;\u5219\u4ecd\u7136\u4f1a \u4f1a\u8bdd\u5c06\u65ad\u5f00\u8fde\u63a5\u3002\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u8d85\u65f6\u60c5\u51b5\u5c06 \u4e5f\u4f1a\u5bfc\u81f4 Full session \u65ad\u5f00\u8fde\u63a5\u3002\u5176\u4ed6\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5 \u9519\u8bef&#xff0c;\u5305\u62ec Retry over Case \u4e0d\u4f1a\u89e6\u53d1\u5b8c\u6574\u4f1a\u8bdd \u65ad\u5f00\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u60a8\u53ef\u4ee5\u8fd0\u884c psql&#xff08;\u6216\u4efb\u4f55\u547d\u4ee4&#xff09; \u5728 backend \u4e2d\u68c0\u7d22 \u811a\u672c&#xff0c;\u4f46\u4f60\u4e0d\u80fd\u5bf9 Pgpool-II \u672c\u8eab\u8fd0\u884c psql&#xff0c;\u56e0\u4e3a \u811a\u672c\u662f\u4ece Pgpool-II \u8c03\u7528\u7684&#xff0c;\u5b83\u9700\u8981\u8fd0\u884c \u800c Pgpool-II \u6b63\u5728\u5f00\u53d1 \u6545\u969c\u8f6c\u79fb\u3002<\/p>\n<p>\u53ef\u4ee5\u627e\u5230\u5b8c\u6574\u7684 failover_command \u793a\u4f8b \u5728 Section 8.2 \u4e2d\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>failback_command &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5f53 PostgreSQL \u540e\u7aef\u8282\u70b9\u8fde\u63a5\u5230 Pgpool-II \u65f6\u8981\u8fd0\u884c\u7684\u7528\u6237\u547d\u4ee4\u3002Pgpool-II \u5c06\u4ee5\u4e0b\u7279\u6b8a\u5b57\u7b26\u66ff\u6362\u4e3a\u540e\u7aef\u7279\u5b9a\u4fe1\u606f\u3002 \u5728\u6267\u884c\u547d\u4ee4\u4e4b\u524d\u3002<\/p>\n<p>\u8868 1-9.failback \u547d\u4ee4\u9009\u9879<\/p>\n<table>\n<tr>\u7279\u6b8a\u5b57\u7b26\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>%d<\/td>\n<td>\u9644\u52a0\u8282\u70b9\u7684\u6570\u636e\u5e93\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%h<\/td>\n<td>\u9644\u52a0\u8282\u70b9\u7684\u4e3b\u673a\u540d<\/td>\n<\/tr>\n<tr>\n<td>%p<\/td>\n<td>\u9644\u52a0\u8282\u70b9\u7684\u7aef\u53e3\u53f7<\/td>\n<\/tr>\n<tr>\n<td>%D<\/td>\n<td>\u9644\u52a0\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>%m<\/td>\n<td>\u65b0\u7684\u4e3b\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%H<\/td>\n<td>\u65b0\u4e3b\u8282\u70b9\u7684\u4e3b\u673a\u540d<\/td>\n<\/tr>\n<tr>\n<td>%M<\/td>\n<td>\u65e7\u7684\u4e3b\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%P<\/td>\n<td>\u65e7\u7684\u4e3b\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%r<\/td>\n<td>\u65b0\u4e3b\u8282\u70b9\u7684\u7aef\u53e3\u53f7<\/td>\n<\/tr>\n<tr>\n<td>%R<\/td>\n<td>\u65b0\u4e3b\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>%N<\/td>\n<td>\u65e7\u4e3b\u8282\u70b9\u7684\u4e3b\u673a\u540d&#xff08;Pgpool-II 4.1 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>%S<\/td>\n<td>\u65e7\u4e3b\u8282\u70b9\u7684\u7aef\u53e3\u53f7 &#xff08;Pgpool-II 4.1 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>%%<\/td>\n<td>\u2018%\u2019 \u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\u6ce8\u610f&#xff1a; \u60a8\u53ef\u4ee5\u8fd0\u884c psql&#xff08;\u6216\u4efb\u4f55\u547d\u4ee4&#xff09; \u5728 backend \u4e2d\u68c0\u7d22 \u811a\u672c&#xff0c;\u4f46\u4f60\u4e0d\u80fd\u5bf9 Pgpool-II \u672c\u8eab\u8fd0\u884c psql&#xff0c;\u56e0\u4e3a \u811a\u672c\u662f\u4ece Pgpool-II \u8c03\u7528\u7684&#xff0c;\u5b83\u9700\u8981\u8fd0\u884c \u800c Pgpool-II \u6b63\u5728\u5f00\u53d1 \u6545\u969c\u56de\u590d\u3002<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>follow_primary_command &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u6545\u969c\u8f6c\u79fb\u540e\u5728 \u4e3b\u8282\u70b9\u6545\u969c\u8f6c\u79fb\u3002\u5728\u5907\u7528\u8282\u70b9\u6545\u969c\u8f6c\u79fb\u7684\u60c5\u51b5\u4e0b&#xff0c; \u547d\u4ee4\u3002\u5982\u679c \u8282\u70b9\u63d0\u5347\u8bf7\u6c42\u7531pcp_promote_node\u547d\u4ee4\u53d1\u51fa\u3002\u8fd9\u4ec5\u9002\u7528\u4e8e \u6d41\u5f0f\u590d\u5236\u6a21\u5f0f\u3002<\/p>\n<p>\u7531\u4e8e\u547d\u4ee4\u662f\u5728 fork \u7684\u5b50\u8fdb\u7a0b\u4e2d\u6267\u884c\u7684 \u6545\u969c\u8f6c\u79fb\u540e\u88ab Pgpool-II \u5173\u95ed \u5df2\u5b8c\u6210&#xff0c;\u5219\u6267\u884c follow primary \u547d\u4ee4\u4e0d\u4f1a \u963b\u6b62\u670d\u52a1 Pgpool-II \u7684\u3002\u8fd9\u662f\u4e00\u4e2a\u522b\u540d \u4ee3\u7801\u6765\u8bf4\u660e\u547d\u4ee4\u7684\u6267\u884c\u65b9\u5f0f&#xff1a;<\/p>\n<p>for each backend node<br \/>\n{<br \/>\n    if (the node is not the new primary)<br \/>\n        set down node status to shared memory status<br \/>\n        memorize that follow primary command is needed to execute<br \/>\n}<br \/>\nif (we need to executed follow primary command)<br \/>\n{<br \/>\n    fork a child process<br \/>\n    (within the child process)<\/p>\n<p>    for each backend node<br \/>\n    {<br \/>\n        if (the node status in shared memory is down)<br \/>\n            execute follow primary command<br \/>\n    }<br \/>\n}<\/p>\n<p>Pgpool-II \u66ff\u6362\u4e86\u4ee5\u4e0b\u7279\u6b8a\u5b57\u7b26 \u66ff\u6362\u4e3a\u540e\u7aef\u7279\u5b9a\u4fe1\u606f\u3002<\/p>\n<p>\u8868 1-10.follow primary \u547d\u4ee4\u9009\u9879<\/p>\n<table>\n<tr>\u7279\u6b8a\u5b57\u7b26\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>%d<\/td>\n<td>\u5df2\u5206\u79bb\u8282\u70b9\u7684\u6570\u636e\u5e93\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%h<\/td>\n<td>\u5206\u79bb\u8282\u70b9\u7684\u4e3b\u673a\u540d<\/td>\n<\/tr>\n<tr>\n<td>%p<\/td>\n<td>\u5df2\u5206\u79bb\u8282\u70b9\u7684\u7aef\u53e3\u53f7<\/td>\n<\/tr>\n<tr>\n<td>%D<\/td>\n<td>\u5df2\u5206\u79bb\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>%m<\/td>\n<td>\u65b0\u7684\u4e3b\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%H<\/td>\n<td>\u65b0\u4e3b\u8282\u70b9\u7684\u4e3b\u673a\u540d<\/td>\n<\/tr>\n<tr>\n<td>%M<\/td>\n<td>\u65e7\u7684\u4e3b\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%P<\/td>\n<td>\u65e7\u7684\u4e3b\u8282\u70b9 ID<\/td>\n<\/tr>\n<tr>\n<td>%r<\/td>\n<td>\u65b0\u4e3b\u8282\u70b9\u7684\u7aef\u53e3\u53f7<\/td>\n<\/tr>\n<tr>\n<td>%R<\/td>\n<td>\u65b0\u4e3b\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>%N<\/td>\n<td>\u65e7\u4e3b\u8282\u70b9\u7684\u4e3b\u673a\u540d&#xff08;Pgpool-II 4.1 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>%S<\/td>\n<td>\u65e7\u4e3b\u8282\u70b9\u7684\u7aef\u53e3\u53f7 &#xff08;Pgpool-II 4.1 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>%%<\/td>\n<td>\u2018%\u2019 \u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\u6ce8\u610f&#xff1a; \u5982\u679c follow_primary_command \u4e0d\u4e3a\u7a7a&#xff0c;\u5219\u5728\u6545\u969c\u8f6c\u79fb\u540e \u5728\u4e3b\u8282\u70b9\u4e0a\u4ee5\u6d41\u5f0f\u590d\u5236\u7684\u539f\u751f\u590d\u5236\u6a21\u5f0f\u5b8c\u6210&#xff0c;Pgpool-II \u4f7f\u9664\u65b0\u4e3b\u8282\u70b9\u4e4b\u5916\u7684\u6240\u6709\u8282\u70b9\u9000\u5316 \u5e76\u542f\u52a8\u65b0\u7684\u5b50\u8fdb\u7a0b\u4ee5\u518d\u6b21\u51c6\u5907\u597d\u63a5\u53d7\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002 \u5728\u6b64\u4e4b\u540e&#xff0c;Pgpool-II \u6267\u884c\u914d\u7f6e\u7684\u547d\u4ee4 \u5728 follow_primary_command \u4e2d\u4e3a\u6bcf\u4e2a\u9000\u5316\u7684\u540e\u7aef\u8282\u70b9\u3002<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u901a\u5e38follow_primary_command\u547d\u4ee4 \u7528\u4e8e\u901a\u8fc7\u8c03\u7528 pcp_recovery_node \u547d\u4ee4\u3002\u5728 follow_primary_command&#xff0c;\u5b83\u662f \u5efa\u8bae\u68c0\u67e5\u662f\u5426 \u76ee\u6807 PostgreSQL \u8282\u70b9\u6b63\u5728\u8fd0\u884c \u6216\u8005\u4e0d\u4f7f\u7528 pg_ctl\u56e0\u4e3a\u5df2\u7ecf\u505c\u6b62\u7684\u8282\u70b9\u901a\u5e38\u6709\u4e00\u4e2a \u505c\u6b62\u7684\u539f\u56e0&#xff1a;\u4f8b\u5982&#xff0c;\u5b83\u88ab\u786c\u4ef6\u7834\u574f \u95ee\u9898\u6216\u7ba1\u7406\u5458\u6b63\u5728\u7ef4\u62a4\u8282\u70b9\u3002\u5982\u679c node \u5df2\u505c\u6b62&#xff0c;\u8bf7\u8df3\u8fc7\u8be5\u8282\u70b9\u3002\u5982\u679c\u8282\u70b9\u6b63\u5728\u8fd0\u884c&#xff0c;\u5219\u505c\u6b62 \u9996\u5148\u662f\u8282\u70b9&#xff0c;\u7136\u540e\u6062\u590d\u5b83\u3002 \u867d\u7136\u53ef\u4ee5\u76f4\u63a5\u6062\u590d \u6267\u884c pg_basebackup \u6216\u5176\u4ed6\u547d\u4ee4 \u60a8\u9700\u8981 pcp_recovery_node \u800c\u4e0d\u662f \u6267\u884c pcp_attach_node \u6ce8\u610f Pgpool-II&#xff0c;\u5907\u7528 \u670d\u52a1\u5668\u5df2\u51c6\u5907\u5c31\u7eea&#xff0c;\u53ef\u4f9b\u4f7f\u7528\u3002\u5426\u5219&#xff0c;\u5907\u7528\u670d\u52a1\u5668\u5c06\u4fdd\u6301\u4e3a down \u72b6\u6001\u3002&#xff08;\u7531\u4e8e pcp_recovery_node \u5185\u90e8\u6267\u884c pcp_attach_node&#xff0c;\u56e0\u6b64\u60a8\u4e0d\u4f1a \u9700\u8981\u5728 pcp_attach_node \u4e4b\u540e\u6267\u884c \u6062\u590d\u3002 \u5b8c\u6574\u7684 follow_primary_command \u793a\u4f8b\u53ef\u4ee5 \u53ef\u5728 Section 8.2 \u4e2d\u627e\u5230\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>failover_on_backend_shutdown &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;Pgpool-II \u68c0\u6d4b\u5230\u4e00\u4e2a \u901a\u8fc7\u68c0\u67e5\u7279\u5b9a\u9519\u8bef\u4ee3\u7801 57P01 \u548c 57P02 \u4e0a\u7684 backend shutdown \u4e8b\u4ef6 \u5728\u5ba2\u6237\u7aef\u548c\u540e\u7aef\u4e4b\u95f4\u5efa\u7acb\u7684\u4f1a\u8bdd\u3002\u5982\u679c\u5b83 \u68c0\u6d4b\u5230\u8fd9\u4e9b\u9519\u8bef\u4ee3\u7801&#xff0c;\u5219\u4f1a\u5728\u8be5\u8282\u70b9\u4e0a\u89e6\u53d1\u6545\u969c\u8f6c\u79fb\u3002 \u5f53\u8bbe\u7f6e\u4e3a off \u65f6&#xff0c;Pgpool-II \u53ea\u62a5\u544a\u4e00\u4e2a\u9519\u8bef\u5e76\u5728\u51fa\u73b0\u9519\u8bef\u65f6\u65ad\u5f00\u4f1a\u8bdd \u9519\u8bef\u3002\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u5ba2\u6237\u7aef\u8fde\u63a5&#xff0c;Pgpool-II \u5c06\u4e0d\u4f1a\u68c0\u6d4b\u5230\u8be5\u4e8b\u4ef6 \u5373\u4f7f\u53c2\u6570\u4e3a on\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u5728\u6d41\u5f0f\u590d\u5236\u6a21\u5f0f\u4e0b&#xff0c;\u5173\u95ed \u7684 PostgreSQL \u4e0d\u4f1a\u89e6\u53d1 \u6545\u969c\u8f6c\u79fb&#xff08;\u5982\u679c\u8282\u70b9\u662f\u5907\u7528\u8282\u70b9\u4e14\u4e0d\u662f\u8d1f\u8f7d&#xff09; \u5e73\u8861\u8282\u70b9\u5076\u6570 \u5982\u679c failover_on_backend_shutdown \u5904\u4e8e\u6253\u5f00\u72b6\u6001\u3002\u5728 order \u67e5\u627e\u54ea\u4e2a\u8282\u70b9\u662f\u8d1f\u8f7d\u5747\u8861\u8282\u70b9&#xff0c;\u5219\u53ef\u4ee5 \u4f7f\u7528 SHOW POOL NODES \u6216 pcp_proc_info\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f&#xff0c;57P01 \u4e0d\u4ec5\u901a\u8fc7 shutdown \u4e8b\u4ef6&#xff0c;\u4f46\u4e5f\u4f1a\u5728\u540e\u7aef\u5f53\u524d connected \u88ab \u6216 SIGTERM \u4fe1\u53f7\u6740\u6b7b\u3002\u8fd9\u5f88\u70e6\u4eba&#xff0c;\u56e0\u4e3a\u5b83\u4f1a\u5bfc\u81f4 \u4e0d\u9700\u8981\u7684\u6545\u969c\u8f6c\u79fb\u3002\u4e3a\u907f\u514d\u8fd9\u79cd\u60c5\u51b5&#xff0c;\u8bf7\u5173\u95ed\u6b64\u53c2\u6570\u3002pg_terminate_backend<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5efa\u8bae\u5f00\u542f\u540e\u7aef\u5065\u5eb7\u68c0\u67e5 &#xff08;\u53c2\u89c1\u7b2c 1.9 \u8282&#xff09; \u5f53 failover_on_backend_shutdown \u8bbe\u7f6e\u4e3a OFF \u65f6\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ef\u7528 \u5728 Pgpool-II 4.3 \u6216\u66f4\u9ad8\u7248\u672c\u4e2d\u3002\u8fd9 \u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<p>failover_on_backend_error &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;Pgpool-II \u4f1a\u8003\u8651\u8bfb \/ \u5199 \u9519\u8bef&#xff0c;\u56e0\u4e3a\u540e\u7aef\u8282\u70b9\u5931\u8d25\u5e76\u89e6\u53d1 \u65ad\u5f00\u8fde\u63a5\u5f53\u524d\u4f1a\u8bdd\u540e&#xff0c;\u8be5\u8282\u70b9\u4e0a\u7684\u6545\u969c\u8f6c\u79fb\u3002 \u5f53\u8bbe\u7f6e\u4e3a off \u65f6&#xff0c;Pgpool-II \u53ea\u62a5\u544a\u4e00\u4e2a\u9519\u8bef \u5e76\u5728\u51fa\u73b0\u6b64\u7c7b\u9519\u8bef\u65f6\u65ad\u5f00\u4f1a\u8bdd\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5efa\u8bae\u5f00\u542f\u540e\u7aef\u5065\u5eb7\u68c0\u67e5 &#xff08;\u53c2\u89c1\u7b2c 1.9 \u8282&#xff09; \u5f53 failover_on_backend_error \u8bbe\u7f6e\u4e3a OFF \u65f6\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5728 Pgpool-II v4.0 \u4e4b\u524d&#xff0c; \u6b64\u914d\u7f6e\u53c2\u6570\u540d\u79f0\u4e3a fail_over_on_backend_error\u3002<\/p>\n<p>search_primary_node_timeout &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u641c\u7d22 \u53d1\u751f\u6545\u969c\u5207\u6362\u573a\u666f\u65f6\u7684\u4e3b\u8282\u70b9\u3002Pgpool-II \u5c06\u653e\u5f03\u5bfb\u627e primary \u8282\u70b9&#xff08;\u5982\u679c\u5728\u6b64\u914d\u7f6e\u7684\u65f6\u95f4\u5185\u672a\u627e\u5230&#xff09;\u3002 \u9ed8\u8ba4\u503c\u4e3a 300&#xff0c;\u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a 0 \u8868\u793a\u6c38\u8fdc\u5c1d\u8bd5\u3002<\/p>\n<p>\u8be5\u53c2\u6570\u4ec5\u9002\u7528\u4e8e\u6d41\u5f0f\u590d\u5236\u6a21\u5f0f\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>detach_false_primary &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5982\u679c\u8bbe\u7f6e\u4e3a on&#xff0c;\u5219\u5206\u79bb false \u4e3b\u8282\u70b9\u3002\u9ed8\u8ba4\u503c\u4e3a \u5173\u95ed\u3002\u6b64\u53c2\u6570\u4ec5\u5728\u6d41\u5f0f\u590d\u5236\u4e2d\u6709\u6548 \u6a21\u5f0f&#xff0c;\u5bf9\u4e8e PostgreSQL 9.6 \u6216 after since this feature \u4f7f\u7528\u3002 \u5982\u679c PostgreSQL 9.5.x \u6216\u66f4\u65e9\u7248\u672c version \u65f6&#xff0c;\u4e0d\u4f1a\u5f15\u53d1\u4efb\u4f55\u9519\u8bef&#xff0c;\u53ea\u662f feature \u662f \u5ffd\u89c6\u3002pg_stat_wal_receiver<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u4e3b\u8282\u70b9&#xff0c;\u5219\u4e0d\u4f1a\u6267\u884c\u68c0\u67e5\u3002<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u5907\u7528\u8282\u70b9&#xff0c;\u5e76\u4e14\u53ea\u6709\u4e00\u4e2a\u4e3b\u8282\u70b9 \u8282\u70b9&#xff0c;\u5219\u4e0d\u4f1a\u6267\u884c\u4efb\u4f55\u68c0\u67e5\u3002<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u5907\u7528\u8282\u70b9&#xff0c;\u5e76\u4e14\u6709\u591a\u4e2a\u4e3b\u8282\u70b9 nodes \u4e2d&#xff0c;\u4fdd\u7559\u5177\u6709\u6700\u5e74\u8f7b\u8282\u70b9\u7684\u4e3b\u8282\u70b9 id \u5e76\u5206\u79bb\u5176\u4f59\u4e3b\u8282\u70b9\u3002<\/p>\n<p>\u5982\u679c\u6709\u4e00\u4e2a\u6216\u591a\u4e2a\u4e3b\u6570\u636e\u5e93\u548c\u4e00\u4e2a\u6216\u591a\u4e2a\u5907\u7528\u6570\u636e\u5e93&#xff0c; \u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u68c0\u67e5\u4e3b\u8282\u70b9\u548c\u5907\u7528\u8282\u70b9\u4e4b\u95f4\u7684\u8fde\u63a5 \u5982\u679c PostgreSQL 9.6 \u6216\u66f4\u9ad8\u7248\u672c&#xff0c;\u5219\u4f7f\u7528 USING \u3002\u5728 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u5982\u679c\u4e3b\u8282\u70b9\u8fde\u63a5\u5230\u6240\u6709\u5907\u7528\u8282\u70b9&#xff0c; \u4e3b\u6570\u636e\u5e93\u88ab\u89c6\u4e3a \u201ctrue\u201d \u4e3b\u6570\u636e\u5e93\u3002\u5176\u4ed6\u521d\u9009 \u88ab\u89c6\u4e3a \u201cfalse\u201d primary&#xff0c;\u800c false primary \u5c06 \u5982\u679c detach_false_primary \u4e3a \u771f\u3002\u5982\u679c\u672a\u627e\u5230 \u201ctrue\u201d primary&#xff0c;\u5219\u4e0d\u4f1a\u53d1\u751f\u4efb\u4f55\u4e8b\u60c5\u3002pg_stat_wal_receiver<\/p>\n<p>\u5f53 Pgpool-II \u542f\u52a8\u65f6&#xff0c; False Primary \u7684\u68c0\u67e5\u4ec5\u5728 Pgpool-II \u4e3b \u8fc7\u7a0b\u3002\u5982\u679c sr_check_period \u66f4\u5927 \u5c0f\u4e8e 0&#xff0c;\u5219\u5c06\u5728 \u6d41\u590d\u5236\u5ef6\u8fdf\u68c0\u67e5\u7684\u76f8\u540c\u65f6\u95f4\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; sr_check_user\u5fc5\u987b \u662f PostgreSQL \u8d85\u7ea7\u7528\u6237\u6216 \u5728 pg_monitor \u7ec4\u4e2d\u4f7f\u7528\u6b64\u529f\u80fd\u3002\u81ea \u5728 pg_monitor \u4e2d\u5236\u4f5csr_check_user \u7ec4&#xff0c;\u6267\u884c\u4ee5\u4e0b SQL \u547d\u4ee4 \u7531 PostgreSQL \u8d85\u7ea7\u7528\u6237 &#xff08;\u5c06 \u201csr_check_user\u201d \u66ff\u6362\u4e3a\u8bbe\u7f6e sr_check_user&#xff09;&#xff1a;<\/p>\n<p>   GRANT pg_monitor TO sr_check_user;<\/p>\n<p>\u5bf9\u4e8e PostgreSQL 9.6&#xff0c;\u6709 \u65e0pg_monitor\u7ec4 \u800c\u4e14sr_check_user\u5fc5\u987b \u6210\u4e3a PostgreSQL \u8d85\u7ea7\u7528\u6237\u3002<\/p>\n<p>\u8be5\u53c2\u6570\u4ec5\u9002\u7528\u4e8e\u6d41\u5f0f\u590d\u5236\u6a21\u5f0f\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<p>\u56fe 1-1\u3002\u68c0\u6d4b\u9519\u8bef\u7684\u539f\u8272<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418150219-6802697bae3fb.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>auto_failback &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;\u5982\u679c\u8282\u70b9\u72b6\u6001 \u5df2\u5173\u95ed&#xff0c;\u4f46\u6d41\u590d\u5236\u6b63\u5e38\u5de5\u4f5c\u3002\u8fd9\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\u5f88\u6709\u7528 \u7531\u4e8e\u4e34\u65f6\u7f51\u7edc\u6545\u969c&#xff0c;\u5907\u7528\u8282\u70b9\u88ab pgpool \u964d\u7ea7\u3002<\/p>\n<p>\u8981\u4f7f\u7528\u6b64\u529f\u80fd&#xff0c;\u6d41\u590d\u5236\u68c0\u67e5&#xff08;\u6709\u5173\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u89c1Section 5.12&#xff09; \u5fc5\u987b\u542f\u7528&#xff0c;\u5e76\u4e14 PostgreSQL 9.1 \u6216\u66f4\u9ad8\u7248\u672c \u4f5c\u4e3a\u540e\u7aef\u8282\u70b9\u662f\u5fc5\u9700\u7684\u3002\u6b64\u529f\u80fd\u5728\u4e3b\u8282\u70b9\u4e0a\u4f7f\u7528\u3002\u81ea\u52a8\u6545\u969c\u56de\u590d\u4ec5\u5728\u5907\u7528\u8282\u70b9\u4e0a\u6267\u884c\u3002 \u8bf7\u6ce8\u610f&#xff0c;\u5982\u679c failback_command \u4e0d\u4e3a\u7a7a&#xff0c;failback_command\u4e5f\u4f1a\u6267\u884c\u3002 \u5982\u679c\u60a8\u8ba1\u5212\u5206\u79bb\u5907\u7528\u8282\u70b9\u8fdb\u884c\u7ef4\u62a4&#xff0c;\u8bf7\u4e8b\u5148\u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a off\u3002 \u5426\u5219&#xff0c;\u53ef\u80fd\u4f1a\u8fdd\u80cc\u60a8\u7684\u610f\u56fe\u91cd\u65b0\u9644\u52a0\u5907\u7528\u8282\u70b9\u3002pg_stat_replication<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a off\u3002\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a;\u4f7f\u7528\u590d\u5236\u69fd\u65f6&#xff0c;auto_failback \u53ef\u80fd\u4e0d\u8d77\u4f5c\u7528\u3002 \u6d41\u590d\u5236\u53ef\u80fd\u4f1a\u505c\u6b62&#xff0c;\u56e0\u4e3a failover_command \u5df2\u6267\u884c\u5e76\u4e14\u590d\u5236\u69fd\u88ab \u547d\u4ee4\u3002<\/p>\n<p>auto_failback_interval &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u81ea\u52a8\u6545\u969c\u56de\u590d\u7684\u6267\u884c\u95f4\u9694\u7684\u6700\u5c0f\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;\u3002 \u5728\u6307\u5b9a\u65f6\u95f4\u8fc7\u53bb\u4e4b\u524d&#xff0c;\u4e0d\u4f1a\u6267\u884c\u4e0b\u4e00\u6b21\u81ea\u52a8\u6545\u969c\u56de\u590d \u5728\u4e0a\u4e00\u4e2a\u81ea\u52a8\u6545\u969c\u6062\u590d\u4e4b\u540e\u3002\u5f53 Pgpool-II \u9891\u7e41\u68c0\u6d4b\u5230 backend down \u4f8b\u5982&#xff0c;\u60a8\u53ef\u4ee5\u907f\u514d\u91cd\u590d \u6545\u969c\u8f6c\u79fb\u548c\u6545\u969c\u56de\u590d&#xff0c;\u65b9\u6cd5\u662f\u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a Greater Enough \u503c\u3002 \u9ed8\u8ba4\u503c\u4e3a 60\u3002\u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a 0 \u8868\u793a\u81ea\u52a8\u6545\u969c\u56de\u590d\u4e0d\u4f1a\u7b49\u5f85\u3002<\/p>\n<h4>1.10.2. \u5728 raw \u6a21\u5f0f\u4e0b\u8fdb\u884c\u6545\u969c\u8f6c\u79fb<\/h4>\n<p>\u5982\u679c\u5b9a\u4e49\u4e86\u591a\u4e2a\u540e\u7aef\u670d\u52a1\u5668&#xff0c;\u5219\u53ef\u4ee5\u5728\u539f\u59cb\u6a21\u5f0f\u4e0b\u6267\u884c\u6545\u969c\u8f6c\u79fb\u3002pgpool-II \u901a\u5e38\u5728\u6b63\u5e38\u64cd\u4f5c\u65f6\u8bbf\u95ee backend_hostname0 \u6307\u5b9a\u7684\u540e\u7aef\u3002\u5982\u679c backend_hostname0 \u7531\u4e8e\u67d0\u79cd\u539f\u56e0\u5931\u8d25&#xff0c;Pgpool-II \u4f1a\u5c1d\u8bd5\u8bbf\u95ee backend_hostname1 \u6307\u5b9a\u7684\u540e\u7aef\u3002\u5982\u679c\u5931\u8d25&#xff0c;Pgpool-II \u4f1a\u5c1d\u8bd5 backend_hostname2\u30013 \u7b49\u3002<\/p>\n<h3>1.11. \u5728\u7ebf\u6062\u590d<\/h3>\n<p>Pgpool-II \u53ef\u4ee5\u540c\u6b65\u6570\u636e\u5e93 \u8282\u70b9\u5e76\u9644\u52a0\u8282\u70b9&#xff0c;\u800c\u65e0\u9700\u505c\u6b62\u670d\u52a1\u3002\u8fd9 \u529f\u80fd\u79f0\u4e3a\u201c\u5728\u7ebf\u6062\u590d\u201d\u3002\u5728\u7ebf \u6062\u590d\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u6267\u884c using pcp_recovery_node \u547d\u4ee4\u3002<\/p>\n<p>\u5bf9\u4e8e\u8054\u673a\u6062\u590d&#xff0c;\u6062\u590d\u76ee\u6807\u8282\u70b9\u5fc5\u987b\u5904\u4e8e\u5206\u79bb\u72b6\u6001 \u5dde\u3002\u8fd9\u610f\u5473\u7740\u8282\u70b9\u5fc5\u987b\u7531 pcp_detach_node \u624b\u52a8\u5206\u79bb\u6216\u81ea\u52a8\u5206\u79bb \u7531 Pgpool-II \u4f5c\u4e3a \u6545\u969c\u8f6c\u79fb\u3002<\/p>\n<p>\u5982\u679c\u8981\u6dfb\u52a0 PostgreSQL \u670d\u52a1\u5668 node \u4e2d&#xff0c;\u5728\u6dfb\u52a0 pgpool.conf \u53ca\u5176\u5173\u8054\u7684 backend_hostname \u53c2\u6570\u3002\u8fd9\u5c06\u6ce8\u518c\u65b0\u670d\u52a1\u5668 \u4f5c\u4e3a\u5206\u79bb\u7684\u540e\u7aef\u53d1\u9001\u5230 Pgpool-II \u8282\u70b9&#xff0c;\u7136\u540e\u6267\u884cpcp_recovery_node\u547d\u4ee4 \u670d\u52a1\u5668\u4e3a ADD\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u6062\u590d\u76ee\u6807 PostgreSQL \u670d\u52a1\u5668\u4e0d\u5f97 \u6b63\u5728\u8fd0\u884c\u4ee5\u6267\u884c\u8054\u673a\u6062\u590d\u3002\u5982\u679c \u76ee\u6807 PostgreSQL \u670d\u52a1\u5668\u5df2\u542f\u52a8&#xff0c; \u5728\u5f00\u59cb\u5728\u7ebf\u6062\u590d\u4e4b\u524d&#xff0c;\u60a8\u5fc5\u987b\u5c06\u5176\u5173\u95ed\u3002<\/p>\n<p>\u5728\u7ebf\u6062\u590d\u5206\u4e24\u4e2a\u9636\u6bb5\u6267\u884c\u3002\u7b2c\u4e00\u9636\u6bb5\u662f \u79f0\u4e3a\u201c\u7b2c\u4e00\u9636\u6bb5\u201d&#xff0c;\u7b2c\u4e8c\u9636\u6bb5\u79f0\u4e3a\u201c\u7b2c\u4e8c\u9636\u6bb5\u201d \u9636\u6bb5\u201d\u3002\u53ea\u6709\u672c\u673a\u590d\u5236\u6a21\u5f0f\u548c\u5feb\u7167\u9694\u79bb\u6a21\u5f0f\u9700\u8981\u7b2c\u4e8c\u4e2a\u9636\u6bb5\u3002 \u5bf9\u4e8e\u5176\u4ed6\u6a21\u5f0f&#xff08;\u5305\u62ec\u6d41\u5f0f\u590d\u5236\u6a21\u5f0f&#xff09;&#xff0c;\u7b2c\u4e8c\u4e2a stage \u672a\u6267\u884c&#xff0c;\u5e76\u4e14\u60a8\u4e0d\u9700\u8981\u4e3a recovery_2nd_stage_command \u4e2d\u7684\u821e\u53f0\u3002\u5373\u60a8\u53ef\u4ee5\u5b89\u5168\u5730\u79bb\u5f00 it \u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u5728\u7b2c\u4e00\u9636\u6bb5&#xff0c;\u5907\u7528&#xff08;\u526f\u672c&#xff09;\u8282\u70b9\u662f\u4f7f\u7528 PostgreSQL \u7684pg_basebackup\u521b\u5efa\u7684&#xff0c;\u4f8b\u5982&#xff0c;\u4ece \u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u3002\u5728\u6267\u884c\u7b2c\u4e00\u9636\u6bb5\u65f6\u66f4\u65b0\u6570\u636e \u5c06\u767b\u5f55\u5230 PostgreSQL \u7684 \u4e8b\u52a1\u65e5\u5fd7\u3002<\/p>\n<p>\u5728\u7b2c\u4e8c\u9636\u6bb5&#xff0c;\u76ee\u6807\u6062\u590d\u8282\u70b9\u542f\u52a8\u3002\u8fd9 Transaction Log \u5c06\u88ab\u91cd\u653e&#xff0c;\u526f\u672c\u8282\u70b9\u5c06\u88ab \u4e0e Master \u8282\u70b9\u5b8c\u5168\u540c\u6b65\u3002<\/p>\n<p>\u60a8\u9700\u8981\u4e3a\u6bcf\u4e2a\u9636\u6bb5\u63d0\u4f9b\u811a\u672c\u3002\u5b8c\u6210\u793a\u4f8b\u811a\u672c \u5728 \/etc\/pgpool-II\/recovery_1st_stage.sample \u548c \/etc\/pgpool-II\/recovery_2nd_stage.sample \u4e2d\u63d0\u4f9b\u3002 \u4f7f\u7528\u8fd9\u4e9b\u811a\u672c\u7684\u5b89\u88c5\u793a\u4f8b\u53ef\u4ee5\u5728 Section 8.2.7.8 \u4e2d\u627e\u5230\u3002<\/p>\n<p>\u4ec5\u5728\u7b2c\u4e8c\u9636\u6bb5\u5141\u8bb8\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8fde\u63a5 \u800c\u6570\u636e\u53ef\u4ee5\u5728\u7b2c\u4e00\u9636\u6bb5\u66f4\u65b0\u6216\u68c0\u7d22\u3002<\/p>\n<p>Pgpool-II \u5728\u5728\u7ebf\u6062\u590d\u4e2d\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4&#xff1a;<\/p>\n<p>\u68c0\u67e5\u7ad9\u3002<\/p>\n<p>\u6267\u884c\u5728\u7ebf\u6062\u590d\u7684\u7b2c\u4e00\u9636\u6bb5\u3002<\/p>\n<p>\u7b49\u5f85\u6240\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u90fd\u5df2\u65ad\u5f00\u8fde\u63a5&#xff08;\u4ec5\u5728\u672c\u673a\u590d\u5236\u6a21\u5f0f\u548c\u5feb\u7167\u9694\u79bb\u6a21\u5f0f\u4e0b&#xff09;\u3002<\/p>\n<p>CHECKPOINT&#xff08;\u4ec5\u5728\u672c\u673a\u590d\u5236\u6a21\u5f0f\u548c\u5feb\u7167\u9694\u79bb\u6a21\u5f0f\u4e0b&#xff09;\u3002<\/p>\n<p>\u6267\u884c\u8054\u673a\u6062\u590d\u7684\u7b2c\u4e8c\u9636\u6bb5&#xff08;\u4ec5\u5728\u672c\u673a\u590d\u5236\u6a21\u5f0f\u548c\u5feb\u7167\u9694\u79bb\u6a21\u5f0f\u4e0b&#xff09;\u3002<\/p>\n<p>\u542f\u52a8 postmaster &#xff08;\u6267\u884cpgpool_remote_start)<\/p>\n<p>pgpool_remote_start\u662f\u542f\u52a8 recovery target \u7684 PostgreSQL \u8282\u70b9\u7684\u811a\u672c\u3002pgpool_remote_start \u63a5\u6536\u4ee5\u4e0b 2 \u4e2a\u53c2\u6570&#xff1a;<\/p>\n<p>\u8981\u6062\u590d\u7684\u540e\u7aef\u8282\u70b9\u7684\u4e3b\u673a\u540d\u3002<\/p>\n<p>\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u8def\u5f84\u3002<\/p>\n<p>\u811a\u672c\u793a\u4f8b\u53ef\u4ee5\u5728 Section 8.2.7.8 \u4e2d\u627e\u5230\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u811a\u672c\u8def\u5f84\u548c\u6587\u4ef6\u540d\u662f\u786c\u7f16\u7801\u7684&#xff0c;$PGDATA\/pgpool_remote_start \u5728\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u4e0a\u6267\u884c\u3002<\/p>\n<p>\u8282\u70b9\u9644\u52a0<\/p>\n<p>\u6ce8\u610f&#xff1a; \u672c\u673a\u590d\u5236\u6a21\u5f0f\u548c\u5feb\u7167\u9694\u79bb\u6a21\u5f0f\u4e0b\u7684\u5728\u7ebf\u6062\u590d\u5b58\u5728\u9650\u5236\u3002 \u5982\u679c\u5b89\u88c5\u4e86 Pgpool-II \u672c\u8eab \u5728\u591a\u4e2a\u4e3b\u673a\u4e0a\u4e0d\u542f\u7528 watchdog&#xff0c; \u5728\u7ebf\u6062\u590d\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c&#xff0c; \u56e0\u4e3a Pgpool-II \u5fc5\u987b\u505c\u6b62\u6240\u6709 \u5728\u7ebf\u6062\u590d\u7b2c 2 \u9636\u6bb5\u7684\u5ba2\u6237\u7aef\u3002 \u5982\u679c\u6709\u591a\u4e2a Pgpool-II \u4e3b\u673a&#xff0c; \u4ed6\u4eec\u4e2d\u53ea\u6709\u4e00\u4e2a\u4eba\u4f1a\u6536\u5230 Online Recovery \u547d\u4ee4&#xff0c;\u5e76\u4e14\u4f1a \u963b\u6b62\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002<\/p>\n<p>recovery_user &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u6267\u884c\u8054\u673a\u6062\u590d\u7684 PostgreSQL \u7528\u6237\u540d\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>recovery_password &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5728 recovery_user \u4e2d\u914d\u7f6e\u7684\u7528\u4e8e\u6267\u884c\u8054\u673a\u6062\u590d\u7684 PostgreSQL \u7528\u6237\u540d\u7684\u5bc6\u7801\u3002<\/p>\n<p>\u5982\u679c recovery_password \u4e3a\u7a7a&#xff0c;Pgpool-II \u5c06\u9996\u5148\u5c1d\u8bd5\u4ecepool_passwd\u6587\u4ef6\u4e2d\u83b7\u53d6 recovery_user \u7684\u5bc6\u7801&#xff0c;\u7136\u540e\u518d\u4f7f\u7528\u7a7a\u5bc6\u7801\u3002<\/p>\n<p>\u60a8\u8fd8\u53ef\u4ee5\u5728recovery_password\u5b57\u6bb5\u4e2d\u6307\u5b9a AES256-CBC \u52a0\u5bc6\u5bc6\u7801\u3002 \u8981\u6307\u5b9a AES \u52a0\u5bc6\u5bc6\u7801&#xff0c;\u5bc6\u7801\u5b57\u7b26\u4e32\u5fc5\u987b\u5728\u52a0\u5bc6\u540e\u4ee5 AES \u4e3a\u524d\u7f00&#xff08;\u4f7f\u7528 aes-256-cbc \u7b97\u6cd5&#xff09;\u548c \u7f16\u7801\u4e3a base64\u3002<\/p>\n<p>\u8981\u6307\u5b9a\u672a\u52a0\u5bc6\u7684\u660e\u6587\u5bc6\u7801&#xff0c;\u8bf7\u5728\u5bc6\u7801\u5b57\u7b26\u4e32\u524d\u52a0\u4e0a TEXT\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u60a8\u60f3\u5c06 mypass \u8bbe\u7f6e\u4e3a \u5bc6\u7801&#xff0c;\u5219\u5e94\u5728\u5bc6\u7801\u5b57\u6bb5\u4e2d\u6307\u5b9a TEXTmypass\u3002 \u5728\u6ca1\u6709\u6709\u6548\u524d\u7f00\u7684\u60c5\u51b5\u4e0b&#xff0c;Pgpool-II \u4f1a\u8ba4\u4e3a \u5b57\u7b26\u4e32\u4f5c\u4e3a\u7eaf\u6587\u672c\u5bc6\u7801\u3002<\/p>\n<p>\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 pg_enc \u5b9e\u7528\u7a0b\u5e8f\u521b\u5efa\u683c\u5f0f\u6b63\u786e\u7684 AES \u52a0\u5bc6\u5bc6\u7801\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; Pgpool-II \u9700\u8981\u4e00\u4e2a\u6709\u6548\u7684\u89e3\u5bc6\u5bc6\u94a5&#xff0c;\u4f4d\u4e8e startup \u4ee5\u4f7f\u7528\u52a0\u5bc6\u7684\u5bc6\u7801\u3002 \u6709\u5173\u63d0\u4f9b Pgpool-II \u7684\u89e3\u5bc6\u5bc6\u94a5<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>recovery_1st_stage_command &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u7531 main &#xff08;primary&#xff09; \u8282\u70b9\u5728 \u5728\u7ebf\u6062\u590d\u7684\u7b2c\u4e00\u9636\u6bb5\u3002\u547d\u4ee4\u6587\u4ef6\u5fc5\u987b\u653e\u5728 database cluster \u76ee\u5f55\u3002 \u4f8b\u5982&#xff0c;\u5982\u679c recovery_1st_stage_command &#061; \u2018sync-command\u2019&#xff0c;\u90a3\u4e48 Pgpool-II \u5c06 \u5728 $PGDATA \u76ee\u5f55\u4e2d\u67e5\u627e\u547d\u4ee4\u811a\u672c&#xff0c;\u5e76\u5c06 \u5c1d\u8bd5\u6267\u884c $PGDATA\/sync-command\u3002<\/p>\n<p>recovery_1st_stage_command \u63a5\u6536\u4ee5\u4e0b 7 \u4e2a\u53c2\u6570&#xff1a;<\/p>\n<p>\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u8def\u5f84\u3002<\/p>\n<p>\u8981\u6062\u590d\u7684\u540e\u7aef\u8282\u70b9\u7684\u4e3b\u673a\u540d\u3002<\/p>\n<p>\u8981\u6062\u590d\u7684\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u8def\u5f84\u3002<\/p>\n<p>\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u7684\u7aef\u53e3\u53f7&#xff08;Pgpool-II 3.4 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;\u3002<\/p>\n<p>\u8981\u6062\u590d\u7684\u8282\u70b9\u53f7&#xff08;Pgpool-II 4.0 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/p>\n<p>\u9700\u8981\u6062\u590d\u7684\u7aef\u53e3\u53f7&#xff08;Pgpool-II 4.1 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/p>\n<p>\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u7684\u4e3b\u673a\u540d &#xff08;Pgpool-II 4.3 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/p>\n<p>\u5728\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u7684\u4e3b\u673a\u540d\u88ab \u4f7f\u7528 hostname \u547d\u4ee4\u3002\u8fd9\u57fa\u672c\u4e0a\u662f\u53ef\u4ee5\u7684 \u7531\u4e8e\u811a\u672c\u5728\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u4e0a\u8fd0\u884c \u65e0\u8bba\u5982\u4f55\u3002\u4f46\u662f&#xff0c;\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d&#xff0c;\u83b7\u5f97 by hostname \u547d\u4ee4\u4e0e hostname \u5b9a\u4e49backend_hostname configuration \u53c2\u6570\u3002 \u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u9ebb\u70e6 detach_false_primary&#xff0c;\u56e0\u4e3a\u5b83\u68c0\u67e5 \u4e3b\u8282\u70b9\u548c\u5907\u7528\u8282\u70b9\u4e4b\u95f4\u7684\u8fde\u63a5 \u4f7f\u7528 host \u53c2\u6570 in primary_conninfo\u53c2\u6570\u4e2d&#xff0c;\u5373 \u751f\u6210 \u7531 recovery_1st_stage_command\u3002\u56e0\u6b64 \u5f3a\u70c8\u5efa\u8bae\u4f7f\u7528\u6b64\u53c2\u6570&#xff0c;\u800c\u4e0d\u662f \u4f7f\u7528 hostname \u547d\u4ee4\u83b7\u53d6 \u4e3b\u8282\u70b9\u7684\u4e3b\u673a\u540d \u5728 recovery_1st_stage_command\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; Pgpool-II \u63a5\u53d7\u8fde\u63a5\u548c\u67e5\u8be2 \u6267\u884crecovery_1st_stage\u547d\u4ee4\u65f6&#xff0c; &#xff0c;\u4ee5\u4fbf\u60a8\u53ef\u4ee5\u68c0\u7d22\u548c\u66f4\u65b0\u6570\u636e\u3002<\/p>\n<p>\u8c28\u614e \u4ece PostgreSQL \u7684\u89d2\u5ea6\u6765\u770b&#xff0c;recovery_1st_stage\u547d\u4ee4\u4f5c\u4e3a SQL \u547d\u4ee4\u8fd0\u884c\u3002\u56e0\u6b64recovery_1st_stage\u5982\u679c PostgreSQL \u7684 statement_time_out \u914d\u7f6e\u4e3a \u5c0f\u4e8e recovery_1st_stage_command \u6240\u9700\u7684\u65f6\u95f4 \u5b8c\u6210\u3002<\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u5178\u578b\u7684\u9519\u8bef\u662f<\/p>\n<p>   rsync used in the command is killed by signal 2 for example.<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>recovery_2nd_stage_command &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u4e3b\u8282\u70b9\u5728\u7b2c\u4e8c\u4e2a \u5728\u7ebf\u6062\u590d\u9636\u6bb5\u3002\u6b64\u547d\u4ee4\u4ec5\u672c\u673a\u590d\u5236\u6a21\u5f0f\u662f\u5fc5\u9700\u7684&#xff0c;\u56e0\u6b64\u5176\u4ed6\u6a21\u5f0f\u4e0d\u9700\u8981 \u4ee5\u63d0\u4f9b\u547d\u4ee4\u6587\u4ef6\u3002\u547d\u4ee4\u6587\u4ef6\u5fc5\u987b\u653e\u5728 database cluster \u76ee\u5f55\u3002 \u4f8b\u5982&#xff0c;\u5982\u679c recovery_2nd_stage_command &#061; \u2018sync-command\u2019&#xff0c;\u90a3\u4e48 Pgpool-II \u5c06 \u5728 $PGDATA \u76ee\u5f55\u4e2d\u67e5\u627e\u547d\u4ee4\u811a\u672c&#xff0c;\u5e76\u5c06 \u5c1d\u8bd5\u6267\u884c $PGDATA\/sync-command\u3002<\/p>\n<p>recovery_2nd_stage_command \u63a5\u6536\u4ee5\u4e0b 7 \u4e2a\u53c2\u6570&#xff1a;<\/p>\n<p>\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u8def\u5f84\u3002<\/p>\n<p>\u8981\u6062\u590d\u7684\u540e\u7aef\u8282\u70b9\u7684\u4e3b\u673a\u540d\u3002<\/p>\n<p>\u8981\u6062\u590d\u7684\u8282\u70b9\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u8def\u5f84\u3002<\/p>\n<p>\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u7684\u7aef\u53e3\u53f7&#xff08;Pgpool-II 3.4 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;\u3002<\/p>\n<p>\u8981\u6062\u590d\u7684\u8282\u70b9\u53f7&#xff08;Pgpool-II 4.0 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/p>\n<p>\u9700\u8981\u6062\u590d\u7684\u7aef\u53e3\u53f7&#xff08;Pgpool-II 4.1 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/p>\n<p>\u4e3b&#xff08;\u4e3b&#xff09;\u8282\u70b9\u7684\u4e3b\u673a\u540d &#xff08;Pgpool-II 4.3 \u6216\u66f4\u9ad8\u7248\u672c&#xff09;<\/p>\n<p>\u6ce8\u610f&#xff1a; Pgpool-II \u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\u4e0d\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5\u548c\u67e5\u8be2 recovery_2nd_stage_command\u547d\u4ee4&#xff0c;\u7136\u540e\u7b49\u5f85 \u8ba9\u73b0\u6709\u5ba2\u6237\u7aef\u5728\u6267\u884c \u547d\u4ee4\u3002 \u56e0\u6b64&#xff0c;recovery_2nd_stage_command \u53ef\u80fd\u65e0\u6cd5\u6267\u884c \u5982\u679c\u5ba2\u6237\u7aef\u957f\u65f6\u95f4\u4fdd\u6301\u8fde\u63a5\u3002<\/p>\n<p>\u8c28\u614e \u4ece PostgreSQL \u7684\u89d2\u5ea6\u6765\u770b&#xff0c;recovery_2nd_stage\u547d\u4ee4\u4f5c\u4e3a SQL \u547d\u4ee4\u8fd0\u884c\u3002\u56e0\u6b64&#xff0c;\u5982\u679c PostgreSQL \u7684 statement_time_out \u914d\u7f6e\u4e3a recovery_2nd_stage \u5c0f\u4e8e recovery_2nd_stage_command \u6240\u9700\u7684\u65f6\u95f4 \u5b8c\u6210\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>recovery_timeout &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u53d6\u6d88\u5728\u7ebf\u6062\u590d\u7684\u8d85\u65f6\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;&#xff0c;\u5982\u679c\u5b83 \u672a\u5728\u6b64\u65f6\u95f4\u5185\u5b8c\u6210\u3002 \u7531\u4e8e Pgpool-II \u4e0d\u63a5\u53d7\u8fde\u63a5 \u5728\u5728\u7ebf\u6062\u590d\u7684\u7b2c\u4e8c\u9636\u6bb5&#xff0c;\u6b64\u53c2\u6570\u53ef\u7528\u4e8e\u53d6\u6d88 \u5728\u7ebf\u6062\u590d&#xff0c;\u7528\u4e8e\u7ba1\u7406\u5728\u7ebf\u6062\u590d\u671f\u95f4\u7684\u670d\u52a1\u505c\u673a\u65f6\u95f4\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>client_idle_limit_in_recovery &#xff08;\u6574\u6570) \u6307\u5b9a\u5728\u5ba2\u6237\u7aef\u4fdd\u6301\u7a7a\u95f2\u72b6\u6001\u65f6\u65ad\u5f00\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09; \u81ea\u8054\u673a\u6062\u590d\u671f\u95f4\u7684\u4e0a\u6b21\u67e5\u8be2\u4ee5\u6765\u3002client_idle_limit_in_recovery \u4e0e client_idle_limit \u7c7b\u4f3c&#xff0c;\u4f46\u4ec5\u5728 \u5728\u7ebf\u6062\u590d\u7684\u7b2c\u4e8c\u9636\u6bb5\u3002<\/p>\n<p>\u8fd9\u5bf9\u4e8e\u9632\u6b62 Pgpool-II \u6062\u590d\u88ab\u61d2\u60f0\u7684\u5ba2\u6237\u7aef\u5e72\u6270&#xff0c;\u6216\u8005\u5982\u679c TCP\/IP \u5ba2\u6237\u7aef\u548c Pgpool-II \u4e4b\u95f4\u7684\u8fde\u63a5\u610f\u5916\u65ad\u5f00&#xff08;\u4f8b\u5982\u7535\u7f06\u88ab\u5207\u65ad&#xff09;\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; client_idle_limit_in_recovery\u5fc5\u987b\u5c0f\u4e8e recovery_timeout\u3002 \u5426\u5219&#xff0c;recovery_timeout \u9996\u5148&#xff0c;\u60a8\u5c06\u5728\u6267\u884c\u5728\u7ebf\u6062\u590d\u65f6\u770b\u5230\u4ee5\u4e0b\u9519\u8bef&#xff1a;<\/p>\n<p> ERROR:  node recovery failed, waiting connection closed in the other pgpools timeout<\/p>\n<p>\u5982\u679c\u8bbe\u7f6e\u4e3a -1&#xff0c;\u5219\u5f53\u7b2c\u4e8c\u4e2a \u9636\u6bb5\u5f00\u59cb\u3002 \u9ed8\u8ba4\u503c\u4e3a 0&#xff0c;\u8fd9\u5c06\u5173\u95ed\u8be5\u529f\u80fd\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<h3>1.12. \u6d41\u590d\u5236\u68c0\u67e5<\/h3>\n<p>Pgpool-II \u53ef\u4ee5\u548c PostgreSQL \u539f\u751f\u4e00\u8d77\u5de5\u4f5c Streaming Replication&#xff0c;\u81ea PostgreSQL 9.0 \u8d77\u53ef\u7528\u3002 \u914d\u7f6e Pgpool-II \u8fdb\u884c\u6d41\u5f0f replication&#xff0c;\u5c06 backend_clustering_mode \u8bbe\u7f6e\u4e3a \u2018streaming-replication\u2019\u3002<\/p>\n<p>Pgpool-II \u5047\u8bbe Streaming Replication \u5728 PostgreSQL \u4e0a\u914d\u7f6e\u4e86\u70ed\u5907\u7528&#xff0c;\u8fd9\u610f\u5473\u7740 \u5907\u7528\u6570\u636e\u5e93\u53ef\u4ee5\u5904\u7406\u53ea\u8bfb\u67e5\u8be2\u3002<\/p>\n<p>sr_check_period &#xff08;\u6574\u6570) \u6307\u5b9a\u68c0\u67e5\u6d41\u7684\u65f6\u95f4\u95f4\u9694&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09; \u590d\u5236\u5ef6\u8fdf\u3002 \u9ed8\u8ba4\u503c\u4e3a 10\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>sr_check_user &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u6267\u884c\u6d41\u590d\u5236\u68c0\u67e5\u7684 PostgreSQL \u7528\u6237\u540d\u3002 \u7528\u6237\u5fc5\u987b\u5177\u6709 LOGIN \u6743\u9650&#xff0c;\u5e76\u4e14\u5b58\u5728\u4e8e\u6240\u6709 PostgreSQL \u540e\u7aef\u3002<\/p>\n<p>\u5982\u679c\u542f\u7528\u4e86 SSL&#xff0c;\u5219 \u6d41\u5f0f\u590d\u5236\u68c0\u67e5\u8fc7\u7a0b\u53ef\u80fd\u4f1a\u4f7f\u7528 SSL \u8fde\u63a5\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a;\u5373\u4f7f sr_check_period \u8bbe\u7f6e\u4e3a 0&#xff08;\u7981\u7528&#xff09;&#xff0c;\u4e5f\u4f1a\u4f7f\u7528 sr_check_user \u548c sr_check_password \u4e3b\u670d\u52a1\u5668\u7684\u6807\u8bc6\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>sr_check_password &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a sr_check_user PostgreSQL \u7528\u6237\u7684\u5bc6\u7801 \u4ee5\u6267\u884c\u6d41\u590d\u5236\u68c0\u67e5\u3002 \u5982\u679c\u7528\u6237\u4e0d\u9700\u8981\u5bc6\u7801&#xff0c;\u8bf7\u4f7f\u7528 \u2018\u2019 &#xff08;\u7a7a\u5b57\u7b26\u4e32&#xff09;\u3002<\/p>\n<p>\u5982\u679c sr_check_password \u4e3a\u7a7a&#xff0c;Pgpool-II \u5c06\u9996\u5148\u5c1d\u8bd5\u4ece\u6587\u4ef6\u4e2d\u83b7\u53d6 sr_check_user \u7684\u5bc6\u7801pool_passwd\u7136\u540e\u518d\u4f7f\u7528\u7a7a\u5bc6\u7801\u3002<\/p>\n<p>Pgpool-II \u63a5\u53d7\u4ee5\u4e0b\u5f62\u5f0f \u7684\u5bc6\u7801sr_check_password \u6216 pool_passwd \u6587\u4ef6\u4e2d&#xff1a;<\/p>\n<p>AES256-CBC \u52a0\u5bc6\u5bc6\u7801 \u6700\u5b89\u5168\u548c\u63a8\u8350\u7684\u5bc6\u7801\u5b58\u50a8\u65b9\u5f0f\u3002\u8fd9 \u5bc6\u7801\u5b57\u7b26\u4e32\u5fc5\u987b\u5e26\u6709\u524d\u7f00 \u4f7f\u7528 AES\u3002 \u60a8\u53ef\u4ee5\u4f7f\u7528 pg_enc \u5b9e\u7528\u7a0b\u5e8f\u521b\u5efa\u683c\u5f0f\u6b63\u786e\u7684 AES \u52a0\u5bc6\u5bc6\u7801\u5b57\u7b26\u4e32\u3002Pgpool-II \u9700\u8981\u4e00\u4e2a\u4f4d\u4e8e startup \u4ee5\u4f7f\u7528\u52a0\u5bc6\u7684\u5bc6\u7801\u3002 \u6709\u5173\u63d0\u4f9b Pgpool-II \u7684\u89e3\u5bc6\u5bc6\u94a5<\/p>\n<p>MD5 \u54c8\u5e0c\u5bc6\u7801 \u4e0d\u5982 AES256 \u5b89\u5168&#xff0c;\u4f46\u4ecd\u7136\u6bd4 clear \u597d text \u5bc6\u7801\u3002\u5bc6\u7801\u5b57\u7b26\u4e32\u5fc5\u987b\u5e26\u6709\u524d\u7f00 \u4f7f\u7528 MD5\u3002\u8bf7\u6ce8\u610f&#xff0c;\u540e\u7aef \u8fd8\u5fc5\u987b\u8bbe\u7f6e MD5 \u8eab\u4efd\u9a8c\u8bc1\u3002\u60a8\u53ef\u4ee5 \u4f7f\u7528 pg_md5 \u5b9e\u7528\u7a0b\u5e8f\u521b\u5efa \u683c\u5f0f\u6b63\u786e\u7684 MD5 \u54c8\u5e0c\u5bc6\u7801\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u7eaf\u6587\u672c\u5bc6\u7801 \u672a\u52a0\u5bc6&#xff0c;\u660e\u6587\u5bc6\u7801\u3002\u4f60\u5e94\u8be5\u907f\u514d \u4ee5\u5c3d\u53ef\u80fd\u4f7f\u7528\u5b83\u3002\u5bc6\u7801\u5b57\u7b26\u4e32\u5fc5\u987b\u4e3a \u524d\u7f00\u4e3a TEXT\u3002\u4f8b\u5982&#xff0c;\u5982\u679c \u60a8\u5e0c\u671b\u5c06 myPass \u8bbe\u7f6e\u4e3a password \u7684 Password&#xff0c;\u60a8\u5e94\u8be5 \u5728\u5bc6\u7801\u4e2d\u6307\u5b9a TEXTmypass \u7530\u3002\u5728\u6ca1\u6709\u6709\u6548\u7684 \u524d\u7f00&#xff0c;Pgpool-II \u5c06 \u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u7eaf\u6587\u672c\u5bc6\u7801\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>sr_check_database &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u6267\u884c\u6d41\u590d\u5236\u5ef6\u8fdf\u68c0\u67e5\u7684\u6570\u636e\u5e93\u3002 \u9ed8\u8ba4\u503c\u4e3a \u201cpostgres\u201d\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>delay_threshold &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u5907\u7528\u670d\u52a1\u5668\u4e0a\u590d\u5236\u5ef6\u8fdf\u7684\u6700\u5927\u5bb9\u5fcd\u7ea7\u522b&#xff08;\u4ee5 WAL \u5b57\u8282\u4e3a\u5355\u4f4d&#xff09;\u76f8\u5bf9\u4e8e \u4e3b\u670d\u52a1\u5668\u3002\u5982\u679c\u5ef6\u8fdf\u8d85\u8fc7\u8fd9\u4e2a\u914d\u7f6e\u7684\u7ea7\u522b&#xff0c;Pgpool-II \u505c\u6b62\u5411\u5907\u7528\u670d\u52a1\u5668\u53d1\u9001 SELECT \u67e5\u8be2\u5e76\u5f00\u59cb\u8def\u7531 \u6240\u6709\u5185\u5bb9\u90fd\u53d1\u9001\u5230\u4e3b\u670d\u52a1\u5668&#xff0c;\u5373\u4f7f\u542f\u7528\u4e86 load_balance_mode&#xff0c;\u76f4\u5230\u5907\u7528\u670d\u52a1\u5668\u8d76\u4e0a\u4e3b\u670d\u52a1\u5668\u3002 \u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a 0 \u5c06\u7981\u7528\u5ef6\u8fdf\u68c0\u67e5\u3002 \u6b64\u5ef6\u8fdf\u9608\u503c\u68c0\u67e5\u6bcf sr_check_period\u6267\u884c\u4e00\u6b21\u3002 \u9ed8\u8ba4\u503c\u4e3a 0\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>delay_threshold_by_time &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u590d\u5236\u5ef6\u8fdf\u7684\u6700\u5927\u5bb9\u5dee\u7ea7\u522b \u5728\u5907\u7528\u670d\u52a1\u5668\u4e0a\u4e0e\u4e3b\u670d\u52a1\u5668\u3002 \u5982\u679c\u6307\u5b9a\u6b64\u503c\u65f6\u4e0d\u5e26\u5355\u4f4d&#xff0c;\u5219\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\u3002 \u5982\u679c\u6307\u5b9a\u7684\u503c\u5927\u4e8e 0&#xff0c;\u5219\u5ffd\u7565 delay_threshold\u3002\u5982\u679c\u5ef6\u8fdf \u8d85\u8fc7\u8fd9\u4e2a\u914d\u7f6e\u7684\u7ea7\u522b&#xff0c;Pgpool-II \u505c\u6b62\u5411\u5907\u7528\u670d\u52a1\u5668\u53d1\u9001 SELECT \u67e5\u8be2\u5e76\u5f00\u59cb\u8def\u7531 \u6240\u6709\u5185\u5bb9\u90fd\u53d1\u9001\u5230\u4e3b\u670d\u52a1\u5668&#xff0c;\u5373\u4f7f\u542f\u7528\u4e86 load_balance_mode&#xff0c;\u76f4\u5230\u5907\u7528\u670d\u52a1\u5668\u8d76\u4e0a\u4e3b\u670d\u52a1\u5668\u3002 \u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a 0 \u5c06\u7981\u7528\u5ef6\u8fdf\u68c0\u67e5\u3002 \u6b64\u5ef6\u8fdf\u9608\u503c\u68c0\u67e5\u6bcf sr_check_period\u6267\u884c\u4e00\u6b21\u3002 \u9ed8\u8ba4\u503c\u4e3a 0\u3002<\/p>\n<p>\u91c7\u7528\u590d\u5236\u5ef6\u8fdf \u4ece PostgreSQL \u7684\u7cfb\u7edf \u67e5\u770bpg_stat_replication\u3002replay_lag\u3002\u8fd9 \u89c6\u56fe\u53ef\u7528 PostgreSQL 10 \u6216 \u540e\u3002\u5982\u679c\u7248\u672c\u66f4\u65e9 \u7684 PostgreSQL \u4e3a used&#xff0c;Pgpool-II \u81ea\u52a8\u6389\u843d \u8fd4\u56de\u5230 delay_threshold&#xff0c;delay_threshold_by_time \u5c06\u88ab\u5ffd\u7565\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u4f9d\u8d56\u4e8e backend_application_name\u6b63\u786e set \u5e76\u5339\u914d application_name \u60a8\u7684 PostgreSQL \u5907\u7528\u6570\u636e\u5e93\u7684 primary_conninfo\u3002<\/p>\n<p>\u5982\u679c\u8be5\u53c2\u6570\u4e3a enabled\u3001SHOW POOL NODES \u548c pcp_node_info \u663e\u793a\u590d\u5236\u5ef6\u8fdf \u79d2&#xff0c;\u800c\u4e0d\u662f\u5b57\u8282\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>prefer_lower_delay_standby &#xff08;\u5e03\u5c14\u503c&#xff09;) \u6b64\u53c2\u6570\u4ec5\u6709\u6548 \u5f53 delay_threshold \u6216 delay_threshold_by_time \u8bbe\u7f6e\u4e3a \u5927\u4e8e 0\u3002\u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;\u5982\u679c\u8d1f\u8f7d\u7684\u5ef6\u8fdf \u5e73\u8861\u8282\u70b9\u66f4\u5927 \u6bd4 delay_threshold \u6216 delay_threshold_by_time&#xff0c;Pgpool-II \u4e0d\u4f1a\u53d1\u9001\u8bfb\u67e5\u8be2 \u6dfb\u52a0\u5230\u4e3b\u8282\u70b9&#xff0c;\u4f46\u5ef6\u8fdf\u6700\u5c11\u7684 standby \u4e0e backend_weight \u8bbe\u7f6e\u4e3a\u5927\u4e8e 0\u3002\u5982\u679c\u6240\u6709\u5907\u7528\u8282\u70b9\u7684\u5ef6\u8fdf \u5927\u4e8e delay_threshold \u6216delay_threshold_by_time\u4e3b \u88ab\u9009\u4e3a\u8d1f\u8f7d\u5747\u8861\u8282\u70b9 \u9996\u5148&#xff0c;Pgpool-II \u5411 \u4e3b\u8981\u3002\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>log_standby_delay &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u4f55\u65f6\u8bb0\u5f55\u590d\u5236\u5ef6\u8fdf\u3002\u4e0b\u8868\u5305\u542b\u5217\u8868 \u53c2\u6570\u7684\u6240\u6709\u6709\u6548\u503c\u3002<\/p>\n<p>\u8868 1-11.\u65e5\u5fd7\u5907\u7528\u5ef6\u8fdf\u9009\u9879<\/p>\n<table>\n<tr>ValueDescription<\/tr>\n<tbody>\n<tr>\n<td>none<\/td>\n<td>\u4ece\u4e0d\u8bb0\u5f55\u5f85\u673a\u5ef6\u8fdf<\/td>\n<\/tr>\n<tr>\n<td>always<\/td>\n<td>\u5982\u679c\u5907\u7528\u5ef6\u8fdf\u5927\u4e8e 0&#xff0c;\u5219\u5728\u6bcf\u6b21\u68c0\u67e5\u590d\u5236\u5ef6\u8fdf\u65f6\u8bb0\u5f55\u5907\u7528\u5ef6\u8fdf<\/td>\n<\/tr>\n<tr>\n<td>if_over_threshold<\/td>\n<td>\u4ec5\u5f53\u5f85\u673a\u5ef6\u8fdf\u8d85\u8fc7 delay_threshold\u6216 delay_threshold_by_time\u503c&#xff08;\u9ed8\u8ba4\u503c&#xff09;\u65f6&#xff0c;\u624d\u8bb0\u5f55\u5f85\u673a\u5ef6\u8fdf<\/td>\n<\/tr>\n<tr>\n<td>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>1.13. \u5185\u5b58\u67e5\u8be2\u7f13\u5b58<\/h3>\n<p>\u5185\u5b58\u67e5\u8be2\u7f13\u5b58\u53ef\u4ee5\u7528\u4e8e Pgpool-II \u7684\u6240\u6709\u6a21\u5f0f\u3002 \u5185\u5b58\u4e2d\u7684\u67e5\u8be2\u7f13\u5b58\u4fdd\u7559 SELECT \u7ed3\u679c&#xff0c;\u5e76\u4e14\u7ed3\u679c\u5c06\u88ab\u91cd\u7528\u3002 \u5f53\u5e95\u5c42\u8868\u66f4\u65b0\u65f6&#xff0c;\u76f8\u5e94\u7684\u7f13\u5b58\u6761\u76ee\u5c06\u88ab\u5220\u9664&#xff08;\u5982\u679c memqcache_auto_cache_invalidation \u5904\u4e8e\u6253\u5f00\u72b6\u6001\u3002\u8fd9\u4e2a\u53c2\u6570\u9ed8\u8ba4\u662f\u5f00\u542f\u7684&#xff09;&#xff0c;\u56e0\u6b64\u91cd\u542f Pgpool-II \u662f\u6ca1\u6709\u5fc5\u8981\u7684\u3002<\/p>\n<p>\u5728\u5185\u5b58\u7f13\u5b58\u4e2d\u4fdd\u5b58\u7528\u6237\u540d\u3001\u6570\u636e\u5e93\u540d\u79f0\u3001SELECT \u8bed\u53e5\u5bf9 \u53ca\u5176\u7ed3\u679c &#xff08;\u4ee5\u53ca Bind \u53c2\u6570&#xff0c;\u5982\u679c SELECT \u662f extended query&#xff09;\u7684 Zip S S\u5982\u679c\u76f8\u540c\u7684\u7528\u6237\u540d\u3001\u6570\u636e\u5e93\u540d\u79f0\u548c SELECT \u8fdb\u6765&#xff0c;Pgpool-II \u8fd4\u56de \u7f13\u5b58\u3002\u7531\u4e8e\u6ca1\u6709 SQL \u89e3\u6790\u6216\u8bbf\u95ee \u5230 PostgreSQL \u4e2d&#xff0c;\u670d\u52a1 \u7684\u7ed3\u679c\u975e\u5e38\u5feb\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u57fa\u672c\u4e0a&#xff0c;\u540e\u9762\u7684 SELECT \u4e0d\u4f1a\u88ab\u7f13\u5b58&#xff1a;<\/p>\n<p>SELECTs including non immutable functions<br \/>\nSELECTs including temp tables, unlogged tables<br \/>\nSELECTs including TIMESTAMP WITH TIMEZONE or TIME WITH TIMEZONE<br \/>\nSELECTs including CAST to TIMESTAMP WITH TIMEZONE or TIME WITH TIMEZONE<br \/>\nSELECTs including SQLValueFunction (CURRENT_TIME, CURRENT_USER etc.)<br \/>\nSELECT result is too large (memqcache_maxcache)<br \/>\nSELECT FOR SHARE\/UPDATE<br \/>\nSELECT starting with &#034;\/*NO QUERY CACHE*\/&#034; comment<br \/>\nSELECT including system catalogs<br \/>\nSELECT uses TABLESAMPLE<br \/>\nSELECT uses row security enabled tables<\/p>\n<p>\u4f46\u662f&#xff0c;\u8bbf\u95ee\u672a\u8bb0\u5f55\u8868\u7684 VIEW \u548c SELECT \u53ef\u4ee5\u662f \u901a\u8fc7\u5728 cache_safe_memqcache_table_list\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u7531\u4e8e\u67e5\u8be2\u7f13\u5b58\u548c\u6570\u636e\u5e93\u5185\u5bb9\u4e4b\u95f4\u7684\u4e00\u81f4\u6027\u53ef\u4ee5 \u4e22\u5931&#xff0c;\u5219\u67e5\u8be2\u7f13\u5b58\u5c06\u5168\u90e8\u5220\u9664&#xff0c;\u5982\u679c \u5b83\u4eec\u88ab\u6267\u884c&#xff1a;<\/p>\n<p>ALTER DATABASE<br \/>\nALTER ROLE or USER (except WITH CONNECTION LIMIT and WITH [ENCRYPTED] PASSWORD)<br \/>\nALTER TABLE<br \/>\nREVOKE<\/p>\n<p>\u6b64\u5916&#xff0c;\u5982\u679c\u6267\u884c SET ROLE \u6216 SET SESSION AUTHORIZATION&#xff0c;\u5219 \u4e0d\u4f1a\u4f7f\u7528\u67e5\u8be2\u7f13\u5b58&#xff0c;\u4e5f\u4e0d\u4f1a\u521b\u5efa\u65b0\u7f13\u5b58 \u5728\u4f1a\u8bdd\u4e2d\u3002Pgpool-II \u5047\u8bbe\u4e24\u4e2a\u67e5\u8be2\u7f13\u5b58 \u5982\u679c\u4f1a\u8bdd\u7528\u6237\u4e0d\u540c&#xff0c;\u5219\u4e0d\u540c\u3002\u53e6\u4e00\u65b9\u9762 hand&#xff0c;PostgreSQL \u7ba1\u7406\u8bbf\u95ee\u63a7\u5236 \u53d6\u51b3\u4e8e\u5f53\u524d\u7528\u6237\u3002\u56e0\u6b64&#xff0c;\u8fd9\u4e9b\u547d\u4ee4\u53ef\u80fd\u4f1a\u7834\u574f \u8fd9\u4e24\u4e2a\u8bbf\u95ee\u63a7\u5236\u4e4b\u95f4\u7684\u4e00\u81f4\u6027\u3002\u4f46\u662f&#xff0c;\u7f13\u5b58 invalidation by update \u547d\u4ee4\u4ee5\u76f8\u540c\u7684\u65b9\u5f0f\u6267\u884c \u8fd9\u4e9b\u547d\u4ee4\u672a\u88ab\u4f7f\u7528\u3002<\/p>\n<p>\u53e6\u4e00\u65b9\u9762&#xff0c;\u5b83\u53ef\u80fd\u6bd4\u6b63\u5e38\u8def\u5f84\u6162 \u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b&#xff0c;\u56e0\u4e3a\u5b83\u4f1a\u589e\u52a0\u4e00\u4e9b\u5b58\u50a8\u7f13\u5b58\u7684\u5f00\u9500\u3002 \u6b64\u5916&#xff0c;\u5f53\u4e00\u4e2a\u8868\u88ab\u66f4\u65b0\u65f6&#xff0c;Pgpool-II \u4f1a\u81ea\u52a8\u5220\u9664\u6240\u6709\u4e0e \u684c\u5b50\u3002\u56e0\u6b64&#xff0c;\u6027\u80fd\u4f1a\u56e0 \u5f88\u591a\u66f4\u65b0\u3002\u5982\u679c\u67e5\u8be2\u7f13\u5b58\u547d\u4e2d\u7387&#xff08;\u53ef\u4ee5\u68c0\u67e5 \u901a\u8fc7\u4f7f\u7528 SHOW POOL_CACHE&#xff09; \u4f4e\u4e8e 70%&#xff0c; \u60a8\u53ef\u80fd\u5e0c\u671b\u5728 Memory Cache \u4e2d\u7981\u7528\u3002<\/p>\n<p>SELECT \u7ed3\u679c\u57fa\u672c\u4e0a\u662f\u5728 SELECT \u901a\u5e38\u4f1a\u5b8c\u6210\u3002\u5982\u679c\u663e\u5f0f\u4e8b\u52a1\u6b63\u5728\u6267\u884c&#xff0c;\u5219 SELECT \u7ed3\u679c\u4e0d\u4f1a\u6ce8\u518c&#xff0c;\u76f4\u5230 \u4e8b\u52a1\u5df2\u63d0\u4ea4\u3002\u540c\u6837\u5728\u6269\u5c55\u67e5\u8be2\u6a21\u5f0f\u4e0b&#xff0c;\u8ba1\u65f6 \u7684\u7f13\u5b58\u6ce8\u518c\u56e0\u96c6\u7fa4\u6a21\u5f0f\u800c\u5f02\u3002\u5728\u6d41\u5f0f\u5904\u7406\u4e2d \u590d\u5236\u6a21\u5f0f\u548c\u903b\u8f91 \u590d\u5236\u6a21\u5f0f&#xff0c;\u5219\u5728\u4ece\u524d\u7aef\u53d1\u9001 Sync \u6d88\u606f\u65f6\u6ce8\u518c\u7f13\u5b58&#xff0c;\u5e76\u4e14 response &#xff08;Ready for query \u6d88\u606f&#xff09; from backend \u7684\u56e0\u6b64&#xff0c;\u5373\u4f7f\u547d\u4ee4\u662f\u4ece\u524d\u7aef\u53d1\u9001\u7684&#xff0c; \u7b2c\u4e8c\u4e2a Execute &#xff08;SELECT 1&#xff09; \u5c06\u4e0d\u4f7f\u7528\u67e5\u8be2\u7f13\u5b58\u3002<\/p>\n<p>   Parse (SELECT 1)<br \/>\n   Bind (SELECT 1)<br \/>\n   Execute (SELECT 1)<br \/>\n   Parse (SELECT 1)<br \/>\n   Bind (SELECT 1)<br \/>\n   Execute (SELECT 1)<br \/>\n   Sync<\/p>\n<p>\u53e6\u4e00\u65b9\u9762&#xff0c;\u5728\u5176\u4ed6\u96c6\u7fa4\u6a21\u5f0f\u4e0b&#xff0c;\u7531\u4e8e \u7b2c\u4e00\u4e2a Execute &#xff08;SELECT 1&#xff09; \u5df2\u6ce8\u518c&#xff0c;\u7b2c\u4e8c\u4e2a Execute &#xff08;SELECT 1&#xff09; \u5c06\u4f7f\u7528\u67e5\u8be2\u7f13\u5b58\u3002<\/p>\n<h4>1.13.1. \u5728\u5185\u5b58\u4e2d\u542f\u7528\u67e5\u8be2\u7f13\u5b58<\/h4>\n<p>memory_cache_enabled &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on \u5c06\u542f\u7528\u5185\u5b58\u7f13\u5b58\u3002 \u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c enable_shared_relcache \u8bbe\u7f6e\u4e3a on&#xff0c;\u5219\u5171\u4eab\u5173\u7cfb\u7f13\u5b58\u4e5f\u5c06\u4f7f\u7528\u67e5\u8be2\u7f13\u5b58\u3002\u6b64\u5916&#xff0c; \u5373\u4f7f memory_cache_enabled \u53c2\u6570\u8bbe\u7f6e\u4e3a OFF&#xff0c;\u4e5f\u4f1a\u4f7f\u7528\u67e5\u8be2\u7f13\u5b58\u3002\u6709\u5173\u5173\u7cfb\u7f13\u5b58\u7684\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u9605 Section 1.16 \u3002<\/p>\n<h4>1.13.2. \u9009\u62e9\u7f13\u5b58\u5b58\u50a8<\/h4>\n<p>memqcache_method &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u7528\u4e8e\u7f13\u5b58\u7684\u5b58\u50a8\u7c7b\u578b\u3002 \u4e0b\u8868\u5305\u542b\u53c2\u6570\u7684\u6240\u6709\u6709\u6548\u503c\u7684\u5217\u8868\u3002<\/p>\n<p>\u8868 5-12.Memqcache \u65b9\u6cd5\u9009\u9879<\/p>\n<table>\n<tr>ValueDescription<\/tr>\n<tbody>\n<tr>\n<td>\u2018shmem\u2019<\/td>\n<td>Use shared memory<\/td>\n<\/tr>\n<tr>\n<td>\u2018memcached\u2019<\/td>\n<td>Use memcached<\/td>\n<\/tr>\n<tr>\n<td>\u4e00\u822c\u6765\u8bf4&#xff0c;shmem \u66f4\u5feb \u6bd4 memcached \u7684 Mccached \u5c11&#xff0c;\u56e0\u4e3a\u524d\u8005\u4e0d\u4f1a \u6d89\u53ca\u4efb\u4f55\u7f51\u7edc\u8bbf\u95ee\u3002\u4f46\u662f&#xff0c;memqcache_total_size \u7684\u4e0a\u9650\u5927\u5c0f\u53d7\u603b\u6570 \u7cfb\u7edf\u5b9a\u4e49\u7684\u5171\u4eab\u5185\u5b58\u5927\u5c0f\u3002\u5c3a\u5bf8\u8f83\u5927 \u5728\u73b0\u4ee3 Linux \u7cfb\u7edf\u4e2d\u5df2\u7ecf\u8db3\u591f\u4e86&#xff0c;\u4f46\u5728\u5176\u4ed6\u7cfb\u7edf\u4e2d\u53ef\u80fd\u5c31\u8db3\u591f\u4e86 \u8f83\u5c0f\u7684\u4e0a\u9650\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u60a8\u9700\u8981\u66f4\u6539\u7cfb\u7edf \u6709\u5173\u6700\u5927\u5171\u4eab\u5185\u5b58\u5927\u5c0f\u7684\u8bbe\u7f6e\u3002\u6709\u4e00\u4e2a \u5173\u4e8e\u5171\u4eab\u5185\u5b58\u7684\u597d\u89e3\u91ca \u5728 PostgreSQL \u6587\u6863\u4e2d\u3002<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u60a8\u4e0d\u786e\u5b9a\u8981\u4f7f\u7528\u54ea\u4e2amemqcache_method&#xff0c;\u8bf7\u4ece shmem \u5f00\u59cb\u3002<\/p>\n<p>\u9ed8\u8ba4\u4e3a \u2018shmem\u2019\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.13.3. \u5e38\u89c1\u914d\u7f6e<\/h4>\n<p>\u4ee5\u4e0b\u53c2\u6570\u5bf9 shmem \u548c memcached \u7c7b\u578b\u7684\u67e5\u8be2\u7f13\u5b58\u5747\u6709\u6548\u3002<\/p>\n<p>memqcache_expire &#xff08;\u6574\u6570) \u6307\u5b9a\u67e5\u8be2\u7f13\u5b58\u7684\u751f\u547d\u5468\u671f&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;\u3002 \u9ed8\u8ba4\u503c\u4e3a 0\u3002\u8fd9\u610f\u5473\u7740\u6ca1\u6709\u7f13\u5b58\u8fc7\u671f\u548c\u7f13\u5b58\u4fdd\u7559 \u5728\u66f4\u65b0\u8868\u4e4b\u524d\u6709\u6548\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>\u6ce8&#xff1a; memqcache_expire \u548c memqcache_auto_cache_invalidation \u5f7c\u6b64\u6b63\u4ea4\u3002<\/p>\n<p>memqcache_auto_cache_invalidation &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on&#xff0c;\u5219\u81ea\u52a8\u5220\u9664\u4e0e\u66f4\u65b0\u7684 table \u76f8\u5173\u7684\u7f13\u5b58\u3002 \u5173\u95ed\u65f6&#xff0c;\u4e0d\u4f1a\u5220\u9664\u7f13\u5b58\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a on\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u6b64\u53c2\u6570 memqcache_auto_cache_invalidation \u548c memqcache_expire \u5f7c\u6b64\u6b63\u4ea4\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>memqcache_maxcache &#xff08;\u6574\u6570) \u6307\u5b9a\u8981\u7f13\u5b58\u7684 SELECT \u67e5\u8be2\u7ed3\u679c\u7684\u6700\u5927\u5927\u5c0f&#xff08;\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d&#xff09;\u3002 \u6570\u636e\u5927\u5c0f\u5927\u4e8e\u6b64\u503c\u7684\u7ed3\u679c\u4e0d\u4f1a\u88ab Pgpool-II \u7f13\u5b58\u3002 \u5f53\u6570\u636e\u7f13\u5b58\u56e0\u5927\u5c0f\u9650\u5236\u800c\u88ab\u62d2\u7edd\u65f6&#xff0c;\u4ee5\u4e0b \u6d88\u606f\u3002<\/p>\n<p>   LOG:   pid 13756: pool_add_temp_query_cache: data size exceeds memqcache_maxcache. current:4095 requested:111 memq_maxcache:4096<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5bf9\u4e8e\u5171\u4eab\u5185\u5b58 query&#xff08;\u2018shmem\u2019&#xff09; \u7f13\u5b58&#xff0c;memqcache_maxcache\u5fc5\u987b\u8bbe\u7f6e\u4e3a\u4f4e\u4e8e memqcache_cache_block_size&#xff0c;\u5bf9\u4e8e \u2018memcached\u2019&#xff0c;\u5b83\u5fc5\u987b\u5c0f\u4e8e slab \u7684\u5927\u5c0f&#xff08;\u9ed8\u8ba4\u4e3a 1 MB&#xff09;\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>cache_safe_memqcache_table_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u4e00\u4e2a\u4ee5\u9017\u53f7\u5206\u9694\u7684\u8868\u540d\u5217\u8868&#xff0c;\u5176 SELECT \u7ed3\u679c\u5e94\u8be5\u7531 Pgpool-II \u7f13\u5b58\u3002\u6b64\u53c2\u6570\u4ec5 \u9002\u7528\u4e8e\u8bbf\u95ee\u672a\u8bb0\u5f55\u8868\u7684 VIEW \u548c SELECT\u3002 \u9664\u975e\u6307\u5b9a&#xff0c;\u5426\u5219\u53ef\u4ee5\u7f13\u5b58\u5e38\u89c4\u8868 \u7531 cache_unsafe_memqcache_table_list\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u4e2d\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u5339\u914d\u8868\u540d &#xff08;^ \u548c $ \u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230\u5176\u4e2d&#xff09;\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c\u67e5\u8be2\u53ef\u4ee5\u5f15\u7528\u5177\u6709\u548c\u4e0d\u5177\u6709\u67b6\u6784\u7684\u8868 qualification \u90a3\u4e48\u4f60\u5fc5\u987b\u6dfb\u52a0\u4e24\u4e2a\u6761\u76ee&#xff08;\u5e26\u548c\u4e0d\u5e26 Schema name&#xff09; \u7684 Schema \u540d\u79f0&#xff09;\u3002<\/p>\n<p>#For example:<br \/>\n#If the queries sometime use &#034;table1&#034; and other times &#034;public.table1&#034;<br \/>\n#to refer the table1 then the cache_safe_memqcache_table_list<br \/>\n#would be configured as follows.<\/p>\n<p>cache_safe_memqcache_table_list &#061; &#034;table1,public.table1&#034;<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>cache_unsafe_memqcache_table_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5176 SELECT \u7684\u8868\u540d\u7684\u9017\u53f7\u5206\u9694\u5217\u8868 \u7ed3\u679c\u4e0d\u5e94\u8be5\u88ab Pgpool-II \u7f13\u5b58\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u4e2d\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u5339\u914d\u8868\u540d &#xff08;^ \u548c $ \u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230\u5176\u4e2d&#xff09;\u3001<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c\u67e5\u8be2\u53ef\u4ee5\u5f15\u7528\u5177\u6709\u548c\u4e0d\u5177\u6709\u67b6\u6784\u7684\u8868 qualification \u90a3\u4e48\u4f60\u5fc5\u987b\u6dfb\u52a0\u4e24\u4e2a\u6761\u76ee&#xff08;\u5e26\u548c\u4e0d\u5e26 Schema name&#xff09; \u7684 Schema \u540d\u79f0&#xff09;\u3002<\/p>\n<p>#For example:<br \/>\n#If the queries sometime use &#034;table1&#034; and other times &#034;public.table1&#034;<br \/>\n#to refer the table1 then the cache_unsafe_memqcache_table_list<br \/>\n#would be configured as follows.<\/p>\n<p>cache_unsafe_memqcache_table_list &#061; &#034;table1,public.table1&#034;<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; cache_unsafe_memqcache_table_list\u4f18\u5148\u4e8ecache_safe_memqcache_table_list<\/p>\n<p>memqcache_oiddir &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u5b58\u50a8 SELECT \u67e5\u8be2\u4f7f\u7528\u7684\u8868\u7684 oid \u7684\u76ee\u5f55\u7684\u5b8c\u6574\u8def\u5f84\u3002<\/p>\n<p>memqcache_oiddir \u76ee\u5f55\u5305\u542b\u5b50\u76ee\u5f55 \u5bf9\u4e8e\u6570\u636e\u5e93\u3002\u76ee\u5f55\u540d\u79f0\u662f\u6570\u636e\u5e93\u7684 OID\u3002\u6b64\u5916&#xff0c;\u6bcf\u4e2a database \u76ee\u5f55\u5305\u542b SELECT \u8bed\u53e5\u4f7f\u7528\u7684\u6bcf\u4e2a table \u7684\u6587\u4ef6\u3002 \u540c\u6837&#xff0c;\u6587\u4ef6\u540d\u662f\u8868\u7684 OID\u3002 \u8fd9\u4e9b\u6587\u4ef6\u5305\u542b\u6307\u5411\u67e5\u8be2\u7f13\u5b58\u7684\u6307\u9488&#xff0c;\u8fd9\u4e9b\u6307\u9488\u7528\u4f5c \u5220\u9664\u7f13\u5b58\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u6b63\u5e38\u91cd\u542f Pgpool-II \u4e0d\u4f1a\u6e05\u9664 memqcache_oiddir\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002<\/p>\n<h4>1.13.4. \u4f7f\u7528\u5171\u4eab\u5185\u5b58\u7684\u914d\u7f6e<\/h4>\n<p>\u8fd9\u4e9b\u662f\u4e0e\u5171\u4eab\u5185\u5b58\u4e00\u8d77\u7528\u4f5c\u7f13\u5b58\u5b58\u50a8\u7684\u53c2\u6570\u3002<\/p>\n<p>memqcache_total_size &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u5171\u4eab\u5185\u5b58\u9ad8\u901f\u7f13\u5b58\u5927\u5c0f\u3002 \u9ed8\u8ba4\u503c\u4e3a 64MB\u3002<\/p>\n<p>\u6bcf\u4e2a\u7f13\u5b58\u90fd\u5b58\u50a8\u5728\u6307\u5b9a\u7684\u56fa\u5b9a\u5927\u5c0f\u7684\u5757\u4e2d \u7531 memqcache_cache_block_size\u3002\u6570\u5b57 \u7684\u5757\u6570 \u7531 memqcache_total_size \/ memqcache_cache_block_size\u3002Any decimal &#xff08;\u4efb\u610f\u5c0f\u6570&#xff09; places \u88ab\u622a\u65ad&#xff0c;\u56e0\u6b64\u5757\u7684\u6570\u91cf\u4e3a \u6574\u6570\u3002\u5982\u679c\u6570\u5b57\u53d8\u4e3a 0&#xff0c;\u5219\u4f1a\u5f15\u53d1\u9519\u8bef\u3002\u90a3 \u662f&#xff0c;memqcache_total_size\u5fc5\u987b\u66f4\u5927 \u6bd4 memqcache_cache_block_size\u3002\u67e5\u8be2 \u7ed3\u679c\u53ca\u5176\u7ba1\u7406\u6570\u636e\u4e0d\u4f1a\u5b58\u50a8\u5728\u591a\u4e2a \u5757&#xff0c;\u56e0\u6b64\u5982\u679c\u67e5\u8be2\u7ed3\u679c\u6570\u636e\u957f\u5ea6 &#043; 64 \u5b57\u8282\u66f4\u5927 memqcache_cache_block_size&#xff0c;\u5b83\u4e0d\u80fd \u5b58\u50a8\u5728\u5757\u4e2d&#xff0c;\u4e0d\u4f1a\u88ab\u7f13\u5b58\u3002<\/p>\n<p>\u5f53\u4e00\u4e2a\u5757\u586b\u5145\u4e86 cache \u65f6&#xff0c;\u5c06\u4f7f\u7528\u4e0b\u4e00\u4e2a\u5757\u3002 \u5f53\u6240\u6709\u5757\u90fd\u5df2\u6ee1\u65f6&#xff0c;\u5c06\u5237\u65b0\u5e76\u91cd\u7528\u6700\u65e7\u7684\u5757 &#xff08;\u8bf7\u6ce8\u610f&#xff0c;\u6700\u65e9\u7684\u533a\u5757\u4e0d\u4e00\u5b9a\u5305\u542b \u6700\u65e7\u7684\u7f13\u5b58\u6570\u636e&#xff0c;\u56e0\u4e3a\u6bcf\u5f53 \u627e\u5230\u7b2c\u4e00\u4e2a\u62df\u5408\u7a7a\u95f4&#xff09;\u3002\u800c \u8f83\u5c0f\u7684memqcache_total_size\u4e0d\u4f1a\u5347\u9ad8 \u9519\u8bef&#xff0c;\u5219\u6027\u80fd\u4f1a\u56e0\u7f13\u5b58\u547d\u4e2d\u7387 \u51cf\u5c11\u3002\u7f13\u5b58\u547d\u4e2d\u7387\u53ef\u4ee5\u901a\u8fc7 SHOW POOL_CACHE \u7684\u54a8\u8be2cache_hit_ratio\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>memqcache_max_num_cache &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u7f13\u5b58\u6761\u76ee\u6570\u3002\u9ed8\u8ba4\u503c\u4e3a 1,000,000\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5c1d\u8bd5\u6ce8\u518c\u66f4\u591a \u6bd4memqcache_max_num_cache\u7f13\u5b58&#xff0c;\u4e00\u4e2a\u5757 \u5305\u542b\u7f13\u5b58\u7684\u6570\u636e\u5c06\u88ab\u5237\u65b0\u5e76\u91cd\u65b0\u4f7f\u7528\u3002\u800c \u8f83\u5c0f\u7684 memqcache_max_num_cache \u4e0d\u4f1a \u5f15\u53d1\u9519\u8bef&#xff0c;\u6027\u80fd\u4f1a\u56e0\u7f13\u5b58\u547d\u4e2d \u6bd4\u7387\u964d\u4f4e\u3002\u7f13\u5b58\u547d\u4e2d\u7387\u53ef\u4ee5\u901a\u8fc7 SHOW POOL_CACHE \u7684\u54a8\u8be2cache_hit_ratio\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u7f13\u5b58\u7531\u5171\u4eab\u5185\u5b58\u4e2d\u7684\u54c8\u5e0c\u8868\u7ba1\u7406&#xff0c;\u4ee5\u4fbf\u5feb\u901f \u8bbf\u95ee\u3002\u54c8\u5e0c\u8868\u7a7a\u95f4\u5927\u5c0f\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8ba1\u7b97&#xff1a;memqcache_max_num_cache * 64 \u5b57\u8282\u3002\u6570 \u7684\u54c8\u5e0c\u6761\u76ee \u5728 SHOW POOL_CACHE \u7684 used_hash_entries\u3002\u54c8\u5e0c\u7f16\u53f7 \u8868\u6761\u76ee\u901a\u5e38 \u5339\u914d memqcache_max_num_cache&#xff0c;\u4f46\u53ef\u80fd\u4e0d\u5339\u914d \u5982\u679c memqcache_max_num_cache \u4e0d\u662f 2 \u7684\u5e42\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u5b83\u56db\u820d\u4e94\u5165\u4e3a\u5927\u4e8e 2 \u7684\u5e42 \u6bd4 memqcache_max_num_cache\u3002\u6570\u91cf \u53ef\u4ee5\u627e\u5230\u6b63\u5728\u4f7f\u7528\u7684\u54c8\u5e0c\u6761\u76ee \u5728 used_hash_entries\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>memqcache_cache_block_size &#xff08;\u6574\u6570) \u6307\u5b9a\u7f13\u5b58\u5757\u5927\u5c0f\u3002 \u9ed8\u8ba4\u503c\u4e3a 1MB\u3002<\/p>\n<p>\u67e5\u8be2\u7ed3\u679c\u53ca\u5176\u7ba1\u7406\u6570\u636e\u4e0d\u4f1a\u5b58\u50a8\u5728 \u591a\u4e2a\u5757&#xff0c;\u56e0\u6b64\u5982\u679c\u67e5\u8be2\u7ed3\u679c\u6570\u636e\u957f\u5ea6 &#043; 64 \u5b57\u8282 \u5927\u4e8e memqcache_cache_block_size&#xff0c; \u5b83\u4e0d\u80fd\u5b58\u50a8\u5728\u5757\u4e2d&#xff0c;\u4e5f\u4e0d\u4f1a\u88ab\u7f13\u5b58\u3002<\/p>\n<p>memqcache_cache_block_size \u5fc5\u987b\u81f3\u5c11\u8bbe\u7f6e\u4e3a 512\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.13.5. \u4f7f\u7528 memcached \u7684\u914d\u7f6e<\/h4>\n<p>\u8fd9\u4e9b\u662f\u4e0e memcached \u4e00\u8d77\u7528\u4f5c\u7f13\u5b58\u5b58\u50a8\u7684\u53c2\u6570\u3002<\/p>\n<p>memqcache_memcached_host &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a memcached \u5728\u5176\u4e0a\u8fd0\u884c\u7684\u4e3b\u673a\u540d\u6216 IP \u5730\u5740\u3002\u5982\u679c memcached \u548c Pgpool-II \u4f4d\u4e8e\u540c\u4e00\u53f0\u670d\u52a1\u5668\u4e0a&#xff0c;\u4f60\u53ef\u4ee5\u4f7f\u7528 \u2018localhost\u2019\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>memqcache_memcached_port &#xff08;\u6574\u6570) \u6307\u5b9a memcached \u7684\u7aef\u53e3\u53f7\u3002 \u9ed8\u8ba4\u503c\u4e3a 11211\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h3>1.14.\u5b89\u5168\u5957\u63a5\u5c42&#xff08;ssh&#xff09;<\/h3>\n<h4>1.14.1. SSL \u8bbe\u7f6e<\/h4>\n<p>ssl &#xff08;\u5e03\u5c14\u503c) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;Pgpool-II \u4e3a\u524d\u7aef\u548c\u540e\u7aef\u901a\u4fe1\u542f\u7528 SSL\u3002 \u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; ssl_key \u548c ssl_cert \u8fd8\u5fc5\u987b \u914d\u7f6e&#xff0c;\u4ee5\u4fbf SSL \u4e0e\u524d\u7aef\u8fde\u63a5\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u8981\u4f7f SSL \u5de5\u4f5c&#xff0c;Pgpool-II \u5fc5\u987b\u6784\u5efa\u6709 OpenSSL \u652f\u6301\u3002 \u53c2\u89c1 Section 2.1 \u6765\u4e86\u89e3\u6784\u5efa Pgpool-II \u7684\u7ec6\u8282\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_key &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u7528\u4e8e\u7684\u79c1\u94a5\u6587\u4ef6 \u4f20\u5165\u7684\u524d\u7aef\u8fde\u63a5\u3002\u76f8\u5bf9\u8def\u5f84\u662f\u76f8\u5bf9\u4e8e Pgpool-II \u914d\u7f6e\u76ee\u5f55\u7684\u3002 \u6b64\u9009\u9879\u6ca1\u6709\u9ed8\u8ba4\u503c&#xff0c;\u5982\u679c\u672a\u8bbe\u7f6e&#xff0c;\u5219\u5c06\u5bf9\u4f20\u5165\u7684\u524d\u7aef\u8fde\u63a5\u7981\u7528 SSL\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_cert &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u4f7f\u7528\u7684\u516c\u5171 x509 \u8bc1\u4e66\u6587\u4ef6 \u5bf9\u4e8e\u4f20\u5165\u7684\u524d\u7aef\u8fde\u63a5\u3002\u76f8\u5bf9\u8def\u5f84\u662f\u76f8\u5bf9\u4e8e Pgpool-II \u914d\u7f6e\u76ee\u5f55\u7684\u3002 \u6b64\u9009\u9879\u6ca1\u6709\u9ed8\u8ba4\u503c&#xff0c;\u5982\u679c\u672a\u8bbe\u7f6e&#xff0c;\u5219\u5c06\u5bf9\u4f20\u5165\u7684\u524d\u7aef\u8fde\u63a5\u7981\u7528 SSL\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_ca_cert &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a PEM \u683c\u5f0f\u7684 CA \u8bc1\u4e66\u6587\u4ef6&#xff0c;\u8be5\u6587\u4ef6\u53ef\u7528\u4e8e\u9a8c\u8bc1\u540e\u7aef\u670d\u52a1\u5668 \u8bc1\u4e66\u3002\u76f8\u5bf9\u8def\u5f84\u662f\u76f8\u5bf9\u4e8e Pgpool-II \u914d\u7f6e\u76ee\u5f55\u7684\u3002\u8fd9\u662f \u7c7b\u4f3c\u4e8e OpenSSL verify&#xff08;1&#xff09; \u547d\u4ee4\u7684 -CApath \u9009\u9879\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_ca_cert_dir &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5305\u542b PEM \u683c\u5f0f CA \u8bc1\u4e66\u6587\u4ef6\u7684\u76ee\u5f55\u7684\u8def\u5f84&#xff0c;\u8be5\u76ee\u5f55\u53ef\u4ee5\u4f7f\u7528 \u4ee5\u9a8c\u8bc1\u540e\u7aef\u670d\u52a1\u5668\u8bc1\u4e66\u3002\u8fd9\u7c7b\u4f3c\u4e8e OpenSSL verify&#xff08;1&#xff09; \u547d\u4ee4\u7684 -CApath \u9009\u9879\u3002<\/p>\n<p>\u6b64\u9009\u9879\u7684\u9ed8\u8ba4\u503c\u4e3a unset&#xff0c;\u5373 no \u8fdb\u884c\u9a8c\u8bc1\u3002\u5982\u679c\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6&#xff0c;\u9a8c\u8bc1\u4ecd\u4f1a\u8fdb\u884c \u6b64\u9009\u9879\u672a\u8bbe\u7f6e&#xff0c;\u4f46\u4f1a\u4e3a ssl_ca_cert \u63d0\u4f9b\u4e00\u4e2a\u503c\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_crl_file &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5305\u542b SSL \u670d\u52a1\u5668\u8bc1\u4e66\u7684\u6587\u4ef6 \u540a\u9500\u5217\u8868 &#xff08;CRL&#xff09;\u3002\u76f8\u5bf9\u8def\u5f84\u662f\u76f8\u5bf9\u4e8e Pgpool-II \u914d\u7f6e\u76ee\u5f55\u7684\u3002 \u9ed8\u8ba4\u503c\u4e3a\u7a7a&#xff0c;\u8fd9\u610f\u5473\u7740\u4e0d\u4f1a\u52a0\u8f7d\u4efb\u4f55 CRL \u6587\u4ef6\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_ciphers &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a SSL \u5bc6\u7801\u5957\u4ef6\u7684\u5217\u8868&#xff0c;\u8be5 \u5141\u8bb8 SSL \u8fde\u63a5\u4f7f\u7528\u3002\u770b OpenSSL \u8f6f\u4ef6\u5305\u4e2d\u7684 ciphers \u624b\u518c\u9875 \u4e86\u89e3\u6b64\u8bbe\u7f6e\u7684\u8bed\u6cd5\u548c\u652f\u6301\u7684\u503c\u5217\u8868\u3002 \u53ea\u6709\u4f7f\u7528 TLS \u7248\u672c 1.2 \u53ca\u66f4\u4f4e\u7248\u672c\u7684\u8fde\u63a5\u4f1a\u53d7\u5230\u5f71\u54cd\u3002 \u76ee\u524d\u6ca1\u6709\u63a7\u5236\u5bc6\u7801\u9009\u62e9\u7684\u8bbe\u7f6e \u7531 TLS \u7248\u672c 1.3 \u8fde\u63a5\u4f7f\u7528\u3002 \u9ed8\u8ba4\u503c \u662f HIGH&#xff1a;MEDIUM&#xff1a;&#043;3DES&#xff1a;&#xff01;aNULL&#xff0c;\u8fd9\u662f\u76f8\u540c\u7684 \u4f5c\u4e3a PostgreSQL\u3002 \u8bf7\u53c2\u9605 PostgreSQL \u624b\u518c\u4ee5\u4e86\u89e3\u539f\u56e0 \u8be5\u503c\u5df2\u9009\u4e2d\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_prefer_server_ciphers &#xff08;\u5e03\u5c14\u503c&#xff09;) \u6307\u5b9a\u662f\u5426\u4f7f\u7528\u670d\u52a1\u5668\u7684 SSL \u5bc6\u7801\u9996\u9009\u9879&#xff0c;\u800c\u4e0d\u662f\u5ba2\u6237\u7aef\u7684 SSL \u5bc6\u7801\u9996\u9009\u9879\u3002 \u9ed8\u8ba4\u503c\u4e3a false\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_ecdh_curve &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u5728 ECDH \u5bc6\u94a5\u4e2d\u4f7f\u7528\u7684\u66f2\u7ebf\u7684\u540d\u79f0 \u4ea4\u6362\u3002\u5b83\u9700\u8981\u5f97\u5230\u6240\u6709\u8fde\u63a5\u7684\u5ba2\u6237\u7aef\u7684\u652f\u6301\u3002 \u5b83\u4e0d\u9700\u8981\u4e0e\u670d\u52a1\u5668\u7684 Elliptic \u4f7f\u7528\u7684\u66f2\u7ebf\u76f8\u540c \u66f2\u7ebf\u952e\u3002\u9ed8\u8ba4\u503c\u4e3a prime256v1\u3002<\/p>\n<p>\u6700\u5e38\u89c1\u66f2\u7ebf\u7684 OpenSSL \u540d\u79f0\u4e3a&#xff1a;prime256v1 &#xff08;NIST P-256&#xff09;\u3001secp384r1 &#xff08;NIST P-384&#xff09;\u3001secp521r1 &#xff08;NIST P-521&#xff09;\u3002 \u53ef\u7528\u66f2\u7ebf\u7684\u5b8c\u6574\u5217\u8868\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4 openssl ecparam -list_curves \u663e\u793a\u3002\u5e76\u975e\u5168\u90e8 \u5728 TLS \u4e2d\u53ef\u7528\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_dh_params_file &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5305\u542b Diffie-Hellman \u53c2\u6570\u7684\u6587\u4ef6\u7684\u540d\u79f0 \u7528\u4e8e\u6240\u8c13\u7684 SSL \u5bc6\u7801\u7684\u4e34\u65f6 DH \u7cfb\u5217\u3002\u9ed8\u8ba4\u503c\u4e3a \u7a7a\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u4f7f\u7528\u7f16\u8bd1\u7684\u9ed8\u8ba4 DH \u53c2\u6570\u3002\u7528 \u5982\u679c\u653b\u51fb\u8005\u8bbe\u6cd5 \u7834\u89e3\u4f17\u6240\u5468\u77e5\u7684\u7f16\u8bd1 DH \u53c2\u6570\u3002\u60a8\u53ef\u4ee5\u521b\u5efa\u81ea\u5df1\u7684 DH \u53c2\u6570\u6587\u4ef6&#xff0c;\u5176\u4e2d\u5305\u542b\u547d\u4ee4 openssl -out dhparams.pem 2048\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ssl_passphrase_command &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u8bbe\u7f6e\u5728\u7528\u4e8e\u89e3\u5bc6\u7684\u5bc6\u7801\u65f6\u8981\u8c03\u7528\u7684\u5916\u90e8\u547d\u4ee4 \u9700\u8981\u83b7\u53d6 SSL \u6587\u4ef6&#xff0c;\u4f8b\u5982\u79c1\u94a5\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c; \u6b64\u53c2\u6570\u4e3a\u7a7a&#xff0c;\u8fd9\u610f\u5473\u7740\u5982\u679c\u9700\u8981\u5bc6\u7801&#xff0c;\u5219\u4e0d\u4f1a\u52a0\u8f7d SSL \u6587\u4ef6\u3002<\/p>\n<p>\u8be5\u547d\u4ee4\u5fc5\u987b\u5c06\u5bc6\u7801\u6253\u5370\u5230\u6807\u51c6\u8f93\u51fa\u4e2d&#xff0c;\u5e76\u4e14 \u4ee5\u4ee3\u7801 0 \u9000\u51fa\u3002\u5728\u53c2\u6570\u503c\u4e2d&#xff0c;%p \u66ff\u6362\u4e3a\u63d0\u793a\u7b26 \u5b57\u7b26\u4e32\u3002&#xff08;\u5bf9\u4e8e\u6587\u672c %&#xff0c;\u8bf7\u5199\u5165 %%\u3002\u8bf7\u6ce8\u610f&#xff0c;\u63d0\u793a\u5b57\u7b26\u4e32\u53ef\u80fd\u4f1a \u5305\u542b\u7a7a\u683c&#xff0c;\u56e0\u6b64\u8bf7\u52a1\u5fc5\u5145\u5206\u5f15\u7528\u3002\u5355\u4e2a\u6362\u884c\u7b26\u88ab\u5265\u79bb \u4ece\u8f93\u51fa\u7684\u672b\u5c3e&#xff08;\u5982\u679c\u5b58\u5728&#xff09;\u3002<\/p>\n<p>\u8be5\u547d\u4ee4\u5b9e\u9645\u4e0a\u4e0d\u5fc5\u63d0\u793a\u7528\u6237\u8f93\u5165\u5bc6\u7801\u3002 \u5b83\u53ef\u4ee5\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u5b83&#xff0c;\u4ece\u94a5\u5319\u4e32\u5de5\u5177\u4e2d\u83b7\u53d6\u5b83&#xff0c;\u6216\u7c7b\u4f3c\u7684\u4e1c\u897f\u3002 \u7528\u6237\u6709\u8d23\u4efb\u786e\u4fdd\u6240\u9009\u673a\u5236\u8db3\u591f\u5b89\u5168\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.14.2. \u751f\u6210 SSL \u8bc1\u4e66<\/h4>\n<p>\u8bc1\u4e66\u5904\u7406\u4e0d\u5728\u672c\u6587\u6863\u7684\u8ba8\u8bba\u8303\u56f4\u4e4b\u5185\u3002\u4f4d\u4e8e postgresql.org \u7684\u201c\u4f7f\u7528 SSL \u4fdd\u62a4 TCP\/IP \u8fde\u63a5\u201d\u9875\u9762\u5177\u6709 \u5305\u542b\u793a\u4f8b\u547d\u4ee4\u7684\u6307\u9488&#xff0c;\u7528\u4e8e\u751f\u6210\u81ea\u7b7e\u540d \u8bc1\u4e66\u3002<\/p>\n<h3>1.15. \u770b\u95e8\u72d7<\/h3>\n<p>\u770b\u95e8\u72d7\u7684\u914d\u7f6e\u53c2\u6570\u5728 pgpool.conf \u4e2d\u63cf\u8ff0\u3002 \u5728 pgpool.conf.sample \u6587\u4ef6\u7684 WATCHDOG \u90e8\u5206\u6709\u793a\u4f8b\u914d\u7f6e\u3002 \u4ee5\u4e0b\u6240\u6709\u9009\u9879\u90fd\u9700\u8981\u5728 watchdog \u8fdb\u7a0b\u4e2d\u6307\u5b9a\u3002<\/p>\n<h4>1.15.1. \u542f\u7528\u770b\u95e8\u72d7<\/h4>\n<p>use_watchdog &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5982\u679c\u6253\u5f00&#xff0c;\u5219\u6fc0\u6d3b watchdog\u3002\u9ed8\u8ba4\u4e3a off<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>pgpool-II 4.1 \u6216\u66f4\u65e9\u7248\u672c&#xff0c;\u56e0\u4e3a\u5b83\u9700\u8981\u6307\u5b9a \u5b83\u81ea\u5df1\u7684 pgpool \u8282\u70b9\u4fe1\u606f\u548c\u76ee\u6807 pgpool \u8282\u70b9\u4fe1\u606f&#xff0c; \u6bcf\u4e2a pgpool \u8282\u70b9\u7684\u8bbe\u7f6e\u90fd\u4e0d\u540c\u3002 \u4ece Pgpool-II 4.2 \u5f00\u59cb&#xff0c;\u6240\u6709\u7684\u914d\u7f6e\u53c2\u6570\u90fd\u662f \u5728\u6240\u6709\u4e3b\u673a\u4e0a\u90fd\u76f8\u540c\u3002\u5982\u679c\u542f\u7528\u4e86 watchdog \u529f\u80fd&#xff0c;\u4ee5\u533a\u5206\u54ea\u4e2a\u4e3b\u673a \u662f\u54ea\u4e2a&#xff0c;\u5219\u9700\u8981 pgpool_node_id \u6587\u4ef6\u3002 \u60a8\u9700\u8981\u521b\u5efa\u4e00\u4e2a pgpool_node_id \u6587\u4ef6\u5e76\u6307\u5b9a pgpool &#xff08;\u770b\u95e8\u72d7&#xff09; \u8282\u70b9\u53f7 &#xff08;\u4f8b\u5982 0&#xff0c; 1&#xff0c; 2 \u2026&#xff09; \u6765\u8bc6\u522b pgpool &#xff08;\u770b\u95e8\u72d7&#xff09; \u4e3b\u673a\u3002<\/p>\n<p>\u4f8b 1-10.pgpool_node_id\u914d\u7f6e<\/p>\n<p>\u5982\u679c\u60a8\u6709 3 \u4e2a pgpool \u8282\u70b9&#xff0c;\u5176\u4e3b\u673a\u540d\u4e3a server1\u3001server2 \u548c server3&#xff0c;\u8bf7\u5728\u6bcf\u53f0\u4e3b\u673a\u4e0a\u521b\u5efa pgpool_node_id \u6587\u4ef6&#xff0c;\u5982\u4e0b\u6240\u793a\u3002 \u5f53\u4f7f\u7528 RPM \u5b89\u88c5 Pgpool-II \u65f6&#xff0c;pgpool.conf \u5b89\u88c5\u5728 \/etc\/pgpool-II\/ \u4e0b\u3002<\/p>\n<p>\u670d\u52a1\u5668 1<\/p>\n<p>[server1]# cat \/etc\/pgpool-II\/pgpool_node_id<br \/>\n0<\/p>\n<p>\u670d\u52a1\u5668 2<\/p>\n<p>[server2]# cat \/etc\/pgpool-II\/pgpool_node_id<br \/>\n1<\/p>\n<p>\u670d\u52a1\u5668 3<\/p>\n<p>[server3]# cat \/etc\/pgpool-II\/pgpool_node_id<br \/>\n2<\/p>\n<h4>1.15.2. \u770b\u95e8\u72d7\u901a\u4fe1<\/h4>\n<p>hostnameX &#xff08;\u5b57\u7b26\u4e32) \u6307\u5b9a Pgpool-II \u670d\u52a1\u5668\u7684\u4e3b\u673a\u540d\u6216 IP \u5730\u5740\u3002 \u8fd9\u7528\u4e8e\u53d1\u9001\/\u63a5\u6536\u67e5\u8be2\u548c\u6570\u636e\u5305&#xff0c; \u4ee5\u53ca\u4f5c\u4e3a watchdog \u8282\u70b9\u7684\u6807\u8bc6\u7b26\u3002 \u5f15\u7528\u53c2\u6570\u540d\u79f0\u672b\u5c3e\u7684\u6570\u5b57 \u4f5c\u4e3a \u201cpgpool node id\u201d&#xff0c;\u5b83\u4ece 0 \u5f00\u59cb&#xff08;\u4f8b\u5982 hostname0&#xff09;\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_portX &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u770b\u95e8\u72d7\u8981\u4f7f\u7528\u7684\u7aef\u53e3\u53f7 process \u6765\u76d1\u542c\u8fde\u63a5\u3002\u9ed8\u8ba4\u503c\u4e3a 9000\u3002 \u5f15\u7528\u53c2\u6570\u540d\u79f0\u672b\u5c3e\u7684\u6570\u5b57 \u4f5c\u4e3a \u201cpgpool node id\u201d&#xff0c;\u5b83\u4ece 0 \u5f00\u59cb&#xff08;\u4f8b\u5982 wd_port0&#xff09;\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>pgpool_portX &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a Pgpool-II \u7aef\u53e3\u53f7\u3002 \u9ed8\u8ba4\u503c\u4e3a 9999\u3002 \u5f15\u7528\u53c2\u6570\u540d\u79f0\u672b\u5c3e\u7684\u6570\u5b57 \u8bbe\u7f6e\u4e3a \u201cpgpool node id\u201d&#xff0c;\u5e76\u4e14\u4ece 0 \u5f00\u59cb&#xff08;\u4f8b\u5982 pgpool_port0&#xff09;\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>\u4f8b 1-11.\u770b\u95e8\u72d7\u914d\u7f6e<\/p>\n<p>\u5982\u679c\u60a8\u6709 3 \u4e2a pgpool \u8282\u70b9&#xff0c;\u5176\u4e3b\u673a\u540d\u4e3a server1\u3001server2 \u548c server3&#xff0c; \u60a8\u53ef\u4ee5\u914d\u7f6e\u4e3b\u673a\u540d\u3001wd_port \u548c pgpool_port&#xff0c;\u5982\u4e0b\u6240\u793a&#xff1a;<\/p>\n<p>hostname0 &#061; \u2018server1\u2019 wd_port0 &#061; 9000 pgpool_port0 &#061; 9999<\/p>\n<p>hostname1 &#061; \u2018server2\u2019 wd_port1 &#061; 9000 pgpool_port1 &#061; 9999<\/p>\n<p>hostname2 &#061; \u2018server3\u2019 wd_port2 &#061; 9000 pgpool_port2 &#061; 9999<\/p>\n<p>wd_authkey &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u6240\u6709 watchdog \u901a\u4fe1\u7684\u8eab\u4efd\u9a8c\u8bc1\u5bc6\u94a5\u3002 \u6240\u6709 Pgpool-II \u5fc5\u987b\u5177\u6709\u76f8\u540c\u7684 key\u3002 \u6765\u81ea\u4e0d\u540c\u5bc6\u94a5\u7684 watchdog \u7684\u6570\u636e\u5305\u5c06\u88ab\u62d2\u7edd\u3002 \u6b64\u8eab\u4efd\u9a8c\u8bc1\u4e5f\u9002\u7528\u4e8e\u68c0\u6d4b\u4fe1\u53f7 \u5f53 Heartbeat Mode \u7528\u4f5c LifeCheck \u65b9\u6cd5\u65f6\u3002<\/p>\n<p>\u56e0\u4e3a\u5728 Pgpool-IIV3.5 \u6216\u66f4\u9ad8\u7248\u672c\u4e2d&#xff0c;wd_authkey \u4e5f\u88ab\u7528\u6765\u9a8c\u8bc1 \u770b\u95e8\u72d7 IPC \u5ba2\u6237\u7aef&#xff0c; \u6240\u6709\u4e0e Pgpool-II \u770b\u95e8\u72d7\u8fdb\u7a0b\u901a\u4fe1\u7684\u5ba2\u6237\u7aef\u90fd\u9700\u8981\u63d0\u4f9b\u8fd9\u4e2a wd_authkey \u503c \u5bf9\u4e8e JSON \u6570\u636e\u4e2d\u7684 \u201cIPCAuthKey\u201d \u952e \u7684\u547d\u4ee4\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a \u2018\u2019 &#xff08;\u7a7a&#xff09;&#xff0c;\u8868\u793a\u7981\u7528 \u770b\u95e8\u72d7\u8eab\u4efd\u9a8c\u8bc1\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.15.3. \u4e0a\u6e38\u670d\u52a1\u5668\u8fde\u63a5<\/h4>\n<p>\u4e0a\u6e38\u670d\u52a1\u5668\u662f Pgpool-II \u670d\u52a1\u7684\u5ba2\u6237\u7aef&#xff08;\u6570\u636e\u5e93\u5ba2\u6237\u7aef&#xff09;\u3002 \u5373\u4f7f Pgpool-II \u8fd8\u6d3b\u7740\u5e76\u4e14 \u8fde\u63a5\u5230 PostgreSQL&#xff0c; \u5982\u679c\u4e0e\u4e0a\u6e38\u670d\u52a1\u5668\u7684\u94fe\u63a5\u65ad\u5f00&#xff0c;Pgpool-II \u5c06\u65e0\u6cd5\u63d0\u4f9b\u670d\u52a1\u3002 \u56e0\u6b64&#xff0c;\u8be5\u770b\u95e8\u72d7\u8fd8\u4f1a\u76d1\u63a7\u4e0e\u4e0a\u6e38\u670d\u52a1\u5668\u7684\u8fde\u63a5 \u6765\u81ea Pgpool-II\u3002<\/p>\n<p>trusted_servers &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u68c0\u67e5\u4e0a\u6e38\u8fde\u63a5\u7684\u53d7\u4fe1\u4efb\u670d\u52a1\u5668\u5217\u8868\u3002 \u4f8b\u5982&#xff0c;Pgpool-II \u548c\u4e0a\u6e38\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u4e0a\u6e38\u670d\u52a1\u5668\u6216\u8def\u7531\u5668\u5217\u8868\u3002 \u5217\u8868\u4e2d\u7684\u6bcf\u53f0\u670d\u52a1\u5668\u90fd\u9700\u8981\u54cd\u5e94 ping\u3002 \u6307\u5b9a\u4ee5\u9017\u53f7\u5206\u9694\u7684\u670d\u52a1\u5668\u5217\u8868&#xff0c;\u4f8b\u5982 \u201chostA&#xff0c;hostB&#xff0c;hostC\u201d\u3002 \u5982\u679c\u65e0\u6cd5\u8bbf\u95ee\u4efb\u4f55\u670d\u52a1\u5668&#xff0c;\u5219\u770b\u95e8\u72d7\u4f1a\u5c06\u5176\u89c6\u4e3a Pgpool-II \u5931\u8d25\u3002 \u56e0\u6b64&#xff0c;\u5efa\u8bae\u6307\u5b9a\u591a\u4e2a\u670d\u52a1\u5668\u3002 \u8bf7\u6ce8\u610f&#xff0c;\u60a8\u4e0d\u5e94\u5c06 PostgreSQL \u670d\u52a1\u5668\u5206\u914d\u7ed9\u6b64\u53c2\u6570\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>trusted_server_command &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a Pgpool-II \u68c0\u67e5\u65f6\u8981\u8fd0\u884c\u7684\u7528\u6237\u547d\u4ee4 \u53d7\u4fe1\u4efb\u7684\u670d\u52a1\u5668\u54cd\u5e94 ping\u3002\u5b57\u7b26\u4e32\u4e2d\u7684\u4efb\u4f55 %h \u90fd\u5c06\u88ab\u6bcf\u4e2a\u4e3b\u673a\u66ff\u6362 \u540d\u79f0 \u6307\u5b9a\u7684 trusted_servers\u3002\u9ed8\u8ba4\u503c\u4e3a ping -q -c3 %h\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.15.4. \u865a\u62df IP \u63a7\u5236<\/h4>\n<p>delegate_ip &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a Pgpool-II \u7684\u865a\u62df IP \u5730\u5740 &#xff08;VIP&#xff09; \u8fde\u63a5 \u5ba2\u6237\u7aef\u670d\u52a1\u5668&#xff08;\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\u7b49&#xff09;\u3002\u5f53 Pgpool-II \u4ece standby \u5207\u6362\u5230 active&#xff0c;\u5219 Pgpool-II \u63a5\u7ba1\u8fd9\u4e2a \u8d35\u5bbe\u3002\u5982\u679c\u8fbe\u5230\u6cd5\u5b9a\u4eba\u6570&#xff0c;\u5219\u4e0d\u4f1a\u63d0\u51fa VIP \u4e0d\u5b58\u5728\u3002\u9ed8\u8ba4\u503c\u4e3a \u2018\u2019&#xff08;\u7a7a&#xff09;&#xff1a;\u5176\u4e2d \u610f\u5473\u7740\u865a\u62df IP \u6c38\u8fdc\u4e0d\u4f1a\u88ab\u542f\u52a8\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>if_cmd_path &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a Pgpool-II \u5c06\u7528\u4e8e\u5207\u6362\u7cfb\u7edf\u4e0a\u865a\u62df IP \u7684\u547d\u4ee4\u7684\u8def\u5f84\u3002 \u4ec5\u8bbe\u7f6e\u5305\u542b\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u76ee\u5f55\u7684\u8def\u5f84&#xff0c; \u4f8b\u5982 \u201c\/sbin\u201d \u6216\u6b64\u7c7b\u76ee\u5f55\u3002 \u5982\u679c if_up_cmd \u6216 if_down_cmd \u4ee5 \u201c\/\u201d \u5f00\u5934&#xff0c; \u6b64\u53c2\u6570\u5c06\u88ab\u5ffd\u7565\u3002 \u9ed8\u8ba4\u503c\u4e3a \/sbin\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>if_up_cmd &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u542f\u52a8\u865a\u62df IP \u7684\u547d\u4ee4\u3002 \u8bbe\u7f6e\u547d\u4ee4\u548c\u53c2\u6570&#xff0c;\u4f8b\u5982 \u201cip addr add <span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span>\/24 dev eth0 label eth0&#xff1a;0\u201d\u3002 \u7531\u4e8e\u6267\u884c\u6b64\u547d\u4ee4\u9700\u8981 root \u6743\u9650&#xff0c;\u56e0\u6b64 \u5728 IP \u547d\u4ee4\u4e0a\u4f7f\u7528 setuid \u6216 \u5141\u8bb8 Pgpool-II \u542f\u52a8\u7528\u6237&#xff08;\u9ed8\u8ba4\u4e3a postgres \u7528\u6237&#xff09; \u5728\u6ca1\u6709\u5bc6\u7801\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c sudo \u547d\u4ee4&#xff0c;\u5e76\u6307\u5b9a\u5b83&#xff0c;\u4f8b\u5982 \u201c\/usr\/bin\/sudo \/sbin\/ip addr add <span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span>\/24 dev eth0 label eth0&#xff1a;0\u201d\u3002<span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span> \u5c06\u88ab IP \u5730\u5740\u66ff\u6362 \u5728 delegate_ip \u4e2d\u6307\u5b9a\u3002<\/p>\n<p>\u9ed8\u8ba4\u4e3a \/usr\/bin\/sudo \/sbin\/ip addr add <span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span>\/24 dev eth0 label eth0&#xff1a;0\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>if_down_cmd &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u5173\u95ed\u865a\u62df IP \u7684\u547d\u4ee4\u3002 \u8bbe\u7f6e\u547d\u4ee4\u548c\u53c2\u6570&#xff0c;\u4f8b\u5982 \u201cip addr del <span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span>\/24 dev eth0\u201d\u3002 \u7531\u4e8e\u6267\u884c\u6b64\u547d\u4ee4\u9700\u8981 root \u6743\u9650&#xff0c;\u56e0\u6b64 \u5728 IP \u547d\u4ee4\u4e0a\u4f7f\u7528 setuid \u6216 \u5141\u8bb8 Pgpool-II \u542f\u52a8\u7528\u6237&#xff08;\u9ed8\u8ba4\u4e3a postgres \u7528\u6237&#xff09; \u5728\u6ca1\u6709\u5bc6\u7801\u7684\u60c5\u51b5\u4e0b\u6267\u884c sudo \u547d\u4ee4&#xff0c;\u5e76\u6307\u5b9a\u5b83&#xff0c;\u4f8b\u5982 \u201c\/usr\/bin\/sudo \/sbin\/ip addr del <span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span>\/24 dev eth0\u201d\u3002<span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span> \u5c06\u88ab IP \u5730\u5740\u66ff\u6362 \u5728 delegate_ip \u4e2d\u6307\u5b9a\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a \/usr\/bin\/sudo \/sbin\/ip addr del <span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span>\/24 dev eth0\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>arping_path &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a Pgpool-II \u5728\u865a\u62df IP \u5207\u6362\u540e\u53d1\u9001 ARP \u8bf7\u6c42\u7684\u547d\u4ee4\u7684\u8def\u5f84\u3002 \u4ec5\u8bbe\u7f6e\u5305\u542b\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u76ee\u5f55\u7684\u8def\u5f84&#xff0c; \u4f8b\u5982 \u201c\/usr\/sbin\u201d \u6216\u7c7b\u4f3c\u76ee\u5f55\u3002 \u5982\u679c arping_cmd \u4ee5 \u201c\/\u201d \u5f00\u5934&#xff0c; \u6b64\u53c2\u6570\u5c06\u88ab\u5ffd\u7565\u3002 \u9ed8\u8ba4\u503c\u4e3a \/usr\/sbin\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>arping_cmd &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u53d1\u9001 ARP \u8bf7\u6c42\u7684\u547d\u4ee4 \u5728\u865a\u62df IP \u5207\u6362\u4e4b\u540e\u3002 \u8bbe\u7f6e\u547d\u4ee4\u548c\u53c2\u6570&#xff0c;\u4f8b\u5982 arping -U <span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span> -w 1 -I eth0\u3002 \u7531\u4e8e\u6267\u884c\u6b64\u547d\u4ee4\u9700\u8981 root \u6743\u9650&#xff0c;\u56e0\u6b64 \u5728 IP \u547d\u4ee4\u4e0a\u4f7f\u7528 setuid \u6216 \u5141\u8bb8 Pgpool-II \u542f\u52a8\u7528\u6237&#xff08;\u9ed8\u8ba4\u4e3a postgres \u7528\u6237&#xff09; \u4e0d\u5e26\u5bc6\u7801\u6267\u884c sudo \u547d\u4ee4&#xff0c;\u5e76\u6307\u5b9a \u201c\/usr\/bin\/sudo \/usr\/sbin\/arping -U <span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span> -w 1 -I eth0\u201d \u7b49\u3002<span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span> \u5c06\u88ab delegate_ip\u4e2d\u6307\u5b9a\u7684 IP \u5730\u5740\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a \/usr\/bin\/sudo \/usr\/sbin\/arping -U <span class=\"katex--inline\">KaTeX parse error: Expected group after &#039;_&#039; at position 4: _IP_\u0332<\/span> -w 1 -I eth0\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>ping_path &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a ping \u547d\u4ee4\u7684\u8def\u5f84&#xff0c;\u7528\u4e8e\u68c0\u67e5\u865a\u62df IP \u7684\u542f\u52a8\u60c5\u51b5\u3002 \u8bbe\u7f6e\u5305\u542b ping \u5b9e\u7528\u7a0b\u5e8f\u7684\u76ee\u5f55\u7684\u552f\u4e00\u8def\u5f84&#xff0c; \u4f8b\u5982 \u201c\/bin\u201d \u6216\u6b64\u7c7b\u76ee\u5f55\u3002 \u9ed8\u8ba4\u503c\u4e3a \/bin\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.15.5. \u5347\u7ea7\u548c\u964d\u7ea7\u7684\u884c\u4e3a<\/h4>\n<p>\u5173\u4e8e Pgpool-II \u5347\u7ea7\u5230 active &#xff08;\u865a\u62df IP \u6301\u6709\u8005&#xff09; \u65f6\u7684\u884c\u4e3a\u7684\u914d\u7f6e<\/p>\n<p>clear_memqcache_on_escalation &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u8bbe\u7f6e\u4e3a on \u65f6&#xff0c;\u770b\u95e8\u72d7\u4f1a\u6e05\u9664\u5171\u4eab\u5185\u5b58\u4e2d\u7684\u6240\u6709\u67e5\u8be2\u7f13\u5b58 \u5f53 pgpool-II \u5347\u7ea7\u4e3a active \u65f6\u3002\u8fd9\u53ef\u4ee5\u9632\u6b62\u65b0\u7684\u6d3b\u52a8 Pgpool-II \u4f7f\u7528\u4e0e\u65e7\u6d3b\u52a8 Pgpool-II \u4e0d\u4e00\u81f4\u7684\u65e7\u67e5\u8be2\u7f13\u5b58\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a on\u3002<\/p>\n<p>\u8fd9\u4ec5\u5728 memqcache_method \u4e3a \u2018shmem\u2019 \u65f6\u6709\u6548\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_escalation_command &#xff08;\u5b57\u7b26\u4e32&#xff09;) Watchdog \u5728\u5347\u7ea7\u7684\u8282\u70b9\u4e0a\u6267\u884c\u6b64\u547d\u4ee4 \u9886\u5bfc\u76d1\u7763\u673a\u6784\u3002<\/p>\n<p>\u6b64\u547d\u4ee4\u5728\u542f\u52a8 \u865a\u62df IP&#xff08;\u5982\u679c\u5728\u8282\u70b9\u4e0a\u914d\u7f6e\u4e86&#xff09;\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_de_escalation_command &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u5f53 Pgpool-II \u770b\u95e8\u72d7\u8282\u70b9\u9000\u51fa\u9886\u5bfc\u8282\u70b9\u804c\u8d23\u65f6&#xff0c;\u770b\u95e8\u72d7\u4f1a\u5728\u8be5\u8282\u70b9\u4e0a\u6267\u884c\u6b64\u547d\u4ee4\u3002 \u9886\u5bfc\u770b\u95e8\u72d7\u8282\u70b9\u53ef\u4ee5\u9000\u51fa\u9886\u5bfc\u8282\u70b9&#xff0c; \u5f53\u9886\u5bfc\u8282\u70b9 Pgpool-II \u5173\u95ed\u65f6&#xff0c;\u68c0\u6d4b\u5230\u7f51\u7edc blackout \u6216\u68c0\u6d4b\u5230 lost of quorum\u3002<\/p>\n<p>\u6b64\u547d\u4ee4\u5728\u5173\u95ed\u865a\u62df\/\u6d6e\u52a8 IP \u5730\u5740\u4e4b\u524d\u6267\u884c \u5982\u679c\u5728 Watchdog \u8282\u70b9\u4e0a\u914d\u7f6e\u4e86\u5b83\u3002<\/p>\n<p>wd_de_escalation_command \u5728 Pgpool-II V3.5 \u4e4b\u524d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.15.6. \u63a7\u5236 Failover \u884c\u4e3a<\/h4>\n<p>\u8fd9\u4e9b\u8bbe\u7f6e\u7528\u4e8e\u63a7\u5236\u542f\u7528\u770b\u95e8\u72d7\u65f6\u540e\u7aef\u8282\u70b9\u6545\u969c\u8f6c\u79fb\u7684\u884c\u4e3a\u3002 \u8fd9\u4e9b\u914d\u7f6e\u7684\u6548\u679c\u4ec5\u9650\u4e8e Pgpool-II \u5185\u90e8\u53d1\u8d77\u7684\u6545\u969c\u8f6c\u79fb\/\u9000\u5316\u8bf7\u6c42&#xff0c;\u800c\u7528\u6237\u53d1\u8d77\u7684 detach \u540e\u7aef\u8bf7\u6c42 &#xff08;\u4f7f\u7528 PCP \u547d\u4ee4&#xff09;\u7ed5\u8fc7\u8fd9\u4e9b\u914d\u7f6e\u8bbe\u7f6e\u3002<\/p>\n<p>failover_when_quorum_exists &#xff08;\u5e03\u5c14\u503c&#xff09;) \u542f\u7528\u540e&#xff0c;Pgpool-II \u5728\u540e\u7aef\u8282\u70b9\u4e0a\u6267\u884c\u9000\u5316\/\u6545\u969c\u8f6c\u79fb\u65f6\u5c06\u8003\u8651 quorum\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u8bf4\u201c\u4ef2\u88c1\u5b58\u5728\u201d&#xff0c;\u5982\u679c live \u770b\u95e8\u72d7\u8282\u70b9&#xff08;\u5373 Number \u7684 Pgpool-II \u8282\u70b9&#xff09;\u53ef\u4ee5\u662f majority \u7684 watchdog \u8282\u70b9\u603b\u6570\u3002\u4e3a \u4f8b\u5982&#xff0c;\u5047\u8bbe Watchdog \u8282\u70b9\u6570\u4e3a 5\u3002\u5982\u679c number \u4e3a \u6d3b\u52a8\u8282\u70b9\u6570\u5927\u4e8e\u6216\u7b49\u4e8e 3&#xff0c;\u5219 quorum \u5b58\u5728\u3002\u53e6\u4e00\u65b9\u9762&#xff0c;\u5982\u679c\u6d3b\u52a8\u8282\u70b9\u6570\u4e3a 2 \u6216 lower&#xff0c;\u5219 quorum \u4e0d\u5b58\u5728&#xff0c;\u56e0\u4e3a\u5b83\u4ece\u6765\u90fd\u4e0d\u5b58\u5728 \u5927\u591a\u6570\u3002<\/p>\n<p>\u5982\u679c quorum \u5b58\u5728&#xff0c;Pgpool-II \u53ef\u4ee5\u5728\u6545\u969c\u68c0\u6d4b\u65b9\u9762\u505a\u5f97\u66f4\u597d&#xff0c;\u56e0\u4e3a\u5373\u4f7f \u770b\u95e8\u72d7\u8282\u70b9\u8bef\u68c0\u5230\u540e\u7aef\u8282\u70b9\u6545\u969c&#xff0c; \u5176\u4ed6\u4e3b\u8981\u770b\u95e8\u72d7\u8282\u70b9\u4f1a\u62d2\u7edd\u5b83\u3002Pgpool-II \u5c31\u662f\u8fd9\u6837\u5de5\u4f5c\u7684 \u5f53 failover_require_consensus \u5904\u4e8e\u5f00\u542f\u72b6\u6001\u65f6 &#xff08;\u9ed8\u8ba4&#xff09;&#xff0c;\u4f46\u60a8\u53ef\u4ee5\u66f4\u6539\u5b83&#xff0c;\u4ee5\u4fbf\u7acb\u5373 \u5f53\u68c0\u6d4b\u5230\u6545\u969c\u65f6&#xff0c;\u5c06\u53d1\u751f\u6545\u969c\u8f6c\u79fb\u3002 \u4e00\u4e2a Pgpool-II \u8282\u70b9\u9519\u8bef\u5730 \u68c0\u6d4b\u5230\u540e\u7aef\u8282\u70b9\u5931\u8d25&#xff0c;\u5c06\u9694\u79bb\u540e\u7aef \u8282\u70b9\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 &#8211;verbose \u9009\u9879\u8c03\u7528pcp_watchdog_info\u547d\u4ee4\u6765\u663e\u793a quorum \u7684\u5b58\u5728\u3002 \u5982\u679c Quorum state \u4e3a QUORUM EXIST \u6216 QUORUM IS ON THE EDGE&#xff0c;\u5219\u4ef2\u88c1\u5b58\u5728\u3002 \u5982\u679c Quorum state \u4e3a QUORUM ABSENT&#xff0c;\u5219\u4ef2\u88c1\u4e0d\u5b58\u5728\u3002<\/p>\n<p>\u5728\u6ca1\u6709 quorum&#xff0c;Pgpool-II \u8282\u70b9 \u68c0\u6d4b\u5230\u540e\u7aef\u5931\u8d25\u5c06\u9694\u79bb\u5931\u8d25\u7684 backend \u8282\u70b9&#xff0c;\u76f4\u5230 quorum \u518d\u6b21\u5b58\u5728\u3002<\/p>\n<p>\u5c3d\u7ba1\u53ef\u4ee5\u5f3a\u5236\u5206\u79bb\u9694\u79bb\u533a node pcp_detach_node\u547d\u4ee4&#xff0c;\u5219 \u65e0\u6cd5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u518d\u6b21\u8fde\u63a5\u8282\u70b9 using pcp_attach_node \u547d\u4ee4\u3002<\/p>\n<p>\u8fd9 \u9694\u79bb\u8282\u70b9\u7684\u884c\u4e3a\u7c7b\u4f3c\u4e8e\u5206\u79bb\u7684\u540e\u7aef\u8282\u70b9 \u4f46\u4e0e failed\/degenerate backends \u4e0d\u540c\u7684\u662f&#xff0c;quarantine status \u4e3a \u6ca1\u6709\u4f20\u64ad\u5230\u770b\u95e8\u72d7\u96c6\u7fa4\u4e2d\u7684\u5176\u4ed6 Pgpool-II \u8282\u70b9&#xff0c;\u56e0\u6b64\u5373\u4f7f\u540e\u7aef\u8282\u70b9\u5728 \u4e00\u4e2a Pgpool-II \u8282\u70b9\u4e0a\u7684\u9694\u79bb\u72b6\u6001&#xff0c;\u5176\u4ed6 Pgpool-II \u8282\u70b9\u53ef\u80fd\u4ecd\u7136 \u7ee7\u7eed\u4f7f\u7528\u8be5\u540e\u7aef\u3002<\/p>\n<p>\u5c3d\u7ba1\u9694\u79bb\u548c\u6545\u969c\u8f6c\u79fb\u64cd\u4f5c\u6709\u8bb8\u591a\u76f8\u4f3c\u4e4b\u5904&#xff0c;\u4f46\u5b83\u4eec\u5728\u4ee5\u4e0b\u65b9\u9762\u5dee\u5f02\u5f88\u5927 \u57fa\u672c\u65b9\u5f0f\u3002\u9694\u79bb\u64cd\u4f5c\u4e0d\u4f1a\u6267\u884c failover_command \u5e76\u9759\u9ed8\u5730\u5206\u79bb\u6709\u95ee\u9898\u7684\u8282\u70b9&#xff0c;\u56e0\u6b64\u5728\u4e3b\u540e\u7aef\u8282\u70b9\u88ab\u9694\u79bb\u7684\u60c5\u51b5\u4e0b&#xff0c;Pgpool-II \u4e0d\u4f1a\u63d0\u5347\u5907\u7528\u8282\u70b9\u6765\u63a5\u7ba1\u4e3b\u8282\u70b9\u7684\u804c\u8d23 \u5728\u4e3b\u8282\u70b9\u88ab\u9694\u79bb\u4e4b\u524d&#xff0c;Pgpool-II \u4e0d\u4f1a\u6709 \u4efb\u4f55\u53ef\u7528\u7684\u4e3b\u540e\u7aef\u8282\u70b9\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u4e0e\u5931\u8d25\u7684\u8282\u70b9\u4e0d\u540c&#xff0c;Pgpool-II \u4fdd\u7559\u4e86\u5065\u5eb7\u68c0\u67e5 \u5728\u9694\u79bb\u7684\u8282\u70b9\u4e0a\u8fd0\u884c&#xff0c;\u5e76\u4e14\u4e00\u65e6\u88ab\u9694\u79bb\u7684 \u8282\u70b9\u518d\u6b21\u53d8\u5f97\u53ef\u8bbf\u95ee&#xff0c;\u5b83\u4f1a\u81ea\u52a8 \u91cd\u65b0\u8fde\u63a5\u3002\u6ce8\u610f&#xff0c;\u8fd9\u4ec5\u9002\u7528\u4e8e Pgpool-II V4.1 \u6216\u66f4\u9ad8\u7248\u672c\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u4ee5\u524d\u7684\u7248\u672c&#xff0c;\u5219\u9700\u8981 pcp_attach_node\u5f53\u8fde\u63a5\u95ee\u9898 \u89e3\u51b3\u3002<\/p>\n<p>\u4ece Pgpool-II V4.1 \u5f00\u59cb&#xff0c;\u5982\u679c watchdog-leader \u8282\u70b9 \u65e0\u6cd5\u4e3a\u4e3b\u540e\u7aef\u8282\u70b9\u6545\u969c\u8f6c\u79fb\u5efa\u7acb\u5171\u8bc6&#xff0c;\u5e76\u4e14\u4e3b\u540e\u7aef\u8282\u70b9\u8fdb\u5165 quarantine \u72b6\u6001&#xff0c;\u7136\u540e\u5b83\u8f9e\u53bb\u5176 Leader\/Coordinator \u804c\u8d23\u5e76\u964d\u4f4e\u5176 wd_priority for next leader election&#xff0c;\u5e76\u8ba9\u96c6\u7fa4\u9009\u4e3e\u4e00\u4e9b\u4e0d\u540c\u7684\u65b0 leader\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5f53 Leader \u8282\u70b9\u65e0\u6cd5\u6784\u5efa\u5907\u7528\u540e\u7aef\u8282\u70b9\u6545\u969c\u7684\u5171\u8bc6\u65f6&#xff0c;\u5b83\u4e0d\u4f1a\u91c7\u53d6\u4efb\u4f55\u63aa\u65bd \u5e76\u4e14 watchdog-leader \u4e0a\u7c7b\u4f3c\u9694\u79bb\u7684\u5907\u7528\u540e\u7aef\u8282\u70b9\u4e0d\u4f1a\u89e6\u53d1\u65b0\u7684 leader \u9009\u4e3e\u3002<\/p>\n<p>\u5982\u679c\u6b64\u53c2\u6570\u4e3a off&#xff0c;\u5219\u5373\u4f7f \u4ef2\u88c1\u4e0d\u5b58\u5728\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a on\u3002<\/p>\n<p>failover_when_quorum_exists \u5728 Pgpool-II V3.7 \u4e4b\u524d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a;\u5728\u672c\u673a\u590d\u5236\u6a21\u5f0f\u4e0b\u4e0d\u5141\u8bb8\u542f\u7528 failover_when_quorum_exists\u3002<\/p>\n<p>failover_require_consensus &#xff08;\u5e03\u5c14\u503c&#xff09;) \u5f53\u542f\u7528\u65f6&#xff0c;Pgpool-II \u5c06\u5728 backend node &#xff08;\u5982\u679c\u5b58\u5728\u76d1\u89c6\u5668 Quorum&#xff09; \u5e76\u4e14\u81f3\u5c11\u9700\u8981\u6700\u5c0f\u6570\u91cf\u7684\u8282\u70b9 \u5bf9\u4e8e\u6545\u969c\u8f6c\u79fb\u7684\u4ef2\u88c1\u6295\u7968\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u5728\u4e09\u8282\u70b9\u770b\u95e8\u72d7\u96c6\u7fa4\u4e2d&#xff0c;\u6545\u969c\u8f6c\u79fb\u53ea\u4f1a\u6267\u884c\u5230 \u81f3\u5c11\u6709\u4e24\u4e2a\u8282\u70b9\u8981\u6c42\u5728\u7279\u5b9a\u540e\u7aef\u8282\u70b9\u4e0a\u6267\u884c\u6545\u969c\u8f6c\u79fb\u3002<\/p>\n<p>\u5982\u679c\u6b64\u53c2\u6570\u4e3a off&#xff0c;\u5219\u5373\u4f7f \u6ca1\u6709\u8fbe\u6210\u5171\u8bc6\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a on\u3002<\/p>\n<p>\u8c28\u614e \u5f53 failover_require_consensus \u4e3a enabled&#xff0c;\u5219 Pgpool-II \u4e0d\u4f1a \u6267\u884c\u6545\u969c\u8f6c\u79fb&#xff0c;\u76f4\u5230\u5b83\u83b7\u5f97\u8db3\u591f\u7684\u9009\u7968 \u5176\u4ed6 Pgpool-II \u8282\u70b9\u3002\u539f\u6765\u5982\u6b64 \u5f3a\u70c8\u5efa\u8bae\u5728 \u6240\u6709 Pgpool-II \u8282\u70b9&#xff0c;\u4ee5\u786e\u4fdd \u6b63\u786e\u68c0\u6d4b\u540e\u7aef\u8282\u70b9\u6545\u969c\u3002\u4e86\u89e3\u66f4\u591a \u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u7684\u8be6\u7ec6\u4fe1\u606f&#xff0c; \u53c2\u89c1 Section 1.9 \u3002<\/p>\n<p>\u6ce8\u610f&#xff1a;\u5728\u672c\u673a\u590d\u5236\u6a21\u5f0f\u4e0b\u4e0d\u5141\u8bb8\u542f\u7528 failover_require_consensus\u3002<\/p>\n<p>failover_require_consensus \u5728 Pgpool-II V3.7 \u4e4b\u524d\u4e0d\u53ef\u7528\u3002\u800c\u8fd9\u53ea\u662f \u542f\u7528 failover_when_quorum_exists \u65f6\u751f\u6548<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>allow_multiple_failover_requests_from_node &#xff08;\u5e03\u5c14\u503c&#xff09;) \u6b64\u53c2\u6570\u4e0e failover_require_consensus \u7ed3\u5408\u4f7f\u7528\u3002\u542f\u7528\u540e&#xff0c;\u5355\u4e2a Pgpool-II \u8282\u70b9\u53ef\u4ee5\u4e3a\u6545\u969c\u8f6c\u79fb\u6295\u4e0b\u591a\u4e2a\u9009\u7968\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u5728\u4e00\u4e2a 3 \u8282\u70b9\u770b\u95e8\u72d7\u96c6\u7fa4\u4e2d&#xff0c;\u5982\u679c\u4e00\u4e2a Pgpool-II \u8282\u70b9\u53d1\u9001\u4e24\u4e2a \u7279\u5b9a\u540e\u7aef\u8282\u70b9\u6545\u969c\u8f6c\u79fb\u7684\u6545\u969c\u8f6c\u79fb\u8bf7\u6c42&#xff0c;\u4e24\u4e2a\u8bf7\u6c42\u90fd\u5c06\u8ba1\u4e3a\u5355\u72ec\u7684 \u6295\u7968\u8d5e\u6210\u6545\u969c\u8f6c\u79fb&#xff0c;\u7136\u540e Pgpool-II \u5c06\u6267\u884c\u6545\u969c\u8f6c\u79fb&#xff0c; \u5373\u4f7f\u5b83\u6ca1\u6709\u5f97\u5230\u4efb\u4f55\u5176\u4ed6 Pgpool-II \u8282\u70b9\u7684\u6295\u7968\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u5982\u679c\u5728\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u8f6e\u6b21\u4e2d\u53d1\u73b0\u9519\u8bef \u6ca1\u6709\u5f97\u5230\u8db3\u591f\u7684\u6295\u7968&#xff0c;\u9519\u8bef\u4ecd\u7136\u5b58\u5728&#xff0c;\u4e0b\u4e00\u8f6e \u7684\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u5c06\u518d\u6295\u4e00\u7968\u3002\u6b64\u53c2\u6570\u4e3a \u5982\u679c\u8981\u68c0\u6d4b\u53ef\u80fd \u4e0d\u4f1a\u88ab\u5176\u4ed6 watchdog \u8282\u70b9\u627e\u5230\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>allow_multiple_failover_requests_from_node \u5728 Pgpool-II V3.7 \u4e4b\u524d\u4e0d\u53ef\u7528\u3002\u800c\u8fd9\u53ea\u662f \u5728 failover_when_quorum_exists \u548c failover_require_consensus \u90fd\u542f\u7528\u65f6\u751f\u6548<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>enable_consensus_with_half_votes &#xff08;\u5e03\u5c14\u503c&#xff09;) \u6b64\u53c2\u6570\u914d\u7f6e\u591a\u6570\u89c4\u5219\u7684\u8ba1\u7b97\u65b9\u5f0f \u7531 Pgpool-II \u7528\u4e8e\u8ba1\u7b97 \u4ef2\u88c1\u548c\u89e3\u51b3\u6545\u969c\u8f6c\u79fb\u7684\u5171\u8bc6\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u6b64\u53c2\u6570\u4e0d\u4ec5\u5f71\u54cd backend \u7684 Quorum \u548c Pgpool-II \u672c\u8eab\u7684\u6545\u969c\u8f6c\u79fb\u884c\u4e3a\u3002<\/p>\n<p>\u542f\u7528\u540e&#xff0c;\u6545\u969c\u8f6c\u79fb\u65f6 quorum \u548c consensus \u7684\u5b58\u5728\u53ea\u9700\u8981 \u96c6\u7fa4\u4e2d\u914d\u7f6e\u7684\u6295\u7968\u603b\u6570\u3002\u5426\u5219&#xff0c;\u8fd9\u4e24\u8005\u90fd\u662f \u51b3\u7b56\u9700\u8981\u81f3\u5c11\u591a\u4e00\u7968&#xff0c;\u8d85\u8fc7\u603b\u7968\u6570\u7684\u4e00\u534a\u3002 \u5bf9\u4e8e\u6545\u969c\u8f6c\u79fb&#xff0c;\u6b64\u53c2\u6570\u4e0e failover_require_consensus \u7ed3\u5408\u4f7f\u7528\u3002\u5728\u8fd9\u4e24\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u65e0\u8bba\u662f\u5c06 \u51b3\u5b9a\u5b58\u5728\u4ef2\u88c1\u6216\u5c31\u6545\u969c\u8f6c\u79fb\u8fbe\u6210\u5171\u8bc6 \u53c2\u6570\u4ec5\u5728 watchdog cluster \u914d\u7f6e\u4e3a\u5076\u6570\u65f6\u8d77\u4f5c\u7528 Pgpool-II \u8282\u70b9\u7684\u6570\u91cf\u3002 \u5177\u6709\u5947\u6570\u4e2a\u53c2\u4e0e\u8005\u7684 watchdog \u96c6\u7fa4\u4e2d\u7684\u591a\u6570\u89c4\u5219\u51b3\u7b56\u3002 \u5b83\u4e0d\u53d7\u6b64\u914d\u7f6e\u53c2\u6570\u503c\u7684\u5f71\u54cd\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u5f53\u5728\u53cc\u8282\u70b9\u770b\u95e8\u72d7\u4e2d\u542f\u7528\u6b64\u53c2\u6570\u65f6 cluster \u7684 Bean \u8282\u70b9&#xff0c;\u4e00\u4e2a Pgpool-II \u8282\u70b9\u9700\u8981 \u5b58\u6d3b\u4ee5\u4f7f quorum \u5b58\u5728\u3002\u5982\u679c\u8be5\u53c2\u6570\u5904\u4e8e\u5173\u95ed\u72b6\u6001&#xff0c;\u5219\u4e3a 2 \u4e2a \u8282\u70b9\u9700\u8981\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001\u624d\u80fd\u4f7f quorum \u5b58\u5728\u3002<\/p>\n<p>\u5728 4 \u8282\u70b9 watchdog \u96c6\u7fa4\u4e2d\u542f\u7528\u6b64\u53c2\u6570\u65f6&#xff0c; \u4e24\u4e2a Pgpool-II \u8282\u70b9\u9700\u8981\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001 \u4f7f quorum \u5b58\u5728\u3002\u5982\u679c\u8be5\u53c2\u6570\u5904\u4e8e\u5173\u95ed\u72b6\u6001&#xff0c;\u5219\u4e09\u4e2a\u8282\u70b9 \u9700\u8981\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001\u624d\u80fd\u4f7f quorum \u5b58\u5728\u3002<\/p>\n<p>\u901a\u8fc7\u542f\u7528\u6b64\u53c2\u6570&#xff0c;\u60a8\u5e94\u8be5\u77e5\u9053\u60a8\u91c7\u7528 \u98ce\u9669\u5bfc\u81f4\u8111\u88c2\u53d1\u751f\u3002\u4f8b\u5982&#xff0c;\u5728 4 \u4e2a\u8282\u70b9\u4e2d cluster \u7531\u8282\u70b9 A\u3001B\u3001C \u548c D \u7ec4\u6210&#xff0c;\u5219 cluster \u8fdb\u5165\u4e24\u4e2a\u72ec\u7acb\u7684\u7f51\u7edc &#xff08;A&#xff0c; B&#xff09; \u548c &#xff08;C&#xff0c; D&#xff09;\u3002\u4e3a &#xff08;A&#xff0c; B&#xff09; \u548c &#xff08;C&#xff0c; D&#xff09; \u4ef2\u88c1\u4ecd\u7136\u5b58\u5728&#xff0c;\u56e0\u4e3a\u5bf9\u4e8e\u8fd9\u4e24\u4e2a\u7ec4 4 \u4e2a\u6d3b\u52a8\u8282\u70b9\u4e2d\u6709 2 \u4e2a\u3002\u8fd9\u4e24\u4e2a\u7ec4\u9009\u62e9\u4ed6\u4eec\u7684 \u81ea\u5df1\u7684 Leader \u770b\u95e8\u72d7&#xff0c;\u5b83\u662f\u4e00\u4e2a split-brain\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>enable_consensus_with_half_votes\u4e0d\u53ef\u7528 Pgpool-II V4.1 \u4e4b\u524d\u7684\u7248\u672c\u3002\u4ee5\u524d\u7684\u7248\u672c\u6709\u6548 \u5c31\u50cf\u53c2\u6570\u662f on \u4e00\u6837\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.15.7. \u63a7\u5236\u770b\u95e8\u72d7\u96c6\u7fa4\u6210\u5458\u8d44\u683c<\/h4>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;\u770b\u95e8\u72d7\u96c6\u7fa4\u7531\u6240\u6709\u770b\u95e8\u72d7\u8282\u70b9\u7ec4\u6210 \u5728 pgpool.conf \u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684 \u4e0e\u8282\u70b9\u7684\u5f53\u524d\u72b6\u6001\u65e0\u5173\u3002\u8282\u70b9 \u662f LOST\u3001SHUTDOWN \u6216\u4ece\u672a\u542f\u52a8&#xff0c;\u5219\u8be5\u8282\u70b9\u88ab\u89c6\u4e3a watchdog \u96c6\u7fa4\u5b9a\u4e49&#xff0c;\u53ea\u8981\u5b83\u5728 \u914d\u7f6e\u6587\u4ef6\u3002 \u7528\u4e8e\u8bc6\u522b\u5b58\u5728\u7684\u6240\u6709\u591a\u6570\u89c4\u5219\u8ba1\u7b97 \u7684 Quorum \u548c\u89e3\u51b3\u5171\u8bc6\u662f\u6839\u636e \u7ec4\u6210 Watchdog \u96c6\u7fa4\u7684 Watchdog \u8282\u70b9\u6570\u3002<\/p>\n<p>Pgpool-II V4.3 \u4f7f\u80fd \u52a8\u6001\u96c6\u7fa4\u5b9a\u4e49&#xff0c;\u901a\u8fc7\u5f15\u5165 Member \u548c Nonmember \u7684\u6982\u5ff5\u3002 \u5982\u679c\u8282\u70b9\u7684\u6210\u5458\u8d44\u683c\u4ece\u76d1\u89c6\u7a0b\u5e8f\u96c6\u7fa4\u4e2d\u88ab\u64a4\u9500&#xff0c; \u7136\u540e&#xff0c;\u96c6\u7fa4\u52a8\u6001\u5730\u91cd\u65b0\u6821\u51c6\u81ea\u8eab\u4ee5\u8c03\u6574\u6240\u6709 \u968f\u540e\u7684\u591a\u6570\u89c4\u5219\u8ba1\u7b97\u3002<\/p>\n<p>\u6240\u6709\u591a\u6570\u89c4\u5219\u8ba1\u7b97\u90fd\u662f\u6839\u636e \u6210\u5458 watchdog nodes \u800c\u4e0d\u662f\u5df2\u914d\u7f6e\u8282\u70b9\u7684\u603b\u6570\u3002<\/p>\n<p>\u4f8b\u5982&#xff1a;\u5728\u4e00\u4e2a 5 \u8282\u70b9\u96c6\u7fa4\u4e2d&#xff08;pgpool.conf \u6709 5 \u4e2a watchdog nodes defined &#xff09;\u81f3\u5c11\u9700\u8981\u4e09\u4e2a\u8282\u70b9\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001\u624d\u80fd\u8fbe\u5230 quorum\u3002 \u4f7f\u7528\u52a8\u6001\u96c6\u7fa4\u6210\u5458\u673a\u5236&#xff0c;\u96c6\u7fa4\u53ef\u4ee5\u91cd\u65b0\u8c03\u6574 \u672c\u8eab\u4ec5\u5bf9 MEMBER \u8282\u70b9\u8fdb\u884c\u8ba1\u6570 &#xff08;\u6210\u5458\u8282\u70b9\u4e0d\u4e00\u5b9a\u9700\u8981\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001&#xff09;\u3002 \u8fd9\u610f\u5473\u7740\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a live \u8282\u70b9 \u8fd8\u53ef\u4ee5\u6ee1\u8db3\u4ef2\u88c1\u8981\u6c42&#xff08;\u53d6\u51b3\u4e8e\u6210\u5458\u8d44\u683c\u6761\u4ef6\u8bbe\u7f6e&#xff09; \u5982\u679c\u5728\u67d0\u4e2a\u65f6\u95f4\u70b9&#xff0c;\u96c6\u7fa4\u53ea\u6709\u4e00\u4e2a\u6216\u4e24\u4e2a\u6210\u5458\u8282\u70b9\u3002<\/p>\n<p>\u8c28\u614e \u4f7f\u7528\u52a8\u6001\u7fa4\u96c6\u6210\u5458\u8d44\u683c\u5b58\u5728\u5bfc\u81f4\u8111\u88c2\u7684\u76f8\u5173\u98ce\u9669\u3002 \u56e0\u6b64&#xff0c;\u5f3a\u70c8\u5efa\u8bae\u4ed4\u7ec6\u68c0\u67e5\u8bbe\u7f6e\u662f\u5426\u9700\u8981\u52a8\u6001\u96c6\u7fa4 membership \u5e76\u8003\u8651\u5bf9\u76f8\u5173\u8bbe\u7f6e\u4f7f\u7528\u4fdd\u5b88\u503c\u3002<\/p>\n<p>\u8fd9\u4e9b\u8bbe\u7f6e\u914d\u7f6e\u4f55\u65f6\u5c06\u8282\u70b9\u6807\u8bb0\u4e3a Nonmember\u3002 \u5c06\u6240\u6709\u8fd9\u4e9b\u8bbe\u7f6e\u4fdd\u7559\u4e3a\u9ed8\u8ba4\u503c\u5c06\u4fdd\u7559 V4.3 \u4e4b\u524d\u7684\u884c\u4e3a\u3002<\/p>\n<p>wd_remove_shutdown_nodes &#xff08;\u5e03\u5c14\u503c&#xff09;) \u542f\u7528\u540e&#xff0c;SHUTDOWN \u8282\u70b9\u5c06\u7acb\u5373\u6807\u8bb0\u4e3a Nonmember \u5e76\u4ece\u96c6\u7fa4\u4e2d\u5220\u9664\u3002\u5982\u679c\u4e4b\u524d\u5173\u95ed\u7684\u8282\u70b9\u518d\u6b21\u542f\u52a8&#xff0c; \u5b83\u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230 Cluster \u4e2d\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>wd_lost_node_removal_timeout &#xff08;\u6574\u6570&#xff09;) \u8d85\u65f6&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;&#xff0c;\u5c06 LOST \u770b\u95e8\u72d7\u8282\u70b9\u6807\u8bb0\u4e3a Nonmember \u5e76\u4ece\u96c6\u7fa4\u4e2d\u5220\u9664\u3002 \u5f53 LOST \u8282\u70b9\u91cd\u65b0\u8fde\u63a5\u5230\u96c6\u7fa4\u65f6&#xff0c;\u5c06\u6062\u590d\u5176\u96c6\u7fa4\u6210\u5458\u8eab\u4efd\u3002<\/p>\n<p>\u5c06\u8d85\u65f6\u8bbe\u7f6e\u4e3a 0 \u5c06\u7981\u7528\u5220\u9664 \u96c6\u7fa4\u4e2d\u4e22\u5931\u7684\u8282\u70b9\u6570\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a 0\u3002<\/p>\n<p>wd_no_show_node_removal_timeout &#xff08;\u6574\u6570) \u8d85\u65f6&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;&#xff0c;\u5982\u679c\u8282\u70b9\u672a\u663e\u793a&#xff0c;\u5219\u5c06\u5176\u6807\u8bb0\u4e3a Nonmember \u5728\u96c6\u7fa4\u521d\u59cb\u5316\u65f6\u3002\u975e\u6210\u5458\u8282\u70b9\u6210\u4e3a\u96c6\u7fa4\u6210\u5458 \u4e00\u65e6\u5b83\u542f\u52a8\u5e76\u8fde\u63a5\u5230\u96c6\u7fa4\u3002<\/p>\n<p>\u5c06\u8d85\u65f6\u8bbe\u7f6e\u4e3a 0 \u5c06\u7981\u7528\u5220\u9664 \u7fa4\u96c6\u4e2d\u7684 NO-SHOW \u8282\u70b9\u6570\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a 0\u3002<\/p>\n<h4>1.15.8. \u5bff\u547d\u68c0\u67e5 Pgpool-II<\/h4>\n<p>\u770b\u95e8\u72d7\u5b9a\u671f\u68c0\u67e5 pgpool-II \u72b6\u6001\u3002\u8fd9\u79f0\u4e3a \u201c\u5bff\u547d\u68c0\u67e5\u201d\u3002<\/p>\n<p>wd_lifecheck_method &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5bff\u547d\u68c0\u67e5\u7684\u65b9\u6cd5\u3002\u8fd9\u53ef\u4ee5\u662f \u2018heartbeat\u2019 &#xff08;\u9ed8\u8ba4&#xff09;\u3001\u2018query\u2019 \u6216 \u2018external\u2019\u3002<\/p>\n<p>heartbeat&#xff1a;\u5728\u6b64\u6a21\u5f0f\u4e0b&#xff0c;\u770b\u95e8\u72d7\u53d1\u9001\u5fc3\u8df3\u4fe1\u53f7&#xff08;UDP \u6570\u636e\u5305&#xff09; \u5b9a\u671f\u53d1\u9001\u5230\u5176\u4ed6 Pgpool-II\u3002\u540c\u6837&#xff0c;\u770b\u95e8\u72d7\u4e5f\u63a5\u6536\u4fe1\u53f7 \u6765\u81ea\u5176\u4ed6 Pgpool-II . \u5982\u679c\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u6ca1\u6709\u4fe1\u53f7&#xff0c;\u5219\u770b\u95e8\u72d7\u8ba4\u4e3a\u662f\u5931\u8d25 \u7684 Pgpool-II .<\/p>\n<p>query&#xff1a;\u5728\u6b64\u6a21\u5f0f\u4e0b&#xff0c;\u770b\u95e8\u72d7\u53d1\u9001\u76d1\u63a7\u67e5\u8be2 \u5230\u5176\u4ed6 Pgpool-II \u5e76\u68c0\u67e5\u54cd\u5e94\u3002 \u5f53 Pgpool-II \u670d\u52a1\u5668\u4e4b\u95f4\u7684\u5b89\u88c5\u4f4d\u7f6e\u5f88\u8fdc\u65f6&#xff0c;\u67e5\u8be2\u53ef\u80fd\u5f88\u6709\u7528\u3002<\/p>\n<p>\u8c28\u614e \u5728\u67e5\u8be2\u6a21\u5f0f\u4e0b&#xff0c;\u5982\u679c\u60a8\u8ba1\u5212\u4f7f\u7528 watchdog&#xff0c;\u5219\u9700\u8981\u5c06 num_init_children \u8bbe\u7f6e\u5f97\u8db3\u591f\u5927\u3002 \u8fd9\u662f\u56e0\u4e3a\u770b\u95e8\u72d7\u8fdb\u7a0b\u4f5c\u4e3a\u5ba2\u6237\u7aef\u8fde\u63a5\u5230 Pgpool-II\u3002<\/p>\n<p>external&#xff1a;\u6b64\u6a21\u5f0f\u7981\u7528\u6784\u5efa\u7684 \u5728 Pgpool-II \u770b\u95e8\u72d7\u7684 lifecheck \u4e2d \u5e76\u4f9d\u8d56\u5916\u90e8\u7cfb\u7edf\u63d0\u4f9b\u8282\u70b9\u5065\u5eb7\u68c0\u67e5 \u672c\u5730\u548c\u8fdc\u7a0b\u770b\u95e8\u72d7\u8282\u70b9\u3002<\/p>\n<p>external \u6a21\u5f0f\u5728 Pgpool-II V3.5 \u4e4b\u524d\u7684\u7248\u672c\u4e2d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_monitoring_interfaces_list &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u8981\u7531 watchdog \u8fdb\u7a0b\u76d1\u63a7\u7684\u7f51\u7edc\u8bbe\u5907\u540d\u79f0\u7684\u9017\u53f7\u5206\u9694\u5217\u8868 \u5bf9\u4e8e\u7f51\u7edc\u94fe\u63a5\u72b6\u6001\u3002\u5982\u679c\u5217\u8868\u4e2d\u7684\u6240\u6709\u7f51\u7edc\u63a5\u53e3\u90fd\u53d8\u4e3a\u975e\u6d3b\u52a8\u72b6\u6001 &#xff08;\u7981\u7528\u6216\u62d4\u4e0b\u7535\u7f06&#xff09;&#xff0c;\u5219\u770b\u95e8\u72d7\u4f1a\u5c06\u5176\u89c6\u4e3a\u5b8c\u5168\u7684\u7f51\u7edc\u6545\u969c \u800c Pgpool-II \u8282\u70b9\u5c06\u81ea\u6740\u3002 \u6307\u5b9a \u2018\u2019&#xff08;\u7a7a&#xff09; \u5217\u8868\u5c06\u7981\u7528\u7f51\u7edc\u63a5\u53e3\u76d1\u63a7\u3002 \u5c06\u5176\u8bbe\u7f6e\u4e3a \u2018any\u2019 \u53ef\u5bf9\u6240\u6709\u53ef\u7528\u7f51\u7edc\u63a5\u53e3\u8fdb\u884c\u76d1\u63a7 \u4f46 loopback \u9664\u5916\u3002\u9ed8\u8ba4\u503c\u4e3a \u2018\u2019 \u7a7a\u5217\u8868&#xff08;\u7981\u7528\u76d1\u63a7&#xff09;\u3002<\/p>\n<p>wd_monitoring_interfaces_list \u5728 Pgpool-II V3.5 \u4e4b\u524d\u7684\u7248\u672c\u4e2d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_interval &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a Pgpool-II \u7684\u5bff\u547d\u68c0\u67e5\u95f4\u9694&#xff0c;\u4ee5\u79d2\u4e3a\u5355\u4f4d\u3002&#xff08;\u5927\u4e8e\u6216\u7b49\u4e8e 1 \u7684\u6570\u5b57&#xff09;\u9ed8\u8ba4\u503c\u4e3a 10\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_priority &#xff08;\u6574\u6570&#xff09;) \u6b64\u53c2\u6570\u53ef\u7528\u4e8e\u63d0\u5347\u9009\u4e3e\u4e2d\u7684\u672c\u5730\u770b\u95e8\u72d7\u8282\u70b9\u4f18\u5148\u7ea7 \u9009\u62e9 Leader Watchdog Node &#xff08;\u9886\u5bfc\u770b\u95e8\u72d7\u8282\u70b9&#xff09;\u3002 \u5c06\u9009\u62e9\u5177\u6709\u8f83\u9ad8 wd_priority \u503c\u7684\u8282\u70b9 \u4f5c\u4e3a leader watchdog node \u5f53 cluster \u5c06\u9009\u4e3e\u5176\u65b0\u7684 leader \u8282\u70b9\u65f6 \u5982\u679c\u65e7\u7684 leader watchdog \u8282\u70b9\u53d1\u751f\u6545\u969c\u3002wd_priority \u5728\u96c6\u7fa4\u542f\u52a8\u65f6\u4e5f\u6709\u6548\u3002 \u5f53\u4e00\u4e9b\u770b\u95e8\u72d7\u8282\u70b9\u540c\u65f6\u542f\u52a8\u65f6&#xff0c;\u4f1a\u9009\u62e9wd_priority\u503c\u8f83\u9ad8\u7684\u8282\u70b9\u4f5c\u4e3a\u9886\u5bfc\u8282\u70b9\u3002 \u6240\u4ee5\u6211\u4eec\u5e94\u8be5\u6309\u7167wd_priority\u4f18\u5148\u7ea7\u7684\u987a\u5e8f\u542f\u52a8\u770b\u95e8\u72d7\u8282\u70b9&#xff0c;\u4ee5\u9632\u6b62 \u610f\u5916\u8282\u70b9\u88ab\u9009\u4e3a leader\u3002 \u5982\u679c\u6bcf\u4e2a\u8282\u70b9\u7684 wd_priority \u5177\u6709\u76f8\u540c\u7684\u503c&#xff0c;\u5219 Leader \u8282\u70b9\u5c06\u6839\u636e watchdog \u7684\u542f\u52a8\u65f6\u95f4\u6765\u51b3\u5b9a\u3002<\/p>\n<p>wd_priority \u5728 Pgpool-II V3.5 \u4e4b\u524d\u7684\u7248\u672c\u4e2d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_ipc_socket_dir &#xff08;\u5b57\u7b26\u4e32&#xff09;) UNIX \u57df\u5957\u63a5\u5b57\u6240\u5728\u7684\u76ee\u5f55 \u63a5\u53d7 Pgpool-II \u770b\u95e8\u72d7\u7684 IPC \u8fde\u63a5\u5c06\u88ab\u521b\u5efa\u3002 \u9ed8\u8ba4\u4e3a \u2018\/tmp\u2019\u3002 \u8bf7\u6ce8\u610f&#xff0c;\u6b64\u5957\u63a5\u5b57\u53ef\u80fd\u4f1a\u88ab cron \u4f5c\u4e1a\u5220\u9664\u3002 \u6211\u4eec\u5efa\u8bae\u5c06\u6b64\u503c\u8bbe\u7f6e\u4e3a \u2018\/var\/run\u2019 \u6216\u6b64\u7c7b\u76ee\u5f55\u3002<\/p>\n<p>wd_ipc_socket_dir \u5728 Pgpool-II V3.5 \u4e4b\u524d\u7684\u7248\u672c\u4e2d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.15.9. Lifecheck Heartbeat \u6a21\u5f0f\u914d\u7f6e<\/h4>\n<p>heartbeat_hostnameX &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u53d1\u9001\u548c\u63a5\u6536\u68c0\u6d4b\u4fe1\u53f7\u7684 IP \u5730\u5740\u6216\u4e3b\u673a\u540d\u3002 \u5f15\u7528\u53c2\u6570\u540d\u79f0\u672b\u5c3e\u7684\u6570\u5b57 \u4f5c\u4e3a \u201cpgpool node id\u201d&#xff0c;\u5b83\u4ece 0 \u5f00\u59cb&#xff08;\u4f8b\u5982 heartbeat_hostname0&#xff09;\u3002 \u60a8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5206\u53f7 &#xff08;&#x1f609;&#xff09; \u5206\u9694\u591a\u4e2a IP \u5730\u5740\u6216\u4e3b\u673a\u540d\u6765\u6307\u5b9a\u5b83\u4eec\u3002<\/p>\n<p>heartbeat_hostnameX\u4ec5\u5728wd_lifecheck_method\u8bbe\u7f6e\u4e3a\u201cheartbeat\u201d\u65f6\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>heartbeat_portX &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u7528\u4e8e\u53d1\u9001\u548c\u63a5\u6536\u68c0\u6d4b\u4fe1\u53f7\u7684\u7aef\u53e3\u53f7\u3002 \u6b64\u5904\u4ec5\u6307\u5b9a\u4e00\u4e2a\u7aef\u53e3\u53f7\u3002\u9ed8\u8ba4\u503c\u4e3a 9694\u3002 \u5f15\u7528\u53c2\u6570\u540d\u79f0\u672b\u5c3e\u7684\u6570\u5b57 \u4f5c\u4e3a \u201cpgpool node id\u201d&#xff0c;\u5b83\u4ece 0 \u5f00\u59cb&#xff08;\u4f8b\u5982 heartbeat_port0&#xff09;\u3002<\/p>\n<p>heartbeat_portX\u4ec5\u5728wd_lifecheck_method\u8bbe\u7f6e\u4e3a \u2018heartbeat\u2019 \u65f6\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>heartbeat_deviceX &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u53d1\u9001\u548c\u63a5\u6536\u68c0\u6d4b\u4fe1\u53f7\u7684\u7f51\u7edc\u8bbe\u5907\u540d\u79f0\u3002 \u5f15\u7528\u53c2\u6570\u540d\u79f0\u672b\u5c3e\u7684\u6570\u5b57 \u4f5c\u4e3a \u201cpgpool node id\u201d&#xff0c;\u5b83\u4ece 0 \u5f00\u59cb&#xff08;\u4f8b\u5982 heartbeat_device0&#xff09;\u3002 \u60a8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5206\u53f7 &#xff08;&#x1f609; \u5206\u9694\u591a\u4e2a\u7f51\u7edc\u8bbe\u5907\u6765\u6307\u5b9a\u5b83\u4eec\u3002<\/p>\n<p>heartbeat_deviceX \u53ea\u5728 Pgpool-II \u4ee5 root \u7528\u6237\u542f\u52a8 \u7279\u6743\u3002\u5982\u679c\u4e0d\u662f&#xff0c;\u8bf7\u5c06\u5176\u4fdd\u7559\u4e3a\u7a7a\u5b57\u7b26\u4e32 &#xff08;\u2018\u2019&#xff09;\u3002<\/p>\n<p>heartbeat_deviceX\u4ec5\u5728wd_lifecheck_method\u8bbe\u7f6e\u4e3a \u2018heartbeat\u2019 \u65f6\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>\u4f8b 1-12.\u5fc3\u8df3\u914d\u7f6e<\/p>\n<p>\u5982\u679c\u60a8\u6709 3 \u4e2a pgpool \u8282\u70b9&#xff0c;\u5176\u4e3b\u673a\u540d\u4e3a server1\u3001server2 \u548c server3&#xff0c; \u60a8\u53ef\u4ee5\u914d\u7f6e heartbeat_hostname\u3001heartbeat_port \u548c heartbeat_device&#xff0c;\u5982\u4e0b\u6240\u793a&#xff1a;<\/p>\n<p> heartbeat_hostname0 &#061; &#039;server1&#039;<br \/>\n heartbeat_port0 &#061; 9694<br \/>\n heartbeat_device0 &#061; &#039;&#039;<\/p>\n<p> heartbeat_hostname1 &#061; &#039;server2&#039;<br \/>\n heartbeat_port1 &#061; 9694<br \/>\n heartbeat_device1 &#061; &#039;&#039;<\/p>\n<p> heartbeat_hostname2 &#061; &#039;server3&#039;<br \/>\n heartbeat_port2 &#061; 9694<br \/>\n heartbeat_device2 &#061; &#039;&#039;<\/p>\n<p>wd_heartbeat_keepalive &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u53d1\u9001\u68c0\u6d4b\u4fe1\u53f7\u4e4b\u95f4\u7684\u95f4\u9694\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;\u3002 \u9ed8\u8ba4\u503c\u4e3a 2\u3002wd_heartbeat_keepalive\u4ec5\u5728wd_lifecheck_method\u8bbe\u7f6e\u4e3a\u201cheartbeat\u201d\u65f6\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_heartbeat_deadtime &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a\u5c06\u8fdc\u7a0b\u770b\u95e8\u72d7\u8282\u70b9\u6807\u8bb0\u4e3a\u5931\u8d25\/\u5931\u6548\u8282\u70b9\u4e4b\u524d\u7684\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;&#xff0c; \u5982\u679c\u5728\u8be5\u65f6\u95f4\u5185\u672a\u6536\u5230\u68c0\u6d4b\u4fe1\u53f7\u3002 \u9ed8\u8ba4\u503c\u4e3a 30 wd_heartbeat_deadtime\u4ec5\u5f53 wd_lifecheck_method \u8bbe\u7f6e\u4e3a \u2018heartbeat\u2019 \u65f6\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<h4>1.15.10. Lifecheck Query \u6a21\u5f0f\u914d\u7f6e<\/h4>\n<p>wd_life_point &#xff08;\u6574\u6570) \u6307\u5b9a\u91cd\u8bd5 pgpool-II \u5931\u8d25\u7684\u5bff\u547d\u68c0\u67e5\u7684\u6b21\u6570\u3002 \u6709\u6548\u503c\u53ef\u4ee5\u662f\u5927\u4e8e\u6216\u7b49\u4e8e 1 \u7684\u6570\u5b57\u3002 \u9ed8\u8ba4\u503c\u4e3a 3\u3002<\/p>\n<p>wd_life_point\u4ec5\u5728wd_lifecheck_method\u8bbe\u7f6e\u4e3a \u2018query\u2019 \u65f6\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_lifecheck_query &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u8fdc\u7a0b Pgpool-II \u751f\u547d\u5468\u671f\u68c0\u67e5\u7684\u67e5\u8be2\u3002 \u9ed8\u8ba4\u503c\u4e3a \u201cSELECT 1\u201d\u3002<\/p>\n<p>wd_lifecheck_query\u4ec5\u5728wd_lifecheck_method\u8bbe\u7f6e\u4e3a \u2018query\u2019 \u65f6\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_lifecheck_dbname &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e \u8fdc\u7a0b Pgpool-II \u7684\u5bff\u547d\u68c0\u67e5\u3002 \u9ed8\u8ba4\u503c\u4e3a \u201ctemplate1\u201d\u3002<\/p>\n<p>wd_lifecheck_dbname\u4ec5\u5728wd_lifecheck_method\u8bbe\u7f6e\u4e3a \u2018query\u2019 \u65f6\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_lifecheck_user &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u751f\u547d\u5468\u671f\u7684\u8fde\u63a5\u7684\u7528\u6237\u540d \u68c0\u67e5\u8fdc\u7a0b Pgpool-II\u3002 \u9ed8\u8ba4\u503c\u4e3a \u201cnobody\u201d\u3002<\/p>\n<p>\u4ec5\u5f53wd_lifecheck_method\u8bbe\u7f6e\u4e3a \u2018query\u2019 \u65f6&#xff0c;wd_lifecheck_user \u624d\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>wd_lifecheck_password &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u7528\u4e8e\u8fdc\u7a0b Pgpool-II \u5bff\u547d\u68c0\u67e5\u7684\u7528\u6237\u5bc6\u7801\u3002<\/p>\n<p>\u5982\u679c wd_lifecheck_password \u4e3a\u7a7a&#xff0c;Pgpool-II \u5c06\u9996\u5148\u5c1d\u8bd5\u4ece\u6587\u4ef6\u4e2d\u83b7\u53d6 wd_lifecheck_user \u7684\u5bc6\u7801pool_passwd\u7136\u540e\u518d\u4f7f\u7528\u7a7a\u5bc6\u7801\u3002<\/p>\n<p>\u60a8\u8fd8\u53ef\u4ee5\u5728\u5b57\u6bb5\u4e2d\u6307\u5b9a AES216-CBC \u52a0\u5bc6wd_lifecheck_password\u5bc6\u7801\u3002 \u8981\u6307\u5b9a AES \u52a0\u5bc6\u5bc6\u7801&#xff0c;\u5bc6\u7801\u5b57\u7b26\u4e32\u5fc5\u987b\u5728\u52a0\u5bc6\u540e\u4ee5 AES \u4e3a\u524d\u7f00&#xff08;\u4f7f\u7528 aes-256-cbc \u7b97\u6cd5&#xff09;\u548c \u7f16\u7801\u4e3a base64\u3002<\/p>\n<p>\u8981\u6307\u5b9a\u672a\u52a0\u5bc6\u7684\u660e\u6587\u5bc6\u7801&#xff0c;\u8bf7\u5728\u5bc6\u7801\u5b57\u7b26\u4e32\u524d\u52a0\u4e0a TEXT\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u60a8\u60f3\u5c06 mypass \u8bbe\u7f6e\u4e3a \u5bc6\u7801&#xff0c;\u5219\u5e94\u5728\u5bc6\u7801\u5b57\u6bb5\u4e2d\u6307\u5b9a TEXTmypass\u3002 \u5728\u6ca1\u6709\u6709\u6548\u524d\u7f00\u7684\u60c5\u51b5\u4e0b&#xff0c;Pgpool-II \u4f1a\u8ba4\u4e3a \u5b57\u7b26\u4e32\u4f5c\u4e3a\u7eaf\u6587\u672c\u5bc6\u7801\u3002<\/p>\n<p>\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 pg_enc \u5b9e\u7528\u7a0b\u5e8f\u521b\u5efa\u683c\u5f0f\u6b63\u786e\u7684 AES \u52a0\u5bc6\u5bc6\u7801\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; Pgpool-II \u9700\u8981\u4e00\u4e2a\u6709\u6548\u7684\u89e3\u5bc6\u5bc6\u94a5&#xff0c;\u4f4d\u4e8e startup \u4ee5\u4f7f\u7528\u52a0\u5bc6\u7684\u5bc6\u7801\u3002 \u6709\u5173\u63d0\u4f9b Pgpool-II \u7684\u89e3\u5bc6\u5bc6\u94a5<\/p>\n<p>wd_lifecheck_password\u4ec5\u5728wd_lifecheck_method\u8bbe\u7f6e\u4e3a \u2018query\u2019 \u65f6\u9002\u7528<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a \u2018\u2019&#xff08;\u7a7a&#xff09;\u3002<\/p>\n<h3>1.16. \u5176\u4ed6\u914d\u7f6e\u53c2\u6570<\/h3>\n<p>relcache_expire &#xff08;\u6574\u6570) \u6307\u5b9a\u5173\u7cfb\u7f13\u5b58\u8fc7\u671f\u65f6\u95f4&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff09;\u3002 \u5173\u7cfb\u7f13\u5b58\u7528\u4e8e\u7f13\u5b58 PostgreSQL \u7cfb\u7edf\u76ee\u5f55\u7684\u67e5\u8be2\u7ed3\u679c&#xff0c;Pgpool-II \u4f7f\u7528\u5b83\u6765\u83b7\u53d6\u5305\u62ec\u8868 \u7ed3\u6784\u4f53\u5e76\u68c0\u67e5\u8868\u7c7b\u578b&#xff08;\u4f8b\u5982&#xff0c;\u8981\u68c0\u67e5\u5f15\u7528\u7684 table \u662f\u5426\u4e3a\u4e34\u65f6\u8868&#xff09;\u3002\u7f13\u5b58\u5728 Pgpool-II \u5b50\u8fdb\u7a0b\u7684\u672c\u5730\u5185\u5b58\u7a7a\u95f4\u53ca\u5176\u751f\u547d\u5468\u671f\u4e0e\u5b50\u8fdb\u7a0b\u76f8\u540c\u3002 \u7f13\u5b58\u4e5f\u4fdd\u5b58\u5728\u5171\u4eab\u5185\u5b58\u4e2d&#xff0c;\u4ee5\u4fbf\u5728\u5b50\u7ea7\u4e4b\u95f4\u5171\u4eab \u8fdb\u7a0b&#xff0c;\u5982\u679c\u542f\u7528 enable_shared_relcache\u3002 \u56e0\u6b64&#xff0c;\u5982\u679c\u4f7f\u7528 ALTER TABLE \u6216\u5176\u4ed6\u65b9\u5f0f\u4fee\u6539\u8868&#xff0c;\u5219 relcache \u5c06\u53d8\u5f97\u4e0d\u4e00\u81f4\u3002 \u4e3a\u6b64&#xff0c;relcache_expire\u63a7\u5236 \u7f13\u5b58\u7684\u751f\u547d\u5468\u671f\u3002 \u9ed8\u8ba4\u503c\u4e3a 0&#xff0c;\u8fd9\u610f\u5473\u7740\u7f13\u5b58\u6c38\u4e0d\u8fc7\u671f\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>relcache_size &#xff08;\u6574\u6570&#xff09;) \u6307\u5b9a relcache \u6761\u76ee\u7684\u6570\u91cf\u3002\u9ed8\u8ba4\u503c\u4e3a 256\u3002 \u7f13\u5b58\u521b\u5efa\u65f6&#xff0c;\u6bcf\u4e2a\u8868\u5927\u7ea6\u6709 10 \u4e2a\u6761\u76ee\u3002\u6240\u4ee5\u4f60\u53ef\u4ee5\u4f30\u8ba1 \u300c\u4f7f\u7528\u8868\u7684\u6570 * 10\u300d\u5904\u6240\u9700\u7684\u5173\u8054\u7f13\u5b58\u6570\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u5982\u679c\u4e0b\u9762\u7684\u6d88\u606f\u7ecf\u5e38\u51fa\u73b0\u5728 Pgpool-II \u65e5\u5fd7\u4e2d&#xff0c;\u4f60\u53ef\u80fd\u9700\u8981 \u589e\u52a0 relcache_size \u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u3002<\/p>\n<p>   &#034;pool_search_relcache: cache replacement occurred&#034;<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>enable_shared_relcache &#xff08;\u5e03\u5c14\u503c&#xff09;) \u901a\u8fc7\u8bbe\u7f6e\u4e3a on&#xff0c;\u5173\u7cfb\u7f13\u5b58\u5728 Pgpool-II \u5b50\u8fdb\u7a0b\u4e4b\u95f4\u5171\u4eab&#xff0c;\u4f7f\u7528 in \u5185\u5b58\u67e5\u8be2\u7f13\u5b58&#xff08;\u6709\u5173\u66f4\u591a\u4fe1\u606f&#xff0c;\u8bf7\u53c2\u89c1Section 5.13.1 \u8be6\u7ec6\u4fe1\u606f&#xff09;\u3002\u9ed8\u8ba4\u503c\u4e3a on\u3002\u6bcf\u4e2a\u5b50\u8fdb\u7a0b\u90fd\u9700\u8981\u8bbf\u95ee \u6765\u81ea PostgreSQL \u7684\u7cfb\u7edf\u76ee\u5f55\u3002 \u901a\u8fc7\u542f\u7528\u6b64\u529f\u80fd&#xff0c;\u5176\u4ed6\u8fdb\u7a0b\u53ef\u4ee5\u63d0\u53d6\u76ee\u5f55 lookup \u7ed3\u679c&#xff0c;\u5b83\u5e94\u8be5\u4f1a\u51cf\u5c11 \u67e5\u8be2\u7684\u9891\u7387\u3002\u5373\u4f7f \u7cfb\u7edf\u76ee\u5f55\u5df2\u4fee\u6539\u3002\u56e0\u6b64&#xff0c;\u5f3a\u70c8\u5efa\u8bae \u4f7f\u7528 relcache_expire \u53c2\u6570\u8bbe\u7f6e Time Out Base Cache Invalidation \u3002<\/p>\n<p>\u5373\u4f7f memory_cache_enabled \u5904\u4e8e\u5173\u95ed\u72b6\u6001&#xff0c;\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6b64\u53c2\u6570\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u4e00\u4e9b \u67e5\u8be2\u7f13\u5b58\u53c2\u6570&#xff08;memqcache_method\u3001memqcache_maxcache\u548c\u6bcf\u4e2a\u7f13\u5b58\u5b58\u50a8 \u53c2\u6570&#xff09;\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<p>Pgpool-II \u641c\u7d22\u672c\u5730\u5173\u7cfb cache \u4f18\u5148\u3002\u5982\u679c\u5728\u7f13\u5b58\u4e2d\u627e\u4e0d\u5230&#xff0c;\u5219\u5171\u4eab\u5173\u7cfb \u5982\u679c\u542f\u7528\u4e86\u6b64\u529f\u80fd&#xff0c;\u5219\u641c\u7d22 Query Cache\u3002\u5982\u679c\u662f \u5728 Query Cache \u4e0a\u627e\u5230&#xff0c;\u5219\u4f1a\u5c06\u5176\u590d\u5236\u5230 local \u5173\u7cfb\u4e2d \u7f13\u5b58\u3002\u5982\u679c\u5728\u4efb\u4f55\u5730\u65b9\u90fd\u627e\u4e0d\u5230\u7f13\u5b58\u6761\u76ee&#xff0c;Pgpool-II \u5bf9 PostgreSQL \u6267\u884c\u67e5\u8be2&#xff0c;\u7ed3\u679c\u88ab\u5b58\u50a8 \u653e\u5165 Shared Relation Cache \u548c Local Cache \u4e2d\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>relcache_query_target &#xff08;\u679a\u4e3e&#xff09;) \u76ee\u6807\u8282\u70b9&#xff0c;\u7528\u4e8e\u53d1\u9001\u67e5\u8be2\u4ee5\u521b\u5efa\u5173\u7cfb\u7f13\u5b58 \u6761\u76ee\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a primary&#xff0c;\u5219\u67e5\u8be2\u5c06 \u53d1\u9001\u5230\u4e3b\u8282\u70b9\u3002\u8fd9\u662f\u9ed8\u8ba4\u503c&#xff0c;\u5e76\u4e14 \u63a8\u8350\u7ed9\u5927\u591a\u6570\u7528\u6237&#xff0c;\u56e0\u4e3a\u67e5\u8be2\u53ef\u80fd\u4f1a\u83b7\u53d6 \u6700\u65b0\u4fe1\u606f\u3002\u5982\u679c\u60a8\u60f3\u964d\u4f4e \u4e3b\u8282\u70b9&#xff0c;\u60a8\u53ef\u4ee5\u5c06\u53c2\u6570\u8bbe\u7f6e\u4e3a load_balance_node&#xff0c;\u8fd9\u5c06\u53d1\u9001 \u67e5\u8be2\u5230\u8d1f\u8f7d\u5747\u8861\u8282\u70b9\u3002\u8fd9\u7279\u522b\u6709\u7528 \u5bf9\u4e8e\u8fd9\u6837\u7684\u7cfb\u7edf \u5176\u4e2d Pgpool-II\/\u4e3b\u670d\u52a1\u5668\u662f \u5728\u5927\u6d32 A \u671f \u5176\u4ed6 Pgpool-II\/\u5907\u7528\u670d\u52a1\u5668\u662f \u5728\u5176\u4ed6\u5927\u6d32 B \u4e0a&#xff0c;\u5ba2\u6237\u7aef\u5e0c\u671b\u4ece standby &#xff08;\u5907\u7528&#xff09;&#xff0c;\u56e0\u4e3a\u5b83\u5728\u5730\u7406\u4e0a\u66f4\u63a5\u8fd1\u3002\u5728\u8fd9\u4e2a case \u4f60\u53ef\u4ee5\u8bbe\u7f6e backend_weight0 &#xff08;\u8fd9\u4ee3\u8868 primary&#xff09; \u8bbe\u7f6e\u4e3a 0&#xff0c;backend_weight1\u8bbe\u7f6e\u4e3a 1&#xff08;\u8fd9\u8868\u793a\u5f85\u673a&#xff09;&#xff0c;\u5e76\u5c06 relcache_query_target load_balance_node\u3002<\/p>\n<p>\u4f46\u8bf7\u6ce8\u610f&#xff0c;\u5982\u679c\u60a8\u5411\u5907\u7528\u8282\u70b9\u53d1\u9001\u67e5\u8be2&#xff0c;\u5219 \u6700\u8fd1\u521b\u5efa\u7684\u8868\u548c\u884c\u53ef\u80fd\u5728 \u4e0a\u4e0d\u53ef\u7528 \u7531\u4e8e\u590d\u5236\u5ef6\u8fdf&#xff0c;\u5907\u7528\u670d\u52a1\u5668\u5c1a\u672a\u3002\u56e0\u6b64 \u5bf9\u4e8e\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u7684\u7cfb\u7edf&#xff0c;\u4e0d\u5efa\u8bae\u4f7f\u7528\u6b64\u7c7b\u914d\u7f6e \u6570\u636e\u4fee\u6539\u6d3b\u52a8\u5f88\u9ad8\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002<\/p>\n<p>check_temp_table &#xff08;\u679a\u4e3e&#xff09;) \u8bbe\u7f6e\u4e3a catalog \u6216 trace \u65f6&#xff0c;\u542f\u7528\u4e34\u65f6\u8868 check \u5728 SELECT \u8bed\u53e5\u4e2d\u3002\u68c0\u67e5 \u4e34\u65f6\u8868 Pgpool-II \u67e5\u8be2 \u4e3b\/\u4e3b PostgreSQL \u540e\u7aef \u5982\u679c\u6307\u5b9a\u4e86 catalog &#xff0c;\u5219 \u589e\u52a0\u4e3b\/\u4e3b\u670d\u52a1\u5668\u4e0a\u7684\u8d1f\u8f7d\u3002<\/p>\n<p>\u5982\u679c trace \u4e3a set&#xff0c;Pgpool-II \u8ddf\u8e2a\u4e34\u65f6 \u521b\u5efa\u548c\u5220\u9664 table \u4ee5\u83b7\u53d6\u4e34\u65f6 table \u4fe1\u606f\u3002\u56e0\u6b64&#xff0c;\u65e0\u9700\u8bbf\u95ee\u7cfb\u7edf\u76ee\u5f55\u3002\u4f46\u662f&#xff0c;\u5982\u679c \u4e34\u65f6\u8868\u521b\u5efa\u4e0d\u53ef\u89c1 \u5230 Pgpool-II \u4e2d&#xff08;\u5728 functions \u4e2d\u5b8c\u6210 \u6216 triggers&#xff0c;\u7528\u4e8e example&#xff09;&#xff0c;Pgpool-II \u4e0d\u80fd \u8bc6\u522b\u4e34\u65f6\u8868\u7684\u521b\u5efa\u3002<\/p>\n<p>\u5982\u679c\u60a8\u7edd\u5bf9\u786e\u5b9a\u60a8\u7684\u7cfb\u7edf\u4ece\u672a\u4f7f\u7528 temporary tables \u7684 SET &#xff0c;\u90a3\u4e48\u60a8\u53ef\u4ee5\u5b89\u5168\u5730\u8bbe\u7f6e\u4e3a none\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a; \u4e3a\u4e86\u5411\u540e\u517c\u5bb9 4.0 \u6216 \u4e4b\u524d&#xff0c;Pgpool-II \u63a5\u53d7 on&#xff0c;\u8fd9\u662f\u4e00\u6837\u7684 \u4f5c\u4e3a catalog \u548c off&#xff0c; \u8fd9\u4e0e none \u76f8\u540c&#xff0c;\u5219\u5b83\u4eec\u53ef\u80fd\u662f \u5728\u5c06\u6765\u7684\u7248\u672c\u4e2d\u5220\u9664\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a catalog\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d\u6765\u66f4\u6539\u6b64\u53c2\u6570 Pgpool-II \u914d\u7f6e\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4 \u66f4\u6539\u5f53\u524d\u4f1a\u8bdd\u7684\u6b64\u53c2\u6570\u7684\u503c\u3002<\/p>\n<p>check_unlogged_table &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8bbe\u7f6e\u4e3a on&#xff0c;\u5728 SELECT \u8bed\u53e5\u4e2d\u542f\u7528\u65e0\u65e5\u5fd7\u8bb0\u5f55\u8868\u68c0\u67e5\u3002\u8981\u68c0\u67e5\u672a\u8bb0\u5f55\u7684\u8868&#xff0c;Pgpool-II \u67e5\u8be2 PostgreSQL \u4e3b\/\u4e3b\u540e\u7aef\u7684\u7cfb\u7edf\u76ee\u5f55&#xff0c;\u8be5\u76ee\u5f55\u4f1a\u589e\u52a0 \u4e3b\/\u4e3b\u670d\u52a1\u5668\u4e0a\u7684\u8d1f\u8f7d\u3002 \u5982\u679c\u60a8\u7edd\u5bf9\u786e\u5b9a\u60a8\u7684\u7cfb\u7edf\u4ece\u672a\u4f7f\u7528\u672a\u8bb0\u5f55\u7684\u8868 &#xff08;\u4f8b\u5982&#xff0c;\u60a8\u4f7f\u7528\u7684\u662f PostgreSQL 9.0 \u6216\u66f4\u65e9\u7248\u672c&#xff09;&#xff0c;\u90a3\u4e48\u60a8 \u53ef\u4ee5\u5b89\u5168\u5730\u5173\u95ed check_unlogged_table\u3002 \u9ed8\u8ba4\u503c\u4e3a on\u3002<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u52a0\u8f7d Pgpool-II \u914d\u7f6e\u6765\u6539\u53d8\u3002 \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 PGPOOL SET \u547d\u4ee4\u6765\u66f4\u6539 this \u53c2\u6570\u3002<\/p>\n<p>pid_file_name &#xff08;\u5b57\u7b26\u4e32&#xff09;) \u6307\u5b9a\u5b58\u50a8 Pgpool-II \u8fdb\u7a0b ID \u7684\u6587\u4ef6\u7684\u5b8c\u6574\u8def\u5f84\u3002 pid_file_name\u8def\u5f84\u53ef\u4ee5\u6307\u5b9a\u4e3a\u76f8\u5bf9\u4e8e pgpool.conf \u6587\u4ef6\u7684\u4f4d\u7f6e\u6216\u7edd\u5bf9\u8def\u5f84 \u9ed8\u8ba4\u662f \u201c\/var\/run\/pgpool\/pgpool.pid\u201d\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>logdir &#xff08;\u5b57\u7b26\u4e32) \u6307\u5b9a\u7528\u4e8e\u5b58\u50a8pgpool_status\u7684\u76ee\u5f55\u7684\u5b8c\u6574\u8def\u5f84\u3002 \u9ed8\u8ba4\u4e3a \u2018\/tmp\u2019\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n<p>health_check_test &#xff08;\u5e03\u5c14\u503c&#xff09;) \u8c28\u614e \u4e0d\u8981\u5728\u4f5c\u54c1\u4e2d\u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a on \u73af\u5883\u3002\u6b64\u529f\u80fd\u4ec5\u7528\u4e8e\u6d4b\u8bd5\u76ee\u7684\u3002<\/p>\n<p>\u8bbe\u7f6e\u4e3a on&#xff0c; \u542f\u7528\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u7684 Testing Facility\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c; \u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u8fc7\u7a0b Look \u8f6c\u6362\u4e3a logdir \u4e0b\u7684 backend_down_request\u3002\u8be5\u6587\u4ef6\u53ef\u80fd\u5305\u542b\u591a\u4e2a \u884c&#xff0c;\u6bcf\u884c\u5bf9\u5e94\u4e8e\u6bcf\u4e2a\u540e\u7aef\u3002\u4e2d \u6587\u4ef6\u4ee5\u540e\u7aef ID \u5f00\u5934&#xff08;\u5fc5\u987b\u662f\u4ee5 backend ID \u5f00\u5934\u7684\u5341\u8fdb\u5236\u6570 \u66ff\u6362\u4e3a 0&#xff09;&#xff0c;\u7136\u540e\u662f TAB&#xff0c;\u5e76\u4ee5 \u201cdown\u201d \u7ed3\u5c3e\u3002\u540e\u7aef\u662f \u5047\u8bbe\u5904\u4e8e\u5b95\u673a\u72b6\u6001&#xff0c;\u5e76\u4e14 Pgpool-II \u5c06\u542f\u52a8\u6545\u969c\u8f6c\u79fb\u3002\u6545\u969c\u8f6c\u79fb\u5b8c\u6210\u540e&#xff0c;\u201cdown\u201d \u4e3a \u901a\u8fc7\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5\u8fc7\u7a0b\u91cd\u5199\u4e3a \u201calready_down\u201d \u4ee5\u9632\u6b62 \u91cd\u590d\u6545\u969c\u8f6c\u79fb\u3002<\/p>\n<p>\u6b64\u529f\u80fd\u7279\u522b\u9002\u7528\u4e8e \u6d4b\u8bd5 failover_require_consensus\u3002\u5047\u8bbe \u6211\u4eec\u6709 3 \u4e2a watchdog \u8282\u70b9\u3002\u6bcf\u4e2a watchdog \u90fd\u4f1a\u68c0\u67e5 backend 0 \u7684\u901a\u8fc7\u5728\u770b\u95e8\u72d7 0 \u4e0b\u7684\u6587\u4ef6\u4e2d\u8bbe\u7f6e \u201c0 down\u201d&#xff0c; \u5176\u4ed6\u770b\u95e8\u72d7\u4e0d\u540c\u610f\u540e\u7aef 0 \u7684\u4e0d\u5065\u5eb7\u6027&#xff0c;\u56e0\u6b64 \u4e0d\u4f1a\u53d1\u751f\u6545\u969c\u8f6c\u79fb\u3002\u8fd9\u79cd\u90e8\u5206\u7f51\u7edc\u6545\u969c\u53ef\u80fd\u4f1a \u4f7f\u7528\u6b64\u529f\u80fd\u8fdb\u884c\u6a21\u62df\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c\u4e3a off\u3002<\/p>\n<p>\u6b64\u53c2\u6570\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.4k\u6b21\uff0c\u70b9\u8d5e25\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u6240\u6709\u53c2\u6570\u540d\u79f0\u5747\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u6bcf\u4e2a\u53c2\u6570\u90fd\u91c7\u7528 \u503c\u4e3a\u4ee5\u4e0b\u4e94\u79cd\u7c7b\u578b\u4e4b\u4e00\uff1aboolean\u3001string\u3001integer\u3001floating point\u3001 \u6216\u679a\u4e3e \uff08enum\uff09\u3002\u7c7b\u578b\u51b3\u5b9a\u4e86\u8bbe\u7f6e \u53c2\u6570\uff1a\u5e03\u5c14\uff1a\u503c\u53ef\u4ee5\u5199\u6210 on\u3001off\u3001true\u3001false\u3001yes\u3001no\u30011\u30010\uff08\u5168\u90e8\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff09\u6216\u5176\u4e2d\u4e4b\u4e00\u7684\u4efb\u4f55\u660e\u786e\u524d\u7f00\u3002\u5b57\u7b26\u4e32\uff1a\u901a\u5e38\uff0c\u5c06\u503c\u62ec\u5728\u5355\u5f15\u53f7\u4e2d\uff0c\u5c06\u4efb\u4f55\u5355\u4e2a \u503c\u5185\u7684 quotes \u4e2d\u3002\u5982\u679c\u503c \u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6570\u5b57\u6216\u6807\u8bc6\u7b26\u3002\u6570\u5b57 \uff08\u6574\u6570\u548c\u6d6e\u70b9\uff09 \uff1a\u4ec5\u5141\u8bb8\u6d6e\u70b9\u53c2\u6570\u4f7f\u7528\u5c0f\u6570\u70b9\u3002\u4e0d\u8981\u4f7f\u7528\u5343\u4f4d\u5206\u9694\u7b26\u3002\u4e0d\u9700\u8981\u62a5\u4ef7\u3002_pgpool<\/p>\n","protected":false},"author":2,"featured_media":16568,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1152,954,100,44],"topic":[],"class_list":["post-16570","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-pgpool","tag-postgresql","tag-100","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>pgpool\u914d\u7f6e\u5b89\u88c5\u4e4b\u670d\u52a1\u5668\u7684\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/16570.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"pgpool\u914d\u7f6e\u5b89\u88c5\u4e4b\u670d\u52a1\u5668\u7684\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.4k\u6b21\uff0c\u70b9\u8d5e25\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u6240\u6709\u53c2\u6570\u540d\u79f0\u5747\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u6bcf\u4e2a\u53c2\u6570\u90fd\u91c7\u7528 \u503c\u4e3a\u4ee5\u4e0b\u4e94\u79cd\u7c7b\u578b\u4e4b\u4e00\uff1aboolean\u3001string\u3001integer\u3001floating point\u3001 \u6216\u679a\u4e3e \uff08enum\uff09\u3002\u7c7b\u578b\u51b3\u5b9a\u4e86\u8bbe\u7f6e \u53c2\u6570\uff1a\u5e03\u5c14\uff1a\u503c\u53ef\u4ee5\u5199\u6210 on\u3001off\u3001true\u3001false\u3001yes\u3001no\u30011\u30010\uff08\u5168\u90e8\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff09\u6216\u5176\u4e2d\u4e4b\u4e00\u7684\u4efb\u4f55\u660e\u786e\u524d\u7f00\u3002\u5b57\u7b26\u4e32\uff1a\u901a\u5e38\uff0c\u5c06\u503c\u62ec\u5728\u5355\u5f15\u53f7\u4e2d\uff0c\u5c06\u4efb\u4f55\u5355\u4e2a \u503c\u5185\u7684 quotes \u4e2d\u3002\u5982\u679c\u503c \u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6570\u5b57\u6216\u6807\u8bc6\u7b26\u3002\u6570\u5b57 \uff08\u6574\u6570\u548c\u6d6e\u70b9\uff09 \uff1a\u4ec5\u5141\u8bb8\u6d6e\u70b9\u53c2\u6570\u4f7f\u7528\u5c0f\u6570\u70b9\u3002\u4e0d\u8981\u4f7f\u7528\u5343\u4f4d\u5206\u9694\u7b26\u3002\u4e0d\u9700\u8981\u62a5\u4ef7\u3002_pgpool\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/16570.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T15:02:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418150219-6802697b92514.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"44 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/16570.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/16570.html\",\"name\":\"pgpool\u914d\u7f6e\u5b89\u88c5\u4e4b\u670d\u52a1\u5668\u7684\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T15:02:20+00:00\",\"dateModified\":\"2025-04-18T15:02:20+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/16570.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/16570.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/16570.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"pgpool\u914d\u7f6e\u5b89\u88c5\u4e4b\u670d\u52a1\u5668\u7684\u914d\u7f6e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"pgpool\u914d\u7f6e\u5b89\u88c5\u4e4b\u670d\u52a1\u5668\u7684\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/16570.html","og_locale":"zh_CN","og_type":"article","og_title":"pgpool\u914d\u7f6e\u5b89\u88c5\u4e4b\u670d\u52a1\u5668\u7684\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.4k\u6b21\uff0c\u70b9\u8d5e25\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u6240\u6709\u53c2\u6570\u540d\u79f0\u5747\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u6bcf\u4e2a\u53c2\u6570\u90fd\u91c7\u7528 \u503c\u4e3a\u4ee5\u4e0b\u4e94\u79cd\u7c7b\u578b\u4e4b\u4e00\uff1aboolean\u3001string\u3001integer\u3001floating point\u3001 \u6216\u679a\u4e3e \uff08enum\uff09\u3002\u7c7b\u578b\u51b3\u5b9a\u4e86\u8bbe\u7f6e \u53c2\u6570\uff1a\u5e03\u5c14\uff1a\u503c\u53ef\u4ee5\u5199\u6210 on\u3001off\u3001true\u3001false\u3001yes\u3001no\u30011\u30010\uff08\u5168\u90e8\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff09\u6216\u5176\u4e2d\u4e4b\u4e00\u7684\u4efb\u4f55\u660e\u786e\u524d\u7f00\u3002\u5b57\u7b26\u4e32\uff1a\u901a\u5e38\uff0c\u5c06\u503c\u62ec\u5728\u5355\u5f15\u53f7\u4e2d\uff0c\u5c06\u4efb\u4f55\u5355\u4e2a \u503c\u5185\u7684 quotes \u4e2d\u3002\u5982\u679c\u503c \u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6570\u5b57\u6216\u6807\u8bc6\u7b26\u3002\u6570\u5b57 \uff08\u6574\u6570\u548c\u6d6e\u70b9\uff09 \uff1a\u4ec5\u5141\u8bb8\u6d6e\u70b9\u53c2\u6570\u4f7f\u7528\u5c0f\u6570\u70b9\u3002\u4e0d\u8981\u4f7f\u7528\u5343\u4f4d\u5206\u9694\u7b26\u3002\u4e0d\u9700\u8981\u62a5\u4ef7\u3002_pgpool","og_url":"https:\/\/www.wsisp.com\/helps\/16570.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T15:02:20+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418150219-6802697b92514.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"44 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/16570.html","url":"https:\/\/www.wsisp.com\/helps\/16570.html","name":"pgpool\u914d\u7f6e\u5b89\u88c5\u4e4b\u670d\u52a1\u5668\u7684\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T15:02:20+00:00","dateModified":"2025-04-18T15:02:20+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/16570.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/16570.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/16570.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"pgpool\u914d\u7f6e\u5b89\u88c5\u4e4b\u670d\u52a1\u5668\u7684\u914d\u7f6e"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/16570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=16570"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/16570\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/16568"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=16570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=16570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=16570"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=16570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}