2008年9月29日月曜日

MySQL5.1.24サーバーをMySQL5.1.28-rcへアップグレードしたら文字化けた

今まで正常に動作していたruby/mysqlがportsupgradeしたとたんに文字化けするようになった。

# portsdb -uU
# pkgdb -F
# portupgrade -a -R

Rubyから読み込んだデータベースの日本語がすべて"?????????????????"みたいに表示されるようになり、Rubyから書き込んだデータベースの内容は"ã�‚ã�„ã� ã‚‚ã‚‚"みたいにギリシャ語かポルトガル語みたいなウムラウトだかティルデが付いたような文字が表示される。
以前も同じ症状がでたんだけど、skip-character-set-client-handshakeをmy.cnfに記述するだけで回避できていました。

[/etc/my.cnf/]
----------------------------------------------------
[mysqld]
skip-character-set-client-handshake
----------------------------------------------------

google先生にきいてみたところ次のように記述すると良いということで,変更したらあっさり直りました!!!
あーよかった(^-^;;;;


[/etc/my.cnf/]
----------------------------------------------------
[mysqld]
skip-character-set-client-handshake
default-character-set=utf8

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqldump]
default-character-set=utf8
----------------------------------------------------

ps.
portsupgradeしたらBIND(DNS)が正常に起動しなくなっていてあせりました。
BINDを

#make deinstall
#make clean
#make install

