FreeBSD 10.4 RELEASE - postgreSQL - 初期設定

クラウディア 
1. ports
2. /etc/rc.conf 編集
3. データベースの初期化と起動

1. ports

 「postgreSQL 10.0」が「ports」に存在しますので、「10.0」をインストールしてみることにします。

/usr/ports/databases/postgresql10-client/
/usr/ports/databases/postgresql10-server/
 サーバ、クライアント間には依存関係が存在しますので、サーバをインストールすれば、クライアントも自動的にインストールされます。

2. /etc/rc.conf 編集

 postgresSQL が起動できるように /etc/rc.conf を編集します。  以下の1行を追加します。

postgresql_enable="YES"

3. データベースの初期化と起動

 バージョン 10.0 では、起動スクリプトに関して、オプションが 4、パラメータが 8 用意されています。主なパラメータについて説明しておきます。

/usr/local/etc/rc.d/postgresql start      起動
/usr/local/etc/rc.d/postgresql stop       停止
/usr/local/etc/rc.d/postgresql restart    再起動
/usr/local/etc/rc.d/postgresql initdb     初期化
/usr/local/etc/rc.d/postgresql status     ステータスの確認
 まず、最初に、データベースの初期化と起動を行います。


	初期化

> /usr/local/etc/rc.d/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/data10 ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
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/data10 -l logfile start

	起動

> /usr/local/etc/rc.d/postgresql start
2017-10-16 09:50:43.208 JST [47621] LOG:  listening on IPv6 address "::1", port 5432
2017-10-16 09:50:43.209 JST [47621] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2017-10-16 09:50:43.210 JST [47621] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2017-10-16 09:50:43.215 JST [47621] LOG:  ending log output to stderr
2017-10-16 09:50:43.215 JST [47621] HINT:  Future log output will go to log destination "syslog".