仮想化ソフトウェア - FreeBSD - jail - PostgreSQL 設定時の注意

 クラウディア
1. 概要
2. 設定

1. 概要

 前ページで、「sshd」を設定し、「ssh」ログインして、ほぼ順調に作業していたのですが、「PostgreSQL」を設定時にはまってしまった。  元々、「jail」をまた使おうとしたのは、メインのマシンの「PostgreSQL」の内容が少し壊れて、別途「PostgreSQL」を立ち上げて、内容だけ修復して戻そうとしたのです。  サブで使っているマシンも調子が悪くて止めているため、仕方なく、「jail」の環境に作ろうとしたのですが・・・  「initdb」でつまづいた。

$ service postgresql initdb
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 "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /var/db/postgres/data96 ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers ... 400kB
selecting default timezone ... Asia/Tokyo
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... FATAL:  could not create shared memory segment: Function not implemented
DETAIL:  Failed system call was shmget(key=5432001, size=48, 03600).
child process exited with exit code 1
initdb: removing data directory "/var/db/postgres/data96"
 てなことになっておる。  検索して、うまいこと当たりました。  本ページは、下記のサイトを参考にさせていただきました。
元スペース・アイ 代表 ブログ » JAIL 内で PostgreSQL を動かす
 当初、上の方でうまくいくかと思いきや、下でないとうまく動きませんでした。

2. 設定

 参考サイト(下のサイト)のままにやってみます。  ホストの操作です。  「root」ユーザ権限で。

vi /etc/sysctl.conf
 1行加えます。

security.jail.sysvipc_allowed=1

vi /etc/rc.conf
 1行加えます。

jail_sql_parameters="allow.sysvipc=1"
 サービスを再起動(「jail」内で「reboot」コマンドはききませんでした)。

service jail restart
 直後に

jail -m jid=1 allow.sysvipc=1
 「jid=1」は、「jail」の環境がひとつしかないからで、「ID」は増えていくんじゃろか?  これでやっと「initdb」が通りました。

# service postgresql initdb
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 "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /var/db/postgres/data96 ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Asia/Tokyo
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/bin/pg_ctl -D /var/db/postgres/data96 -l logfile start

 参考サイトによれば、「FreeBSD jail を使っている場合に、子ホスト環境で PostgreSQL を動かす難易度が高いのは、比較的有名な話である」ですって。  しまったなぁ。
ハイスピードプラン