としたら直りました。
これもかなりあせった(^-^;;;


FreeBSD6.3
MYSQL5.1.24→MYSQL5.1.28
phpMyAdmin2.11.6
Ruby1.8.6

サイクルコンピューター

ロードレーサー(自転車)で走っていると今の時速や平均速度、走行距離を知りたくなります。
昨今、自転車用スピードメーターも進化しており、名前はスピードメーターでも内部にコンピューターを内蔵するようになって来ています。
付加機能がいろいろありまして、ペダルの回転数や心拍数、GPS付では緯度経度を記録しUSBでパソコンに送り記録する、といった機能まであります。
特に気になるのは、ブリジストンのE-Meters。走行距離、走行時間を計測しUSBでパソコンに送ることができます。この機能で7560円。
他の機種でパソコンに送る機能があるものは。。。。2万円以下ではなかなかみつかりません。

E-Megersならパソコンに走行データを取り出し、パソコン上で時間軸上に速度のグラフを表示したり、地図上に走行データを重ね合わせ、どの地点でどれくらいの速度で走っていたのか表示できるでしょう。
その走行データをもとにネット上で掲載し、他人のデータと比較できるということでなんか楽しそうです。

この値段ならE-Metersもお買い得ではないでしょうか。

2008年9月24日水曜日

mod_cband Apache2.2の設定 帯域制限@FreeBSD

FreeBSDの場合Portsからmake install すればとりあえずApache2へのインストールは完了します。以前の記事参照 mod_cbandを入れてみた

■Apache2の帯域制限の設定 mod_cband

ここではmod_cbandの設定方法を説明します。
httpd.confを編集します。
FreeBSDの場合
/usr/local/etc/apache22/httpd.conf
を編集します。
他のOSを使われているかたは、それぞれのApache2の設定ファイルを編集します。
FedoraCore5: /etc/httpd/conf/httpd.conf
Debian: /etc/apache2/httpd.conf

mod_cbandはVirtualHostごとに設定を行うので、ディレクティブに記入していきます。ローカルでサーバーを立てているときやドメイン1個にしか対応していないときは、ディレクティブが無いので追記します。
サーバーのIPアドレスが192.168.0.200ならば

<VirtualHost 192.168.0.200>
</VirtualHost>

としてください。
以下サーバーのIPアドレスが192.168.0.200として説明します。
このサーバーのドメイン名はwww.example.jpとして公開されているものとします。

<VirtualHost 192.168.0.200>
ServerName www.example.jp
ServerAdmin admin@example.jp
DocumentRoot /home/www/public_html
</VirtualHost>

ここでServerNameは必須です。
もしServerNameを指定しなかった場合

Starting httpd:[Sun Jun 11 13:24:11 2008][warn]
Invalid command 'CBandSpeed',undefined virtualhost name

と表示されます。

■単位の表記方法
帯域制限をかける上で、帯域の表記方法が必要になります。
次にその表記方法を示します。

送信速度
kbps:1024 bits per second
Mbps:1024x1024 bits per second
Gbps:1024x1024x1024 bits per second
デフォルト kbps

クオータ(送信データの累積量)
K:1000 bytes
M:1000x1000 bytes
G:1000x1000x1000 bytes
Ki:1000 bytes
Mi:1000x1000 bytes
Gi:1000x1000x1000 bytes
デフォルト K (キロバイト)

時間
S:秒
M:分
H:時
D:日
W:週
デフォルト S (秒)

mod_cbandのパフォーマンスを改善するために、次のディレクティブをhttpd.confに追加します。
[/usr/local/etc/apache2/httpd.conf]
CBandScoreFlushPeriod 1
CBandRandomPulse On

次にスコアボードを保存するフォルダを作成します。
このフォルダはどこでもいいのですが、パーミッションの設定が必要です。
#mkdir /var/apache
#mkdir /var/apache/scoreboard
chown www:www /var/apache
chown www:www /var/apache/scoreboard

■ダウンロードスピードの設定

以下httpd.confを設定しますが、設定を反映させるには

#apachectl restart

を行って下さい。


○例1:
ホストの帯域制限+接続クライアントの帯域制限

<VirtualHost 192.168.0.200>
ServerName www.example.jp
ServerAdmin admin@example.jp
DocumentRoot /home/www/public_html
CBandSpeed 1024kbps 10 30
CBandRemoteSpeed 20kbps 3 3
</VirtualHost>

CBandSpeedでは、バーチャルホスト www.example.jp全体の帯域制限を行います。
送信速度1024kbps、1秒あたりの最大接続要求数 10、最大(継続)接続数 30
に制限します。
CBandRemoteSpeedでは、接続してきたクライアントに対して帯域制限をおこないます。
帯域制限 20kbps、1秒あたりの最大接続要求数 3、最大(継続)接続数 3
に制限します。
CBandSpeedの帯域制限は、www.example.jpに接続する各クライアント(ブラウザ等)すべて積算し(含め)た帯域を制限します。


○例2:
ホストの月間送信量の制限+超過時の減速設定

<VirtualHost 192.168.0.200>
ServerName www.example.jp
ServerAdmin admin@example.jp
DocumentRoot /home/www/public_html
CBandLimit 100M
CBandExceededSpeed 128kbps 5 15
CBandScoreBoard /var/apache/scoreboard
CBandPeriod 4W
</VirtualHost>

CBandLimit 100M
CBandPeriod 4W
で、1ヶ月あたり100MByteの送信量に制限しています。
もし、この送信量を超えれば、
CBandExceededSpeed 128kbps 5 15
で、128kbps 1秒当たりの最大接続要求 5  最大(継続)接続数 15
に制限されます。


○例3:
ホストの月間送信量の制限+超過時は503エラーを返す

<VirtualHost 192.168.0.200>
ServerName www.example.jp
ServerAdmin admin@example.jp
DocumentRoot /home/www/public_html
CBandLimit 100M
CBandScoreBoard /var/apache/scoreboard
CBandPeriod 4W
</VirtualHost>

CBandExceededSpeedディレクティブを削除すると503エラーを返します


○例4:
ホストの月間送信量の制限+超過時は503エラーを返し+指定されたURLへリダイレクトする

<VirtualHost 192.168.0.200>
ServerName www.example.jp
ServerAdmin admin@example.jp
DocumentRoot /home/www/public_html
CBandLimit 100M
CBandExeededURL http://www.example.jp/traffic_exceeded.html
CBandScoreBoard /var/apache/scoreboard
CBandPeriod 4W
</VirtualHost>


■ステータスページの表示
mod_cbandには現在の動作状態を表示するステータスページがあります。
VirtualHostディレクティブに<Location /cband-status>...等を追加します


<VirtualHost 192.168.0.200>
ServerName www.example.jp
ServerAdmin admin@example.jp
DocumentRoot /home/www/public_html
CBandLimit 100M
CBandExeededURL http://www.example.jp/traffic_exceeded.html
CBandScoreBoard /var/apache/scoreboard
CBandPeriod 4W
<Location /cband-status>
SetHandler cband-status
</Location>
<Location /cband-status-me>
SetHandler cband-status-me
</Location>

</VirtualHost>

これらの画面を表示するには、
www.example.jp/cband-status
www.example.jp/cband-status-me
をブラウザで開きます。

mod_cband documentation bandwidth limitter module for Apache2

mod_cband - A per-user, per-virtualhost and per-destination bandwidth
limiter for the Apache HTTP Server Version 2

Documentation
=============

1. Units accepted in various directives:
* transfer speeds:
o kbps, Mbps, Gbps - multiples of "bits per second", respectively: 1024, 10241024 and 10241024*1024 bps
o kb/s, Mb/s, Gb/s - multiples of "bytes per second", respectively: 1024, 10241024 and 10241024*1024 b/s
o defaults to kbps
* transfer quotas:
o K, M, G - multiples of bytes, respectively: 1000, 10001000 and 10001000*1000 bytes
o Ki, Mi, Gi - multiples of bytes, respectively: 1024, 10241024 and 10241024*1024 bytes
o defaults to K
* time periods:
o S, M, H, D, W - multiples of seconds: Seconds, Minutes, Hours, Days, Weeks; respectively: 1, 60, 3600, 86400, 604800 seconds
o defaults to S
2. Directives

Name CBandDefaultExceededURL
Description Default URL where mod_cband should redirect all requests to the virtualhost or
user when the configured transfer limit is exceeded
NOTE: If you don't specify the exceeded URL location then standard 503 Service Unavailable
will be sent
Context Server config
Syntax CBandDefaultExceededURL URL

Name CBandDefaultExceededCode
Description The http code sent to the user when the configured transfer is exceeded
Context Server config
Syntax CBandDefaultExceededCode HTTP_CODE
Example CBandDefaultExceededCode 509

Name CBandScoreFlushPeriod
Description Specifies a period after which the score for the virtualhost or user is written to the scoreboard file. Use this to improve mod_cband's performance
Default 1
Context Server config
Syntax CBandScoreFlushPeriod number_of_requests
Example CBandScoreFlushPeriod 100
Any virtualhost's or user's scoreboard will be saved after 100 requests

Name CBandSpeed
Description Specifies a maximal speed for a virtualhost
Context
Syntax CBandSpeed kbps rps max_conn
kbps - maximal transfer speed in [kMG]bps or [kMG]B/s
rps - maximal requests per second
max_conn - maximal number of simultaneous connections
Example CBandSpeed 1024 10 30
Specifies maximal speed 1024kbps (1024 * 1024 bits per second),
maximal 10 requests per second and with a maximum of 30 open connections
NOTE: This feature is available from version 0.9.6.0

Name CBandRemoteSpeed
Description Specifies maximal speed for any remote client
Context
Syntax CBandRemoteSpeed kbps rps max_conn
kbps - maximal transfer speed in [kMG]bps or [kMG]B/s
rps - maximal requests per second
max_conn - maximal number of simultaneous connections
Example CBandRemoteSpeed 20kb/s 3 3
Specifies maximal speed 20kB/s (20 * 1024 bytes per second),
maximal 3 requests per second and 3 open connections for any remote client
NOTE: This feature is available from version 0.9.6.1-rc2

Name CBandClassRemoteSpeed
Description Specifies maximal speed for any remote client from some destination class
Context
Syntax CBandClassRemoteSpeed class_name kbps rps
class_name - name of defined destination class
kbps - maximal transfer speed in kbps or kB/s
rps - maximal requests per second
max_conn - maximal number of simultaneous connections
Example
CBandClasDst 66.249.64/24
CBandClasDst 66.249.65/24
CBandClasDst 66.249.79/24

CBandClassRemoteSpeed googlebot_class 20kb/s 2 3

Specifies maximal speed 20kB/s (20 * 1024 bytes per second),
maximal 2 requests per second and 3 open connections for any remote client from
class googlebot_class
NOTE: This feature is available from version 0.9.6.1-rc2

Name CBandRandomPulse
Description Turns On or Off the random pulse generator for data sending
Random pulse generator is a part of the speed-limiting implementation of mod_cband.
This directive changes the way a connection's speed is determined and enforced.
The connections' speeds are measured within some time period and then provided for in
that period. When r.p.g. is enabled this period is chosen randomly,
providing for a statisticaly saner load distribution. Disabling this causes spikes both in
bandwidth and cpu usages
Context Global
Syntax CBandRandomPulse On/Off

Name CBandLimit
Description Specifies bandwidth limit for virtualhost
Context
Syntax CBandLimit limit
limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi),
Mi (mebi), Gi (gibi)
Example CBandLimit 10M
Specifies 10 * 1000 * 1000 bytes bandwidth quota

