PostgreSQL8のインストール
CentOS5にpostgresql-8.2.5をソースからインストールしたときのメモ
- インストール前の準備作業
- Postgresql専用ユーザ
postgresの登録:# useradd postgres # passwd postgres
- Postgresql用ディレクトリの作成:
# mkdir /usr/local/pgsql/ # chown postgres:postgres /usr/local/pgsql/
-
postgresql-8.2.5.tar.gzを ダウンロード し、/usr/local/src/に置く。:# chown postgres:postgres /usr/local/src/ ← インストール作業終了後は、rootに戻しておくこと!! # chown postgres:postgres /usr/local/src/postgresql-8.2.5.tar.gz
- Postgresql専用ユーザ
- readlineとzlibのインストール:
# yum install readline-devel # yum install zlib-devel
- インストール:
# cd /usr/local/src/ # su postgres $ tar zxf postgresql-8.2.5.tar.gz $ cd postgresql-8.2.5 $ ./configure $ gmake $ gmake check All 103 tests passed. $ su root # gmake install PostgreSQL installation complete.
- PostgreSQLの環境設定
- コマンドサーチパスの設定:
# su - postgres $ vi /home/postgres/.bash_profile 以下の内容を追記する。 PGHOME=/usr/local/pgsql PGDATA=/usr/local/pgsql/data PGLIB=/usr/local/pgsql/lib PATH=$PATH:$HOME/bin:$PGHOME/bin export PGHOME PGDATA PGLIB PATH $ source /home/postgres/.bash_profile - PostgreSQLのライブラリパスの設定:
$ su - root # vi /etc/ld.so.conf 次の一行を追記する。 /usr/local/pgsql/lib # /sbin/ldconfig <-- 共有ライブラリをシステムに登録
- コマンドサーチパスの設定:
- データベースの初期設定:
# su - postgres $ initdb --encoding=UTF8 --no-locale
- PostgreSQL認証/設定ファイルの設定(LAN内からのアクセスは全てOKとする設定)
-
pg_hba.confファイルの編集:# su - postgres $ vi /usr/local/pgsql/data/pg_hba.conf 次のように編集する。 | 途中省略 | # TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust host all all 192.168.0.0/24 trust ← この一行を追加する。 # IPv6 local connections: host all all ::1/128 trust
-
postgresql.confファイルの編集:$ vi /usr/local/pgsql/data/postgresql.conf 次のように編集する。 | 途中省略 | #--------------------------------------------------------------------------- # CONNECTIONS AND AUTHENTICATION #--------------------------------------------------------------------------- # - Connection Settings - #listen_addresses = 'localhost' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost', '*' = all # Papasan added. listen_addresses = '*' ← この一行を追加する。 #port = 5432 max_connections = 100 | 以下省略 |
-
- PostgreSQLの自動起動
マシン起動時にPostgreSQLも起動するようにします。:
$ su - root # cd /usr/local/src/postgresql-8.2.5/contrib/start-scripts/ # cp linux /etc/rc.d/init.d/postgresql # cd /etc/rc.d/init.d/ # chmod 755 postgresql # chkconfig --add postgresql # shutdown -r now
- 以上でPostgreSQL8のインストールができましたので、あとは用途に応じたデータベースやテーブルを作成することになります。