ページ更新: 2005-11-13 (日) (4875日前)

2005-11-13

作成中

setup.exeをダウンロード

defaultのパッケージを入れる

システム環境変数CYGWINを定義、PATHにc:\cygwin\binを追加

cygrunsrvパッケージを入れる

postgresql-8.1.0-1を入れる。Exprに切り替え、All->Databaseでpostgresql 8.1.0-1を選ぶ、他のパッケージはkeepに戻す、インストールする。

パッケージのリスト

$ cygcheck -cd
Cygwin Package Information
Package              Version
_update-info-dir     00327-1
alternatives         1.3.20a-1
ash                  20040127-3
base-files           3.6-1
base-passwd          2.2-1
bash                 3.0-11
bzip2                1.0.3-1
coreutils            5.3.0-9
crypt                1.1-1
cygrunsrv            1.10-1
cygutils             1.2.9-1
cygwin               1.5.18-1
cygwin-doc           1.4-3
diffutils            2.8.7-1
editrights           1.01-1
findutils            4.2.25-2
gawk                 3.1.5-1
gdbm                 1.8.3-7
grep                 2.5.1a-2
groff                1.18.1-2
gzip                 1.3.5-1
less                 381-1
libbz2_1             1.0.3-1
libcharset1          1.9.2-1
libgdbm              1.8.0-5
libgdbm-devel        1.8.3-7
libgdbm3             1.8.3-3
libgdbm4             1.8.3-7
libiconv             1.9.2-1
libiconv2            1.9.2-1
libintl              0.10.38-3
libintl1             0.10.40-1
libintl2             0.12.1-3
libintl3             0.14.1-1
libncurses5          5.2-1
libncurses6          5.2-8
libncurses7          5.3-4
libncurses8          5.4-4
libpcre0             6.3-1
libpopt0             1.6.4-4
libreadline4         4.1-2
libreadline5         4.3-5
libreadline6         5.0-4
login                1.9-7
man                  1.5p-1
mktemp               1.5-3
ncurses              5.4-4
openssl              0.9.8a-1
openssl097           0.9.7i-1
postgresql           8.1.0-1
run                  1.1.6-1
sed                  4.1.4-1
tar                  1.15.1-2
termcap              20050421-1
terminfo             5.4_20041009-1
texinfo              4.8-1
which                1.7-1
zlib                 1.2.3-1

cygserver-configを実行

cygserverを起動

initdbを実行

$ /usr/sbin/initdb --no-locale -D ~/pgsql
   2394 [main] initdb 1216 fork_copy: linked dll data/bss pass 0 failed, 0x50D00
0..0x50D020, done 0, windows pid 1204, Win32 error 487
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/sbin/initdb".
Check your installation.

/usr/sbin/postgres が見つけられない? 調べてみる:

$ ls /usr/sbin/postgres*
/usr/sbin/postgres.exe

$ ls /usr/sbin/initdb*
/usr/sbin/initdb.exe

もう一回試すと、動いた。

$ rm ~/pgsql
$ /usr/sbin/initdb --no-locale -D ~/pgsql
The files belonging to this database system will be owned by user "username".
This user must also own the server process.

The database cluster will be initialized with locale C.

creating directory /home/username/pgsql ... ok
creating directory /home/username/pgsql/global ... ok
creating directory /home/username/pgsql/pg_xlog ... ok
creating directory /home/username/pgsql/pg_xlog/archive_status ... ok
creating directory /home/username/pgsql/pg_clog ... ok
creating directory /home/username/pgsql/pg_subtrans ... ok
creating directory /home/username/pgsql/pg_twophase ... ok
creating directory /home/username/pgsql/pg_multixact/members ... ok
creating directory /home/username/pgsql/pg_multixact/offsets ... ok
creating directory /home/username/pgsql/base ... ok
creating directory /home/username/pgsql/base/1 ... ok
creating directory /home/username/pgsql/pg_tblspc ... ok
selecting default max_connections ... 40
selecting default shared_buffers ... 1000
creating configuration files ... ok
creating template1 database in /home/username/pgsql/base/1 ... ok
initializing pg_authid ... ok
enabling unlimited row size for system tables ... ok
initializing dependencies ... ok
creating system views ... ok
loading pg_description ... ok
creating conversions ... 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:

    /usr/sbin/postmaster -D /home/username/pgsql
or
    /usr/sbin/pg_ctl -D /home/username/pgsql -l logfile start

起動する

$ /usr/sbin/pg_ctl -D ~/pgsql -l ~/pgsql.log start
postmaster starting

$ cat ~/pgsql.log
LOG:  database system was shut down at 2005-11-13 03:33:52
LOG:  checkpoint record is at 0/38D6D8
LOG:  redo record is at 0/38D6D8; undo record is at 0/0; shutdown TRUE
LOG:  next transaction ID: 565; next OID: 10794
LOG:  next MultiXactId: 1; next MultiXactOffset: 0
LOG:  database system is ready
LOG:  transaction ID wrap limit is 2147484146, limited by database "postgres"

接続してみる

$ psql template1
Welcome to psql 8.1.0, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

template1=# select version();
                                                      version

--------------------------------------------------------------------------------
-----------------------------------
 PostgreSQL 8.1.0 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.4.4 (cygming sp
ecial) (gdc 0.12, using dmd 0.125)
(1 row)

template1=# \q