2012年4月12日木曜日

SPDY 構築太郎

やっと構築までこぎつけたので、一旦メモで。

SPDYとはGoogleが策定を進めている通信プロトコルらしく
HTTPよりはやいお!!ってことらしい。

gmail、googlecalenderとか、Twitterとかが実装しているらしい太郎。

なんかみたところ、通常のHTTPの50%近くの高速化を目標としているらしい。
今後の主流となること間違いないという予想太郎。

ただ、Firefox11系と、Choromeの最新版?でしか対応してないので
大規模サービスの画像配信とかで使うにはちょっと難しいのかな・・・

まあ、apacheのモジュール公開されてたんで構築してみた。
環境は、Ubuntu 11.04


#まずは事前準備
apt-get install subversion curl g++ apache2 patch binutils julius make

#任意のディレクトリで

mkdir mod_spdy
mkdir temp
cd temp

#depot_tools持ってくる
svn co http://src.chromium.org/svn/trunk/tools/depot_tools

#PATH通す
export PATH="$PATH":`pwd`/depot_tools
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/yattarou/temp/depot_tools

#SPDYのコード落としてくる ちなみにrootで実行してる
gclient config "http://mod-spdy.googlecode.com/svn/trunk/src"
Running depot tools as root is sad.
#失敗したw

#gclientソース見てみる
#base_dirんとこでうまくいってないっぽいので、パワープレイ。
#パス直書きにしてやったw
vim /home/yattarou/temp/depot_tools/gclient

#!/usr/bin/env bash
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

base_dir=$(dirname "$0")

"$base_dir"/update_depot_tools

PYTHONDONTWRITEBYTECODE=1 exec python "$base_dir/gclient.py" "$@"

#もっかいチャレンジ
/home/yattarou/temp/depot_tools/gclient config "http://mod-spdy.googlecode.com/svn/trunk/src"
Running depot tools as root is sad.

#失敗した
#update_depot_toolsのコードみる
#rootの権限チェック、コメントアウトした。
vim /home/yattarou/temp/depot_tools/update_depot_tools

#!/usr/bin/env bash
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This script will try to sync the bootstrap directories and then defer control.

if [ "$USER" == "root" ];
then
echo Running depot tools as root is sad.
exit
fi

#もっかいやってみる
/home/yattarou/temp/depot_tools/gclient config "http://mod-spdy.googlecode.com/svn/trunk/src"

#いけたぽいので
/home/udagawa/temp/depot_tools/gclient sync --force
1>________ running 'svn checkout http://mod-spdy.googlecode.com/svn/trunk/src /home/udagawa/mod_spdy/src --non-interactive --force --ignore-externals' in '/home/yattarou/mod_spdy'
・・・・
いっぱいおとしてくる。

26>Checked out revision 933.
Syncing projects: 96% (26/27), done.ols/gyp

________ running '/usr/bin/python src/build/gyp_chromium' in '/home/yattarou/mod_spdy'
Updating projects from gyp files...

#落としてきたら


cd src/
./build_modssl_with_npn.sh

#.soをコピー
cp -rp mod_ssl.so /usr/lib/apache2/modules/
a2enmod ssl

#おれおれ証明書作成
apt-get install ssl-cert

make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /tmp/selfsigned.crt
mkdir /etc/apache2/ssl
mv /tmp/selfsigned.crt /etc/apache2/ssl/

#証明書の設定編集
vim /etc/apache2/sites-available/default-ssl

SSLCertificateFile /etc/apache2/ssl/selfsigned.crt
#コメントアウト
#SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

a2ensite default-ssl

#apache再起動
/etc/init.d/apache2 restart

#SPDYのBUILD
make BUILDTYPE=Release
・・・・
#いっぱいでる

cp out/Release/libmod_spdy.so /usr/lib/apache2/modules/mod_spdy.so
echo "LoadModule spdy_module /usr/lib/apache2/modules/mod_spdy.so" | tee /etc/apache2/mods-available/spdy.load
echo "SpdyEnabled on" | tee /etc/apache2/mods-available/spdy.conf

a2enmod spdy
Enabling module spdy.
Run '/etc/init.d/apache2 restart' to activate new configuration!

#apache再起動
/etc/init.d/apache2 restart


#これでおk
#下のでいろいろ見れる
chrome://net-internals/#spdy

#あと、SPDY用のベンチマークツール
#windowsで確認するとき、chrome.exe --enable-benchmarkingしないと起動しないので注意
http://dev.chromium.org/developers/design-documents/extensions/how-the-extension-system-works/chrome-benchmarking-extension


すこし、確認したところ、まあまま早い感じがする。
検証結果は、あとでちゃんと載せます。

2012年4月10日火曜日

glusterFS(Distribute)構築太郎

GlusterFSを構築するお。

環境は、ubuntu 11.04とかCentOS5.4。とりあえず作ってみたかったので
バラバラです。

