ページ更新: 2005-11-12 (土) (5634日前)
2005-11-12 2005-11-11に出たpostgresql-8.0.4-1パッケージを試してみたので、メモ。 目次 [編集]環境 #OSはWindows 2000 SP4 (on VMware)。OSとAnti-Virus (AVG Free)をインストールした直後の環境を使った。 [編集]Cygwinとpostgresqlパッケージのインストール #http://cygwin.comからsetup.exeをc:\setup\cygwin\にダウンロード。 setup.exeを起動、すべて「Default」でインストール。 システム環境変数PATHにc:\cygwin\binを追加。(これをやらないと、initdbを実行すると延々デバッグメッセージが表示される。) Cygwinのbashを起動。ユーザの初期設定が行われるので終了を待って、いったん閉じる。 再度Cygwinのbashを起動、パッケージのチェック(cygcheck -c)を実行。 再度setup.exeを起動、今度はpostgresql 8.0.4を選択し、インストール。 インストールされたパッケージの一覧: $ 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 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.0.4-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 postgresqlパッケージのREADMEを読んでおく。7.X.Xとは手順が一部異なるようだ。説明もそこそこ多くなった。 $ less /usr/share/doc/Cygwin/postgresql-8.0.4.README postgresql-8.0.4 ------------------------------------------ PostgreSQL is an advanced Object-Relational database management system (DBMS) that supports almost all SQL constructs (including transactions, subselects and user-defined types and functions). Admin binaries are now in /usr/sbin/ Contrib binaries in /usr/lib/postgreql/bin cygrunsrv is not required anymore, pg_ctl has now the service functions included. cygserver must run as service, CYGWIN must contain server. :(以下略) ようするに:
また、メンテナは Jason Tishler氏から Reini Urban氏に移ったとのこと。(以下,READMEの該当部分) ---------- postgresql-8.0.0cvs-1 ----------- Maintainership changed from Jason Tishler to Reini Urban. init.dのスクリプト (/etc/rc.d/init.d/postgresql) も追加された。 [編集]postgresqlのセットアップ #動作確認なので、サービスにはしないし、環境変数もその場で定義する。 サービス化の手順も異なるようだけど、試してない。たぶん本家のネイティブ版8.0.Xのpg_ctlと同じだと思うが。 cygserverの設定 $ cygserver-config Generating /etc/cygserver.conf file Warning: The following function requires administrator privileges! Do you want to install cygserver as service? (Say "no" if it's already installed as service) (yes/no) no ★今回はサービスにしない Further configuration options are available by editing the configuration file /etc/cygserver.conf. Please read the inline information in that file carefully. The best option for the start is to just leave it alone. Please keep in mind, that a client application which wants to use the services provided by cygserver *must* have the environment variable CYGWIN set so that it contains the word "server". So, if you don't need any other special CYGWIN setting, just set it to "server". It is advisable to add this setting to the Windows system environment. Basic Cygserver configuration finished. Have fun! 環境変数CYGWINを定義 $ export CYGWIN=server cygserverをバックグラウンドで起動し、確認 $ /usr/sbin/cygserver & [1] 1148 cygserver: Initialization complete. Waiting for requests. $ jobs [1]+ Running /usr/sbin/cygserver & $ ipcs Message Queues: T ID KEY MODE OWNER GROUP Shared Memory: T ID KEY MODE OWNER GROUP Semaphores: T ID KEY MODE OWNER GROUP initdbを実行。(注意:bashを実行する前に、WINDOWSの環境変数PATHにc:\cygwin\binを追加しておくこと。これをやらないと、デバッグメッセージらしきものが延々と出て止まらない) $ /usr/sbin/initdb --no-locale -D /var/postgresql/data 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 /var/postgresql/data ... ok creating directory /var/postgresql/data/global ... ok creating directory /var/postgresql/data/pg_xlog ... ok creating directory /var/postgresql/data/pg_xlog/archive_status ... ok creating directory /var/postgresql/data/pg_clog ... ok creating directory /var/postgresql/data/pg_subtrans ... ok creating directory /var/postgresql/data/base ... ok creating directory /var/postgresql/data/base/1 ... ok creating directory /var/postgresql/data/pg_tblspc ... ok selecting default max_connections ... 40 selecting default shared_buffers ... 1000 creating configuration files ... ok creating template1 database in /var/postgresql/data/base/1 ... ok initializing pg_shadow ... ok enabling unlimited row size for system tables ... ok initializing pg_depend ... 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 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 /var/postgresql/data or /usr/sbin/pg_ctl -D /var/postgresql/data -l logfile start pg_ctlを使ってPostgreSQLを起動し、ログを確認 $ /usr/sbin/pg_ctl -D /var/postgresql/data -l /var/log/postgres.log start postmaster starting $ cat /var/log/postgres.log LOG: database system was shut down at 2005-11-12 20:14:49 LOG: checkpoint record is at 0/ABCF08 LOG: redo record is at 0/ABCF08; undo record is at 0/0; shutdown TRUE LOG: next transaction ID: 544; next OID: 17230 LOG: database system is ready psqlでアクセスしてみる。 $ psql template1 Welcome to psql 8.0.4, 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.0.4 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[編集] サービスで稼働 #[編集]準備 #システム環境変数CYGWINを定義、値は'server'で定義。 システム環境変数PATHにc:\cygwin\binを追加。 Windowsを再起動する。 [編集]cygserver #cygserverをサービスに登録するには cygrunsrvコマンドが必要だが、デフォルトではインストールされなかった。 setup.exeでインストールしておく。(cygrunsrvはCategory All->Adminにある。インストール後は $ cygcheck -c cygrunsrv で確認) cygserver-configを実行する。 $ cygserver-config Overwrite existing /etc/cygserver.conf file? (yes/no) no Warning: The following function requires administrator privileges! Do you want to install cygserver as service? (Say "no" if it's already installed as service) (yes/no) yes The service has been installed under LocalSystem account. To start it, call `net start cygserver' or `cygrunsrv -S cygserver'. Further configuration options are available by editing the configuration file /etc/cygserver.conf. Please read the inline information in that file carefully. The best option for the start is to just leave it alone. Please keep in mind, that a client application which wants to use the services provided by cygserver *must* have the environment variable CYGWIN set so that it contains the word "server". So, if you don't need any other special CYGWIN setting, just set it to "server". It is advisable to add this setting to the Windows system environment. Basic Cygserver configuration finished. Have fun! ちなみに、cygrunsrvをいれてないときには、次のメッセージが出る。 $ cygserver-config Overwrite existing /etc/cygserver.conf file? (yes/no) no Warning: The following function requires administrator privileges! Do you want to install cygserver as service? (Say "no" if it's already installed as service) (yes/no) yes /usr/bin/cygserver-config: line 176: cygrunsrv: command not found Installation of cygserver as service failed. Please check the error messages you got. They might give a clue why it failed. A good start is either you don't have administrator privileges or a missing cygrunsrv binary. Please check for both. cygserverを起動する $ cygrunsrv -S cygserver $ cygrunsrv -Q cygserver Service : cygserver Display name : CYGWIN cygserver Current State : Running Controls Accepted : Stop Command : /usr/sbin/cygserver[編集] PostgreSQLを起動するユーザの設定 #ユーザアカウントの作成、/etc/passwdの更新、"サービスとしてログイン"権限付加は従来と同じなので、略。 [編集]データベースクラスタの作成 #データベースクラスタの作成。c:\cygwin\bin\bash.exeをpostgresユーザで起動(runasコマンドを使う、あるいはc:\cygwin\binフォルダを開いて、bash.exe上でSHIFT+右クリック→「別のユーザーとして実行」)、initdbしておく。 bash-3.00$ whoami postgres bash-3.00$ export CYGWIN=server bash-3.00$ initdb --no-locale -D /var/postgresql/data bash: initdb: command not found bash-3.00$ /usr/sbin/initdb --no-locale -D /var/postgresql/data 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. creating directory /var/postgresql/data ... ok creating directory /var/postgresql/data/global ... ok creating directory /var/postgresql/data/pg_xlog ... ok creating directory /var/postgresql/data/pg_xlog/archive_status ... ok creating directory /var/postgresql/data/pg_clog ... ok creating directory /var/postgresql/data/pg_subtrans ... ok creating directory /var/postgresql/data/base ... ok creating directory /var/postgresql/data/base/1 ... ok creating directory /var/postgresql/data/pg_tblspc ... ok selecting default max_connections ... 40 selecting default shared_buffers ... 1000 creating configuration files ... ok creating template1 database in /var/postgresql/data/base/1 ... ok initializing pg_shadow ... ok enabling unlimited row size for system tables ... ok initializing pg_depend ... 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 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 /var/postgresql/data or /usr/sbin/pg_ctl -D /var/postgresql/data -l logfile start bash-3.00$[編集] pg_ctlでサービスに登録、実行(失敗) #pg_ctlコマンドのオプションを確認 $ /usr/sbin/pg_ctl --help pg_ctl is a utility to start, stop, restart, reload configuration files, report the status of a PostgreSQL server, or signal a PostgreSQL process. Usage: pg_ctl start [-w] [-D DATADIR] [-s] [-l FILENAME] [-o "OPTIONS"] pg_ctl stop [-W] [-D DATADIR] [-s] [-m SHUTDOWN-MODE] pg_ctl restart [-w] [-D DATADIR] [-s] [-m SHUTDOWN-MODE] [-o "OPTIONS"] pg_ctl reload [-D DATADIR] [-s] pg_ctl status [-D DATADIR] pg_ctl kill SIGNALNAME PID pg_ctl register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR] [-w] [-o "OPTIONS"] pg_ctl unregister [-N SERVICENAME] サービスに登録 $ /usr/sbin/pg_ctl register -U postgres -P postgresユーザのパスワード -D /var/postgresql/data Windowsの「コンピュータの管理」で調べると、
サービス名は 'PostgreSQL'、 サービスとして起動してみる……失敗。メーリングリスト(Cygwin/情報源#ml_bbs)を当たれば何か見つかるかも知れないけど、調べてない。 $ net start postgresql PostgreSQL サービスを開始します. PostgreSQL サービスを開始できませんでした。 サービスはエラーを報告しませんでした。 NET HELPMSG 3534 と入力すると、より詳しい説明が得られます。 サービスから削除 $ /usr/sbin/pg_ctl unregister $ /usr/sbin/pg_ctl unregister pg_ctl: service "PostgreSQL" not registered[編集] cygrunsrvでサービスに登録、実行 #従来と同じ手順、つまりcygrunsrvを使ってみた。こちらは稼働するようだ。 サービスを登録 $ cygrunsrv --install postmaster --path /usr/sbin/postmaster \ --args "-D /var/postgresql/data" --dep cygserver --termsig INT \ --user postgres --shutdown Enter password of user `HOSTNAME\postgres': Reenter, please: サービスを起動 $ net start postmaster postmaster サービスを開始します. postmaster サービスは正常に開始されました。 ログを確認 $ cat /var/log/postmaster.log LOG: database system was shut down at 2005-11-12 21:13:47 LOG: checkpoint record is at 0/ABCF08 LOG: redo record is at 0/ABCF08; undo record is at 0/0; shutdown TRUE LOG: next transaction ID: 544; next OID: 17230 LOG: database system is ready postgresユーザでbash.exeを実行、その中でpsqlを実行 bash-3.00$ whoami postgres bash-3.00$ psql template1 Welcome to psql 8.0.4, 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=# \q サービスを削除 $ cygrunsrv -R postmaster $ cygrunsrv -R postmaster cygrunsrv: Error removing a service: OpenService: Win32 error 1060: 指定されたサービスはインストールされたサービスとして存在しません。 |