2009年9月14日月曜日

PostgreSQL 8.4の起動スクリプト

PostgreSQL 8.4をUbuntu 9.04 x64で動かしていて、他のPCからTCP/IPで接続したいが、なかなかできなかった。
結局の原因はサーバーの起動時にiオプションがついていなかったという。
サーバーの起動スクリプトはPostgreSQL 8.4のソースコードに付属の(./contrib/start-scripts/linux)を使っていたが、これにiオプションがついていないからいけないのかな?ということで適当に修正してみる。
./contrib/start-srcipts/linuxをUbuntu 9.04ならば/etc/init.dにコピーしてpostgresとかに適当にリネーム。
startとrestartの部分でそれぞれサーバーを起動させている行である以下の部分を、
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1



下記のように変更した。っていうか-iを付けただけー。
su - $PGUSER -c "$DAEMON -D '$PGDATA' -i &" >>$PGLOG 2>&1


その後chkconfig --add postgresで導入。
service postgres statusや、ps aux |grep postgresなどのコマンドで動作を確認。
TCP/IPでの接続もできるようになりました。
(もちろんpostgresql.confやpg_hba.confの設定は必要)

以下サーバーの起動スクリプトの全文。

#! /bin/sh

# chkconfig: 2345 98 02
# description: PostgreSQL RDBMS

# This is an example of a start/stop script for SysV-style init, such
# as is used on Linux systems. You should edit some of the variables
# and maybe the 'echo' commands.
#
# Place this file at /etc/init.d/postgresql (or
# /etc/rc.d/init.d/postgresql) and make symlinks to
# /etc/rc.d/rc0.d/K02postgresql
# /etc/rc.d/rc1.d/K02postgresql
# /etc/rc.d/rc2.d/K02postgresql
# /etc/rc.d/rc3.d/S98postgresql
# /etc/rc.d/rc4.d/S98postgresql
# /etc/rc.d/rc5.d/S98postgresql
# Or, if you have chkconfig, simply:
# chkconfig --add postgresql
#
# Proper init scripts on Linux systems normally require setting lock
# and pid files under /var/run as well as reacting to network
# settings, so you should treat this with care.

# Original author: Ryan Kirkpatrick

# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.8 2006/07/13 14:44:33 petere Exp $

## EDIT FROM HERE

# Installation prefix
prefix=/usr/local/pgsql

# Data directory
PGDATA="/usr/local/pgsql/data"

# Who to run the postmaster as, usually "postgres". (NOT "root")
PGUSER=postgres

# Where to keep a log file
PGLOG="$PGDATA/serverlog"

## STOP EDITING HERE

# The path that is to be used for the script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# What to use to start up the postmaster (we do NOT use pg_ctl for this,
# as it adds no value and can cause the postmaster to misrecognize a stale
# lock file)
DAEMON="$prefix/bin/postmaster"

# What to use to shut down the postmaster
PGCTL="$prefix/bin/pg_ctl"

set -e

# Only start if we can find the postmaster.
test -x $DAEMON || exit 0

# Parse command line parameters.
case $1 in
start)
echo -n "Starting PostgreSQL: "
su - $PGUSER -c "$DAEMON -D '$PGDATA' -i &" >>$PGLOG 2>&1
# su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
stop)
echo -n "Stopping PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
echo "ok"
;;
restart)
echo -n "Restarting PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
su - $PGUSER -c "$DAEMON -D '$PGDATA' -i &" >>$PGLOG 2>&1
# su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
reload)
echo -n "Reload PostgreSQL: "
su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
echo "ok"
;;
status)
su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
;;
*)
# Print help
echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
exit 1
;;
esac

exit 0



今回はpostmasterを利用しているので、オプションは以下のコマンドで確認した。
# /usr/local/pgsql/bin/postmaster --help

postmaster is the PostgreSQL server.

Usage:
postmaster [OPTION]...

Options:
-B NBUFFERS number of shared buffers
-c NAME=VALUE set run-time parameter
-d 1-5 debugging level
-D DATADIR database directory
-e use European date input format (DMY)
-F turn fsync off
-h HOSTNAME host name or IP address to listen on
-i enable TCP/IP connections
-k DIRECTORY Unix-domain socket location
-N MAX-CONNECT maximum number of allowed connections
-o OPTIONS pass "OPTIONS" to each server process (obsolete)
-p PORT port number to listen on
-s show statistics after each query
-S WORK-MEM set amount of memory for sorts (in kB)
--NAME=VALUE set run-time parameter
--describe-config describe configuration parameters, then exit
--help show this help, then exit
--version output version information, then exit

