PostgreSQL のインストール                      t-gototop.jpg (5772 バイト)

生logの状態です.これから整理します.

(1)PostgreSQL管理ユーザ用アカウントの作成

 

(1)PostgreSQL管理ユーザ用アカウントの作成

[papa@svr0 papa]$ su -
Password:
[root@svr0 /root]#
groupadd postgres
[root@svr0 /root]#
adduser postgres -g postgres -d /home/postgres -s /bin/bash
[root@svr0 /root]#
passwd postgres
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully

    (1)スーパユーザで作業します.
  
(2)グループ"postgres"を追加します.
    (3)ユーザ"postgres"を追加します.(パスワードを設定します)
[papa@svr0 papa]$ su -
Password:
[root@svr0 /root]#
groupadd postgres
[root@svr0 /root]#
adduser postgres -g postgres -d /home/postgres -s /bin/bash
[root@svr0 /root]#
passwd postgres
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully


適当なディレクトリ(ここでは,/usr/local/src/tmp)にソースを展開します
    (1)/usr/local/src/tmpを作成します.
  
(2)ソース(ここでは,"postgresql-6.4.2-patched.tar.gz"です)
    (3)ユーザ"postgres"を追加します.(パスワードを設定します)
[root@svr0 /root]# cd /usr/local/src
[root@svr0 src]# mkdir tmp
[root@svr0 src]# cd tmp
[root@svr0 tmp]# ls -l

total 5531

-r--r--r--   1 postgres postgres       69 Nov  3 13:59 TRANS.TBL

-rw-r--r--   1 postgres postgres  5638843 Nov  3 14:00 postgresql-6.4.2-patched.

tar.gz

[root@svr0 src]# chown postgres.postgres tmp
[root@svr0 src]# ls -l
total 1
drwxr-xr-x   2 postgres postgres     1024 Nov 20 15:55 tmp/
[root@svr0 src]# cd tmp
[root@svr0 tmp]# ls -l
total 5531
-r--r--r--   1 postgres postgres       69 Nov  3 13:59 TRANS.TBL
-rw-r--r--   1 postgres postgres  5638843 Nov  3 14:00 postgresql-6.4.2-patched.
tar.gz
[root@svr0 tmp]# mkdir /usr/local/pgsql
[root@svr0 tmp]# chown postgres.postgres /usr/local/pgsql
[root@svr0 tmp]# su - postgres
[postgres@svr0 postgres]$ vi .bash_profile
[postgres@svr0 postgres]$ source .bash_profile
[postgres@svr0 postgres]$ env
LESSOPEN=|lesspipe.sh %s
USERNAME=
        |
POSTGRES_HOME=/usr/local/pgsql
PGLIB=/usr/local/pgsql/lib
USER=postgres
PGDATA=/usr/local/pgsql/data
MANPATH=:/usr/local/pgsql/man
[postgres@svr0 postgres]$ cd /usr/local/src/tmp
[postgres@svr0 tmp]$ ls -l
total 5531
-r--r--r--   1 postgres postgres       69 Nov  3 13:59 TRANS.TBL
-rw-r--r--   1 postgres postgres  5638843 Nov  3 14:00 postgresql-6.4.2-patched.tar.gz
[postgres@svr0 tmp]$ tar xfz postgresql-6.4.2-patched.tar.gz
[postgres@svr0 tmp]$ ls -l
total 5532
-r--r--r--   1 postgres postgres       69 Nov  3 13:59 TRANS.TBL
drwxr-xr-x   6 postgres postgres     1024 Jan  4  1999 postgresql-6.4.2/
-rw-r--r--   1 postgres postgres  5638843 Nov  3 14:00 postgresql-6.4.2-patched.tar.gz[postgres@svr0 tmp]$ ls -l postgresql-6.4.2
total 133
-rw-r--r--   1 postgres postgres     1111 May 11  1997 COPYRIGHT
drwxr-xr-x   2 postgres postgres     1024 Jan  4  1999 CVS/
-rw-r--r--   1 postgres postgres    52509 Jan  4  1999 HISTORY
-rw-r--r--   1 postgres postgres    71071 Dec 29  1998 INSTALL
-rw-r--r--   1 postgres postgres     1921 Dec 29  1998 README
drwxr-xr-x  23 postgres postgres     1024 Dec 31  1998 contrib/
drwxr-xr-x   4 postgres postgres     1024 Mar  8  1999 doc/
-rw-r--r--   1 postgres postgres      684 Dec 29  1998 register.txt
drwxr-xr-x  17 postgres postgres     1024 Mar  8  1999 src/
[postgres@svr0 tmp]$ cd postgresql-6.4.2/src
[postgres@svr0 src]$ ./configure --with-mb=EUC_JP
creating cache ./config.cache
checking host system type... i586-pc-linux-gnu
                        |
linking ./template to interfaces/odbc/template
linking ./include/config.h to interfaces/odbc/config.h
[postgres@svr0 src]$ make all
make lexverify
make[1]: Entering directory `/usr/local/src/tmp/postgresql-6.4.2/src'
                        |
make[1]: Leaving directory `/usr/local/src/tmp/postgresql-6.4.2/src/pl'
cat ../register.txt
(1998-12-29)
PostgreSQL has a Web site at http://www.postgresql.org/ which carries details
on the latest release, upcoming features, and other information to make your
work or play with PostgreSQL more productive.
Please check the following URL for a listing of the current user-support
mailing lists:
        http://www.postgresql.org/supp-mlists.shtml