CBandLimit 10Mi
Specifies 10 * 1024 * 1024 bytes bandwidth quota

Name CBandClassLimit
Description Specifies bandwidth limit for virtualhost's destination class
Context
Syntax CBandClassLimit class_name limit
class_name - the name of defined class
limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi),
Mi (mebi), Gi (gibi)

Name CBandExceededURL
Description Specifies a URL where mod_cband should redirect all requests to a virtualhost when the configured transfer limit is exceeded NOTE: If you don't specify the exceeded URL location then standard 503 Service Unavailable will be sent
Context
Syntax CBandExceededURL URL

Name CBandExceededSpeed
Description Specifies maximal speed to which mod_cband slows down a virtualhost when the configured transfer limit is exceeded
Context
Syntax CBandExceededSpeed kbps rps max_conn
kbps - maximal transfer speed in kbps or kB/s
rps - maximal requests per second
max_conn - maximal number of simultaneous connections
NOTE: This feature is available from version 0.9.6.0

Name CBandScoreboard
Description Specifies virtualhost's scoreboard file
Context
Syntax CBandScoreboard path
NOTE: The path must be writeable for the apache-user

Name CBandPeriod
Description Specifies a period after which a virtualhost's usages are cleared
Context
Syntax CBandPeriod period
period - available units: S (seconds), M (minutes), H (hours), D (days), W (weeks)
Example CBandPeriod 1W
CBandPeriod 14D
CBandPeriod 60M

Name CBandPeriodSlice
Description Specifies the period slice length
Default slice_len = limit
Context
Syntax CBandPeriodSlice slice_length
Example CBandLimit 100G
CBandPeriod 4W
CBandPeriodSlice 1W
A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G
bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G ...

Name
Description Define a new cband user
Context Server config
Syntax

Name CBandUserSpeed
Description Specifies maximal speed for a cband user
Context
Syntax CBandUserSpeed kbps rps max_conn
kbps - maximal transfer speed in kbps or kB/s
rps - maximal requests per second
max_conn - maximal number of simultaneous connections
Example CBandUserSpeed 100kb/s 10 5
Specifies maximal speed 100 kB/s (100 * 1024 bytes per second),
maximal 10 requests per second and 5 open connections
NOTE: This feature is available from version 0.9.6.0

Name CBandUserLimit
Description Specifies bandwidth limit for a cband user
Context
Syntax CBandUserLimit limit
limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi),
Mi (mebi), Gi (gibi)
Example CBandUserLimit 10M
Specifies 10 * 1000 * 1000 bytes bandwidth quota

CBandUserLimit 10Mi
Specifies 10 * 1024 * 1024 bytes bandwidth quota

Name CBandUserClassLimit
Description Specifies bandwidth limit for a cband user's destination class
Context
Syntax CBandUserClassLimit class_name limit
class_name - the name of defined class
limit - bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi),
Mi (mebi), Gi (gibi)

