2010年1月20日水曜日

abコマンドによるApacheサーバーの測定

Apacheサーバーの読み込み速度の向上を目指す。

まずは測定から
1回目

[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxx-net.jp (be patient).....done


Server Software:        Apache
Server Hostname:        xxxx-net.jp
Server Port:            80

Document Path:          /
Document Length:        37584 bytes

Concurrency Level:      10
Time taken for tests:   28.921658 seconds
Complete requests:      100

Failed requests: 79   (Connect: 0, Length: 79, Exceptions: 0)
Write errors:           0
Total transferred:      826546 bytes
HTML transferred:       789264 bytes
Requests per second:    3.46 [#/sec] (mean)
Time per request:       2892.166 [ms] (mean)
Time per request:       289.217 [ms] (mean, across all concurrent requests)
Transfer rate:          27.90 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       51  887 2012.3     64    7519
Processing:   290 1933 2688.8   1083   15819
Waiting:      289 1864 2673.5   1063   15819
Total:        393 2821 3243.5   1224   15896

Percentage of the requests served within a certain time (ms)
  50%   1224
  66%   2863
  75%   3277
  80%   3749
  90%   7847
  95%  10987
  98%  15701
  99%  15896
 100%  15896 (longest request)
「Failed requests: 79」なんでだろう?

2回目
[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking tachibana-net.jp (be patient).....done


Server Software:        Apache
Server Hostname:        xxxx-net.jp
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   22.197865 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      36400 bytes
HTML transferred:       0 bytes
Requests per second:    4.50 [#/sec] (mean)
Time per request:       2219.786 [ms] (mean)
Time per request:       221.979 [ms] (mean, across all concurrent requests)
Transfer rate:          1.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       52  513 1073.0     64    3177
Processing:   285 1652 2012.3    989   13347
Waiting:      285 1651 2012.3    989   13346
Total:        339 2165 2563.8   1283   16357

Percentage of the requests served within a certain time (ms)
  50%   1283
  66%   1750
  75%   2931
  80%   3542
  90%   4922
  95%   7382
  98%  11485
  99%  16357
 100%  16357 (longest request)

3回目
[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking tachibana-net.jp (be patient).....done


Server Software:        Apache
Server Hostname:        xxxx-net.jp
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   29.39944 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      36400 bytes
HTML transferred:       0 bytes
Requests per second:    3.44 [#/sec] (mean)
Time per request:       2903.994 [ms] (mean)
Time per request:       290.399 [ms] (mean, across all concurrent requests)
Transfer rate:          1.21 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       52  954 2424.7     65    9165
Processing:   288 1633 2457.4    965   13319
Waiting:      288 1632 2457.3    963   13318
Total:        341 2587 3746.6   1221   21347

Percentage of the requests served within a certain time (ms)
  50%   1221
  66%   1653
  75%   2385
  80%   2710
  90%   8585
  95%  10120
  98%  20832
  99%  21347
 100%  21347 (longest request)


次回から
1.Apacheのキャッシュ機能を有効にした場合
2.PHPのアクセラレーターを使った場合
3.Xoopsモジュールのキャッシュを使用した場合

を調べてみることにします。どうなることやら・・・

RPMforgeインストール&使い方

Perlモジュールパッケージ管理システム導入(cpan2rpm)において、RPMforgeのインストールが必要となったので、その方法を記述。

RPMforgeとは?
サードパーティのRPMパッケージ郡の事で、正規RPMではサポートされていない部分までサポートしてくれるリポジトリです。

1.RPMforgeインストール

# wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

2.プラグインインストール
# yum -y install yum-priorities

3.設定変更
# vi /etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
※追加

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
※追加

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
※追加

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
※追加

以上

2010年1月18日月曜日

Apache Server カスタマイズ??

Apacheのカスタマイズについて記事を拾ってみた。
そのうち時間ができたら検証してみることに・・・

まずは参照サイトを記述

GIGAZINE

ここを参照に随時トライしてみようと思う・・・

1.BufferedLogs ディレクティブの変更
参考
apacheのコンフィグファイルにBufferedLogsディレクティブをonにする

BufferedLogs on
後は、ab(apache bench)で検証しよう。

2.mod_mem_cacheの有効化
参考1  参考2
テストした環境はDSO環境なのでApacheへのモジュール有効化はLoadModuleで行うこと。
気をつける点はmod_mem_cacheは mod_cacheのサポートモジュールとして動作するので、
モジュールを有効にする場合はmod_cacheとセットで扱うこと。
<ifmodule mod_mem_cache.c="">
CacheEnable mem /
MCacheSize 262144
MCacheMaxObjectCount 100000
MCacheMinObjectSize 1
MCacheMaxObjectSize 131072
</IfModule>

2010年1月13日水曜日

ulogd「IPTables log analyzer」のインストール

CentOSで自宅サーバー構築を参考にサイトを構築しているが、

40.2.iptablesログ解析(IPTables log analyzer)

■ulogdインストール
 ここで問題発生

[root@centos /] # ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/local/lib --with-mysql
[root@centos /] # make
ulogd_MYSQL.c:174: 警告: format '%lld' expects type 'long long int', but argument 3 has type 'int64_t' ulogd_MYSQL.c:206: 警告: format '%llu' expects type 'long long unsigned int', but argument 3 has type 'u_int64_t'
ld -shared -rdynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto -o ulogd_MYSQL.so ulogd_MYSQL_sh.o -lc
ld: bad -rpath option
make[1]: *** [ulogd_MYSQL.so] エラー 1
make[1]: ディレクトリ `/root/work/ulogd/ulogd-1.24/mysql' から出ます
make: *** [recurse] エラー 1

Makeがうまくいかないみたい!いろいろなサイトを見てみると、どうも -rdynamic がいけないみたい。 で
Rules.make を編集(-rdynamic オプションを削除)
# mysql output support
#ULOGD_SL+=MYSQL
MYSQL_CFLAGS=-I-I/usr/include/mysql -DOLD_MYSQL=1
#MYSQL_LDFLAGS= -rdynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto
MYSQL_LDFLAGS= -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto
再度
[root@centos /] # make
[root@centos /] # make install

今度は成功!良し良し

2010年1月4日月曜日

VMware WorkstationのBIOSを変更してOEM版Windowsの認証を回避できるみたい!

これは面白い!メモ、メモ

まずは変更するBIOSファイルを入手します。腕のある方なら自分で作ってもOK。

・Bios Build v.295 for VMWare v6.5.3 (Dell Slic 2.1 + Multi SLP 1.0)
http://rapidshare.com/files/297106763/VM.DELL.SLIC.21.SLP.IMAGE.rar
・Bios Build v.314 for VMWare v7.0.0 (Dell Slic 2.1 + Multi SLP 1.0)
http://rapidshare.com/files/310472637/VM.314.DELL.SLIC.21.MULTI-SLP.10.IMAGE.ROM
・Bios Build v.314 for VMWare v7.0.0 (Dell Slic 2.1 + Multi SLP 1.0 + XP Mode Activation)
http://rapidshare.com/files/310879279/VM.314.DELL.SLIC.21.MULTI-SLP.10.XP-MODE.IMAGE.ROM
どれかファイルを入手したら、早速実験。
まずは普通通りにVMwareで仮想マシンを作成。

そして作成された仮想マシンの.vmxファイルに、以下ようにBIOSファイル名の文字を追記。
bios440.filename = "VM.DELL.SLIC.21.SLP.IMAGE.ROM"
そのあと、.vmxファイルと同じ場所にBIOSファイルを置いてあげれば準備完了。
この状態で仮想マシンを起動させ、次のような感じでBIOS画面が変更されていれば成功。


DELL SLIC v2.1と表示されます。
あとは普通にOEMのディスクでWindowsをインストールすれば、アクティベーション無しです。

VMware Workstation7 で USB2 の有効化

vmx ファイルに以下の行を追加

usb.present = "TRUE" # USB を利用
ehci.present = "TRUE" # EHCI コントローラを有効化
これで有効化できました。

リダイレクトの仕方

サーバーのログを見ていると、以前のトップファイル(あえてtop.phpとしていた)にアクセスする人がかなり多い。
もしかしたら、ページが表示されなくて未だに閉鎖中と思う方も多いと思ったので、リダイレクトしホームページを見ていただくようにした。

ネットで調べてみると幾つかの方法があるようです。
おもなリダイレクトの方法のなかから三つを試してみた。

  1. 301リダイレクトと呼ばれる方法で、.httaccessを使うなどして行うもの。
  2. HTML<meta http-equiv="Refresh" ...>を使う方法
  3. JavaScriptのlocation.href、またはlocation.replace()を使う方法
1.301リダイレクト
サーバー側に.htaccessを設置する方法。具体的なコードは以下。
Redirect permanent /top.php http://hogehoge.jp/index.php
Redirect permanent /top.html http://hogehoge.jp/index.php

top.phpにアクセスした場合に、index.phpにリダイレクトする
top.htmlにアクセスした場合に、index.phpにリダイレクトする

2.HTMLファイルのヘッダーに直接書き込む方法
head要素内に下記のようなコードを書けば良いだけです。簡単。しかし・・・
<meta http-equiv="Refresh" content="0; URL=/index.php">
/index.php に0秒後にリダイレクトする
*古いURLにリダイレクト用のHTMLを残しておかねばならない。

3.JavaScriptを使ってリダイレクトする
しかしlocation.hrefを使うと"「戻る」ボタンで戻れない問題"が発生するので、履歴の残らないlocation.replace()の方がいいかも(こちらでは戻れる)。
この手法も古いURLにリダイレクト用のHTMLファイルを置いておかねばならないという点で、1.に劣る。

したがって、今回は1.301リダイレクトの手法を選択した。