{"id":62513,"date":"2026-01-20T03:49:42","date_gmt":"2026-01-19T19:49:42","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/62513.html"},"modified":"2026-01-20T03:49:42","modified_gmt":"2026-01-19T19:49:42","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e9%a6%99%e6%b8%af%e6%9c%8d%e5%8a%a1%e5%99%a8-ubuntu-20-04-%e4%b8%8a%e5%ae%9e%e7%8e%b0-postgres-14-pgbouncer-%e8%bf%9e%e6%8e%a5%e6%b1%a0%e9%83%a8%e7%bd%b2%e6%8c%87","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/62513.html","title":{"rendered":"\u5982\u4f55\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u5b9e\u73b0 Postgres 14 + PgBouncer \u8fde\u63a5\u6c60\u90e8\u7f72\u6307\u5357"},"content":{"rendered":"<p>\u672c\u6587\u9488\u5bf9\u4f7f\u7528 Ubuntu 20.04 LTS \u5728\u9999\u6e2f\u670d\u52a1\u5668\u73af\u5883\u4e0b\u90e8\u7f72 PostgreSQL 14 \u4e0e PgBouncer \u7684\u751f\u4ea7\u7ea7\u8fde\u63a5\u6c60\u89e3\u51b3\u65b9\u6848\u505a\u6df1\u5165\u6280\u672f\u8bb2\u89e3\u3002\u5185\u5bb9\u6db5\u76d6\u786c\u4ef6\u914d\u7f6e\u5efa\u8bae\u3001\u7cfb\u7edf\u4e0e\u7f51\u7edc\u4f18\u5316\u3001\u5b89\u88c5\u90e8\u7f72\u6b65\u9aa4\u3001\u5173\u952e\u914d\u7f6e\u8bf4\u660e\u3001\u8c03\u4f18\u5efa\u8bae\u4e0e\u6027\u80fd\u5bf9\u6bd4\u8bc4\u4f30\u3002A5\u6570\u636e\u91cd\u70b9\u5173\u6ce8\u5b9e\u9645\u53ef\u843d\u5730\u7684\u914d\u7f6e\u7ec6\u8282\u3001\u4ee3\u7801\u793a\u4f8b\u4ee5\u53ca\u6027\u80fd\u6d4b\u8bd5\u7ed3\u679c&#xff0c;\u9002\u7528\u4e8e\u8de8\u5883\u7535\u5546\u3001SaaS\u3001\u5b9e\u65f6\u5206\u6790\u7b49\u4e1a\u52a1\u573a\u666f\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u73af\u5883\u4e0e\u786c\u4ef6\u914d\u7f6e\u5efa\u8bae<\/h3>\n<p>\u5728\u5f00\u59cb\u90e8\u7f72\u4e4b\u524d&#xff0c;\u63a8\u8350\u7684\u9999\u6e2f\u670d\u52a1\u5668www.a5idc.com\u786c\u4ef6\u914d\u7f6e\u5982\u4e0b&#xff08;\u9002\u7528\u4e8e\u4e2d\u5230\u5927\u578b\u751f\u4ea7\u6570\u636e\u5e93\u8d1f\u8f7d&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u786c\u4ef6\u9879\u5efa\u8bae\u914d\u7f6e\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>CPU<\/td>\n<td>8 \u6838 AMD EPYC \/ Intel Xeon<\/td>\n<td>\u652f\u6301\u591a\u5e76\u53d1\u67e5\u8be2\u4e0e\u540e\u53f0\u7ef4\u62a4<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58<\/td>\n<td>32 GB DDR4<\/td>\n<td>\u8db3\u591f\u7f13\u5b58\u70ed\u70b9\u6570\u636e\u4e0e\u8fde\u63a5\u6c60\u7f13\u51b2<\/td>\n<\/tr>\n<tr>\n<td>\u78c1\u76d8<\/td>\n<td>1 \u00d7 1TB NVMe SSD<\/td>\n<td>\u9ad8 IOPS \u8bfb\u5199\u6027\u80fd<\/td>\n<\/tr>\n<tr>\n<td>\u7f51\u7edc<\/td>\n<td>1 Gbps \u516c\u7f51\u5e26\u5bbd<\/td>\n<td>\u8de8\u5883\u8bbf\u95ee\u5ef6\u8fdf\u654f\u611f\u4e1a\u52a1\u63a8\u8350 CN2\/\u76f4\u8fde<\/td>\n<\/tr>\n<tr>\n<td>\u64cd\u4f5c\u7cfb\u7edf<\/td>\n<td>Ubuntu 20.04 LTS x64 UEFI<\/td>\n<td>\u957f\u671f\u652f\u6301\u7a33\u5b9a\u7248\u672c<\/td>\n<\/tr>\n<tr>\n<td>\u65f6\u533a<\/td>\n<td>UTC \u6216 Asia\/Hong_Kong<\/td>\n<td>\u65e5\u5fd7\u65f6\u95f4\u4e00\u81f4\u6027<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5728\u9999\u6e2f\u6570\u636e\u4e2d\u5fc3&#xff0c;\u516c\u7f51\u8bbf\u95ee\u5ef6\u8fdf\u5bf9\u4e8e\u6d77\u5916\u7528\u6237\u4f53\u9a8c\u81f3\u5173\u91cd\u8981&#xff0c;\u5efa\u8bae\u540c\u65f6\u6d4b\u8bd5 CN2\/\u76f4\u8fde\u7f51\u7edc\u5ef6\u8fdf\u5e76\u4f9d\u636e\u4e1a\u52a1&#xff0c;\u7ed3\u5408 Anycast \/ \u591a BGP \u63d0\u4f9b\u66f4\u7a33\u5b9a\u8def\u7531\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u57fa\u7840\u7cfb\u7edf\u51c6\u5907\u4e0e\u4f18\u5316<\/h3>\n<h4>2.1 \u7cfb\u7edf\u66f4\u65b0<\/h4>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> update<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> upgrade -y<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">reboot<\/span><\/p>\n<h4>2.2 \u7528\u6237\u4e0e\u57fa\u672c\u5de5\u5177<\/h4>\n<p><span class=\"token comment\"># \u521b\u5efa PostgreSQL \u7ba1\u7406\u7528\u6237<\/span><br \/>\n<span class=\"token function\">sudo<\/span> adduser dbadmin<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">usermod<\/span> -aG <span class=\"token function\">sudo<\/span> dbadmin<\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5\u5fc5\u8981\u5de5\u5177<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> -y <span class=\"token function\">wget<\/span> <span class=\"token function\">curl<\/span> <span class=\"token function\">htop<\/span> iotop <span class=\"token function\">unzip<\/span> <span class=\"token function\">git<\/span><\/p>\n<h4>2.3 \u5185\u6838\u53c2\u6570\u4f18\u5316&#xff08;\u751f\u4ea7\u63a8\u8350&#xff09;<\/h4>\n<p>\u7f16\u8f91 \/etc\/sysctl.conf \u6dfb\u52a0&#xff1a;<\/p>\n<p># \u589e\u52a0\u6587\u4ef6\u53e5\u67c4\u6570<br \/>\nfs.file-max &#061; 1000000<\/p>\n<p># \u5185\u6838\u5171\u4eab\u5185\u5b58<br \/>\nkernel.shmmax &#061; 68719476736<br \/>\nkernel.shmall &#061; 4294967296<\/p>\n<p># \u7f51\u7edc\u8fde\u63a5\u8ffd\u8e2a<br \/>\nnet.core.somaxconn &#061; 1024<br \/>\nnet.ipv4.tcp_tw_reuse &#061; 1<br \/>\nnet.ipv4.tcp_fin_timeout &#061; 15<br \/>\nnet.ipv4.ip_local_port_range &#061; 1024 65535<\/p>\n<p>\u5e94\u7528&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> sysctl -p<\/p>\n<h4>2.4 \u65f6\u949f\u540c\u6b65<\/h4>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> -y chrony<br \/>\n<span class=\"token function\">sudo<\/span> systemctl <span class=\"token builtin class-name\">enable<\/span> &#8211;now chrony<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u5b89\u88c5 PostgreSQL 14<\/h3>\n<p>Ubuntu 20.04 \u9ed8\u8ba4\u6e90\u4e0d\u5305\u542b\u6700\u65b0 PostgreSQL 14&#xff0c;\u56e0\u6b64\u9700\u8981\u6dfb\u52a0\u5b98\u65b9\u6e90&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u6dfb\u52a0\u5b98\u65b9\u4ed3\u5e93<\/span><br \/>\n<span class=\"token function\">wget<\/span> -qO &#8211; https:\/\/www.postgresql.org\/media\/keys\/ACCC4CF8.asc <span class=\"token operator\">|<\/span> <span class=\"token function\">sudo<\/span> apt-key <span class=\"token function\">add<\/span> &#8211;<br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;deb http:\/\/apt.postgresql.org\/pub\/repos\/apt\/ focal-pgdg main&#034;<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">sudo<\/span> <span class=\"token function\">tee<\/span> \/etc\/apt\/sources.list.d\/pgdg.list<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> update<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> -y postgresql-14 postgresql-server-dev-14<\/p>\n<p>\u9a8c\u8bc1\u5b89\u88c5&#xff1a;<\/p>\n<p>psql &#8211;version<br \/>\n<span class=\"token comment\"># \u8f93\u51fa\u793a\u4f8b: psql (PostgreSQL) 14.x<\/span><\/p>\n<hr \/>\n<h3>\u56db\u3001PostgreSQL 14 \u751f\u4ea7\u7ea7\u53c2\u6570\u914d\u7f6e<\/h3>\n<p>\u7f16\u8f91 PostgreSQL \u4e3b\u914d\u7f6e \/etc\/postgresql\/14\/main\/postgresql.conf&#xff1a;<\/p>\n<p># \u76d1\u542c\u6240\u6709\u5730\u5740<br \/>\nlisten_addresses &#061; &#039;*&#039;<\/p>\n<p># \u5185\u5b58\u8bbe\u7f6e\u793a\u4f8b&#xff08;32GB \u7cfb\u7edf&#xff09;<br \/>\nshared_buffers &#061; 8GB<br \/>\neffective_cache_size &#061; 24GB<br \/>\nwork_mem &#061; 64MB<br \/>\nmaintenance_work_mem &#061; 2GB<\/p>\n<p># WAL \u65e5\u5fd7<br \/>\nwal_level &#061; replica<br \/>\nmax_wal_size &#061; 4GB<br \/>\nmin_wal_size &#061; 1GB<\/p>\n<p># \u8fde\u63a5\u6570<br \/>\nmax_connections &#061; 200<\/p>\n<p># \u63d0\u5347\u900f\u660e\u5927\u9875\u4e0e\u9501<br \/>\ntcp_keepalives_idle &#061; 60<br \/>\ntcp_keepalives_interval &#061; 30<br \/>\ntcp_keepalives_count &#061; 10<\/p>\n<p># \u65f6\u533a<br \/>\ntimezone &#061; &#039;Asia\/Hong_Kong&#039;<\/p>\n<p>\u7f16\u8f91\u8bbf\u95ee\u63a7\u5236 \/etc\/postgresql\/14\/main\/pg_hba.conf&#xff0c;\u589e\u52a0\u4fe1\u4efb\u6216\u5bc6\u7801\u8ba4\u8bc1&#xff1a;<\/p>\n<p># \u672c\u5730<br \/>\nlocal   all             all                                     md5<br \/>\n# \u5185\u7f51\u8fde\u63a5<br \/>\nhost    all             all             0.0.0.0\/0             md5<\/p>\n<p>\u91cd\u542f PostgreSQL&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> systemctl restart postgresql<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u5b89\u88c5\u4e0e\u914d\u7f6e PgBouncer<\/h3>\n<h4>5.1 \u5b89\u88c5 PgBouncer<\/h4>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> -y pgbouncer<\/p>\n<h4>5.2 \u521b\u5efa\u6c60\u5316\u7528\u6237<\/h4>\n<p>\u5728 PostgreSQL \u5185&#xff1a;<\/p>\n<p><span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">USER<\/span> pgbouncer <span class=\"token keyword\">WITH<\/span> PASSWORD <span class=\"token string\">&#039;\u5f3a\u5bc6\u7801\u793a\u4f8b&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">GRANT<\/span> <span class=\"token keyword\">CONNECT<\/span> <span class=\"token keyword\">ON<\/span> <span class=\"token keyword\">DATABASE<\/span> your_db <span class=\"token keyword\">TO<\/span> pgbouncer<span class=\"token punctuation\">;<\/span><\/p>\n<h4>5.3 PgBouncer \u4e3b\u914d\u7f6e<\/h4>\n<p>\u7f16\u8f91 \/etc\/pgbouncer\/pgbouncer.ini&#xff1a;<\/p>\n<p>[databases]<br \/>\nyour_db &#061; host&#061;127.0.0.1 port&#061;5432 dbname&#061;your_db<\/p>\n<p>[pgbouncer]<br \/>\n# \u76d1\u542c<br \/>\nlisten_addr &#061; *<br \/>\nlisten_port &#061; 6432<\/p>\n<p># \u6388\u6743<br \/>\nauth_type &#061; md5<br \/>\nauth_file &#061; \/etc\/pgbouncer\/userlist.txt<\/p>\n<p># \u6c60\u5316\u6a21\u5f0f<br \/>\npool_mode &#061; transaction<\/p>\n<p># \u6700\u5927\u8fde\u63a5\u4e0e\u8d85\u65f6<br \/>\nmax_client_conn &#061; 1000<br \/>\ndefault_pool_size &#061; 100<br \/>\nreserve_pool_size &#061; 20<br \/>\nreserve_pool_timeout &#061; 5<\/p>\n<p># \u65e5\u5fd7\u4e0e\u76d1\u63a7<br \/>\nlogfile &#061; \/var\/log\/pgbouncer\/pgbouncer.log<br \/>\nadmin_users &#061; pgbouncer<\/p>\n<h4>5.4 \u7528\u6237\u5217\u8868<\/h4>\n<p>\u7f16\u8f91 \/etc\/pgbouncer\/userlist.txt&#xff1a;<\/p>\n<p>&#034;pgbouncer&#034; &#034;md5$(echo -n pgbouncer\u5f3a\u5bc6\u7801\u793a\u4f8bpgbouncer | md5sum | awk &#039;{print $1}&#039;)&#034;<\/p>\n<h4>5.5 \u542f\u52a8 PgBouncer<\/h4>\n<p><span class=\"token function\">sudo<\/span> systemctl <span class=\"token builtin class-name\">enable<\/span> &#8211;now pgbouncer<\/p>\n<hr \/>\n<h3>\u516d\u3001PgBouncer \u6c60\u5316\u6a21\u5f0f\u89e3\u91ca\u4e0e\u9009\u62e9<\/h3>\n<table>\n<tr>\u6a21\u5f0f\u8bf4\u660e\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>session<\/td>\n<td>\u6bcf\u4e2a\u5ba2\u6237\u7aef\u4fdd\u6301\u4e00\u4e2a\u540e\u7aef\u8fde\u63a5<\/td>\n<td>\u7ef4\u6301\u4f1a\u8bdd\u72b6\u6001\u5e94\u7528<\/td>\n<\/tr>\n<tr>\n<td>transaction<\/td>\n<td>\u6bcf\u6b21\u4e8b\u52a1\u91cd\u65b0\u83b7\u53d6\u540e\u7aef\u8fde\u63a5<\/td>\n<td>\u5bf9\u5927\u591a\u6570 Web \u5e94\u7528\u6700\u4f18<\/td>\n<\/tr>\n<tr>\n<td>statement<\/td>\n<td>\u6bcf\u6761 SQL \u90fd\u91cd\u65b0\u83b7\u53d6\u8fde\u63a5<\/td>\n<td>\u9ad8\u5e76\u53d1\u4f46\u9700\u8c28\u614e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u751f\u4ea7\u5efa\u8bae\u4f7f\u7528 transaction&#xff0c;\u5728\u9ad8\u5e76\u53d1\u77ed\u4e8b\u52a1\u573a\u666f\u4e0b\u53ef\u663e\u8457\u51cf\u5c11 PostgreSQL \u540e\u7aef\u8fde\u63a5\u5f00\u9500\u3002<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u76d1\u63a7\u4e0e\u6027\u80fd\u6d4b\u8bd5<\/h3>\n<h4>7.1 \u57fa\u51c6\u6d4b\u8bd5\u5de5\u5177<\/h4>\n<p>\u5b89\u88c5 pgbench&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> -y postgresql-client-14<\/p>\n<p>\u521d\u59cb\u5316\u6d4b\u8bd5\u5e93&#xff1a;<\/p>\n<p>pgbench -i -s <span class=\"token number\">50<\/span> -h localhost -p <span class=\"token number\">6432<\/span> -U pgbouncer your_db<\/p>\n<p>\u6267\u884c\u538b\u529b\u6d4b\u8bd5&#xff1a;<\/p>\n<p>pgbench -c <span class=\"token number\">200<\/span> -j <span class=\"token number\">4<\/span> -T <span class=\"token number\">60<\/span> -h localhost -p <span class=\"token number\">6432<\/span> -U pgbouncer your_db<\/p>\n<h4>7.2 \u521d\u59cb\u6027\u80fd\u7ed3\u679c&#xff08;\u793a\u4f8b&#xff09;<\/h4>\n<table>\n<tr>\u8fde\u63a5\u65b9\u5f0fTPS \u5e73\u5747\u5e73\u5747\u5ef6\u8fdf (ms)\u6700\u5927\u540e\u7aef\u8fde\u63a5\u6570<\/tr>\n<tbody>\n<tr>\n<td>\u76f4\u8fde PostgreSQL (\u65e0\u6c60)<\/td>\n<td>3500<\/td>\n<td>12.5<\/td>\n<td>200<\/td>\n<\/tr>\n<tr>\n<td>PgBouncer transaction<\/td>\n<td>8200<\/td>\n<td>5.8<\/td>\n<td>120<\/td>\n<\/tr>\n<tr>\n<td>PgBouncer session<\/td>\n<td>6800<\/td>\n<td>7.2<\/td>\n<td>200<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4ece\u6570\u636e\u53ef\u4ee5\u770b\u51fa&#xff0c;\u5728\u5178\u578b OLTP \u573a\u666f\u4e0b&#xff0c;PgBouncer transaction \u6a21\u5f0f\u80fd\u6709\u6548\u63d0\u5347 TPS \u5e76\u964d\u4f4e\u5ef6\u8fdf&#xff0c;\u540c\u65f6\u51cf\u5c11\u540e\u7aef\u6570\u636e\u5e93\u8fde\u63a5\u6570\u3002<\/p>\n<hr \/>\n<h3>\u516b\u3001\u5173\u952e\u6027\u80fd\u4f18\u5316\u5efa\u8bae<\/h3>\n<h4>8.1 Linux \u7f51\u7edc\u4e0e\u6587\u4ef6\u53e5\u67c4<\/h4>\n<p><span class=\"token comment\"># \u63d0\u5347 ulimit<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">bash<\/span> -c <span class=\"token string\">&#034;echo &#039;dbadmin soft nofile 1000000&#039; &gt;&gt; \/etc\/security\/limits.conf&#034;<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">bash<\/span> -c <span class=\"token string\">&#034;echo &#039;dbadmin hard nofile 1000000&#039; &gt;&gt; \/etc\/security\/limits.conf&#034;<\/span><\/p>\n<h4>8.2 PostgreSQL WAL \u4e0e checkpoint \u8c03\u6574<\/h4>\n<p>\u9002\u5408\u5199\u5bc6\u96c6\u573a\u666f&#xff1a;<\/p>\n<p>checkpoint_timeout &#061; 15min<br \/>\ncheckpoint_completion_target &#061; 0.9<\/p>\n<h4>8.3 \u8fde\u63a5\u6c60\u5927\u5c0f\u7ec6\u8c03<\/h4>\n<p>\u6839\u636e\u5e94\u7528\u6c60\u5316\u540e\u7684\u5e76\u53d1\u8fde\u63a5\u6570\u4e0e\u4e8b\u52a1\u5e73\u5747\u65f6\u95f4\u8c03\u6574&#xff1a;<\/p>\n<table>\n<tr>\u4e1a\u52a1\u7c7b\u578b\u5efa\u8bae default_pool_size\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>Web API \u8bf7\u6c42<\/td>\n<td>100 ~ 150<\/td>\n<td>\u9ad8\u5e76\u53d1\u77ed\u4e8b\u52a1<\/td>\n<\/tr>\n<tr>\n<td>\u5206\u6790 ETL \u4efb\u52a1<\/td>\n<td>20 ~ 50<\/td>\n<td>\u957f\u4e8b\u52a1\u51cf\u5c11\u62a2\u5360<\/td>\n<\/tr>\n<tr>\n<td>\u6df7\u5408\u573a\u666f<\/td>\n<td>80 ~ 120<\/td>\n<td>\u9700\u89c2\u5bdf\u5b9e\u9645\u8d1f\u8f7d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e5d\u3001\u5e38\u89c1\u95ee\u9898\u4e0e\u89e3\u51b3<\/h3>\n<h4>9.1 \u201cFATAL: too many clients\u201d \u9519\u8bef<\/h4>\n<p>\u68c0\u67e5 PgBouncer \u4e0e PostgreSQL \u7684 max_connections \u662f\u5426\u5408\u7406&#xff1a;<\/p>\n<p><span class=\"token comment\"># PostgreSQL<\/span><br \/>\nSHOW max_connections<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\"># PgBouncer<\/span><br \/>\nSHOW CONFIG<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5efa\u8bae PostgreSQL \u8bbe\u7f6e\u4e3a\u8f83\u5c0f\u503c&#xff0c;\u7531 PgBouncer \u63a7\u5236\u603b\u8fde\u63a5\u3002<\/p>\n<h4>9.2 \u957f\u4e8b\u52a1\u5bfc\u81f4\u6c60\u8017\u5c3d<\/h4>\n<p>PgBouncer transaction \u6a21\u5f0f\u907f\u514d\u5728\u4e8b\u52a1\u5916\u957f\u65f6\u95f4\u5360\u7528\u540e\u7aef\u8fde\u63a5&#xff1b;\u82e5\u4ecd\u51fa\u73b0\u9700\u6392\u67e5\u5e94\u7528\u4e8b\u52a1\u8fb9\u754c\u3002<\/p>\n<hr \/>\n<h3>\u5341\u3001\u603b\u7ed3<\/h3>\n<p>A5\u6570\u636e\u901a\u8fc7\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u90e8\u7f72 PostgreSQL 14 &#043; PgBouncer&#xff0c;\u7ed3\u5408\u5408\u7406\u786c\u4ef6\u914d\u7f6e\u4e0e\u7cfb\u7edf\u5185\u6838\u4f18\u5316&#xff0c;\u53ef\u4ee5\u663e\u8457\u63d0\u5347\u6570\u636e\u5e93\u5e76\u53d1\u5904\u7406\u80fd\u529b\u4e0e\u8fde\u63a5\u6548\u7387\u3002\u672c\u6587\u4ece\u57fa\u7840\u5b89\u88c5\u3001\u6df1\u5165\u53c2\u6570\u914d\u7f6e\u5230\u6027\u80fd\u8bc4\u4f30&#xff0c;\u4e3a\u5efa\u8bbe\u9ad8\u53ef\u7528\u3001\u9ad8\u6027\u80fd\u7684\u6570\u636e\u5e93\u670d\u52a1\u63d0\u4f9b\u4e86\u8be6\u5c3d\u6307\u5357\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u9488\u5bf9\u4f7f\u7528 Ubuntu 20.04 LTS \u5728\u9999\u6e2f\u670d\u52a1\u5668\u73af\u5883\u4e0b\u90e8\u7f72 PostgreSQL 14 \u4e0e PgBouncer \u7684\u751f\u4ea7\u7ea7\u8fde\u63a5\u6c60\u89e3\u51b3\u65b9\u6848\u505a\u6df1\u5165\u6280\u672f\u8bb2\u89e3\u3002\u5185\u5bb9\u6db5\u76d6\u786c\u4ef6\u914d\u7f6e\u5efa\u8bae\u3001\u7cfb\u7edf\u4e0e\u7f51\u7edc\u4f18\u5316\u3001\u5b89\u88c5\u90e8\u7f72\u6b65\u9aa4\u3001\u5173\u952e\u914d\u7f6e\u8bf4\u660e\u3001\u8c03\u4f18\u5efa\u8bae\u4e0e\u6027\u80fd\u5bf9\u6bd4\u8bc4\u4f30\u3002A5\u6570\u636e\u91cd\u70b9\u5173\u6ce8\u5b9e\u9645\u53ef\u843d\u5730\u7684\u914d\u7f6e\u7ec6\u8282\u3001\u4ee3\u7801\u793a\u4f8b\u4ee5\u53ca\u6027\u80fd\u6d4b\u8bd5\u7ed3\u679c&#xff0c;\u9002\u7528\u4e8e\u8de8\u5883\u7535\u5546\u3001SaaS\u3001\u5b9e\u65f6\u5206\u6790\u7b49\u4e1a\u52a1\u573a\u666f\u3002 \u4e00\u3001\u73af\u5883\u4e0e\u786c\u4ef6\u914d\u7f6e\u5efa\u8bae<br \/>\n\u5728\u5f00\u59cb\u90e8\u7f72\u4e4b\u524d&#xff0c;\u63a8\u8350\u7684\u9999\u6e2f\u670d\u52a1\u5668www.a5idc.com\u786c\u4ef6<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[103,43,44],"topic":[],"class_list":["post-62513","post","type-post","status-publish","format-standard","hentry","category-server","tag-ubuntu","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5982\u4f55\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u5b9e\u73b0 Postgres 14 + PgBouncer \u8fde\u63a5\u6c60\u90e8\u7f72\u6307\u5357 - \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\/62513.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5982\u4f55\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u5b9e\u73b0 Postgres 14 + PgBouncer \u8fde\u63a5\u6c60\u90e8\u7f72\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6587\u9488\u5bf9\u4f7f\u7528 Ubuntu 20.04 LTS \u5728\u9999\u6e2f\u670d\u52a1\u5668\u73af\u5883\u4e0b\u90e8\u7f72 PostgreSQL 14 \u4e0e PgBouncer \u7684\u751f\u4ea7\u7ea7\u8fde\u63a5\u6c60\u89e3\u51b3\u65b9\u6848\u505a\u6df1\u5165\u6280\u672f\u8bb2\u89e3\u3002\u5185\u5bb9\u6db5\u76d6\u786c\u4ef6\u914d\u7f6e\u5efa\u8bae\u3001\u7cfb\u7edf\u4e0e\u7f51\u7edc\u4f18\u5316\u3001\u5b89\u88c5\u90e8\u7f72\u6b65\u9aa4\u3001\u5173\u952e\u914d\u7f6e\u8bf4\u660e\u3001\u8c03\u4f18\u5efa\u8bae\u4e0e\u6027\u80fd\u5bf9\u6bd4\u8bc4\u4f30\u3002A5\u6570\u636e\u91cd\u70b9\u5173\u6ce8\u5b9e\u9645\u53ef\u843d\u5730\u7684\u914d\u7f6e\u7ec6\u8282\u3001\u4ee3\u7801\u793a\u4f8b\u4ee5\u53ca\u6027\u80fd\u6d4b\u8bd5\u7ed3\u679c&#xff0c;\u9002\u7528\u4e8e\u8de8\u5883\u7535\u5546\u3001SaaS\u3001\u5b9e\u65f6\u5206\u6790\u7b49\u4e1a\u52a1\u573a\u666f\u3002 \u4e00\u3001\u73af\u5883\u4e0e\u786c\u4ef6\u914d\u7f6e\u5efa\u8bae \u5728\u5f00\u59cb\u90e8\u7f72\u4e4b\u524d&#xff0c;\u63a8\u8350\u7684\u9999\u6e2f\u670d\u52a1\u5668www.a5idc.com\u786c\u4ef6\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/62513.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-19T19:49:42+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/62513.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/62513.html\",\"name\":\"\u5982\u4f55\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u5b9e\u73b0 Postgres 14 + PgBouncer \u8fde\u63a5\u6c60\u90e8\u7f72\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-19T19:49:42+00:00\",\"dateModified\":\"2026-01-19T19:49:42+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/62513.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/62513.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/62513.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5982\u4f55\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u5b9e\u73b0 Postgres 14 + PgBouncer \u8fde\u63a5\u6c60\u90e8\u7f72\u6307\u5357\"}]},{\"@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":"\u5982\u4f55\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u5b9e\u73b0 Postgres 14 + PgBouncer \u8fde\u63a5\u6c60\u90e8\u7f72\u6307\u5357 - \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\/62513.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5982\u4f55\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u5b9e\u73b0 Postgres 14 + PgBouncer \u8fde\u63a5\u6c60\u90e8\u7f72\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u672c\u6587\u9488\u5bf9\u4f7f\u7528 Ubuntu 20.04 LTS \u5728\u9999\u6e2f\u670d\u52a1\u5668\u73af\u5883\u4e0b\u90e8\u7f72 PostgreSQL 14 \u4e0e PgBouncer \u7684\u751f\u4ea7\u7ea7\u8fde\u63a5\u6c60\u89e3\u51b3\u65b9\u6848\u505a\u6df1\u5165\u6280\u672f\u8bb2\u89e3\u3002\u5185\u5bb9\u6db5\u76d6\u786c\u4ef6\u914d\u7f6e\u5efa\u8bae\u3001\u7cfb\u7edf\u4e0e\u7f51\u7edc\u4f18\u5316\u3001\u5b89\u88c5\u90e8\u7f72\u6b65\u9aa4\u3001\u5173\u952e\u914d\u7f6e\u8bf4\u660e\u3001\u8c03\u4f18\u5efa\u8bae\u4e0e\u6027\u80fd\u5bf9\u6bd4\u8bc4\u4f30\u3002A5\u6570\u636e\u91cd\u70b9\u5173\u6ce8\u5b9e\u9645\u53ef\u843d\u5730\u7684\u914d\u7f6e\u7ec6\u8282\u3001\u4ee3\u7801\u793a\u4f8b\u4ee5\u53ca\u6027\u80fd\u6d4b\u8bd5\u7ed3\u679c&#xff0c;\u9002\u7528\u4e8e\u8de8\u5883\u7535\u5546\u3001SaaS\u3001\u5b9e\u65f6\u5206\u6790\u7b49\u4e1a\u52a1\u573a\u666f\u3002 \u4e00\u3001\u73af\u5883\u4e0e\u786c\u4ef6\u914d\u7f6e\u5efa\u8bae \u5728\u5f00\u59cb\u90e8\u7f72\u4e4b\u524d&#xff0c;\u63a8\u8350\u7684\u9999\u6e2f\u670d\u52a1\u5668www.a5idc.com\u786c\u4ef6","og_url":"https:\/\/www.wsisp.com\/helps\/62513.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-19T19:49:42+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/62513.html","url":"https:\/\/www.wsisp.com\/helps\/62513.html","name":"\u5982\u4f55\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u5b9e\u73b0 Postgres 14 + PgBouncer \u8fde\u63a5\u6c60\u90e8\u7f72\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-19T19:49:42+00:00","dateModified":"2026-01-19T19:49:42+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/62513.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/62513.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/62513.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5982\u4f55\u5728\u9999\u6e2f\u670d\u52a1\u5668 Ubuntu 20.04 \u4e0a\u5b9e\u73b0 Postgres 14 + PgBouncer \u8fde\u63a5\u6c60\u90e8\u7f72\u6307\u5357"}]},{"@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\/62513","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=62513"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/62513\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=62513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=62513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=62513"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=62513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}