Name CBandUserExceededURL
Description Specifies a URL where mod_cband should redirect all requests to user's virtualhost when the configured transfer limit is exceeded
NOTE: If you don't specify the exceeded URL location then standard 503 Service Unavailable will be sent
Context
Syntax CBandUserExceededURL URL

Name CBandUserExceededSpeed
Description Specifies maximal speed to which mod_cband slows down user when the configured transfer limit is exceeded
NOTE: CBandUserExceededURL must not be used if you want to only slow down user's pages with
CBandUserExceededSpeed directive
Context
Syntax CBandUserExceededSpeed kbps rps max_conn
kbps - maximal transfer speed in kbps or kB/s
rps - maximal requests per second
max_conn - maximal number of simultaneous connections
NOTE: This feature is available from version 0.9.6.0

Name CBandUserScoreboard
Description Specifies a user's scoreboard file
Context
Syntax CBandUserScoreboard path
NOTE: The path must be writeable for the apache-user

Name CBandUserPeriod
Description Specifies a period after which a user's usages are cleared
Context
Syntax CBandUserPeriod period
period - available units: S (seconds), M (minutes), H (hours), D (days), W (weeks)
Example CBandUserPeriod 1W
CBandUserPeriod 14D
CBandUserPeriod 60M

Name CBandUserPeriodSlice
Description Specifies a period slice length
Default slice_len = limit
Context
Syntax CBandUserPeriodSlice slice_length
Example CBandUserLimit 100G
CBandUserPeriod 4W
CBandUserPeriodSlice 1W
A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G
bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G ...

3. Status Handler Configuration Example To view actual bandwidth limits, usages, users, scoreboards, add the following lines into the config file:


SetHandler cband-status



SetHandler cband-status-me


Then you can access the status page with a URL like: http://server_name/cband-status
http://server_name/cband-status-me

An example of the cband-status is available here An example of the cband-status-me is available here

In versions >=0.9.5-rc1 you can also view /cband-status handler in the XML format:

http://server_name/cband-status?xml
http://server_name/cband-status-me?xml

An example of the cband-status in the XML format is available here An example of the cband-status-me in the XML format is available here

4. Bandwidth Speed Configuration Example



DocumentRoot /var/www/xyz.org/
ServerName xyz.org
CustomLog /var/log/apache2/xyz.org.access combined ErrorLog /var/log/apache2/xyz.org.access.error RewriteEngine On
RewriteOptions inherit

# Maximal 1024kbps speed for this virtualhost # Maximal 10 requests per second for this virtualhost # Maximal 30 open connections for this virtualhost CBandSpeed 1024 10 30

# Maximal 10kB/s speed, 3 requests/s and 2 open connections for any remote client CBandRemoteSpeed 10kb/s 3 2

# Maximal 20kB/s speed, 2 requests/s and 3 open connections for remote # clients from class googlebot_class :P CBandClassRemoteSpeed googlebot_class 20kb/s 2 3


5. Bandwidth Quota Configuration Example per-virtualhost bandwidth limiting configuration Next, you may define virtualhost's bandwidth limits, URL location and the path to scoreboard files for individual virtualhosts:

# specify default 'bandwidth exceeded' location CBandDefaultExceededURL http://haha.org/bandwidth_exceeded.html



DocumentRoot /var/www/xyz.org/
ServerName xyz.org
CustomLog /var/log/apache2/xyz.org.access combined ErrorLog /var/log/apache2/xyz.org.access.error RewriteEngine On
RewriteOptions inherit

# 100MB virtualhost bandwidth limit CBandLimit 100000

# redirect to http://abc.org/bandwidth_exceeded.html # when the limit has been reached
CBandExceededURL http://abc.org/bandwidth_exceeded.html

# virtualhost's scoreboard file
CBandScoreboard /var/run/apache2/xyz.org.scoreboard

# a period of time after which the scoreboard will be cleared (30 minutes) # (only in >=0.9.5-rc2)
CBandPeriod 30M


per-user bandwidth limiting configuration (only in versions >=0.9.1) In versions >=0.9.1 you can define limits for users and assign virtualhosts to them

# define user 'dembol'


# 200MB bandwidth limit for user 'dembol' CBandUserLimit 200000

# redirect to http://abc.org/bandwidth_exceeded.html # when the limit has been reached
CBandUserExceededURL http://abc.org/bandwidth_exceeded.html

# user's scoreboard file
CBandUserScoreboard /var/run/apache2/dembol.scoreboard

# a period of time after which the scoreboard will be cleared (5 weeks) # (only in >=0.9.5-rc2)
CBandUserPeriod 5W


# assign virtualhost 'xyz.org' to user 'dembol'

ServerName xyz.org
# Specify virtualhost's owner
CBandUser dembol


# assign virtualhost 'aga.org' to user 'dembol'

ServerName aga.org
# Specify virtualhost's owner
CBandUser dembol


per-user and per-virtualhost bandwidth limiting configuration (only in versions >=0.9.1) In versions >=0.9.1 you can also mix per-user and per-virtualhost bandwidth limiting techniques

# define user 'dembol'


# 200MB bandwidth limit for user 'dembol' CBandUserLimit 200000

# redirect to http://abc.org/bandwidth_exceeded.html # when the limit has been reached
CBandUserExceededURL http://abc.org/bandwidth_exceeded.html

# user's scoreboard file
CBandUserScoreboard /var/run/apache2/dembol.scoreboard

