/usr/share/doc/pgpool2/tutorial-ja.html is in pgpool2 3.4.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>pgpool-II $B%A%e!<%H%j%"%k(B</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-2022-jp" />
<link href="pgpool.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>pgpool-II $B%A%e!<%H%j%"%k(B</h1>
<p>pgpool-II $B$N%A%e!<%H%j%"%k$K$h$&$3$=!#(B
$B$3$3$G$O!"(Bpgpool-II $B$N%$%s%9%H!<%k$+$i4pK\E*$J@_Dj!"%l%W%j%1!<%7%g%s$*$h$S%Q%i%l%k%/%(%j$N<B9T$r9T$&$^$G$N<j=g$K$D$$$F@bL@$7$^$9!#(B
$B$^$?!"(BPostgreSQL $B$N4pK\E*$JA`:n$K4X$9$k@bL@$O9T$$$^$;$s$N$G!"I,MW$G$"$l$P(B PostgreSQL $B$N%I%-%e%a%s%H$r;2>H$7$F$/$@$5$$!#(B</p>
<dl>
<dt><em>$BL\<!(B</em></dt>
<dt>1. <a href="#start">$B$5$";O$a$^$7$g$&(B</a></dt>
<dd>1.1. <a href="#install">pgpool-II $B$N%$%s%9%H!<%k(B</a></dd>
<dd>1.2. <a href="#config">$B@_Dj%U%!%$%k$N:n@.(B</a></dd>
<dd>1.3. <a href="#pcp-config">PCP $B%3%^%s%I$N@_Dj(B</a></dd>
<dd>1.4. <a href="#db-node">$B%G!<%?%Y!<%9%N!<%I$N=`Hw(B</a></dd>
<dd>1.5. <a href="#start-shutdown">pgpool-II $B$N5/F0$HDd;_(B</a></dd>
<dt>2. <a href="#replication">$B=i$a$F$N%l%W%j%1!<%7%g%s(B</a></dt>
<dd>2.1. <a href="#replication-config">$B%l%W%j%1!<%7%g%s$N@_Dj(B</a></dd>
<dd>2.2. <a href="#replication-check">$B%l%W%j%1!<%7%g%s$N3NG'(B</a></dd>
<dt>3. <a href="#parallel">$B%Q%i%l%k%/%(%j$r;H$C$F$_$h$&(B</a></dt>
<dd>3.1. <a href="#parallel-config">$B%Q%i%l%k%/%(%j$N@_Dj(B</a></dd>
<dd>3.2. <a href="#system-db">$B%7%9%F%`%G!<%?%Y!<%9$N:n@.(B</a></dd>
<dd>3.3. <a href="#dist-def">$BJ,;6%k!<%k$NDj5A(B</a></dd>
<dd>3.4. <a href="#replicate-def">$BJ#@=%k!<%k$N3NG'(B</a></dd>
<dd>3.5. <a href="#parallel-check">$B%Q%i%l%k%/%(%j$N3NG'(B</a></dd>
</dl>
<h2>1. <a name="start">$B$5$";O$a$^$7$g$&(B</a></h2>
<p>$B$3$3$G$O!"%l%W%j%1!<%7%g%s$*$h$S%Q%i%l%k%/%(%j$N<B9T$r9T$&$?$a$N=`Hw$H$7$F!"(Bpgpool-II $B$N%$%s%9%H!<%k$d@_Dj!"%G!<%?%Y!<%9%N!<%I$N=`Hw$K$D$$$F@bL@$7$^$9!#(B</p>
<h3>1.1. <a name="install">pgpool-II $B$N%$%s%9%H!<%k(B</a></h3>
<p>pgpool-II $B$r%$%s%9%H!<%k$9$k$K$O%=!<%9%3!<%I$rE83+$7$?%G%#%l%/%H%j$G0J2<$N$h$&$K%3%^%s%I$r<B9T$7$^$9!#(B</p>
<pre>$ ./configure
$ make
$ make install</pre>
<p><code>configure</code> $B%9%/%j%W%H$G$O(B pgpool-II $B$r%$%s%9%H!<%k$9$k4D6-$K9g$o$;$?@_Dj$,9T$o$l$^$9!#(B
$B$^$?!"(B<code>configure</code> $B%9%/%j%W%H$r<B9T$9$k:]$K%3%^%s%I%i%$%s0z?t$r;XDj$9$k$3$H$K$h$j!"(Bpgpool-II $B$N%$%s%9%H!<%k@h$NJQ99$J$I$r9T$&$3$H$,$G$-$^$9!#(B
$B%3%^%s%I%i%$%s0z?t$r;XDj$7$J$1$l$P!"(Bpgpool-II $B$O(B <code>/usr/local</code> $B%G%#%l%/%H%j0J2<$K%$%s%9%H!<%k$5$l$^$9!#(B</p>
<p><code>make</code> $B%3%^%s%I$r<B9T$9$k$H(B pgpool-II $B$N%=!<%9%3!<%I$,%3%s%Q%$%k$5$l!"(B<code>make install</code> $B%3%^%s%I$G$O<B:]$K%$%s%9%H!<%k$5$l$^$9!#(B
$B$J$*!"(B<code>make install</code> $B%3%^%s%I$r<B9T$9$k:]$K(B pgpool-II $B$r%$%s%9%H!<%k$9$k%G%#%l%/%H%j$X$N=q$-9~$_8"8B$,I,MW$G$9!#(B</p>
<p>$B$3$3$G$O!"(Bpgpool-II $B$r(B <code>/usr/local</code> $B%G%#%l%/%H%j0J2<$K%$%s%9%H!<%k$7$^$9!#(B</p>
<p><em>$BCm0U(B</em>: pgpool-II $B$N%=!<%9%3!<%I$r%3%s%Q%$%k$9$k$K$O(B PostgreSQL 7.4 $B0J9_$G<BAu$5$l$?(B libpq $B%i%$%V%i%j(B (3.0 $B%W%m%H%3%k(B) $B$,I,MW$G$9!#(B
<code>configure</code> $B%9%/%j%W%H$r<B9T$7$?:]$K0J2<$N%(%i!<%a%C%;!<%8$,I=<($5$l$?>l9g!"(Blibpq $B%i%$%V%i%j$,%$%s%9%H!<%k$5$l$F$$$J$$$+!"%$%s%9%H!<%k$5$l$F$$$F$b%W%m%H%3%k$N%P!<%8%g%s$,(B 3.0 $B$G$J$$2DG=@-$,$"$j$^$9!#(B</p>
<pre>configure: error: libpq is not installed or libpq is old</pre>
<p>$B$^$?!"%W%m%H%3%k$N%P!<%8%g%s$,(B 3.0 $B$N(B libpq $B%i%$%V%i%j$,%$%s%9%H!<%k$5$l$F$$$k$K$b78$o$i$:!">e5-$N%(%i!<%a%C%;!<%8$,I=<($5$l$k>l9g!"(B<code>configure</code> $B%9%/%j%W%H$r<B9T$7$?:]$K(B libpq $B%i%$%V%i%j$,G'<1$5$l$F$$$J$$2DG=@-$,$"$j$^$9!#(B</p>
<p><code>configure</code> $B%9%/%j%W%H$OI8=`$G$O(B <code>/usr/local/pgsql</code> $B%G%#%l%/%H%j0J2<$+$i%X%C%@%U%!%$%k$d(B libpq $B%i%$%V%i%j$r8!:w$7$^$9!#(B
PostgreSQL $B$N%$%s%9%H!<%k@h$,(B <code>/usr/local/pgsql</code> $B%G%#%l%/%H%j0J2<$G$J$1$l$P!"(B<code>configure</code> $B%9%/%j%W%H$r<B9T$9$k:]$K%3%^%s%I%i%$%s0z?t$H$7$F(B <code>--with-pgsql</code> $B$d(B <code>--with-pgsql-includedir</code>$B!"(B<code>--with-pgsql-libdir</code> $B%*%W%7%g%s$r;XDj$7$F$/$@$5$$!#(B</p>
<h3>1.2. <a name="config">$B@_Dj%U%!%$%k$N:n@.(B</a></h3>
<p>pgpool-II $B$K$D$$$F$N@_Dj$O(B <code>pgpool.conf</code> $B%U%!%$%k$K5-=R$7$^$9!#(B
<code>pgpool.conf</code> $B%U%!%$%k$N=q<0$O(B 1 $B9T$4$H$K%Q%i%a!<%?L>$HCM$r(B = $B$G6h@Z$C$?$b$N$G$9!#(B
pgpool-II $B$r%$%s%9%H!<%k$9$k$H%5%s%W%k$H$7$F(B <code>pgpool.conf.sample</code> $B%U%!%$%k$,:n@.$5$l$k$N$G!"$=$l$r(B <code>pgpool.conf</code> $B$H$$$&%U%!%$%kL>$K%3%T!<$7$F$+$iJT=8$9$k$H$$$$$G$7$g$&!#(B</p>
<pre>$ cp /usr/local/etc/pgpool.conf.sample /usr/local/etc/pgpool.conf</pre>
<p><code>pgpool.conf</code> $B%U%!%$%k$N=i4|@_Dj$G$O!"(Bpgpool-II $B$O(B pgpool-II $B$HF1$8%[%9%H$+$i$N%]!<%HHV9f(B 9999 $B$X$N@\B3$r<u$1IU$1$^$9!#(B
pgpool-II $B$H0[$J$k%[%9%H$+$i$N@\B3$r<u$1IU$1$k>l9g$O(B <code>listen_addresses</code> $B%Q%i%a!<%?$K(B * $B$r@_Dj$7$^$9!#(B</p>
<pre>listen_addresses = 'localhost'
port = 9999</pre>
<p>$B$3$3$G$O!"(B<code>pgpool.conf</code> $B%U%!%$%k$N=i4|@_Dj$r$=$N$^$^;HMQ$7$^$9!#(B</p>
<h3>1.3. <a name="pcp-config">PCP $B%3%^%s%I$N@_Dj(B</a></h3>
<p>pgpool-II $B$G$O(B PCP $B%3%^%s%I$H8F$P$l$k%$%s%?%U%'!<%9$rDL$7$F(B pgpool-II $B$NDd;_$d%G!<%?%Y!<%9%N!<%I$K4X$9$k>pJs$NI=<($r9T$$$^$9!#(B
PCP $B%3%^%s%I$r;HMQ$9$k$K$O%f!<%6G'>Z$,I,MW$K$J$k$N$G!"%f!<%6L>$H%Q%9%o!<%I$r(B <code>pcp.conf</code> $B%U%!%$%k$K@_Dj$7$^$9!#(B
<code>pcp.conf</code> $B%U%!%$%k$N=q<0$O0J2<$N$h$&$K(B 1 $B9T$4$H$K%f!<%6L>$H(B MD5 $B%O%C%7%e$KJQ49$5$l$?%Q%9%o!<%I$r(B : $B$G6h@Z$C$?$b$N$G$9!#(B</p>
<pre>postgres:e8a48653851e28c69d0506508fb27fc5</pre>
<p>pgpool-II $B$r%$%s%9%H!<%k$9$k$H%5%s%W%k$H$7$F(B <code>pcp.conf.sample</code> $B%U%!%$%k$,:n@.$5$l$k$N$G!"$=$l$r(B <code>pcp.conf</code> $B$H$$$&%U%!%$%kL>$K%3%T!<$7$F$+$iJT=8$9$k$H$$$$$G$7$g$&!#(B</p>
<pre>$ cp /usr/local/etc/pcp.conf.sample /usr/local/etc/pcp.conf</pre>
<p>$B$J$*!"%Q%9%o!<%I$r(B MD5 $B%O%C%7%e$KJQ49$9$k:]$K$O(B pgpool-II $B$H$H$b$K%$%s%9%H!<%k$5$l$k(B <code>pg_md5</code> $B%3%^%s%I$r;HMQ$7$^$9!#(B
<code>pg_md5</code> $B%3%^%s%I$O!"%3%^%s%I%i%$%s0z?t$H$7$F%Q%9%o!<%I$r;XDj$9$k$H!"$=$l$r(B MD5 $B%O%C%7%e$KJQ49$7$?$b$N$rI=<($7$^$9!#(B</p>
<p>$BNc$($P!"0J2<$N$h$&$K(B <code>pg_md5</code> $B%3%^%s%I$N%3%^%s%I%i%$%s0z?t$H$7$F(B postgres $B$r;XDj$7$F<B9T$9$k$H!"(Bpostgres $B$r(B MD5 $B%O%C%7%e$KJQ49$7$?$b$N$,I=<($5$l$^$9!#(B</p>
<pre>$ /usr/bin/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"(B5433$B!"(B5434 $B$G5/F0$7$^$9!#(B
$B%G!<%?%Y!<%9%5!<%P$r%G!<%?%Y!<%9%N!<%I$H$7$F;HMQ$9$k$K$O!"(B<code>pgpool.conf</code> $B%U%!%$%k$K0J2<$N$h$&$K%Q%i%a!<%?$r@_Dj$7$^$9!#(B</p>
<pre>backend_hostname0 = 'localhost'
backend_port0 = 5432
backend_weight0 = 1
backend_hostname1 = 'localhost'
backend_port1 = 5433
backend_weight1 = 1
backend_hostname2 = 'localhost'
backend_port2 = 5434
backend_weight2 = 1</pre>
<p><code>backend_hostname</code>$B!"(B<code>backend_port</code>$B!"(B<code>backend_weight</code> $B%Q%i%a!<%?$K$O!"%G!<%?%Y!<%9%N!<%I$N%[%9%HL>!"%]!<%HHV9f!"Ii2YJ,;6$9$k:]$N=E$_IU$1$r@_Dj$7$^$9!#(B
$B%Q%i%a!<%?L>$N8e$m$K$O(B 0$B!"(B1$B!"(B2$B!"(B… $B$H$$$&$h$&$KJ#?t$N%G!<%?%Y!<%9%N!<%I$r6hJL$9$k$?$a$N?t;z$r;XDj$7$^$9!#(B
<code>backend_weight</code> $B%Q%i%a!<%?$O!"J#?t$N%G!<%?%Y!<%9%N!<%I$KLd$$9g$o$;$rIi2YJ,;6$9$k:]!"$I$N%G!<%?%Y!<%9%N!<%I$K$I$N$/$i$$$N3d9g$GLd$$9g$o$;$r9T$&$+$H$$$&$3$H$r@_Dj$9$k%Q%i%a!<%?$G$9!#(B
$B$3$3$G$O!"(B3 $BBf$N%G!<%?%Y!<%9%N!<%I$N=E$_IU$1$,$9$Y$F(B 1 $B$K@_Dj$7$F$"$k$N$G!"Ld$$9g$o$;$O(B 1 $BBP(B 1 $BBP(B 1 $B$N3d$j9g$$$GIi2YJ,;6$5$l$k$3$H$K$J$j$^$9!#(B</p>
<h3>1.5. <a name="start-shutdown">pgpool-II $B$N5/F0$HDd;_(B</a></h3>
<p>pgpool-II $B$r5/F0$9$k$K$O0J2<$N$h$&$K(B <code>pgpool</code> $B%3%^%s%I$r<B9T$7$^$9!#(B</p>
<pre>$ pgpool</pre>
<p>
$B$?$@$7!"$3$N$^$^$G$O(B <code>pgpool</code> $B%W%m%;%9$O@)8fC<Kv$r@Z$jN%(B
$B$9$?$a!"%m%0$,=PNO$5$l$J$/$J$j$^$9(B($B%(%i!<$OI8=`%(%i!<$K=PNO$5$l$^$9(B)$B!#(B
$B@)8fC<Kv$r@Z$jN%$5$J$$$G5/F0$9$k>l9g$O(B <code>-n</code> $B%*%W%7%g%s$r;XDj$7$^$9!#(B
</p>
<pre>
$ pgpool -n &
</pre>
<p>
$B%3%^%s%I$r<B9T$7$?C<Kv$K%m%0%a%C%;!<%8$,I=<($5$l$k$N$G!"0J2<$N$h$&$K%m%0%a%C%;!<%8$r%U%!%$%k$KJ]B8$9$k$h$&$K<B9T$9$k$3$H$r$*4+$a$7$^$9!#(B</p>
<pre>$ pgpool -n -d > /var/log/pgpool/pgpool.log 2>&1 &</pre>
<p><code>-d</code> $B%*%W%7%g%s$O%G%P%C%0%a%C%;!<%8$N=PNO$rM-8z$K$7$^$9!#(B</p>
<p>
$B>e5-$NNc$O%U%!%$%k$K%j%@%$%l%/%H$5$;$F$$$k$?$a!"%m%0$,DI2C$5$lB3$1$^$9!#(B
$B%m%0$r%m!<%F!<%H$5$;$?$$>l9g$O!"%m!<%F!<%H5!G=$r;}$C$?%3%^%s%I$K%m%0$r(B
$BEO$7$F$/$@$5$$!#(B
$B$?$H$($P!"(BApache2$B$KIUB0$9$k(Brotatelogs$B$r;H$&$N$G$"$l$P!"(B
<pre>
$ pgpool -n 2>&1 | /usr/local/apache2/bin/rotatelogs \
-l -f /var/log/pgpool/pgpool.log.%A 86400 &
</pre>
$B$H$9$l$PKhF|LkCf$N(B0$B;~$K%m%0$,%m!<%F!<%H$5$l!"(Bpgpool.log.Thursday $B$N$h$&$JL>A0$N%m%0%U%!%$%k$,KhF|:n@.$5$l$^$9!#(B
$B$?$@$7!"$9$G$KF1$8L>A0$N%U%!%$%k$,$"$k>l9g$K$O%m%0$,$=$N%U%!%$%k$KDI2C$5$l$F$7$^$&$N$G!"(Bcron$B$r;H$C$F8E$$%m%0%U%!%$%k$r>C5n$9$k@_Dj$rJ;$;$F9T$C$F$*$/J}$,NI$$$G$7$g$&!#(B
$BNc$r<($7$^$9!#(B
<pre>
55 23 * * * /usr/bin/find /var/log/pgpool -type f -mtime +5 -exec /bin/rm -f '{}' \;
</pre>
</p>
<p>
<em>$BCm0U(B</em>: Linux$B%G%#%9%H%j%S%e!<%7%g%s$K$h$C$F$O!"(Brotatelogs $B$O(B /usr/sbin/rotatelogs2 $B$N$h$&$JL>A0$G%$%s%9%H!<%k$5$l$F$$$k$+$bCN$l$^$;$s!#(B
-f $B%*%W%7%g%s$O(B rotatelogs $B$,5/F0$5$l$?D>8e$KD>$A$K%m%0%U%!%$%k$r:n$k%*%W%7%g%s$G!"(Bapache2 2.2.9 $B0J9_$G$N$_M-8z$G$9!#(B
</p>
<p>
<a href="http://www.cronolog.org/"><code>cronolog</code></a> $B$r;H$&>l9g$G$"$l$P!"0J2<$N$h$&$K%Q%$%W$G%m%0%a%C%;!<%8$rEO$7$F$/$@$5$$!#(B
<pre>
$ pgpool -n 2>&1 | /usr/sbin/cronolog \
--hardlink=/var/log/pgpool/pgpool.log \
'/var/log/pgpool/%Y-%m-%d-pgpool.log' &
</pre>
</p>
<p>pgpool-II $B$rDd;_$9$k$K$O0J2<$N$h$&$K(B <code>pgpool</code> $B%3%^%s%I$r<B9T$7$^$9!#(B</p>
<pre>$ pgpool stop</pre>
<p>pgpool-II $B$rDd;_$9$k:]$K%/%i%$%"%s%H$,@\B3$7$F$$$k>l9g!"$=$N@\B3$,@ZCG$5$l$k$^$GBT$C$F$+$iDd;_$7$^$9!#(B
$B%/%i%$%"%s%H$N@\B3$,@ZCG$5$l$k$^$GBT$?$:$KDd;_$9$k$K$O0J2<$N$h$&$K(B <code>pgpool</code> $B%3%^%s%I$r<B9T$7$^$9!#(B</p>
<pre>$ pgpool -m fast stop</pre>
<h2>2. <a name="replication">$B=i$a$F$N%l%W%j%1!<%7%g%s(B</a></h2>
<p>$B%l%W%j%1!<%7%g%s$G$OJ#?t$N%G!<%?%Y!<%9%N!<%I$KF1$8%G!<%?$rJ#@=$7$F3JG<$7$^$9!#(B</p>
<p>$B$3$3$G$O!"!V(B1. <a href="#start">$B$5$";O$a$^$7$g$&(B</a>$B!W$G=`Hw$7$?(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$r;HMQ$7!"(Bpgbench $B$,:n@.$9$k%G!<%?%Y!<%9$N%l%W%j%1!<%7%g%s$r9T$&$^$G$N<j=g$K$D$$$F@bL@$7$^$9!#(B</p>
<h3>2.1. <a name="replication-config">$B%l%W%j%1!<%7%g%s$N@_Dj(B</a></h3>
<p>$B%G!<%?%Y!<%9%N!<%I$N%l%W%j%1!<%7%g%s$rM-8z$K$9$k$K$O!"(B<code>pgpool.conf</code> $B%U%!%$%k$N(B <code>replication_mode</code> $B%Q%i%a!<%?$r(B true $B$K@_Dj$7$^$9!#(B</p>
<pre>replication_mode = true</pre>
<p>$B>e5-$N$h$&$K(B <code>replication_mode</code> $B%Q%i%a!<%?$r(B true $B$K@_Dj$9$k$3$H$K$h$j!"(Bpgpool-II $B$X$NLd$$9g$o$;$,$9$Y$F$N%G!<%?%Y!<%9%N!<%I$KBP$7$F<B9T$5$l!"F1$8%G!<%?$,J#@=$5$l$F3JG<$5$l$k$h$&$K$J$j$^$9!#(B
<p>$B$5$i$K!"(B<code>load_balance_mode</code> $B%Q%i%a!<%?$r(B true $B$K@_Dj$9$k$3$H$K$h$j!"(Bpgpool-II $B$KBP$9$k(B SELECT $BJ8$rJ#?t$N%G!<%?%Y!<%9%N!<%I$KBP$7$F?6$jJ,$1!"Ii2YJ,;6$r9T$&$3$H$,$G$-$^$9!#(B</p>
<pre>load_balance_mode = true</pre>
<p>$B$3$3$G$O!"(B<code>replication_mode</code>$B!"(B<code>load_balance_mode</code> $B%Q%i%a!<%?$r(B true $B$K@_Dj$7$^$9!#(B</p>
<h3>2.2. <a name="replication-check">$B%l%W%j%1!<%7%g%s$N3NG'(B</a></h3>
<p>$B%l%W%j%1!<%7%g%s$N@_Dj$r(B pgpool-II $B$KH?1G$5$;$k$K$O(B pgpool-II $B$r:F5/F0$9$kI,MW$,$"$j$^$9!#(B
pgpool-II $B$N:F5/F0$K$D$$$F$O!V(B1.5. <a href="#start-shutdown">pgpool-II $B$N5/F0$HDd;_(B</a>$B!W$r;2>H$7$F$/$@$5$$!#(B</p>
<p>$B%l%W%j%1!<%7%g%s$rM-8z$K$7$F(B pgpool-II $B$r5/F0$G$-$?$i!"<B:]$K(B pgbench $B$r;HMQ$7$F%l%W%j%1!<%7%g%s$,9T$o$l$F$$$k$3$H$r3NG'$7$^$7$g$&!#(B</p>
<p>$B$^$:!"(Bpgbench $B$,;HMQ$9$k%G!<%?%Y!<%9(B bench_replication $B$r:n@.$7$^$9!#(B
<code>createdb</code> $B%3%^%s%I$r(B pgpool-II $B$KBP$7$F<B9T$9$k$H!"$9$Y$F$N%G!<%?%Y!<%9%N!<%I$KBP$7$F%G!<%?%Y!<%9(B bench_replication $B$,:n@.$5$l$^$9!#(B</p>
<pre>$ createdb -p 9999 bench_replication</pre>
<p>$B$=$7$F!"(B<code>pgbench</code> $B%3%^%s%I$K(B <code>-i</code> $B%*%W%7%g%s$r;XDj$7$F<B9T$9$k$3$H$K$h$j!"%G!<%?%Y!<%9(B bench_replication $B$KBP$7$F(B pgbench $B$G;HMQ$9$k%F!<%V%k$r:n@.$7!"%G!<%?$r=i4|2=$7$^$9!#(B</p>
<pre>$ pgbench -i -p 9999 bench_replication</pre>
<p><code>pgbench</code> $B%3%^%s%I$K(B <code>-i</code> $B%*%W%7%g%s$r;XDj$7$F<B9T$7$?:]$K:n@.$5$l$k%F!<%V%k$H$=$l$>$l$N%F!<%V%k$N9T?t$O0J2<$N$H$*$j$G$9!#(B
$B$9$Y$F$N%G!<%?%Y!<%9%N!<%I$N%G!<%?%Y!<%9(B bench_replication $B$K0J2<$N9T?t$N%G!<%?$,3JG<$5$l$F$$$l$P!"@5>o$K%l%W%j%1!<%7%g%s$,9T$o$l$F$$$k$3$H$K$J$j$^$9!#(B</p>
<center>
<table border>
<tr>
<th>$B%F!<%V%kL>(B</th>
<th>$B9T?t(B</th>
</tr>
<tr>
<td>branches</td>
<td>1</td>
</tr>
<tr>
<td>tellers</td>
<td>10</td>
</tr>
<tr>
<td>accounts</td>
<td>100000</td>
</tr>
<tr>
<td>history</td>
<td>0</td>
</tr>
</table>
</center>
<p>$BNc$($P!"0J2<$N$h$&$K%3%^%s%I$r<B9T$9$k$H!"$9$Y$F$N%G!<%?%Y!<%9%N!<%I(B ($B%]!<%HHV9f(B 5432$B!"(B5433$B!"(B5434) $B$N%G!<%?%Y!<%9(B bench_replication $B$K4^$^$l$k%F!<%V%k(B branches$B!"(Btellers$B!"(Baccounts$B!"(Bhistory $B$N9T?t$,I=<($5$l$^$9!#(B</p>
<pre>$ for port in 5432 5433 5434; do
> echo $port
> for table_name in branches tellers accounts history; do
> echo $table_name
> psql -c "SELECT count(*) FROM $table_name" -p $port bench_replication
> done
> done
</pre>
<h2>3. <a name="parallel">$B%Q%i%l%k%/%(%j$r;H$C$F$_$h$&(B</a></h2>
<p>$B%Q%i%l%k%/%(%j$G$OJ#?t$N%G!<%?%Y!<%9%N!<%I$K0[$J$kHO0O$N%G!<%?$r3JG<$7$^$9!#$3$l$r%Q!<%F%#%7%g%K%s%0$H8F$S$^$9!#$^$?%Q!<%F%#%7%g%s%K%s%0$H6&$KJ#?t$N%G!<%?%Y!<%9%N!<%I$KF1$8%G!<%?$rJ#@=$9$k$3$H$b$G$-$^$9!#$D$^$j%Q!<%F%#%7%g%K%s%0$7$F$$$k%F!<%V%k$H%l%W%j%1!<%7%g%s$7$F$$$k%F!<%V%k$r6&B8$5$;$k$3$H$,$G$-$^$9!#(B</p>
<p>$B%Q%i%l%k%/%(%j$r;HMQ$9$k$K$O%7%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NDj5A$HEPO?$r9T$&I,MW$,$"$j$^$9!#(B</p>
<p>$B$^$?!"(Bdblink $B$G$O%7%9%F%`%G!<%?%Y!<%9$+$i(B pgpool-II $B$X$N(B TCP/IP $B@\B3$,9T$o$l$k$?$a!"(B<code>listen_addresses</code> $B%Q%i%a!<%?$rE,@Z$K@_Dj$9$kI,MW$,$"$j$^$9!#(B</p>
<pre>listen_addresses = '*'</pre>
<p><em>$BCm0U(B</em>: $B%Q%i%l%k%/%(%j$H%l%W%j%1!<%7%g%s$rF1;~$KM-8z$K$9$k$3$H$,$G$-$^$9$,!"%Q!<%F%#%7%g%K%s%0$7$F$$$k%F!<%V%k$KBP$7$F$O!"%l%W%j%1!<%7%g%s$5$l$^$;$s!#(B
$B$^$?!"%Q%i%l%k%/%(%j$H%l%W%j%1!<%7%g%s$G$O%G!<%?%Y!<%9$K3JG<$5$l$k%G!<%?$N9=@.$,0[$J$k$?$a!"!V(B2. <a href="#replication">$B=i$a$F$N%l%W%j%1!<%7%g%s(B</a>$B!W$G:n@.$7$?%G!<%?%Y!<%9(B bench_replication $B$r$=$N$^$^;HMQ$9$k$3$H$O$G$-$^$;$s!#(B</p>
<pre>replication_mode = true
load_balance_mode = false</pre>
<p>$B$^$?$O!"(B</p>
<pre>replication_mode = false
load_balance_mode = true</pre>
<p>$B$3$3$G$O!"(B<code>parallel_mode</code> $B%Q%i%a!<%?$r(B true $B$K!"(B<code>listen_addresses</code> $B%Q%i%a!<%?$r(B * $B$K!"(B<code>replication_mode</code>$B!"(B<code>load_balance_mode</code> $B%Q%i%a!<%?$r(B false $B$K@_Dj$7$^$9!#(B</p>
<h3>3.2. <a name="system-db">$B%7%9%F%`%G!<%?%Y!<%9$N:n@.(B</a></h3>
<p>$B%7%9%F%`%G!<%?%Y!<%9$HDL>o$N%G!<%?%Y!<%9$K0c$$$O$"$j$^$;$s!#(B
$B$?$@$7!"%7%9%F%`%G!<%?%Y!<%9$K$O!"(Bdblink $B$N4X?t$,Dj5A$5$l$F$*$j!"J,;6%k!<%k$r3JG<$9$k%F!<%V%k(B dist_def $B$,Dj5A$5$l$F$$$kI,MW$,$"$j$^$9!#(B
$B$^$?!"%G!<%?%Y!<%9%N!<%I$N(B 1 $BBf$K%7%9%F%`%G!<%?%Y!<%9$r:n@.$9$k$3$H$b$G$-$^$9$7!"(Bpgpool-II$B$r%+%9%1!<%I@\B3$9$k$3$H$GIi2YJ,;6$9$k$3$H$b$G$-$^$9!#(B</p>
<p>$B$3$3$G$O!"0J2<$N(B <code>pgpool.conf</code> $B%U%!%$%k$N=i4|@_Dj$K=>$C$F%7%9%F%`%G!<%?%Y!<%9$r:n@.$7$^$9!#(B</p>
<pre>system_db_hostname = 'localhost'
system_db_port = 5432
system_db_dbname = 'pgpool'
system_db_schema = 'pgpool_catalog'
system_db_user = 'pgpool'
system_db_password = ''</pre>
<p><code>pgpool.conf</code> $B%U%!%$%k$N=i4|@_Dj$G$O!"%7%9%F%`%G!<%?%Y!<%9$O(B pgpool-II $B$HF1$8%[%9%H$N%]!<%HHV9f(B 5432 $B$G5/F0$9$k%G!<%?%Y!<%9%5!<%P!"$D$^$j!"(B1 $BBfL\$N%G!<%?%Y!<%9%N!<%I$K:n@.$9$k$3$H$K$J$j$^$9!#(B
$B$^$?!"%7%9%F%`%G!<%?%Y!<%9$N%G!<%?%Y!<%9L>$O(B pgpool $B$K!"%7%9%F%`%G!<%?%Y!<%9$K@\B3$9$k%f!<%6L>$b(B pgpool $B$K@_Dj$5$l$F$$$k$N$G!"(Bpgpool $B$H$$$&%f!<%6$r:n@.$7$F$+$i%f!<%6(B pgpool $B$r=jM-<T$H$7$F%G!<%?%Y!<%9(B pgpool $B$r:n@.$7$^$9!#(B
</p>
<pre>$ createuser -p 5432 pgpool
$ createdb -p 5432 -O pgpool pgpool</pre>
<h4><p>3.2.1. dblink $B$N%$%s%9%H!<%k(B</p></h4>
<p>$B%7%9%F%`%G!<%?%Y!<%9$H$7$F%G!<%?%Y!<%9(B pgpool $B$,:n@.$G$-$?$i!"(Bdblink $B$r%$%s%9%H!<%k$7$^$9!#(B
dblink $B$O(B PostgreSQL $B$N%=!<%9%3!<%I$N(B <code>contrib</code> $B%G%#%l%/%H%j$K4^$^$l$k%D!<%k$N(B 1 $B$D$G$9!#(B</p>
<p>dblink $B$r%$%s%9%H!<%k$9$k$K$O(B PostgreSQL $B$N%=!<%9%3!<%I$rE83+$7$?%G%#%l%/%H%j$G0J2<$N$h$&$K%3%^%s%I$r<B9T$7$^$9!#(B</p>
<pre>$ USE_PGXS=1 make -C contrib/dblink
$ USE_PGXS=1 make -C contrib/dblink install</pre>
<p>$B%G!<%?%Y!<%9(B pgpool $B$KBP$7$F(B dblink $B$N4X?t$rDj5A$7$^$9!#(B
PostgreSQL $B$N%$%s%9%H!<%k@h$,(B <code>/usr/local/pgsql</code> $B%G%#%l%/%H%j0J2<$G$"$l$P!"(B<code>/usr/local/pgsql/share/contrib</code> $B%G%#%l%/%H%j$K(B dblink $B$N4X?t$rDj5A$9$k$?$a$N(B <code>dblink.sql</code> $B%U%!%$%k$,B8:_$7$^$9!#(B
$B$=$l$r;HMQ$7$F0J2<$N$h$&$K(B <code>psql</code> $B%3%^%s%I$r<B9T$7$^$9!#(B</p>
<pre>$ psql -f /usr/local/pgsql/share/contrib/dblink.sql -p 5432 pgpool</pre>
<h4><p>3.2.2. $B%F!<%V%k(B dist_def $B$NDj5A(B</p></h4>
<p>$BJ,;6%k!<%k$r3JG<$9$k%F!<%V%k(B dist_def $B$r%7%9%F%`%G!<%?%Y!<%9(B pgpool $B$KDj5A$7$^$9!#(B
pgpool-II $B$r%$%s%9%H!<%k$9$k$H%F!<%V%k(B dist_def $B$r4^$a$F%7%9%F%`%G!<%?%Y!<%9$r:n@.$9$k$?$a$N(B <code>system_db.sql</code> $B%U%!%$%k$,:n@.$5$l$k$N$G!"$=$l$r;HMQ$7$F0J2<$N$h$&$K(B <code>psql</code> $B%3%^%s%I$r<B9T$7$^$9!#(B</p>
<pre>$ psql -f /usr/local/share/system_db.sql -p 5432 -U pgpool pgpool</pre>
<p><code>system_db.sql</code> $B%U%!%$%k$G$O!"%9%-!<%^(B pgpool_catalog $B$K%F!<%V%k(B dist_def $B$J$I$rDj5A$7$F$$$^$9!#(B
$B=>$C$F!"(B<code>pgpool.conf</code> $B%U%!%$%k$N(B <code>system_db_schema</code> $B%Q%i%a!<%?$G(B pgpool_catalog $B$G$J$$%9%-!<%^L>$r;XDj$7$F$$$k>l9g!"(B<code>system_db.sql</code> $B%U%!%$%k$rJT=8$7$F%9%-!<%^L>$rJQ99$9$kI,MW$,$"$j$^$9!#(B</p>
<p>$B%F!<%V%k(B dist_def $B$O0J2<$N$h$&$KDj5A$5$l$F$*$j!"%F!<%V%kL>$rJQ99$9$k$3$H$O$G$-$^$;$s!#(B</p>
<pre>CREATE TABLE pgpool_catalog.dist_def (
dbname text, -- $B%G!<%?%Y!<%9L>(B
schema_name text, -- $B%9%-!<%^L>(B
table_name text, -- $B%F!<%V%kL>(B
col_name text NOT NULL CHECK (col_name = ANY (col_list)), -- $BJ,;6%-!<NsL>(B
col_list text[] NOT NULL, -- $B%F!<%V%k$NNsL>(B
type_list text[] NOT NULL, -- $B%F!<%V%k$N%G!<%?7?L>(B
dist_def_func text NOT NULL, -- $BJ,;6%k!<%k4X?t(B
PRIMARY KEY (dbname, schema_name, table_name)
);</pre>
<p>$B%F!<%V%k(B dist_def $B$K3JG<$5$l$k%G!<%?$OBg$-$/J,$1$F0J2<$N(B 2 $B$D$G$9!#(B</p>
<ul>
<li>$BJ,;6%k!<%k(B (col_name$B!"(Bdist_def_func)</li>
<li>$B%F!<%V%k$N%a%?>pJs(B (dbname$B!"(Bschema_name$B!"(Btable_name$B!"(Bcol_list$B!"(Btype_list)</li>
</ul>
<p>$B$^$:!"J,;6%k!<%k$O$I$N%G!<%?$r$I$N%G!<%?%Y!<%9%N!<%I$K3JG<$9$k$+$H$$$&$3$H$r7hDj$9$k$?$a$N%G!<%?$G$9!#(B
col_name $BNs$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<%^L>(B
table_name TEXT, -- $B%F!<%V%kL>(B
col_list TEXT[] NOT NULL, -- $B%F!<%V%k$NNsL>(B
type_list TEXT[] NOT NULL, -- $B%F!<%V%k$N%G!<%?7?L>(B
PRIMARY KEY (dbname,schema_name,table_name)
);
</pre>
</p>
<p>
$B%F!<%V%k(B replicate_def $B$K3JG<$5$l$k%G!<%?$O%F!<%V%k$N%a%?>pJs(B(dbname$B!"(Bschema_name$B!"(Btable_name$B!"(Bcol_list$B!"(Btype_list)$B$H$J$j$^$9!#(B
</p>
<p>
pgpool-ll $B$O!"%/%(%j$K;H$o$l$F$$$k!"$9$Y$F$N%F!<%V%k!"%+%i%`!"7?>pJs$r(Bdist_def$B$^$?$O!"(Breplicate_def$B%F!<%V%k$KEPO?$7$F$$$k>pJs(B
$B$rMQ$$$F!"%/%(%j$N2r@O$H%/%(%j$N=q$-49$($r9T$$$^$9!#$=$N$?$a(B replicate_def$B%F!<%V%k$K@5$7$$>pJs$rEPO?$7$F$*$+$J$$$H!"@5$7$$<B9T(B
$B7k2L$,F@$i$l$J$$2DG=@-$,$"$j$^$9!#(B
</p>
<h3>3.3. <a name="dist-def">$BJ,;6%k!<%k$NDj5A(B</a></h3>
<p>$BJ,;6%k!<%k$O$I$N%G!<%?$r$I$N%G!<%?%Y!<%9%N!<%I$K3JG<$9$k$+$H$$$&$3$H$r7hDj$9$k$b$N$G$9!#(B</p>
<p>$B$3$3$G$O!"%9%1!<%k%U%!%/%?!<(B 3 $B$r;XDj$7$F%G!<%?$r=i4|2=$7$?(B pgbench $B$N%F!<%V%k$r(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$K?6$jJ,$1$k$?$a$NJ,;6%k!<%k$rDj5A$7$^$9!#(B
$B$J$*!"%G!<%?%Y!<%9$O!V(B2. <a href="#replication">$B=i$a$F$N%l%W%j%1!<%7%g%s(B</a>$B!W$G;HMQ$7$?%G!<%?%Y!<%9(B bench_replication $B$H$OJL$K%G!<%?%Y!<%9(B bench_parallel $B$r:n@.$9$k$3$H$K$7$^$9!#(B</p>
<p>$B$J$*!"%=!<%9%3!<%I$N(B <code>sample</code> $B%G%#%l%/%H%j$K$O0J2<$N@bL@$G;HMQ$9$kJ,;6%k!<%k$,Dj5A$5$l$?%U%!%$%k(B <code>dist_def_pgbench.sql</code> $B$,=`Hw$5$l$F$$$^$9!#(B
$B$3$l$r;HMQ$7$FJ,;6%k!<%k$rDj5A$9$k$K$O%=!<%9%3!<%I$rE83+$7$?%G%#%l%/%H%j$G0J2<$N$h$&$K(B psql $B%3%^%s%I$r<B9T$7$^$9!#(B</p>
<pre>$ psql -f sample/dist_def_pgbench.sql -p 5432 pgpool</pre>
<p>$B$^$:!"J,;6%k!<%k$H%F!<%V%k$N%a%?>pJs$r%7%9%F%`%G!<%?%Y!<%9(B pgpool $B$N%F!<%V%k(B dist_def $B$K3JG<$7$^$9!#(B
$B$3$3$G$O(Baccounts$B%F!<%V%k$r3F%G!<%?%Y!<%9%N!<%I$KBP$7$F%G!<%?J,3d$r9T$$$^$9!#(B
$BJ,;6%-!<NsL>$O!"(Baccounts $B$K$D$$$F$O%W%i%$%^%j%-!<@)Ls$,;XDj$5$l$?Ns(B aid $B$K;XDj$7$^$9!#(B</p>
<pre>
INSERT INTO pgpool_catalog.dist_def VALUES (
'bench_parallel',
'public',
'accounts',
'aid',
ARRAY['aid', 'bid', 'abalance', 'filler'],
ARRAY['integer', 'integer', 'integer', 'character(84)'],
'pgpool_catalog.dist_def_accounts'
);
</pre>
<p>$B<!$K!"J,;6%k!<%k4X?t$r%F!<%V%k$4$H$K%7%9%F%`%G!<%?%Y!<%9(B pgpool $B$KDj5A$7$^$9!#(B
$BJ,;6%k!<%k4X?t$O!"I,$:$7$b%F!<%V%k$4$H$K:n@.$9$kI,MW$O$J$/!"FbIt4X?t$r;HMQ$9$k$3$H$b$G$-$^$9!#(B
$B$^$?!"J,;6%k!<%k4X?t$O(B SQL $B$G$J$/$H$b(B PL/pgSQL $B$d(B PL/Tcl $B$G:n@.$7$F$b9=$$$^$;$s!#(B</p>
<p>$B%9%1!<%k%U%!%/%?!<(B 3 $B$r;XDj$7$F%G!<%?$r=i4|2=$7$?>l9g!"(Baccounts $B%F!<%V%k$N(B aid $BNs$NCM$O(B 1 $B$+$i(B 300000 $B$^$G$K$J$k$N$G!"$3$l$i$NCM$r$b$H$K(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$KBP$7$F%G!<%?$,6QEy$KJ,;6$5$l$k$h$&$K4X?t$rDj5A$7$^$9!#(B</p>
<p>$B$3$3$G$O!"0z?t$H$7$F<u$1<h$C$?CM$+$i(B WHEN $B<0$K$h$C$F(B 0 $B$+$i(B 2 $B$^$G$N%G!<%?%Y!<%9%N!<%I$NHV9f$rJV$9C1=c$J(B SQL $B4X?t$rDj5A$9$k$3$H$K$7$^$9!#(B</p>
<pre>
CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_accounts(anyelement)
RETURNS integer AS $$
SELECT CASE WHEN $1 > 0 AND $1 <= 100000 THEN 0
WHEN $1 > 100000 AND $1 <= 200000 THEN 1
ELSE 2
END;
$$ LANGUAGE sql;
</pre>
<h3>3.4 <a name="replicate-def">$BJ#@=%k!<%k$NDj5A(B</a></h3>
<p>$BJ#@=%k!<%k$O$I$N%F!<%V%k$,%l%W%j%1!<%7%g%s$5$l$F$$$k$+$I$&$+$r7hDj$9$k$b$N$G$9!#(B</p>
<p>$B$3$3$G$O!"(Bpgbench$B$G:n@.$5$l$k!!(Bbranches $B%F!<%V%k$H(B tellers $B$rEPO?$7$F$*$-$^$9!#$3$l$K$h$j!"(Baccounts$B%F!<%V%k!"(Bbranches$B%F!<%V%k$H(Btellers$B%F!<%V%k$r(B
$B;H$C$?Ld$$9g$o$;$,2DG=$H$J$j$^$9!#(B
<pre>
INSERT INTO pgpool_catalog.replicate_def VALUES (
'bench_parallel',
'public',
'branches',
ARRAY['bid', 'bbalance', 'filler'],
ARRAY['integer', 'integer', 'character(88)']
);
INSERT INTO pgpool_catalog.replicate_def VALUES (
'bench_parallel',
'public',
'tellers',
ARRAY['tid', 'bid', 'tbalance', 'filler'],
ARRAY['integer', 'integer', 'integer', 'character(84)']
);
</pre>
<p>$B$J$*!"%=!<%9%3!<%I$N(B <code>sample</code> $B%G%#%l%/%H%j$K$O>e5-$N@bL@$G;HMQ$9$kJ#@=%k!<%k$,Dj5A$5$l$?%U%!%$%k(B <code>replicate_def_pgbench.sql</code> $B$,=`Hw$5$l$F$$$^$9!#(B
$B$3$l$r;HMQ$7$FJ,;6%k!<%k$rDj5A$9$k$K$O%=!<%9%3!<%I$rE83+$7$?%G%#%l%/%H%j$G0J2<$N$h$&$K(B psql $B%3%^%s%I$r<B9T$7$^$9!#(B</p>
<pre>
$ psql -f sample/replicate_def_pgbench.sql -p 5432 pgpool
</pre>
<h3>3.5. <a name="parallel-check">$B%Q%i%l%k%/%(%j$N3NG'(B</a></h3>
<p>$B%Q%i%l%k%/%(%j$N@_Dj$r(B pgpool-II $B$KH?1G$5$;$k$K$O(B pgpool-II $B$r:F5/F0$9$kI,MW$,$"$j$^$9!#$J$*!"%F!<%V%k(B dist_def$B!"(Breplicate_def $B$r99?7$7$?>l9g$b(B pgpool-II $B$N:F5/F0$,I,MW$G$9!#(B
pgpool-II $B$N:F5/F0$K$D$$$F$O!V(B1.5. <a href="#start-shutdown">pgpool-II $B$N5/F0$HDd;_(B</a>$B!W$r;2>H$7$F$/$@$5$$!#(B</p>
<p>$B%Q%i%l%k%/%(%j$rM-8z$K$7$F(B pgpool-II $B$r5/F0$G$-$?$i!"<B:]$K(B pgbench $B$r;HMQ$7$F%Q%i%l%k%/%(%j$,<B9T$5$l$k$3$H$r3NG'$7$^$7$g$&!#(B</p>
<p>$B$^$:!"(Bpgbench $B$,;HMQ$9$k%G!<%?%Y!<%9(B bench_parallel $B$r:n@.$7$^$9!#(B
<code>createdb</code> $B%3%^%s%I$r(B pgpool-II $B$KBP$7$F<B9T$9$k$H!"$9$Y$F$N%G!<%?%Y!<%9%N!<%I$KBP$7$F%G!<%?%Y!<%9(B bench_parallel $B$,:n@.$5$l$^$9!#(B</p>
<pre>$ createdb -p 9999 bench_parallel</pre>
<p>$B$=$7$F!"0J2<$N$h$&$K%9%1!<%k%U%!%/%?!<(B 3 $B$r;XDj$7$F(B pgbench $B$G;HMQ$9$k%F!<%V%k$r:n@.$7!"%G!<%?$r=i4|2=$7$^$9!#(B</p>
<pre>$ pgbench -i -p 9999 -s 3 bench_parallel</pre>
<p>$B%9%1!<%k%U%!%/%?!<(B 3 $B$r;XDj$7$F%G!<%?$r=i4|2=$7$?(B pgbench $B$N%F!<%V%k$H$=$l$>$l$N9T?t$O0J2<$N$H$*$j$G$9!#(B
$B%G!<%?$r=i4|2=$9$k$3$H$K$h$C$F3JG<$5$l$k%G!<%?$O!"%F!<%V%k(B dist_def $B$KEPO?$5$l$F$$$k%F!<%V%k$KBP$7$F$OJ,;6%k!<%k$K=>$C$F(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$KJ,;6$5$l$^$9!#(B</p>
<center>
<table border="1">
<tr>
<th>$B%F!<%V%kL>(B</th>
<th>$B9T?t(B</th>
</tr>
<tr>
<td>branches</td>
<td>3</td>
</tr>
<tr>
<td>tellers</td>
<td>30</td>
</tr>
<tr>
<td>accounts</td>
<td>300000</td>
</tr>
<tr>
<td>history</td>
<td>0</td>
</tr>
</table>
</center>
<p>$B%G!<%?$,(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$KJ,;6$5$l$F$$$k$3$H$O!"(Bpgpool-II $B$KBP$7$FLd$$9g$o$;$r<B9T$7$?7k2L$H%G!<%?%Y!<%9%N!<%I$KD>@\Ld$$9g$o$;$r<B9T$7$?7k2L$rHf3S$9$l$P3NG'$G$-$^$9!#(B
$BNc$($P!"0J2<$N$h$&$K%3%^%s%I$r<B9T$9$k$H!"$9$Y$F$N%G!<%?%Y!<%9%N!<%I(B ($B%]!<%HHV9f(B 5432$B!"(B5433$B!"(B5434$B!"(B9999) $B$N%G!<%?%Y!<%9(B bench_parallel $B$N%F!<%V%k(B accounts $B$N:G>.CM!":GBgCM$,I=<($5$l$^$9!#(B</p>
<pre>$ for port in 5432 5433 5434 9999; do
> echo $port
> psql -c "SELECT min(aid), max(aid) FROM accounts" -p $port bench_parallel
> done
</pre>
<div class="copyright">
<hr>
<copyright>
Copyright © 2003 – 2013 pgpool Global Development Group
</copyright>
</div>
</body>
</html>
|