データベースの代替領域

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 the location it points to must be writable by the postgres administrator account. Consult with the site administrator regarding preconfigured alternate database locations. Any valid environment variable name may be used to reference an alternate location, although using variable names 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. Although the environment variable style of specification is to be preferred since it allows the site administrator more flexibility in managing disk storage, it is also possible to use an absolute path to specify an alternate location. The administrator's guide discusses how to enable this feature.

前バージョンの Postgres では代替記憶領域 を指定する絶対パス名も同様許されていました。 サイト管理者がより柔軟にディスク管理を行えることから、環境変数 での設定が好まれるとはいっても、代替領域の指定に絶対パスを使う ことが出来ます。 管理者ガイドにはこの機能を使う方法についての記載があります。

For security and integrity reasons, any path or environment variable specified has some additional path fields appended. Alternate database locations must be prepared by running initlocation.

セキュリティと完全性の理由から、指定されたパスや環境変数には 付加的なパスフィールドが加えられます。 代替のデータベース領域は initlocation を走らせることで準備されなければなりません。

To create a data storage area using the environment variable PGDATA2 (for this example set to /alt/postgres), ensure that /alt/postgres already exists and is writable by the Postgres administrator account. Then, from the command line, type

% initlocation $PGDATA2
Creating Postgres database system directory /alt/postgres/data
Creating Postgres database system directory /alt/postgres/data/base
    

(この例のように /alt/postgres に)データ記憶領域 を環境変数 PGDATA2 をつかって作成するには、 /alt/postgres が既に存在しているかどうか、 また Postgres 管理者アカウントで書き込み可能かを確認して下さい。 確認が出来たら、コマンドラインから以下を入力します。

% initlocation $PGDATA2
Creating Postgres database system directory /alt/postgres/data
Creating Postgres database system directory /alt/postgres/data/base
    

To create a database in the alternate storage area PGDATA2 from the command line, use the following command:

% createdb -D PGDATA2 mydb
    
and to do the same from within psql type
* CREATE DATABASE mydb WITH LOCATION = 'PGDATA2';
    

代替記憶領域 PGDATA2 にデータベースを作成するには コマンドラインから以下のコマンドを入力します。

% createdb -D PGDATA2 mydb
    
そして同じ事を psql から行うには
* CREATE DATABASE mydb WITH LOCATION = 'PGDATA2';
    
のように入力します。

If you do not have the privileges required to create a database, you will see the following:

% createdb mydb
WARN:user "your username" is not allowed to create/destroy databases
createdb: database creation failed on mydb.
    

データベースを作成する権限がなかった場合は以下のメッセージが出ます。

% createdb mydb
WARN:user "your username" is not allowed to create/destroy databases
createdb: database creation failed on mydb.
    

If the specified location does not exist or the database backend does not have permission to access it or to write to directories under it, you will see the following:

% createdb -D /alt/postgres/data mydb
ERROR:  Unable to create database directory /alt/postgres/data/base/mydb
createdb: database creation failed on mydb.
    

指定した場所が存在しないとか、データベースバックエンドが そこへアクセスするあるいはその下のディレクトリに書き込む権限がない 場合には次ぎのようなメッセージがでます。

% createdb -D /alt/postgres/data mydb
ERROR:  Unable to create database directory /alt/postgres/data/base/mydb
createdb: database creation failed on mydb.