PostgreSQL > データ保存先の変更

更新日 2013-03-14
広告
以下、Ubuntuで、apt-get installでPostgreSQLをインストールした場合を例に説明します。 データ保存先のディレクトリは、設定ファイル(/etc/postgresql/9.1/main/postgresql.conf)の data_directory パラメータで指定できます。
data_directory = '/some/data/directory'
data_directoryで指定したディレクトリの所有者、権限を設定します。
$ sudo chown postgres:postgres /some/data/directory
$ sudo chmod 700 /some/data/directory
ディレクトリを初期化します。
$ /usr/lib/postgresql/9.1/bin/initdb /some/data/directory
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to "english".

fixing permissions on existing directory pgdata ... ok
  :
これで再起動します。
$ sudo /etc/init.d/postgresql start
 * Starting PostgreSQL 9.1 database server
 * The PostgreSQL server failed to start. Please check the log output:
2013-03-06 14:52:57 JST FATAL:  could not load server certificate file "server.crt": No such file or directory
このエラーを手っ取り早く回避するためには、設定ファイル(/etc/postgresql/9.1/main/postgresql.conf)の ssl パラメータをコメントアウトすればよいです。
#ssl = true
SSLでアクセスする必要があるなら、証明書を用意する必要があります。 元々のデータ保存ディレクトリにある証明書をコピーしてもよいです。
広告
お問い合わせは sweng.tips@gmail.com まで。
inserted by FC2 system