All of the mailing lists are currently archived and viewable at:
        http://www.postgresql.org/mhonarc
 And, so that we have an idea of who is using what, please connect to the
following registration URL:
        http://www.postgresql.org/register.shtml
Thank you for choosing PostgreSQL, the most advanced open source database engine
[postgres@svr0 src]$ cd ../doc
[postgres@svr0 doc]$ cd ../src
[postgres@svr0 src]$ make install-man
make -C man install
                        |
cp *.l* /usr/local/pgsql/man/manl
make[1]: Leaving directory `/usr/local/src/tmp/postgresql-6.4.2/src/man'
[postgres@svr0 pgsql]$ initdb
We are initializing the database system with username postgres (uid=902).
This user will own all the files and must also own the server process.
Creating Postgres database system directory /usr/local/pgsql/data
Creating Postgres database system directory /usr/local/pgsql/data/base
Creating template database in /usr/local/pgsql/data/base/template1
Creating global classes in /usr/local/pgsql/data/base
Adding template1 database to pg_database...
Vacuuming template1
Creating public pg_user view
Creating view pg_rules
Creating view pg_views
Creating view pg_tables
Creating view pg_indexes
Loading pg_description
[postgres@svr0 pgsql]$ cd /usr/local/pgsql
[postgres@svr0 pgsql]$ cd /usr/local/pgsql/data
[postgres@svr0 data]$ ls -ltotal 44
-rw-------   1 postgres postgres        4 Nov 20 17:14 PG_VERSION
drwx------   3 postgres postgres     1024 Nov 20 17:14 base
-rw-------   1 postgres postgres     8192 Nov 20 17:14 pg_database
-r--------   1 postgres postgres     2838 Nov 20 17:14 pg_geqo.sample
-rw-------   1 postgres postgres        0 Nov 20 17:14 pg_group
-r--------   1 postgres postgres     5192 Nov 20 17:14 pg_hba.conf
-rw-------   1 postgres postgres     8192 Nov 20 17:14 pg_log
-rw-rw-rw-   1 postgres postgres       53 Nov 20 17:14 pg_pwd
-rw-------   1 postgres postgres     8192 Nov 20 17:14 pg_shadow
-rw-------   1 postgres postgres     8192 Nov 20 17:14 pg_variable
[postgres@svr0 data]$ chmod 600 pg_hba.conf
[postgres@svr0 data]$ vi pg_hba.conf
#host         all        0.0.0.0       0.0.0.0           trust
                                     
host         all        0.0.0.0       0.0.0.0           trust

 

1.2 自動起動

[postgres@svr0 data]$ su -
Password:
[root@svr0 tmp]# cd /etc
[root@svr0 /etc]# cd rc.d
[root@svr0 rc.d]# ls -l
total 21
drwxr-xr-x   2 root     root         1024 Nov  3 13:45 init.d
-rwxr-xr-x   1 root     root         1871 Oct 16  1998 rc
-rwxr-xr-x   1 root     root          693 Oct 16  1998 rc.local
-r-xr-x---   1 news     news         2082 Sep 10  1998 rc.news
-rwxr-xr-x   1 root     root         7165 Oct 16  1998 rc.sysinit
drwxr-xr-x   2 root     root         1024 Jul 11 01:26 rc0.d
drwxr-xr-x   2 root     root         1024 Jul 11 01:26 rc1.d
drwxr-xr-x   2 root     root         1024 Jul 11 01:26 rc2.d
drwxr-xr-x   2 root     root         1024 Nov  3 13:45 rc3.d
drwxr-xr-x   2 root     root         1024 Nov  3 13:45 rc4.d
drwxr-xr-x   2 root     root         1024 Nov  3 13:45 rc5.d
drwxr-xr-x   2 root     root         1024 Jul 11 01:26 rc6.d
[root@svr0 rc.d]# vi rc.local
#!/bin/sh
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
if [ -f /etc/redhat-release ]; then
    arch=$(uname -m)
    a="a"
            _i*) a="an";;
    # This will overwrite /etc/issue at every boot.  So, make any changes you
    # want to make to /etc/issue here or you will lose them when you reboot.
    echo "" > /etc/issue
    echo "$R" >> /etc/issue
#!/bin/sh

# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

if [ -f /etc/redhat-release ]; then
    R=$(cat /etc/redhat-release)
    arch=$(uname -m)
    a="a"
            _i*) a="an";;
    esac
    # This will overwrite /etc/issue at every boot.  So, make any changes you
    # want to make to /etc/issue here or you will lose them when you reboot.
    echo "" > /etc/issue
    echo "$R" >> /etc/issue
    echo "Kernel $(uname -r) on $a $(uname -m)" >> /etc/issue
 
    cp -f /etc/issue /etc/issue.net
rm /tmp/.s.PGSQL.*
su - postgres -c "/usr/local/pgsql/bin/postmaster -S -i"

[root@svr0 rc.d]# reboot  -i
Broadcast message from root (ttyp0) Sat Nov 20 17:21:41 1999...
The system is going down for reboot NOW !!

  [root@svr0 /root]# ps  ax
  PID TTY STAT TIME COMMAND
   
1  ?  S    0:03 init
   
2  ?  SW   0:00 (kflushd)
                       
|
 
436  ?  S    0:00 /usr/local/pgsql/bin/postmaster -S -i