Chapter 4. システムレイアウト

Figure 4-1. Postgres ファイルレイアウト

Postgres ファイルレイアウト shows how the Postgres distribution is laid out when installed in the default way. For simplicity, we will assume that Postgres has been installed in the directory /usr/local/pgsql. Therefore, wherever you see the directory /usr/local/pgsql you should substitute the name of the directory where Postgres is actually installed. All Postgres commands are installed in the directory /usr/local/pgsql/bin. Therefore, you should add this directory to your shell command path. If you use a variant of the Berkeley C shell, such as csh or tcsh, you would add
set path = ( /usr/local/pgsql/bin path )
in the .login file in your home directory. If you use a variant of the Bourne shell, such as sh, ksh, or bash, then you would add
PATH=/usr/local/pgsql/bin:$PATH
export PATH
to the .profile file in your home directory. From now on, we will assume that you have added the Postgres bin directory to your path. In addition, we will make frequent reference to "setting a shell variable" or "setting an environment variable" throughout this document. If you did not fully understand the last paragraph on modifying your search path, you should consult the UNIX manual pages that describe your shell before going any further. Postgres ファイルレイアウトPostgres がデフォルトで導入された時に、 どのように展開されるかを示しています。 話を単純にするためここでは Postgres/usr/local/pgsql ディレクトリに導入されている としましょう。 したがって、 /usr/local/pgsql ディレクトリと書 かれている部分を Postgres が実際に導入されているディレクトリ と読み変えてください。 全ての Postgres のコマンドは /usr/local/pgsql/bin ディレクトリに格納されて います。 ですから、シェルコマンドパスにこのディレクトリを追加しておかなければ なりません。 csh あるいは tcsh のようなバークレイ系の C シェルを使っている場合は、自分の home ディレクトリの .login ファイルに、
set path = ( /usr/local/pgsql/bin path )
と書き加えます。 shksh または bash のような Bourne シェルを使っている場合 は、home ディレクトリの .profile ファイルに以下を 付け加えます。
$ PATH=/usr/local/pgsql/bin:$PATH
$ export PATH
さらに、この文書を通じて "シェル変数の設定" とか "環境変数の設定" といった単語が頻繁にでてきます。 すぐ前に述べた自分の検索パスの変更について理解することが難しければ 先に進む前に、どのように自分のシェルを記述するか UNIX のマニュアルを 読んで下さい。

If you have not set things up in the default way, you may have some more work to do. For example, if the database server machine is a remote machine, you will need to set the PGHOST environment variable to the name of the database server machine. The environment variable PGPORT may also have to be set. The bottom line is this: if you try to start an application program and it complains that it cannot connect to the postmaster, you must go back and make sure that your environment is properly set up.

デフォルト環境で設定をしていない場合は、さらに追加の作業が必要に なります。例えばデータベースサーバが別のコンピュータで稼働している場合には、 環境変数 PGHOST でデータベースサーバの名前を指定しなければ なりません。環境変数 PGPORT の設定も多分必要になる でしょう。 最後に一言: アプリケーションを起動した時、postmaster に接続出来 ない場合は自分の設定した環境が正しいかどうかサイト管理者に相談して下さい。