# a period of time after which the scoreboard will be cleared (4 days) # (only in >=0.9.5-rc2)
CBandUserPeriod 4D


# assign virtualhost 'xyz.org' to user 'dembol'

ServerName xyz.org
# Specify virtualhost's owner
CBandUser dembol

# 100MB virtualhost bandwidth limit CBandLimit 100000

# redirect to http://abc.org/bandwidth_exceeded.html # when the limit has been reached
CBandExceededURL http://abc.org/bandwidth_exceeded.html

# virtualhost's scoreboard file
CBandScoreboard /var/run/apache2/xyz.org.scoreboard

# a period of time after which the scoreboard will be cleared (50 minutes) # (only in >=0.9.5-rc2)
CBandPeriod 50M


# assign virtualhost 'aga.org' to user 'dembol'

ServerName aga.org
# Specify virtualhost's owner
CBandUser dembol


per-destination bandwidth limiting configuration (only in >=0.9.5-rc1 versions) In >= 0.9.5-rc1 you can limit traffic to some destination classes. The destination classes are defined by section. The limits for the classes are specified by CBandClassLimit and CBandUserClassLimit commands

# define 'class_1'


CBandClassDst 217.172.231.67
CBandClassDst 127/8
CBandClassDst 192.168.0.0/24
CBandClassDst 10.0.0.20


# define 'class_2'


CBandClassDst 192.168.100.100
CBandClassDst 153.19/16




CBandUserLimit 1000000
CBandUserExceededURL http://edns.pl/bandwidth_exceeded.html CBandUserScoreboard /home/dembol/write/user.dembol.scoreboard

# 500MB limit for 'class_2'
CBandUserClassLimit class_2 500000




...
CBandUser dembol

# 1GB limit for 'class_1'
CBandClassLimit class_1 1000000

# a period of time after which the scoreboard will be cleared (120 seconds) # (only in >=0.9.5-rc2)
CBandPeriod 120S

2008年9月21日日曜日

ロードレーサー(自転車)にはまっていまして


こんなドロップハンドルの自転車です。
めーちゃめちゃスピードが出るのでたのしいです。
で、今のペダルは普通のママチャリについているような普通のペダルなのですが、いまはビンディングペダルと言うのがあり、靴がペダルにくっつきます!!!
いやいや、私の子供のころのロードレーサーにはそんなものありませんでした。
あってもせいぜいペダルに靴を差し込む紐か金属の輪がつけてあるぐらいでした。それからするとすごく時代を感じます。
で、そのペダルとくっつく靴。。。スキーとブーツを思い出す名前ですが、ビンディングというらしいのです。今それがめちゃめちゃ欲しい!!
ペダルを踏み込むだけじゃなくて、足を引き上げる力も推力に使える。さらに自転車が軽快になるという触れ込み。
選んだのが


シマノ PD-A530

ビンディング面と普通の靴でも漕げるフラット面の両用タイプ。
SPDという規格の接続金具がついている。このタイプだと、靴の接合部分が靴の裏から飛び出ることがなく、楽に歩くこともできるということです。
あぁ。ビンディングペダルと靴が欲しい。。。
あわせて15000円前後か。
んーーーー
ほしい。。。

2008年9月18日木曜日

WindowsXP ServicePack3 がインストールできない

■この記事も書きかけです(苦笑)

WindowsXP ServicePack3がインストールできない!
ということでお客さんのパソコンを見てみました。
が、はてさてこれがなかなか原因がつかめない。

ServicePack3のインストールを始めるとエラーが発生する。
『アクセスが拒否されました』
ネットでいろいろ検索してみると、この症状ではまっている人が多く、まともな回答が掲載されているサイトがなかなか見つからない。
MicrosoftのKnowledgeBaseをのぞいてみて、そこに記載されている手順を追ってみても解決できない。なにやら、レジストリのアクセス権が間違って変更されているために、ServicePack3のインストール途中でエラーになるらしい。


[エラーメッセージの写真入れる]。


[svcpack.log]

インストール中の詳細ログを表示してみたら、怪しい行が出力されていた。
---------
#-198 コマンドラインは処理されました。: c:\ed27bf718467297f86c1a6a6ad83\i386\update\update.exe
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_common_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_inetmgr_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_pwmgr_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_www_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_doc_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_ftp_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
---------

レジストリのアップデート中のエラーとなっているが、spupdate.logをよく見るとINF_REGISTORY_ERRORとなっているので、この名前から類推すると、INFファイルの更新エラーとなるとどうもiis.infファイルが原因で更新できていないのではないだろうか。

さらにiis.infで検索してみると
http://www.windowsbbs.com/windows-xp/59275-service-pack-2-update-fails-iis-inf-error-0xe0000102.html

iis.infを他のPCからコピーしてきた。
エラーが出た!!!
だめらしい。




[setupapi.log]

