サーバー: Ubuntu サーバー 14 lts + PostgreSQL 9.2 drbd を使用してクラスター データベースを作成したいのですが、クラスターの初期化を行わないと PGDATA を設定できません。pgsqlがdrbdディスクからのデータを使用していると言うだけです。どうすればできますか?
例 1:
mkdir /cluster/var/lib/pgsql -p
chown postgres:postgres /cluster/var/lib/pgsql -R
cp -R /var/lib/pgsql /cluster/var/lib/pgsql
edit /etc/init.d/postgresql :
PGDATA=/cluster/var/lib/pgsql/data
...
PGLOG=/cluster/var/lib/pgsql/pgstartup.log
/etc/init.d/postgresql start
postgresql 8.3 では動作しますが、9.2 では /etc/init.d/postgresql の pgdata を変更できません。別のファイルを見つけて pgdata を設定する必要がありますが、驚いたことに何もしません。
例 2: PGDATA - データベース クラスタを格納するディレクトリを指定します。-D オプションを使用してオーバーライドできます。
では、始めましょう: --pgdata=directory ええ、うまくいきました! しかし、今ではpostgresql-xcがあり、「postgresql don't know this user - postgresql」のようなエラーがあります。drbd はクラスターからデータのレプリケートを開始しますが、postgresql もそれを開始します。
更新 1:
root: initdb --pgdata=/home/username/dir
~initdb not install~bla-bla-bla~use apt-get install postgres-xc
UPD2:
$: /usr/lib/postgresql/9.3/bin/initdb --pgdata=/whateveryouwant
#now you can run postgresql only one way:
$: /usr/lib/postgresql/9.3/bin/postgres -D /see_up
#then:
LOG: database system was shut down at 2014-09-26 15:56:33 YEKT
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
#aaaaaaaaaaand...nothing. just empty console, ^C stopping postgres
#another SSH connect:
$: ps-ela
S 1000 5995 5217 0 80 0 - 62202 poll_s pts/0 00:00:00 postgres
1 S 1000 5997 5995 0 80 0 - 62202 poll_s ? 00:00:00 postgres
1 S 1000 5998 5995 0 80 0 - 62202 poll_s ? 00:00:00 postgres
1 S 1000 5999 5995 0 80 0 - 62202 poll_s ? 00:00:00 postgres
1 S 1000 6000 5995 0 80 0 - 62415 poll_s ? 00:00:00 postgres
1 S 1000 6001 5995 0 80 0 - 26121 poll_s ? 00:00:00 postgres
#is it ok? because...
$: /etc/init.d/postgresql status
9.3/main (port 5432): down