Cloud Nine

Avatar

About IT things and others.

2月
21
PostgresSQL9.1.2の設定 in CentOS5.7
2月 21, 2012 0

基本設定部分

$ vi /var/lib/pgsql/9.1/data/postgresql.conf
#listen_addresses = 'localhost'
↓
listen_addresses = '*'
#port = 5432
↓
port = 5432

ログの名前
log_filename = 'postgresql-%Y-%m-%d_%H%M.log'
ログのローテーション
log_rotation_age = 1d
ログのサイズ
log_rotation_size = 2MB
同名のファイルが存在する時は上書きする。ローテーション用。
log_truncate_on_rotation = on
ログのレベル
log_min_error_statement = error

ログの細かい内容はこちらを参照してください。
http://lets.postgresql.jp/documents/technical/log_setting

セキュリティ設定部分

$ vi /var/lib/pgsql/9.1/data/pg_hba.conf
ローカル接続の許可
local    all             all                      peer
外部からの接続の設定
host    all             all             123.123.123.123/32(接続元のIP)            password

2月
13
CentOS5.7にPostgresSQL9.1.2をyumでインストール
2月 13, 2012 0

Postgresのサイトからrpmを取得
http://yum.postgresql.org/reporpms/

インストール

$ wget http://yum.postgresql.org/9.1/redhat/rhel-5-i386/pgdg-centos91-9.1-4.noarch.rpm
$ rpm -ivh pgdg-centos91-9.1-4.noarch.rpm
$ vi /etc/yum.repos.d/CentOS-Base.repo
[base]の中に下記のコメントを追加
exclude=postgresql*
[update]の中に下記のコメントを追加
exclude=postgresql*
$ yum -y install postgresql-server
Installed:
  postgresql91-server.i386 0:9.1.2-1PGDG.rhel5
Dependency Installed:
  postgresql91.i386 0:9.1.2-1PGDG.rhel5                    postgresql91-libs.i386 0:9.1.2-1PGDG.rhel5

初期設定

$ chkconfig postgresql-9.1 on
DBの初期化
$ service postgresql-9.1 initdb
データベースを初期化中: mkdir: ディレクトリ `/var/lib/pgsql/9.1/data/pg_log' を作成できません: ファイルが存在します
$ rm -rf /var/lib/pgsql/9.1/data/pg_log/
$ service postgresql-9.1 initdb
データベースを初期化中:                                    [  OK  ]
$ service postgresql-9.1.2 start
postgresql-9.1 サービスを開始中:                           [  OK  ]
$ su - postgres
$ psql -V
psql (PostgreSQL) 9.1.2

設定関連

基本関係
$ vi /var/lib/pgsql/9.1/data/postgresql.conf
セキュリティ関係
$ vi /var/lib/pgsql/9.1/data/pg_hba.conf

4月
30
初心者用pg_dumpの方法
4月 30, 2008 0

pg_dumpは

pg_dump database_name > database_name.sql

を実行すればできると、あるが実際はいろいろと気をつけないことが、たくさんあるのでそのメモ

その一、ユーザの準備
postgresでDBを作成しているなら、postgresユーザがいります。

useradd -d /home/postgres/ postgres

このときに、ホームディレクトリーも作っておきます。

その二、ファイルの準備
先ほど上のつくったホームディレクトリーの中にdatabase_name.sqlのファイルを作っておきます。

touch database_name.sql

その三、bushが引けてない場合があるのでlocateでpg_dumpを調べてひいいておきましょう。

その四、いざ実行

[postgres@www postgres]$ pg_dump database_name.sql > database_name.sql

Real Time Analytics