PostgreSQLアカウント

  • # su - postgres
          ※PostgreSQL用のアカウントを事前に作成しておく必要があります。

PostgreSQLのソースを取得(NPO法人 日本PostgreSQLユーザ会)

  • $ cd SOURCE_DIR
  • $ wget ftp://ftp.sra.co.jp/pub/cmd/postgres/8.3.0/postgresql-8.3.0.tar.gz

ソースの展開

  • $ tar -xvzf  postgresql-8.3.0.tar.gz

コンパイル

  • $ ./configure --prefix=/var/lib/pgsql \
    --without-docdir
  • $ make check

インストール

  • $ make install

PostgreSQLアカウントの環境設定

  • $ vi /var/lib/pgsql/.bash_profile [追記]

    # User specific aliases and functions
    export POSTGRES_HOME=/var/lib/pgsql
    export PGLIB=$POSTGRES_HOME/lib
    export PGDATA=$POSTGRES_HOME/data
    export MANPATH=$MANPATH:$POSTGRES_HOME/man
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PGLIB
  • $ source /var/lib/pgsql/.bash_profile

PostgreSQLデータベースクラスタの作成

  • $ initdb --no-locale
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.

    The database cluster will be initialized with locale C.
    The default database encoding has accordingly been set to SQL_ASCII.
    The default text search configuration will be set to "english".

    creating directory /var/lib/pgsql/data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers/max_fsm_pages ... 24MB/153600
    creating configuration files ... ok
    creating template1 database in /var/lib/pgsql/data/base/1 ... ok
    initializing pg_authid ... ok
    initializing dependencies ... ok
    creating system views ... ok
    loading system objects' descriptions ... ok
    creating conversions ... ok
    creating dictionaries ... ok
    setting privileges on built-in objects ... ok
    creating information schema ... ok
    vacuuming database template1 ... ok
    copying template1 to template0 ... ok
    copying template1 to postgres ... ok

    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the -A option the
    next time you run initdb.

    Success. You can now start the database server using:

        postgres -D /var/lib/pgsql/data
    or
        pg_ctl -D /var/lib/pgsql/data -l logfile start

起動スクリプトの設置

  • $ exit
  • # cd SOURCE_DIR/postgresql-8.3.0/contrib/start-scripts
  • # sed -i 's/\/usr\/local\/pgsql/\/var\/lib\/pgsql/g' linux
  • # cp linux /etc/init.d/postgres
  • # chmod 700 /etc/init.d/postgres

PostgreSQlの起動

  • # /etc/init.d/postgres start
    Starting PostgreSQL: ok

PostgreSQLの接続チェック

  • # su - postgres
  • $ psql -l