事前に
・python2.4以上
・python-crypt
・flex
・bison
いれた。

コマンドの結果、とり忘れたのであとでつけますね。


#まずは、FUSEから。
tar zxvf fuse-2.8.7.tar.gz
./configure
make && make install

#FUSE読み込み
modprobe fuse
dmesg | grep -i fuse
#fuse init (API version 7.13)

#次、gluster。
tar zxvf glusterfs-3.2.6.tar.gz
./configure
make && make install

#インストールすると、/etc/glusterd配下にディレクトリ・ファイルが展開される。
# ls -lHR
.:
total 4
drwxr-xr-x 2 root root 24 Apr 12 03:25 geo-replication
-rw-r--r-- 1 root root 42 Apr 12 03:25 glusterd.info
drwxr-xr-x 2 root root 6 Apr 12 03:25 nfs
drwxr-xr-x 2 root root 6 Apr 12 03:25 peers
drwxr-xr-x 2 root root 6 Apr 12 03:25 vols

./geo-replication:
total 4
-rwxr-xr-x 1 root root 1137 Apr 12 03:25 gsyncd.conf

./nfs:
total 0

./peers:
total 0

./vols:
total 0

#glusterFS 起動 ( 各サーバで)
/etc/init.d/glusterd start

#ディレクトリほる
mkdir /gluster_data

#peerの作成 (各ノード間で信頼関係をつくるらしい)

#まずはpeerの状態確認
/usr/local/sbin/gluster peer status
No peers present

#peerはる
/usr/local/sbin/gluster peer probe xxx.xxx.xxx.xxx
Probe successful

#peerの状態確認
/usr/local/sbin/gluster peer status
Number of Peers: 1

Hostname: xxx.xxx.xxx.xxx
Uuid: ad0bb29e-f91b-4053-8ab0-9a90adbd095e
State: Peer in Cluster (Connected)

#volumeの作成(今回は、とりあえず全ノードの領域を使う方法にしました。ほかに、stripe、replicaがあるみたいす。あとでやり方あげます)

/usr/local/sbin/gluster volume create gluster-vol xxx.xxx.xxx.xxx:/gluster_data xxx.xxx.xxx.xxx:/gluster_data
Creation of volume gluster-vol has been successful. Please start the volume to access data.

#volume確認
/usr/local/sbin/gluster volume info

Volume Name: gluster-vol
Type: Distribute
Status: Created
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: xxx.xxx.xxx.xxx:/gluster_data
Brick2: xxx.xxx.xxx.xxx:/gluster_data

#volume 起動
/usr/local/sbin/gluster volume start gluster-vol
Starting volume gluster-vol has been successful

#確認
/usr/local/sbin/gluster volume info

Volume Name: gluster-vol
Type: Distribute
Status: Started
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: xxx.xxx.xxx.xxx:/gluster_data
Brick2: xxx.xxx.xxx.xxx:/gluster_data

#各Clientからmount
mount -t glusterfs -o log-level=WARNING,log-file=/var/log/gluster.log xxx.xxx.xxx.xxx:gluster-vol /mnt/glusterfs

#これでとりあえず使えます。
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 1.9T 3.4G 1.9T 1% /
none 5.9G 204K 5.9G 1% /dev
none 5.9G 0 5.9G 0% /dev/shm
none 5.9G 48K 5.9G 1% /var/run
none 5.9G 0 5.9G 0% /var/lock
none 5.9G 0 5.9G 0% /lib/init/rw
/dev/sdb1 51T 11G 51T 1% /gluster_data
/dev/sda1 472M 27M 422M 6% /boot
xxx.xxx.xxx.xxx:gluster-vol
52T 17G 52T 1% /mnt/glusterfs

#こんなファイルできてる
/etc/glusterd# ls -lhR
.:
total 4.0K
drwxr-xr-x 2 root root 24 Apr 12 03:25 geo-replication
-rw-r--r-- 1 root root 42 Apr 12 03:25 glusterd.info
drwxr-xr-x 3 root root 37 Apr 12 03:42 nfs
drwxr-xr-x 2 root root 49 Apr 12 03:34 peers
drwxr-xr-x 3 root root 24 Apr 12 03:40 vols

./geo-replication:
total 4.0K
-rwxr-xr-x 1 root root 1.2K Apr 12 03:25 gsyncd.conf

./nfs:
total 4.0K
-rw-r--r-- 1 root root 1.3K Apr 12 03:42 nfs-server.vol
drwxr-xr-x 2 root root 20 Apr 12 03:42 run

./nfs/run:
total 64K
-rw-r--r-- 1 root root 6 Apr 12 03:42 nfs.pid

./peers:
total 4.0K
-rw-r--r-- 1 root root 74 Apr 12 03:34 ad0bb29e-f91b-4053-8ab0-9a90adbd095e

