Creating Postgres tablespaces
=============================

デプロイメント中にPostgresテーブルスペースを作成するには、それらの名前と場所を\ ``cluster_vars``
の下の\ ``postgres_tablespaces``
、またはconfig.ymlの特定のインスタンスの\ ``vars`` 定義します。

``volume_for: postgres_tablespace`` を設定し、 ``tablespace_name``
を定義して :ref:`define volumes <Filesystem configuration>` を実行すると、それらはデフォルトのエントリとして\ ``postgres_tablespaces``
に追加されます。

.. code:: yaml

   cluster_vars:
     postgres_tablespaces:
       explicit:
         location: /some/path

   instances:

   - Name: example
     …
     volumes:
     - device_name: /dev/xvdh
       …
       vars:
         volume_for: postgres_tablespace
         tablespace_name: implicit

上記の例では、2つのテーブルスペースが作成されます：明示的（/some/path）および暗黙的（ボリュームに別のマウントポイントを指定しない限り、デフォルトで/opt/postgres/tablespaces/implicit/tablespace_data）。

すべての\ ``postgres_tablespace`` ボリュームには\ ``tablespace_name``
が定義されている必要があります。表領域の場所は、ボリュームのマウントポイントから導出されます。

``postgres_tablespaces``
のすべてのエントリは、テーブルスペース名（キーとして）とその\ ``location``
を指定する必要があります。テーブルスペースの場所を明示的に指定する場合は、テーブルスペースをPGDATA内に置かないでください。また、ボリュームマウントポイントをテーブルスペースの場所として直接使用しないでください（\ ``lost+found``
は、一部のツールを混乱させて、ディレクトリが空でないと判断します）。

デフォルトでは、表領域\ ``owner`` は\ ``postgres``
ですが、任意の有効なユーザー名（ :ref:`postgres_users <The postgres Unix user>` のユーザー

この時点で作成されます）。

ストリーミングレプリカには、上流のインスタンスと同じ\ ``postgres_tablespace``
ボリュームと\ ``postgres_tablespaces`` 設定が必要です

 :ref:`postgres_databases <Creating Postgres databases>` でデータベースのデフォルトの表領域を設定できます。
