いやいやmysqlよりもこっちがいいぜぃって方に

9.0系が出ました。
8.x系とはもちろん互換性が無いので、8.2→8.3でやった方法でデータの救済をする必要が
あります。

HP: http://www.postgresql.org/
日本HP: http://www.postgresql.jp/

8.xから9.xへアップグレードする際の注意

アップグレードをする前にデータベースをバックアップしましょう。
バックアップ後にインストールして、initdbをしなおさないと
エラーがでて起動しません。
initdbし終えたらバックアップしたsqlをpsql < hoge.sqlで流し込んで
アップグレード完了です。

sudo -u postgres /usr/local/pgsql/bin/pg_dumpall -c -d -D > /var/tmp/8.2.x.sql
/etc/init.d/postgresql stop
mv /usr/local/pgsql/data /usr/local/pgsql/data.bak
(後述のインストールを実施)
sudo -u postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

ここで8.3.x用のデータベース構築がおわります。
8.2.x系のpostgresql.conf等のコンフィグファイルはコピーよりも差分を手動で
やったほうが良いかもしれません。

/etc/init.d/postgresql start
sudo -u postgres /usr/local/pgsql/bin/psql < /var/tmp/8.2.x.sql

インストール

useradd -d /usr/local/pgsql postgres
cd /usr/local/src
wget ftp://ftp2.jp.postgresql.org/pub/postgresql/source/v9.1.0/postgresql-9.1.0.tar.gz
tar zxvf postgresql-9.1.0.tar.gz
cd postgresql-9.1.0
./configure --with-perl --with-pam --with-openssl
make
make install
chown -R postgres. /usr/local/pgsql
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
#initdbのエラーが出る場合はsu postgresでユーザー変更(編集:nn-- 2009/12/09)
cp contrib/start-scripts/linux /etc/init.d/postgresql
chmod 755 /etc/init.d/postgresql
chkconfig --add postgresql

接続できるユーザの設定

/usr/local/pgsql/data/pg_hba.conf

追加(SSL接続を使用しなければならない)
hostssl all all 127.0.0.1/32 trust
hostssl all all 192.168.xx.xx/32 trust

Postgresqlの設定

/usr/local/pgsql/data/postgresql.conf

#listen_address = 'localhost'

listen_address = '*'

#port = 5432

port = 5432

#max_connections = 100

max_connections = 100

#ssl = on

ssl=on

#password_encryption = on

password_encryption = on

#log_destination = 'stderr'

log_destination = 'stderr'

#redirect_stderr = off

redirect_stderr = on

#log_directory = 'pg_log'

log_directory = 'logs'

#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'

log_filename = 'postgresql.log'
(なぜかpostgresqlxxxxxxxx.log xxxは数字 になってしまう)

#log_truncate_on_rotation = off

log_truncate_on_rotation = off

#log_rotation_age = 1440

log_rotation_age = 0

log_rotation_size = 10240

log_rotation_size = 0

#log_connections = off
#log_disconnections = off
#log_duration = off

log_connections = on
log_disconnections = on
log_duration = on

#log_statement = 'none'

log_statement = 'all'

とりあえずログは全部取得・ローテーションはスクリプトで行うという設定です。
後は起動して接続が出来ればOKです。

/etc/init.d/postgresql start
su - postgres
psql
postgres=# \q

最近あんまりpostgresql触って無いなぁ。

タグ

コメントを追加

制限付き HTML

  • 使用できるHTMLタグ: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 行と段落は自動的に折り返されます。
  • ウェブページのアドレスとメールアドレスは自動的にリンクに変換されます。
CAPTCHA
半角で
この質問はあなたが人間の訪問者であるかどうかをテストし、自動化されたスパム送信を防ぐためのものです。
ももーい に投稿