CentOS6 - postgresqlのインストール

PostgreSQLをインストールする。

確認環境
  • CentOS6.2

確認手順

(1) インストール
# yum install postgresql-server

(2) 初期設定
# service postgresql initdb

(3) 起動
# service postgresql start

(4) 自動起動設定
# chkconfig postgresql on

(5) 起動の確認
# su - postgres
-bash-4.1$ psql
psql (8.4.9)
"help" でヘルプを表示します.

postgres=# \q
-bash-4.1$ exit
#

(2012.2.26追記. 外部アクセスできるように)

(6) パスワードの設定
# su - postgres
-bash-4.1$ psql
psql (8.4.9)
"help" でヘルプを表示します.

postgres=# alter user postgres with encrypted password 'test';
ALTER ROLE
postgres=# \q
-bash-4.1$ exit
#

(7) /var/lib/pgsql/data/pg_hba.confに下記行を追記※IPアドレスは環境に合わせること
host    all         all         192.168.11.0/24       md5

(8) /var/lib/pgsql/data/postgresql.confの59行目を編集

(編集前)
#listen_addresses = 'localhost'          # what IP address(es) to listen on;
(編集後)
listen_addresses = '*'          # what IP address(es) to listen on;

(9) ファイウウォールの設定

別途、ファイルウォールの設定として、tcp/5432を開けておく(詳細割愛)

(10) postgresqlを再起動
# service postgresql restart

(11) 接続確認 ※postgresqlの動作サーバーのIPが192.168.11.6の場合の例
# su - postgres
-bash-4.1$ psql -h 192.168.11.6 -U postgres
ユーザ postgres のパスワード: 
psql (8.4.9)
"help" でヘルプを表示します.

postgres=# \q
-bash-4.1$

備考

参照サイト


以上


コメント