./vols:
total 4.0K
drwxr-xr-x 4 root root 4.0K Apr 12 03:42 gluster-vol

./vols/gluster-vol:
total 24K
drwxr-xr-x 2 root root 66 Apr 12 03:42 bricks
-rw-r--r-- 1 root root 16 Apr 12 03:42 cksum
-rw-r--r-- 1 root root 1.2K Apr 12 03:40 gluster-vol-fuse.vol
-rw-r--r-- 1 root root 995 Apr 12 03:40 gluster-vol.xxx.xxx.xxx.xxx.gluster_data.vol
-rw-r--r-- 1 root root 995 Apr 12 03:40 gluster-vol.xxx.xxx.xxx.xxx.gluster_data.vol
-rw-r--r-- 1 root root 174 Apr 12 03:42 info
-rw-r--r-- 1 root root 12 Apr 12 03:42 rbstate
drwxr-xr-x 2 root root 39 Apr 12 03:42 run

./vols/gluster-vol/bricks:
total 8.0K
-rw-r--r-- 1 root root 75 Apr 12 03:42 xxx.xxx.xxx.xxx:-gluster_data
-rw-r--r-- 1 root root 71 Apr 12 03:42 xxx.xxx.xxx.xxx:-gluster_data

./vols/gluster-vol/run:
total 64K
-rw-r--r-- 1 root root 6 Apr 12 03:42 xxx.xxx.xxx.xxx-gluster_data.pid

#/etc/glusterd/glusterd.infoの中身
cat glusterd.info
UUID=e0548668-aec6-49c0-96e7-46761d97015d

#/etc/glusterd/nfs//nfs-server.volの中身
/etc/glusterd/nfs# cat nfs-server.vol

#各clientの情報
volume gluster-vol-client-0
type protocol/client
option remote-host xxx.xxx.xxx.xxx
option remote-subvolume /gluster_data
option transport-type tcp
end-volume

volume gluster-vol-client-1
type protocol/client
option remote-host xxx.xxx.xxx.xxx
option remote-subvolume /gluster_data
option transport-type tcp
end-volume

#volumeの情報?
volume gluster-vol-dht
type cluster/distribute
subvolumes gluster-vol-client-0 gluster-vol-client-1
end-volume

#writeのパラメータ。バックグラウンドで遅延書き込みするってことみたい。
volume gluster-vol-write-behind
type performance/write-behind
subvolumes gluster-vol-dht
end-volume

#readのパラメータ。read-aheadってことは先読みか。
volume gluster-vol-read-ahead
type performance/read-ahead
subvolumes gluster-vol-write-behind
end-volume

#cacheのパラメータ。clientとserver間の接続のパラメータみたい。
volume gluster-vol-io-cache
type performance/io-cache
subvolumes gluster-vol-read-ahead
end-volume

#こっから下まだ調べてない
volume gluster-vol-quick-read
type performance/quick-read
subvolumes gluster-vol-io-cache
end-volume

volume gluster-vol
type debug/io-stats
option latency-measurement off
option count-fop-hits off
subvolumes gluster-vol-quick-read
end-volume

volume nfs-server
type nfs/server
option nfs.dynamic-volumes on
option rpc-auth.addr.gluster-vol.allow *
option nfs3.gluster-vol.volume-id dc957ba2-188a-48bf-8c80-e6899ed999c7
subvolumes gluster-vol
end-volume

#↑のパラメータは、http://www.gluster.org/community/documentation/index.php/Translators/performanceに結構書いてあるので後でまとめます。


結構チューニングするとこ多そうなので、調べなきゃ。

LSI9285 - Potential non-optimal configuration太郎

Megaraid9285のFWを21.0.1-0111 → 23.1.1-0004にしたところ、ストレージがピーピー言っておる。

しらべた。


#ログだす
/opt/MegaRAID/MegaCli/MegaCli64 -AdpEventLog -GetEvents -f /home/yattarou/getlog.log -a0

#確認する 一部抜粋
#各physical disk(計8本)で、下記のメッセージがでていた。
#見る限り、おで、emergency spareになるよってことだと思う。
===========
Device ID: 14
Enclosure Index: 252
Slot Number: 5


seqNum: 0x0000070d
Time: Wed Mar 28 14:11:21 2012

Code: 0x00000196
Class: 1
Locale: 0x02
Event Description: Reminder: Potential non-optimal configuration due to drive PD 0f(e0xfc/s4) commissioned as emergency spare
Event Data:
===========



確認する限り、ディスクのread,write、RAIDの状態には問題なさそう。
ただDiskが死んだ時、変な動きをしそうなのでLSIさんに問い合わせてみた。

結果、farmのバグらしく下のlinkから最新版を当てたらなおった。
2週間もたたないくらいで直してくれました。ありがとうございます。

http://www.lsi.com/products/storagecomponents/Pages/MegaRAIDSAS9285-8e.aspx

Version:23.4.1-0028

です。