#-198 コマンドラインは処理されました。: c:\ed27bf718467297f86c1a6a6ad83\i386\update\update.exe
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_common_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_inetmgr_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_pwmgr_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_www_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_doc_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
#E077 C:\WINDOWS\INF\iis.inf のディスク領域を計算しているときに空でないセクション [iis_ftp_install] が見つかりませんでした。 エラー 0xe0000102: INF に必要な行が見つかりませんでした。
[2008/09/18 16:50:38 604.3 Driver Install]
#-198 コマンドラインは処理されました。: C:\WINDOWS\system32\services.exe
#-166 デバイス インストール関数: DIF_SELECTBESTCOMPATDRV。
#W059 最も互換性のあるドライバの選択に失敗しました。 エラー 0xe0000228: このデバイスと互換性のあるドライバがありません。
#W157 既定のインストーラは失敗しました。 エラー 0xe0000228: このデバイスと互換性のあるドライバがありません。
[2008/09/18 16:50:41 2424.2]
#-199 C:\WINDOWS\system32\rundll32.exe をコマンド ライン: rundll32.exe newdev.dll,ClientSideInstall \\.\pipe\PNP_Device_Install_Pipe_0.{18595994-88E3-4C8C-814C-9F4A900CA176} で実行しています
#I060 選択したドライバの設定
#-166 デバイス インストール関数: DIF_SELECTBESTCOMPATDRV。
#W059 最も互換性のあるドライバの選択に失敗しました。 エラー 0xe0000228: このデバイスと互換性のあるドライバがありません。
#W157 既定のインストーラは失敗しました。 エラー 0xe0000228: このデバイスと互換性のあるドライバがありません。


---

2008年9月17日水曜日

FreeBSD6.3 Sambaのインストール

Sambaは、Linux...Fedora,Knoppix,VineLinuxその他あまたやMacOSX,FreeBSD,OpenBSD,NetBSDなどのBSD系UnixとWindowsとのファイル共有を行う、世界標準的なソフトウエアです。

FreeBSD6.3
Apache2.3
なサーバーにインストールします。
ja-samba 3.0.31_1,1
をインストールします。

FreeBSDではPortsからのインストールができるのでそちらを使います。


#cd /usr/ports/japanese/samba3

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x Options for ja-samba 3.0.31_1,1 x
x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
x x [X] LDAP With LDAP support x x
x x [ ] ADS With Active Directory support x x
x x [X] CUPS With CUPS printing support x x
x x [X] WINBIND With WinBIND support x x
x x [ ] ACL_SUPPORT With ACL support x x
x x [ ] AIO_SUPPORT With Asyncronous IO support x x
x x [ ] FAM_SUPPORT With File Alteration Monitor x x
x x [ ] SYSLOG With Syslog support x x
x x [ ] QUOTAS With Disk quota support x x
x x [X] UTMP With UTMP accounting support x x
x x [ ] PAM_SMBPASS With PAM authentication vs passdb backends x x
x x [ ] CLUSTER With experimental cluster support x x
x x [ ] DNSUPDATE With dynamic DNS update(require ADS) x x
x x [ ] EXP_MODULES With experimental modules x x
x x [X] POPT With system-wide POPT library x x
x x [X] PCH With precompiled headers optimization x x
x x [ ] MAX_DEBUG With maximum debugging x x
x x [ ] SMBTORTURE With smbtorture x x
tqmqqqqqqv(+)qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjqu
x [ OK ] Cancel x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

オプションは特に設定を変えずにデフォルトで使用します。
キーボード左右を[OK]を選択し、キーボードの[Enter]を押します。

ダウンロード、コンパイルが始まりインストールされます。

  :
  :
Installing bin/script.so as ///usr/local/lib/samba/auth/script.so
install -o root -g wheel -m 444 "/usr/ports/japanese/samba3/work/smb.conf.sample" "/usr/local/share/examples/ja-samba/smb.conf.sample"
install -o root -g wheel -m 555 "/usr/ports/japanese/samba3/work/samba-3.0.31/source/script/mksmbpasswd.sh" "/usr/local/bin/make_smbpasswd"
install -s -o root -g wheel -m 555 "/usr/ports/japanese/samba3/work/samba-3.0.31/source/nsswitch/nss_winbind.so" "/usr/local/lib/nss_winbind.so.1"
install -s -o root -g wheel -m 555 "/usr/ports/japanese/samba3/work/samba-3.0.31/source/nsswitch/nss_wins.so" "/usr/local/lib/nss_wins.so.1"
install -s -o root -g wheel -m 555 "/usr/ports/japanese/samba3/work/samba-3.0.31/source/bin/pam_winbind.so" "/usr/local/lib"
===============================================================================
NOTICE: This version of port has changed location of Samba password
NOTICE: (smbpasswd) directory. Files in '/usr/local/private'
NOTICE: have moved to '/usr/local/etc/samba'.
===============================================================================
Samba3 *package* now doesn't include ADS support due the portability problems
with Kerberos5 libraries on different installations. You need to compile port
yourself to get this functionality.

For additional hints and directions, please, look into the README.FreeBSD file.
===============================================================================
===> Installing rc.d startup script(s)
===> Compressing manual pages for ja-samba-3.0.31_1,1
===> Registering installation for ja-samba-3.0.31_1,1
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/bin/smbspool
/usr/local/bin/smbtree
/usr/local/bin/smbcontrol
/usr/local/bin/nmblookup
/usr/local/bin/testparm
/usr/local/sbin/winbindd
/usr/local/bin/smbget
/usr/local/bin/profiles
/usr/local/lib/nss_wins.so.1
/usr/local/bin/smbstatus
/usr/local/bin/pdbedit
/usr/local/bin/net
/usr/local/bin/wbinfo
/usr/local/bin/smbcacls
/usr/local/bin/smbclient
/usr/local/sbin/swat
/usr/local/sbin/nmbd
/usr/local/bin/eventlogadm
/usr/local/bin/rpcclient
/usr/local/bin/ntlm_auth
/usr/local/sbin/smbd
/usr/local/bin/smbpasswd
/usr/local/bin/smbcquotas

