Personal tools
You are here: Home サーバー Pingサーバー PostgreSQL8のインストール
Navigation

今の天気
  14℃ 41% 1024hPa NNW 3m
福岡地方の今の天気
« November 2008 »
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
最近のログイン

Papasan
2008/11/22 11:45

Guest
2008/11/12 15:50

seko
2008/11/11 20:05

Reiko
2008/11/02 16:58

hage88
2008/10/19 17:39

Peter
2008/10/06 21:22

猫さん。
2008/10/06 04:19

 
Document Actions

PostgreSQL8のインストール

by Papasan last modified 2008-11-19 16:37

CentOS5にpostgresql-8.2.5をソースからインストールしたときのメモ

  • インストール前の準備作業
    1. Postgresql専用ユーザpostgresの登録:
        # useradd postgres
        # passwd postgres
      
    2. Postgresql用ディレクトリの作成:
        # mkdir /usr/local/pgsql/
        # chown postgres:postgres /usr/local/pgsql/
      
    3. 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
      
  • 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の環境設定
    1. コマンドサーチパスの設定:
          # 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
      
    2. PostgreSQLのライブラリパスの設定:
          $ su - root
          # vi /etc/ld.so.conf
      
          次の一行を追記する。
           /usr/local/pgsql/lib
      
          # /sbin/ldconfig <-- 共有ライブラリをシステムに登録
      
  • データベースの初期設定:
     # su - postgres
     $ initdb --encoding=UTF8 --no-locale
    
  • PostgreSQL認証/設定ファイルの設定(LAN内からのアクセスは全てOKとする設定)
    1. 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
      
    2. 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のインストールができましたので、あとは用途に応じたデータベースやテーブルを作成することになります。