Chapter 10. ディスク管理

代替領域

It is possible to create a database in a location other than the default location for the installation. Remember that all database access actually occurs through the database backend, so that any location specified must be accessible by the backend.

インストールの際のデフォルトの領域以外にデータベースを作成することが 可能です。全てのデータベースアクセスはデータベースバックエンドを通じて 発生するため、指定されたいかなる領域もバックエンドからアクセス出来なく てはなりません。

Alternate database locations are created and referenced by an environment variable which gives the absolute path to the intended storage location. This environment variable must have been defined before the backend was started and must be writable by the postgres administrator account. Any valid environment variable name may be used to reference an alternate location, although using variable name with a prefix of PGDATA is recommended to avoid confusion and conflict with other variables.

作成された代替のデータベース領域は意図された記憶領域への絶対パスを指定する環境変数 によって参照されます。環境変数はバックエンドが起動する前に設定され、postgres の 管理者アカウントで書き込めなければなりません。代替領域を参照するいかなる環境変数 名も使用できますが混乱と他の変数との抵触を避けるため、PGDATA と先頭に付けた変数名 を使うことを推奨します。

Note: In previous versions of Postgres, it was also permissable to use an absolute path name to specify an alternate storage location. The environment variable style of specification is to be preferred since it allows the site administrator more flexibility in managing disk storage. If you prefer using absolute paths, you may do so by defining "ALLOW_ABSOLUTE_DBPATHS" and recompiling Postgres To do this, either add this line

前バージョンの Postgres では代替記憶領域 を指定する絶対パス名も同様許されていました。仕様による環境変数の形式 はサイトの管理者がディスク記憶管理をより柔軟に行えるようになっています。 もし、絶対パスを好むのであれば "ALLOW_ABSOLUTE_DBPATHS" の定義を行い Postgres を再コンパイルします。 このためには、次の行

#define ALLOW_ABSOLUTE_DBPATHS 1
     
to the file src/include/config.h, or by specifying を src/include/config.h ファイルに付け加えるか、又は
 CFLAGS+= -DALLOW_ABSOLUTE_DBPATHS
     
in your Makefile.custom. を Makefile.custom の中で指定します。

Remember that database creation is actually performed by the database backend. Therefore, any environment variable specifying an alternate location must have been defined before the backend was started. To define an alternate location PGDATA2 pointing to /home/postgres/data, first type

% setenv PGDATA2 /home/postgres/data
    
to define the environment variable to be used with subsequent commands. Usually, you will want to define this variable in the Postgres superuser's .profile or .cshrc initialization file to ensure that it is defined upon system startup. Any environment variable can be used to reference alternate location, although it is preferred that the variables be prefixed with "PGDATA" to eliminate confusion and the possibility of conflicting with or overwriting other variables.

データベースの作成は実際にはデータベースバックエンドによって行われる点に注意 して下さい。ですから、代替領域を指定するいかなる環境変数もバックエンドが起動 される前に定義されていなければなりません。 PGDATA2 が指し示す代替領域 /home/postgres/data を定義する には、先ず

% setenv PGDATA2 /home/postgres/data
    
と入力し、引き続く命令とともに使用される環境変数を定義します。 通常この変数を Postgres のスーパーユーザの初期化 ファイル、.profile または .cshrc でシステム起動時点で確実に定義されるようにします。どんな環境変数も代替領域 の参照に使用できますが、混乱と他の変数との抵触、あるいは他の変数を書き換えて しまう事を避けるため、"PGDATA" と先頭に付けた変数名を使うことを推奨します。

To create a data storage area in PGDATA2, ensure that /home/postgres already exists and is writable by the postgres administrator. Then from the command line, type

% setenv PGDATA2 /home/postgres/data
% initlocation $PGDATA2
Creating Postgres database system directory /home/postgres/data

Creating Postgres database system directory /home/postgres/data/base

    

PGDATA2 にデータ記憶領域を作成するためには、先ず /home/postgres が存在し、そこが postgres 管理者 の書き込み可能領域であることを確認します。 次にコマンドラインから以下の入力を行います。

% setenv PGDATA2 /home/postgres/data
% initlocation $PGDATA2
Creating Postgres database system directory /home/postgres/data

Creating Postgres database system directory /home/postgres/data/base

    

To test the new location, create a database test by typing

% createdb -D PGDATA2 test
% destroydb test
    

新規領域のテストにはデータベース test を次のように入力して 作成します。

% createdb -D PGDATA2 test
% destroydb test