1<!-- doc/src/sgml/runtime.sgml --> 2 3<chapter id="runtime"> 4 <!-- 5 <title>Server Setup and Operation</title> 6 --> 7 <title>サーバの準備と運用</title> 8 9 <para> 10 <!-- 11 This chapter discusses how to set up and run the <productname>Pgpool-II</> server 12 and its interactions with the operating system. 13 --> 14 本章では、<productname>Pgpool-II</>サーバの設定と実行方法、そしてオペレーティングシステムとの相互作用について説明します。 15 </para> 16 17 <sect1 id="pgpool-II-user"> 18 <!-- 19 <title>The <productname>Pgpool-II</productname> User Account</title> 20 --> 21 <title><productname>Pgpool-II</productname>ユーザアカウント</title> 22 23 <indexterm> 24 <!-- 25 <primary>Pgpool-II user</primary> 26 --> 27 <primary>Pgpool-IIユーザ</primary> 28 </indexterm> 29 30 <para> 31 <!-- 32 As with any server daemon that is accessible to the outside world, 33 it is advisable to run <productname>Pgpool-II</productname> under a 34 separate user account. This user account should only own the data 35 that is managed by the server, and should not be shared with other 36 daemons. (For example, using the user <literal>nobody</literal> is a bad 37 idea.) It is not advisable to install executables owned by this 38 user because compromised systems could then modify their own 39 binaries. 40 --> 41 外部へアクセスできるサーバデーモンと同じように、<productname>Pgpool-II</productname>を独立したユーザアカウントで実行することをお勧めします。 42 このユーザアカウントは、サーバによって管理されるデータのみを所有する必要があります。 43 また、他のデーモンとアカウントを共有しない方が良いです。 44 (例えば、<literal>nobody</literal>ユーザの使用はお勧めできません。) 45 このユーザによって所有される実行プログラムをインストールすることも好ましくありません。 46 システムが攻撃を受けた場合などに、自分自身のバイナリを変更されてしまう可能性があるからです。 47 </para> 48 49 <para> 50 <!-- 51 To add a Unix user account to your system, look for a command 52 <command>useradd</command> or <command>adduser</command>. The user 53 name <systemitem>pgpool</systemitem> is often used, and is assumed 54 throughout this book, but you can use another name if you like. 55 --> 56 システムにUnixのユーザアカウントを追加するためには、コマンド<command>useradd</command>か<command>adduser</command>を使用してください。 57 <systemitem>pgpool</systemitem>というユーザ名がよく使われ、本書全体でも使用していますが、好みの名前を使用しても構いません。 58 </para> 59 </sect1> 60 61 <sect1 id="configuring-pcp-conf"> 62 <!-- 63 <title>Configuring pcp.conf</title> 64 --> 65 <title>pcp.confの設定</title> 66 67 <indexterm> 68 <!-- 69 <primary>pcp configuration</primary> 70 --> 71 <primary>pcpの設定</primary> 72 </indexterm> 73 74 <para> 75 <!-- 76 <productname>Pgpool-II</productname> provides a interface 77 for administrators to perform management operation, such as 78 getting <productname>Pgpool-II</productname> status or terminating 79 <productname>Pgpool-II</productname> processes 80 remotely. <filename>pcp.conf</filename> is the user/password file 81 used for authentication by this interface. All operation modes 82 require the <filename>pcp.conf</filename> file to be set. A 83 <filename>$prefix/etc/pcp.conf.sample</filename> file is created 84 during the installation 85 of <productname>Pgpool-II</productname>. Copy the file as 86 <filename>$prefix/etc/pcp.conf</filename> and add your user name and password 87 to it. 88 --> 89 <productname>Pgpool-II</productname>は管理者が<productname>Pgpool-II</productname>のステータス取得や、リモートからの<productname>Pgpool-II</productname>プロセスの停止といった、管理操作を行うためのインターフェイスを提供しています。 90 <filename>pcp.conf</filename>はこのインタフェースの認証に使われるユーザ/パスワードのファイルです。 91 全ての動作モードにおいて<filename>pcp.conf</filename>の設定が必要です。 92 <productname>Pgpool-II</productname>のインストール中に<filename>$prefix/etc/pcp.conf.sample</filename>が作られます。 93 そのファイルを<filename>$prefix/etc/pcp.conf</filename>という名前でコピーしてユーザ名とパスワードを追加してください。 94 95 <screen> 96 <prompt>$</> <userinput>cp $prefix/etc/pcp.conf.sample $prefix/etc/pcp.conf</userinput> 97 </screen> 98 99 <!-- 100 An empty line or a line starting with <literal>#</literal> is treated as a 101 comment and will be ignored. A user name and its associated 102 password must be written as one line using the following format: 103 --> 104 空白行や<literal>#</literal>で始まる行はコメントと見なされ無視されます。 105 ユーザ名とそれに対応するパスワードは以下の形式を使って1行で書かれなくてはなりません。 106 107 <synopsis> 108 <!-- 109 <replaceable>username</>:<replaceable>[md5 encrypted password]</> 110 --> 111 <replaceable>ユーザ名</>:<replaceable>[md5暗号化されたパスワード]</> 112 </synopsis> 113 114 <!-- 115 <replaceable>[md5 encrypted password]</> can be produced with the <filename>$prefix/bin/pg_md5</> command. 116 --> 117 <replaceable>[md5暗号化されたパスワード]</>は、<filename>$prefix/bin/pg_md5</filename>コマンドで作成できます。 118 119 <screen> 120 <prompt>$</> <userinput>pg_md5 your_password</userinput> 121 1060b7b46a3bd36b3a0d66e0127d0517 122 </screen> 123 124 <!-- 125 If you don't want pass the password as the argument, execute <command>pg_md5 -p</command>. 126 --> 127 パスワードを引数に渡したくない場合は<command>pg_md5 -p</command>を実行してください。 128 129 <screen> 130 <prompt>$</> <userinput>pg_md5 -p</userinput> 131 password: <userinput>your_password</userinput> 132 </screen> 133 134 <!-- 135 The <filename>pcp.conf</filename> file must be readable by the 136 user who executes <productname>Pgpool-II</productname>. 137 --> 138 <filename>pcp.conf</filename>は、<productname>Pgpool-II</productname>を実行するユーザから読み取り可能になっていなければなりません。 139 </para> 140 141 </sect1> 142 143 <sect1 id="configuring-pgpool"> 144 <!-- 145 <title>Configuring Pgpool-II</title> 146 --> 147 <title>Pgpool-IIの設定</title> 148 149 <indexterm> 150 <!-- 151 <primary>Pgpool-II configuration</primary> 152 --> 153 <primary>Pgpool-IIの設定</primary> 154 </indexterm> 155 156 <sect2 id="configuring-pgpool-conf"> 157 <!-- 158 <title>Configuring pgpool.conf</title> 159 --> 160 <title>pgpool.confの設定</title> 161 162 <para> 163 <!-- 164 <filename>pgpool.conf</filename> is the main configuration file 165 of <productname>Pgpool-II</productname>. You need to specify the 166 path to the file when 167 starting <productname>Pgpool-II</productname> 168 using <option>-f</option> option. 169 <filename>pgpool.conf</filename> is located 170 at <filename>$prefix/etc/pgpool.conf</filename> by default. 171 --> 172 <filename>pgpool.conf</filename>は<productname>Pgpool-II</productname>のメインの設定ファイルです。 173 <productname>Pgpool-II</productname>の起動時には<option>-f</option>オプションでこのファイルのパスを指定する必要があります。 174 デフォルトでは<filename>pgpool.conf</filename>は<filename>$prefix/etc/pgpool.conf</filename>に配置されます。 175 </para> 176 </sect2> 177 178 <sect2 id="running-mode"> 179 <!-- 180 <title>Running mode of Pgpool-II</title> 181 --> 182 <title> Pgpool-IIの動作モード</title> 183 184 <para> 185 <!-- 186 There are four different running modes in <productname>Pgpool-II</>: streaming 187 replication mode, master slave mode, native replication mode and 188 raw mode. In any mode, <productname>Pgpool-II</> provides connection pooling 189 and automatic fail over. Online recovery can be used only with streaming replication 190 mode and native replication mode. The sample configuration 191 files for each mode are provied. They are located 192 under <filename>$prefix/etc</filename>. You can copy one of them 193 to <filename>$prefix/etc/pgpool.conf</filename>. 194 --> 195 <productname>Pgpool-II</>にはストリーミングレプリケーションモード、マスタースレーブモード、ネイティブレプリケーションモード、rawモードの4つの動作モードがあります。 196 いずれのモードにおいても、<productname>Pgpool-II</>はコネクションプーリング、自動フェイルオーバの機能を提供します。 197 ストリーミングレプリケーションモードとネイティブレプリケーションモードのときにのみオンラインリカバリが可能です。 198 各モードのためのサンプルの設定ファイルが提供されています。 199 これらは<filename>$prefix/etc/</filename>以下に配置されており、<filename>$prefix/etc/pgpool.conf</filename>としてコピーして使用することができます。 200 </para> 201 202 <para> 203 <!-- 204 Those modes are exclusive each other and cannot be changed after 205 starting the server. You should make a decision which to use in 206 the early stage of designing the system. If you are not sure, it 207 is recommended to use the streaming replication mode. 208 --> 209 これらのモードは互いに排他的であり、サーバ起動後は変更することができません。 210 システム設計の初期の段階でどのモードを使うか決めなければなりません。 211 どれを使えば良いかわからない場合は、ストリーミングレプリケーションモードを使うことを推奨します。 212 </para> 213 214 <para> 215 <!-- 216 The streaming replication mode can be used with <productname>PostgreSQL</> servers 217 operating streaming replication. In this mode, <productname>PostgreSQL</> is 218 responsible for synchronizing databases. This mode is widely used 219 and most recommended way to use <productname>Pgpool-II</>. Load balancing is 220 possible in the mode. The sample configuration file 221 is <filename>$prefix/etc/pgpool.conf.sample-stream</filename>. 222 --> 223 ストリーミングレプリケーションモードはストリーミングレプリケーションを使用する<productname>PostgreSQL</>サーバと一緒に使うことができます。 224 このモードでは、<productname>PostgreSQL</>がデータベースを同期する責任を持ちます。 225 このモードは広く使われており、最も推奨される<productname>Pgpool-II</>の使用法です。 226 このモードでは負荷分散が可能です。 227 サンプルの設定ファイルは<filename>$prefix/etc/pgpool.conf.sample-stream</filename>です。 228 </para> 229 230 <para> 231 <!-- 232 The master slave mode mode can be used with <productname>PostgreSQL</> servers 233 operating <productname>Slony</>. In this mode, <productname>Slony</>/<productname>PostgreSQL</> is responsible for 234 synchronizing databases. Since <productname>Slony</> is being obsoletd by streaming 235 replication, we do not recommend to use this mode unless you have 236 specific reason to use <productname>Slony</>. Load balancing is possible in the 237 mode. The sample configuration file 238 is <filename>$prefix/etc/pgpool.conf.sample-master-slave</filename>. 239 --> 240 <firstterm>マスタスレーブモード</firstterm>(slonyモード)は<productname>Slony-I</>を使用する<productname>PostgreSQL</>サーバと一緒に使うことができます。 241 このモードでは、<productname>Slony</>/<productname>PostgreSQL</>がデータベースを同期する責任を持ちます。 242 <productname>Slony</>はストリーミングレプリケーションの登場により廃れつつあるため、<productname>Slony</>を使う特別な理由が無い限りこのモードの使用を推奨しません。 243 このモードでは負荷分散が可能です。 244 サンプルの設定ファイルは<filename>$prefix/etc/pgpool.conf.sample-master-slave</filename>です。 245 </para> 246 247 <para> 248 <!-- 249 In the native replication mode, <productname>Pgpool-II</> is responsible for 250 synchronizing databases. The advantage for the mode is the 251 synchronization is done in synchronous way: writing to the 252 database does not return until all of <productname>PostgreSQL</> servers finish 253 the write operation. Note, however, read snapshot control is not 254 done and consistent visibility is not guaranteed in the mode. 255 Load balancing is possible in the mode. The sample configuration 256 file <filename>$prefix/etc/pgpool.conf.sample-replication</filename>. 257 --> 258 ネイティブレプリケーションモードでは、<productname>Pgpool-II</>がデータベースを同期する責任を持ちます。 259 このモードの利点は同期が同期的に行われることです。 260 すなわち、データベースへの書き込みは全ての<productname>PostgreSQL</>サーバが書き込み操作を完了するまで返ってきません。 261 しかし、<productname>PostgreSQL</> 9.6以降では、ストリーミングレプリケーションで<literal>synchronous_commit = remote_apply</literal>と設定することにより、同様の効果が得られます。 262 ネイティブレプリケーションモードの<xref linkend="restrictions">を回避できるので、この設定が使える場合には、ネイティブレプリケーションモードではなくてこの設定を使うことをお勧めします。 263 <productname>PostgreSQL</>はノードをまたがるスナップショット管理を提供しないため、セッションYがノードBでコミットする前に、ノードAでコミットしたデータをセッションXが見ることがあり得ます。 264 もしセッションXが、そのときノードAで見た見たデータに基づいてノードBのデータを更新しようとすると、ノードAとノードBのデータ一貫性は損なわれるかもしれません。 265 この問題を回避するには、ユーザは明示的にノードAのデータをロックしなければなりません。 266 これがストリーミングレプリケーションと<literal>synchronous_commit = remote_apply</literal>を使用することをおすすめするもう一つの理由です。 267 </para> 268 <para> 269 このモードでは負荷分散が可能です。 270 サンプルの設定ファイルは<filename>$prefix/etc/pgpool.conf.sample-replication</filename>です。 271 </para> 272 273 <para> 274 <!-- 275 In the raw mode, <productname>Pgpool-II</> does not care about the database 276 synchronization. It's user's responsibility to make the whole 277 system does a meaningfull thing. Load balancing 278 is <emphasis>not</emphasis> possible in the mode. The sample 279 configuration 280 file <filename>$prefix/etc/pgpool.conf.sample</filename>. 281 --> 282 rawモードでは、<productname>Pgpool-II</>はデータベースの同期に関しては関与しません。 283 システム全体に意味の有る動作をさせるのはユーザの責任となります。 284 このモードでは負荷分散は<emphasis>できません</emphasis>。 285 サンプルの設定ファイルは<filename>$prefix/etc/pgpool.conf.sample</filename>です。 286 287 </para> 288 </sect2> 289 </sect1> 290 291 <sect1 id="configuring-backend-info"> 292 <!-- 293 <title>Configuring backend information</title> 294 --> 295 <title>バックエンド情報の設定</title> 296 297 <para> 298 <!-- 299 For <productname>Pgpool-II</productname> to recognize <productname>PostgreSQL</> 300 backend servers, you need to configure <varname>backend*</varname> 301 in <filename>pgpool.conf</filename>. For starters, at 302 least <xref linkend="guc-backend-hostname"> 303 and <xref linkend="guc-backend-port"> paramters are required to 304 be set up to start <productname>Pgpool-II</> server. 305 --> 306 <productname>Pgpool-II</>が<productname>PostgreSQL</>バックエンドサーバを認識するために、<filename>pgpool.conf</filename>の<varname>backend*</varname>を設定する必要があります。 307 手始めに、<productname>Pgpool-II</>を起動するには少なくても<xref linkend="guc-backend-hostname">と<xref linkend="guc-backend-port">パラメータが設定されている必要があります。 308 </para> 309 310 <sect2 id="backend-settings"> 311 <!-- 312 <title>Backend Settings</title> 313 --> 314 <title>バックエンドの設定</title> 315 316 <para> 317 <!-- 318 Backend <productname>PostgreSQL</> used by <productname>Pgpool-II</> must be specified in <filename>pgpool.conf</filename>. 319 See <xref linkend="runtime-config-backend-settings"> 320 --> 321 <productname>Pgpool-II</>に使用されるバックエンド<productname>PostgreSQL</>が<filename>pgpool.conf</filename>で指定されている必要があります。 322 <xref linkend="runtime-config-backend-settings">を参照してください。 323 </para> 324 325 <!-- 326 <variablelist> 327 328 <varlistentry id="guc-backend-hostname" xreflabel="backend_hostname"> 329 <term><varname>backend_hostname</varname> (<type>string</type>) 330 <indexterm> 331 <primary><varname>backend_hostname</varname> configuration parameter</primary> 332 </indexterm> 333 </term> 334 335 <listitem> 336 <para> 337 <varname>backend_hostname</varname> specifies where to 338 connect to the <productname>PostgreSQL</productname> 339 backend. It is used 340 by <productname>Pgpool-II</productname> to communicate 341 with the server. 342 </para> 343 344 <para> 345 For TCP/IP communication, this parameter can take a hostname 346 or an IP address. If this begins with a slash, it specifies 347 Unix-domain communication rather than TCP/IP; the value is 348 the name of the directory in which the socket file is 349 stored. The default behavior when backend_hostname is empty 350 ('') is to connect to a Unix-domain socket in /tmp. 351 </para> 352 353 <para> 354 Multiple backends can be specified by adding a number at the 355 end of the parameter name (e.g.backend_hostname0). This 356 number is referred to as "DB node ID", and it starts from 357 0. The backend which was given the DB node ID of 0 will be 358 called "Master DB". When multiple backends are defined, the 359 service can be continued even if the Master DB is down (not 360 true in some modes). In this case, the youngest DB node ID 361 alive will be the new Master DB. 362 </para> 363 364 <para> 365 Please note that the DB node which has id 0 has no special 366 meaning if operated in streaming replication mode. Rather, 367 you should care about if the DB node is the "primary node" or 368 not. See Streaming Replication for more details. 369 </para> 370 371 <para> 372 If you plan to use only one PostgreSQL server, specify it by 373 backend_hostname0. 374 </para> 375 376 <para> 377 New nodes can be added in this parameter by reloading a 378 configuration file. However, values cannot be updated so 379 you must restart <productname>Pgpool-II</productname> in 380 that case. 381 </para> 382 383 </listitem> 384 385 </varlistentry> 386 387 <varlistentry id="guc-backend-port" xreflabel="backend_port"> 388 <term><varname>backend_port</varname> (<type>integer</type>) 389 <indexterm> 390 <primary><varname>backend_port</varname> configuration parameter</primary> 391 </indexterm> 392 </term> 393 394 <listitem> 395 <para> 396 <varname>backend_port</varname> specifies the port number 397 of the backends. Multiple backends can be specified by 398 adding a number at the end of the parameter name 399 (e.g. backend_port0). If you plan to use only one 400 PostgreSQL server, specify it by backend_port0. 401 </para> 402 <para> 403 New backend ports can be added in this parameter by 404 reloading a configuration file. However, values cannot be 405 updated so you must 406 restart <productname>Pgpool-II</productname> in that case. 407 </para> 408 </listitem> 409 </varlistentry> 410 411 <varlistentry id="guc-backend-data-directory" xreflabel="backend_data_directory"> 412 <term><varname>backend_data_directory</varname> (<type>string</type>) 413 <indexterm> 414 <primary><varname>backend_data_directory</varname> configuration parameter</primary> 415 </indexterm> 416 </term> 417 418 <listitem> 419 <para> 420 <varname>backend_data_directory</varname> specifies the 421 database directory. Multiple backends can be 422 specified by adding a number at the end of the parameter 423 name (e.g. backend_data_directory0). If you plan to use 424 only one PostgreSQL server, specify it by 425 backend_data_directory0. 426 </para> 427 <para> 428 New backend data_directorys can be added in this parameter 429 by reloading a configuration file. However, values cannot 430 be updated so you must 431 restart <productname>Pgpool-II</productname> in that case. 432 </para> 433 </listitem> 434 </varlistentry> 435 436 <varlistentry id="guc-backend-flag" xreflabel="backend_flag"> 437 <term><varname>backend_flag</varname> (<type>string</type>) 438 <indexterm> 439 <primary><varname>backend_flag</varname> configuration parameter</primary> 440 </indexterm> 441 </term> 442 443 <listitem> 444 <para> 445 <varname>backend_flag</varname> controls various backend 446 behavior. Multiple backends can be specified by adding a 447 number at the end of the parameter name 448 (e.g. backend_flag0). If you plan to use only one 449 PostgreSQL server, specify it by backend_flag0. 450 </para> 451 <para> 452 New backend flags can be added in this parameter by 453 reloading a configuration file. Currently followings are 454 allowed. Multiple flags can be specified by using "|". 455 </para> 456 457 <table id="backend-flag-table"> 458 <title>Backend flags</title> 459 <tgroup cols="2"> 460 <thead> 461 <row> 462 <entry>Flag</entry> 463 <entry>Description</entry> 464 </row> 465 </thead> 466 467 <tbody> 468 <row> 469 <entry><literal>ALLOW_TO_FAILOVER</literal></entry> 470 <entry>Allow to failover or detaching backend. This 471 is the default. You cannot specify with 472 DISALLOW_TO_FAILOVER at a same time.</entry> 473 </row> 474 <row> 475 <entry><literal>DISALLOW_TO_FAILOVER</literal></entry> 476 <entry>This is useful when you protect backend by 477 using HA (High Availability) softwares such as 478 Heartbeat or Pacemaker. You cannot specify with 479 ALLOW_TO_FAILOVER at a same time. 480 </entry> 481 </row> 482 </tbody> 483 </tgroup> 484 </table> 485 486 </listitem> 487 </varlistentry> 488 489 </variablelist> 490 491 --> 492 493 </sect2> 494 495 </sect1> 496 497</chapter> 498