This port has installed the following startup scripts which may cause
these network services to be started at boot time.
/usr/local/etc/rc.d/samba

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://www.samba.org/
===> Cleaning for autoconf-2.62
===> Cleaning for libexecinfo-1.1_2
===> Cleaning for cups-base-1.3.8_1
===> Cleaning for popt-1.7_5
===> Cleaning for openldap-client-2.4.11
===> Cleaning for tiff-3.8.2_1
===> Cleaning for gnutls-2.4.1_1
===> Cleaning for libgcrypt-1.4.1_1
===> Cleaning for libgpg-error-1.6_1
===> Cleaning for ja-samba-3.0.31_1,1

で終了。
sambaの設定ファイルを編集します。
#cd /usr/local/etc
設定ファイルsmb.confは最初リードオンリーになっているので書き込み属性を設定します。
#chmod 644 smb.conf

#emacs smb.conf
[smb.conf]
workgroup = <ワークグループ名>

server string = Samba %v on %h FreeBSD

hosts allow = <接続を許可するIPアドレス>

display charset = CP932
unix charset = EUCJP
dos charset = cp932

続いてsambaの起動設定を行います。

#cd /etc
#emacs rc.conf
[rc.conf]

samba_enable="YES"


■いま書きかけ中。

2008年9月15日月曜日

Apache2の帯域制限にmod_cbandを入れてみた!

前回の記事に続いてmod_cbandについてです。
FreeBSD6.3
Apache2.2
なサーバーに
mod_cbandのインストールを行う。
mod_cbandはPortsにもありましたのでこちらからインストールします。


#cd /usr/local/www/mod_cband
#make install clean

===> Vulnerability check disabled, database not found
=> mod-cband-0.9.7.5.tgz doesn't seem to exist in /usr/ports/distfiles/apache2.
=> Attempting to fetch from http://cband.linux.pl/download/.
fetch: http://cband.linux.pl/download/mod-cband-0.9.7.5.tgz: No address record
=> Attempting to fetch from http://www.sfr-fresh.com/unix/privat/.
mod-cband-0.9.7.5.tgz 100% of 69 kB 39 kBps
===> Extracting for mod_cband-0.9.7.5_1
=> MD5 Checksum OK for apache2/mod-cband-0.9.7.5.tgz.
=> SHA256 Checksum OK for apache2/mod-cband-0.9.7.5.tgz.
===> Patching for mod_cband-0.9.7.5_1
===> mod_cband-0.9.7.5_1 depends on file: /usr/local/sbin/apxs - found
===> Configuring for mod_cband-0.9.7.5_1
configure: WARNING: you should use --build, --host, --target
checking for i386-portbld-freebsd6.3-gcc... cc
checking for C compiler default output file name... a.out
:
:
config.status: creating Makefile
===> Building for mod_cband-0.9.7.5_1

/usr/local/sbin/apxs -Wc,-Wall -Wc,-DDST_CLASS=3 -c src/mod_cband.c
/usr/local/build-1/libtool --silent --mode=compile cc -prefer-pic -O2 -fno-strict-aliasing -pipe -I/usr/local/include/mysql -DHAVE_MYSQL_H -I/usr/include -I/usr/local/include/apache22 -I/usr/local/include/apr-1 -I/usr/local/include/apr-1 -I/usr/local/include -Wall -DDST_CLASS=3 -c -o src/mod_cband.lo src/mod_cband.c && touch src/mod_cband.slo
/usr/local/build-1/libtool --silent --mode=link cc -o src/mod_cband.la -rpath /usr/local/libexec/apache22 -module -avoid-version src/mod_cband.lo

write "make install" to install module