Developer options:
-f s|i|n|m|h forbid use of some plan types
-n do not reinitialize shared memory after abnormal exit
-O allow system table structure changes
-P disable system indexes
-t pa|pl|ex show timings after each query
-T send SIGSTOP to all backend servers if one dies
-W NUM wait NUM seconds to allow attach from a debugger

Options for single-user mode:
--single selects single-user mode (must be first argument)
DBNAME database name (defaults to user name)
-d 0-5 override debugging level
-E echo statement before execution
-j do not use newline as interactive query delimiter
-r FILENAME send stdout and stderr to given file

Options for bootstrapping mode:
--boot selects bootstrapping mode (must be first argument)
DBNAME database name (mandatory argument in bootstrapping mode)
-r FILENAME send stdout and stderr to given file
-x NUM internal use

Please read the documentation for the complete list of run-time
configuration settings and how to set them on the command line or in
the configuration file.

Report bugs to .

第28回 日本企業を見限ったインドの“システム屋”から学んだこと - ダメな“システム屋”にだまされるな:ITpro

第28回 日本企業を見限ったインドの“システム屋”から学んだこと - ダメな“システム屋”にだまされるな:ITpro: "日本人的な現場が知恵を出し合うという考え方と、欧米的な「要件を決めて、決めた通りに作る」「多少現場が苦労してもパッケージソフトのやり方に業務プロセスを合わせる」という考え方は、折り合わないところがあるのかもしれません。インド人との議論を通じて、そう考えるようになりました。"

2009年9月11日金曜日

ipcs -m
コマンド

2009年9月4日金曜日

Fedora 11のインストール。

*[ソフトウェア]Fedora 11を使う上で必要になることなど
古いFedora 11のKDEのライブからインストールしたので、いろいろと不都合があったので適当に対処。
まずは日本語関係が全然入っていないので、System settingのAdd and Remove Softwareのソフトウェアの追加あたりから、Japaneseで検索。
japanese-supportとkde-l10n-japanese -4.3.0 (KDEのバージョンに合わせる。今回は4.3)を導入。
日本語入力環境もないので、scim-lang-japaneseを導入。


Flashはhttp://get.adobe.com/jp/flashplayer/からYUM版をダウンロードして導入。
ブラウザはFirefoxをyumから、Operaは公式のサイトから導入。


ATIのドライバ
kernelとkernel-develをyumで導入。
http://get.adobe.com/jp/flashplayer/
から取得したドライバに適宜実行権限を与えて(chmod u+x [FILENAME])、実行。

適当なグラボを選んで最新を利用したらうまくいきました。
http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx?type=2.4.1&product=2.4.1.3.36&lang=English


./ati-driver-installer-9-3-x86.x86_64.run --listpkg
を実行すると、
Fedora Packages:
Fedora/FC3
Fedora/FC4
Fedora/FC5
Fedora/FC6
Fedora/F7
Fedora/F8
Fedora/F9
Fedora/F10
Fedora/RHEL3
Fedora/RHEL4
という結果に。どうやらFedora/F11はまだみたい。

とりあえず生成オプションを追加して、以下のように実行してみる。
./ati-driver-installer-9-3-x86.x86_64.run --buildpkg Fedora/F10

すると次のようなエラーが
Package build failed!
Package build utility output:
./packages/Fedora/ati-packager.sh: line 266: rpmbuild: command not found

auto-buildrequires.x86_64 : Work out BuildRequires for rpmbuild automatically
rpm-build-4.7.1-1.fc11.x86_64.rpm

2009年9月3日木曜日

ゲームがおもしろい。

個人的にゲームはあまりやらない主義。
でも、昔少しだけ遊んだ懐かしいゲームがふとPSPのオンラインストアにあったりすると買ってしまうというもの。


*[アニメ]空の境界 6章
妹がメインなのでテンポや音楽に変化をつけてきた感じ。
しかし、先生の妖精話なんかがごっそり省略されてた。いいのかなぁ。
原作ではそんなに印象に残っていなかった戦闘シーンが素晴らしい出来に。
腕に光り輝いていたのは魔術刻印でしょうか?

*[その他]自転車が一番危ないと思う今日この頃。
自転車事故で1300万円賠償命令 パート女性の後悔:産経関西(産経新聞大阪本社公式ニュースサイト)
http://www.sankei-kansai.com/2009/09/02/20090902-014087.php
車なんかよりも保険の加入義務もなく、信号もなく、通る道もきっちり決まって無くて、車体自体は搭乗者の安全性を保証しない。
車の方がまだ安全だと個人的には思ってしまう。
あまり進まない自転車の進化に期待したい。

*[日記]今日はPS3が届く日。
なので、徹夜でお出迎えの準備は万端です。