===> Installing for mod_cband-0.9.7.5_1
===> mod_cband-0.9.7.5_1 depends on file: /usr/local/sbin/apxs - found
===> Generating temporary packing list
===> Checking if www/mod_cband already installed
/usr/local/sbin/apxs -Wc,-Wall -Wc,-DDST_CLASS=3 -i -a -n cband src/mod_cband.la
/usr/local/share/apache22/build/instdso.sh SH_LIBTOOL='/usr/local/build-1/libtool' src/mod_cband.la /usr/local/libexec/apache22
/usr/local/build-1/libtool --mode=install cp src/mod_cband.la /usr/local/libexec/apache22/
cp src/.libs/mod_cband.so /usr/local/libexec/apache22/mod_cband.so
cp src/.libs/mod_cband.lai /usr/local/libexec/apache22/mod_cband.la
cp src/.libs/mod_cband.a /usr/local/libexec/apache22/mod_cband.a
chmod 644 /usr/local/libexec/apache22/mod_cband.a
ranlib /usr/local/libexec/apache22/mod_cband.a
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/libexec/apache22

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/libexec/apache22/mod_cband.so
[activating module `cband' in /usr/local/etc/apache22/httpd.conf]
===> Registering installation for mod_cband-0.9.7.5_1
===> Cleaning for mod_cband-0.9.7.5_1

#cd /usr/local/etc/apache22/
#emacs httpd.conf

例:www.example.comに4週間で100MBの転送量制限をして、超えた場合には最大速度を 128kbps、リクエストを 5、同時接続数を 15 にする


# <VirtualHost 1.2.3.4>
ServerName www.example.com
ServerAdmin webmaster@example.com
DocumentRoot /var/www
CBandLimit 100M
CBandExceededSpeed 128 5 15
CBandScoreboard /var/www/scoreboard
CBandPeriod 4W
#</VirtualHost>



ドキュメントはこちら
mod_cband documentation.txt

CBandRemoteSpeed 1M 3 3
CBandExceededSpeed 


現在書きかけ中の記事です。


.

Apache2.2 帯域制限をかける mod_cband最強?mod_bandwidth mod_bwshare... どれがいい?

しばらくサイトを運営していると、サーバーに接続するクローラーやダウンローダーなどが、帯域を占有し、ブラウザの表示が遅くなったり、レスポンスが遅くなりすぎてエラーが出るようになってきた。そこで、そのような一般ユーザーよりも強烈なダウンロードをおこなうユーザーやソフトの帯域を制限するためにApacheに帯域制限モジュールを導入しようと考えた。
ところが、この帯域制限モジュールはたくさんあり、どれが最適なのかよくわからない。
Apache1.3、Apache2初期のころの評価記事は見つけることができるが、Apache2.2の情報をまとめたものがなかなかみつからない。








モジュール名対応ApachePortsコメント
mod_cbandApache2.0-YesVirtualHostごとに帯域制限をかけ月間転送量、同時接続数、転送速度を指定できる。
クライアントごとも可能。http://www.howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling http://cband.linux.pl/documentation
mod_bw Apache1.3 Apache2.0-2.2Yesセッションごとの転送帯域の制限
mod_bandwidthApache1.2-1.3Yes2.0対応になりmod_bwに名前が変わった?
mod_bwshare pache1.2-1.3 Apache2.0-2.0.55Yesファイル数バイト数の設定値を超えると503エラーを返す
mod_tsunamiApache1.3Yes


http://cowscorpion.com/Network/mod_cband.html より
-----
mod_cband は転送量やダウンロード速度の制限や同時接続数の制限などができる Apache 2 サーバーのモジュールです。
 mod_cband は従来の帯域制限モジュール (mod_bandwidth, mod_limitipconn, mod_curb) を合わせ、Apache 2で使えるように作られたもので、サーバー全体やバーチャルホストごと、またはIPごとに帯域/転送量の制限、最大のダウンロード速度の制限、一秒間のリクエスト数(Requests per Second)、最大の同時接続数(maximum number of simultaneous IP connections) の制限をすることができるます。
 サーバーのユーザーに「10GB/月 」などのデータ転送量の制限をしたり、クライアント毎にダウンロード速度や同時接続数の制限を行いたい場合などに使うことができます。
-----
だそうな。mod_cband最強?
http://www.sfr-fresh.com/unix/privat/mod-cband-0.9.7.5.tgz:a/mod-cband-0.9.7.5/doc/documentation.txt

でも、mod_cbandが最強みたいです。
あぁ。。。たしかに最強かも。


ほかにもこんなアパッチモジュールがあるみたいです。
一応覚書。以下調べるのやめました(爆)
mod_access_limit
mod_bandwidth
mod_bwshare 接続数、帯域、容量での制限を行う
mod_choke
mod_conn
mod_curb
mod_dosevasive
mod_limitipconn 接続数での制限を行う
mod_throttle
mod_traf_thief
mod_tsunami
mod_vhost_limit

.

2008年9月14日日曜日

sendmail_enable="NONE"ではsendmailが自動起動している

FreeBSD6.3にて

ふと、
$ps -ax
としてみたらsendmailが起動していた。
/etc/rc.confには
sendmail_enable="NONE"
とちゃんと間違いなく記入されているのに。
なんで?
とネットで調べてみましたら、この記述方法はもう古い方法だったみたいで
sendmail_enable="NONE"は使われなくなったそうです。

すべてのプロセスを止めるには

sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

とするようです。


マニュアルはこちら
rc.sendmail

お。起動しなくなった。
.

2008年9月3日水曜日

Rubyでコンストラクタの多重定義(オーバーロード,オーバーローディング) ってできないの?

Rubyでコンストラクタの多重定義(オーバーロード,オーバーローディング) ってできないの?

出来ないらしい。
そもそも、メソッド(関数)の多重定義が出来ないから出来ないのもあたりまえ。

コンストラクタを多重定義するには、スタティック(静的)関数を定義すると出来る。




class Vector


def initialize(x,y)
 @x = x
 @y = y
end

def self.NewUnit()
 obj = Vector.new(1,1)
 return obj
end


end


v1 = Vector.new(3,4)
p v1

v2 = Vector.NewUnit()
p v2




def self.NewUnit()

で静的なメソッドを定義し、その中でオブジェクトを作成し戻り値にし返します。

v2 = Vector.NewUnit()

のような形でオブジェクトの生成が出来るようになるわけです。
もし、メソッド名initialize()で多重定義関数のような振る舞いをさせるには、
Rubyでは引数にいろいろな型を渡すことができるので、initialize()内で
渡された引数の型を調べ内部で分岐するようにすれば出来ます。しかし、それではあまりにも美しくないし、バグの温床にもなりおすすめできません。
メソッドを分けて作ったほうがいいでしょう。