ラベル Linux の投稿を表示しています。 すべての投稿を表示
ラベル Linux の投稿を表示しています。 すべての投稿を表示

2015年12月3日木曜日

Ubuntu でMSSの値を変える。

ファイルを新規作成
sudo vi /etc/network/if-up.d/mtu

以下の内容をファイルに書き込む。
#!/bin/sh
/sbin/ifconfig eth0 mtu 1345

ファイルが出来ている事を確認。
ls -al /etc/network/if-up.d/

ファイルの中身があっている事を確認。
more /etc/network/if-up.d/mtu

再起動
sudo shutdown -fr now

設定値が反映されている事を確認。
ifconfig

2010年9月2日木曜日

LinuxへのJDK Installメモ

http://java.sun.com/javase/ja/6/download.html
chmod +x jdk.bin
./jdk.bin

CentOS系だと下記のパスにはいるらしい
/usr/java/jdk1.6.0_23/

2010年6月9日水曜日

Linux版のTTCP

取り敢えずwikiに纏めたのはこっち

sudo apt-get install gcc
wget http://ftp.uni-koeln.de/net/performance/ttcp/ttcp.tar.gz
tar xzf ttcp.tar.gz
cd ttcp
cc -o ttcp ttcp.c
受信側
./ttcp -r -s >>/deb/null
送信側
./ttcp -t -s ${受信側IP} >>/deb/null

注意点として、引数「-s」の機能がWindows版のTTCPと真逆の意味を有しいるので気をつける事。
Windows版での-sなし → Linux版での-sあり
Windows版での-sあり → Linux版での-sなし

2009年7月27日月曜日

NFSのError

NFS: short packet in readdir reply!
というErrorが出ていた。気になったので調べて見ると
■nfs problem: hp-server --- linux 2.4.13 client, ooops
というWebを発見。気になる文章はこれ。

Kernel version: 2.4.13 (up and smp), Trond's seekdir patch, ext3 patch
Hardware: P4 1700 (1 and 2), 2 GB RAM.
Compiled with RedHat 7.1 gcc (2.96-85)
nfs-Server: HP-UX 10.20

Without the nfs patch I had a lot of trouble with Irix servers - now Irix,
NetApp, Aix, Linux... nfs- servers are fine, but connecting to a HP server
leads to statements like this in the syslog:
NFS: short packet in readdir reply!

Even worse: Accessing one particular directory (using ls, find etc) leads
to a segmentation fault in the accessing process. The machine stays up and
running, but some other processes (without relationship to nfs mount) die a
sudden death as well.

There is nothing special about the directory on the nfs server.
There is no problem with Linux 2.2.14-5.0smp. I can check with other 2.4
versions if necessary. The problem is independent of the nfs version.

さて意訳。間違ってたら指摘をお願いします。
Kernel version: 2.4.13 (up and smp), Trond's seekdir patch, ext3 patch
Hardware: P4 1700 (1 and 2), 2 GB RAM.
Compiled with RedHat 7.1 gcc (2.96-85)
nfs-Server: HP-UX 10.20

Patch未適用下のIrixサーバで多数の問題に遭遇した。
Irix、NetApp、Aix、Linux、NFS-Server等は正常に動作しているが、HPのサーバへ接続しようとするとシステムログにこの様な文言が残っている。
NFS: short packet in readdir reply!
酷い時には、とあるDirectoryにAccessするとそのAccessをしたProcessがSegmentation Faultを起こしてしまう。
サーバ自体は問題なく動いているが、NFSマウントとは無関係な他のProcessまでもが同じように突然死んでしまう。
問題を起こしたDirectoryやNFSServerに対して特に変わった事はやっていない。
私は2.2.14-5smp利用下ではこの問題に遭遇しなかった。もし必要であれば他の2.4kernelでも試す事は出来る。


でこの人に対するレスがこれ
That particular Oops should already be fixed in 2.4.14.

そのバグは2.4.14kernelで直ってるぜ!

うーむ・・・。
でそれに問題投げた人がレスしてる。
Thanks, I've tried 2.4.15pre5 (+ seekdir patch) now and could not
reproduce the Ooops with the HP nfs server. But still: The Kernel
complains about: "NFS: short packet in readdir reply!" when I access
any directory provided by a HP-UX 10.20 nfs-server (using nfs2 |
nfs3). I dont' notice any strange behaviour other than that, though.

But a new problem emerged: Copying from a linux (2.4.13 | 2.4.15pre5)
nfs-client onto an AIX nfs-server doesn't work. About 800kb are copied
then the cp command just hangs. Syslog says:
Nov 16 11:51:12 capc20 kernel: nfs: server caes04 not responding, still trying
This problem only occures with nfs3, and not with nfs2.

意訳。
2.4.15pre5 (seekdir修正適用)環境で試してみたら、この問題は起きなかった。
気持ち悪い事にそれでもHP-UXでNFS2/3を使ったNFS-ServerDirectoryにAccessした際の「NFS: short packet in readdir reply!」というエラーログは消えなかった。

なお別のErrorが発生した。
NFS ClientであるLinux(2.4.13 | 2.4.15pre5)からAIXのnfs-serverへ接続すると動かない。例えば800KBのファイルをコピーするとハングアップしてしまい、シスログには下記の様なErrorが残っている。
Nov 16 11:51:12 capc20 kernel: nfs: server caes04 not responding, still trying
このErrorはNFS3を使った時に起き、NFS2を使うと起きない。
何かそう難しくない修正方法を知っているなら教えて欲しい。


という訳でNFSの通信をNFSのver2に制限する方法を探す。
これだ。
■[ロ] NFSのバージョン設定

2009年7月8日水曜日

ChromeOS Ready!

■Google、ネットブック向けOS「Google Chrome OS」を開発
キタ━━━━━(゚(゚∀(゚∀゚(☆∀☆)゚∀゚)∀゚)゚)━━━━━!!
これは楽しみ。取り敢えずまず速攻いれる。
そしてノートではなくてServerで使いたい。

あと気になるのはARM対応という事。
最近注目を浴びてるARMとえばnvidiaのTegra。GoogleChromeOSはTegraでも動く訳だ。
これはひょっとするとひょっとするかもしれない・・・

2009年6月22日月曜日

CentOSにZabbixのClientを入れる。

CentOS5.3にZabbixのClientだけ入れてみる。
yumでとれる様にyumの検索先を追加。
vi /etc/yum.repos.d/zabbix-jp.repo

でファイルを開いたら書きの設定を書き加える。
[zabbix-jp]
name=ZABBIX-JP
baseurl=http://www.zabbix.jp/rpms/rhel5/$basearch/
gpgcheck=0
enabled=1
で追加完了。

yum install zabbix-agent
で入る。

続いて設定ファイルを変更する。下記二つのファイルを編集する。
vi /etc/zabbix/zabbix_agent.conf
vi /etc/zabbix/zabbix_agentd.conf

で開いてserver=127.0.0.1の部分を正しいZabbix-ServerのIPに変更する。

ZabbixをUbuntuに入れる

Server負荷監視Softを入れる。Nagiosに続いてZabbixを入れてみる。
■Zabbix公式
環境は勿論Ubuntu 9.04 Server。MySQLやphpが必要なのでInstall時の選択でLAMPにCheckを入れておく事。
参考資料はこちら。
■ZABBIXインストール
■ZABBIXフロントエンドのインストール
■統合監視ツールZABBIX事始め
Zabbixの基本概念
ホスト・・・監視対象の事
アイテム・・・監視対象項目の事

■Zabbix ServerのInstall。
sudo apt-get install zabbix-server-mysql
Install途中でMySQLのRootのPassword、Zabbix用のPasswordの設置を要求されるので適宜設置する。

■Zabbix AgentのInstall
必要であれば、Agentも入れる。
sudo apt-get install zabbix-agent


■Zabbix ServerのFrontEndのInstall。
sudo apt-get install zabbix-frontend-php
ここでもMySQLのPasswordが聞かれるので適宜入力。これで基本は終わり。
後々色々設定する必要がある項目を今の内にやって、Apache2再起動
・タイムゾーンの設定
・各スクリプトの最大実行時間
・設定ファイルの読み込み権限
sudo echo date.timezone=Asia/Tokyo >> /etc/php5/apache2/php.ini
sudo echo max_execution_time=300 >> /etc/php5/apache2/php.ini
sudo chown www-data:www-data /etc/zabbix/dbconfig.php
sudo chown zabbix:zabbix /etc/zabbix/zabbix_*.conf
sudo chmod 666 /etc/zabbix/dbconfig.php
sudo chmod 666 /etc/zabbix/zabbix_*.conf (Agentでも必要)
sudo mkdir /var/run/zabbix-agent (Agentで必要)
sudo mkdir /var/run/zabbix-server
sudo chown zabbix:zabbix /var/run/zabbix-* (Agentでも必要)
sudo chmod 775 /var/run/zabbix-* (Agentでも必要)
sudo echo zabbix_agent 10050/tcp >> /etc/services (Agentで必要)
sudo echo zabbix_trap 10051/tcp >> /etc/services
sudo /etc/init.d/apatch2 restart
これで終了。
http://${いれた鯖のIP}/zabbix/
で画面にAccess出来る。初期ID/Passはadmin/zabbix。

■設定ファイルの変更
sudo vi /etc/zabbix/zabbix_agent.conf
sudo vi /etc/zabbix/zabbix_agentd.conf
sudo vi /etc/zabbix/zabbix_server.conf

で各設定ファイルを開き、Server=127.0.0.1の部分を正しいZabbix-ServerのIPに変更する。

■日本語表示化と初期設定
Zabbixにログインしたら上部Menuから「Administration」→「User」と移動してUser一覧画面を開いてそこから「Admin」を選ぶ。すると設定画面が開き、真ん中辺りに「Language」項目があるのでそれを日本語に変更する。
「管理」→「インストール」を押すと初期設定画面が開くのでここを進める。特に考える事なく同意とかはいで作業は進むはず。途中でMySQLの接続設定があるのでこれを正しく設定する。接続テストもあるから必ずやって確認する。最後まで言ったらフィニッシュでおわり。

■起動スクリプトの修正(Bug対策)
さてここまでやってUbuntuを再起動したら、なぜかZabbixがAgentもserverも自動起動しなかった。
原因を調べてみるとZabbixの起動に必要なpidファイルを置くフォルダが無くなっているようだった。もう他力本願丸投げでぐぐってみたら案の定ヒット。
[覚え書き] ubuntu 9.04 の Zabbix の不具合
このWebの情報を元に作業開始。まずはserver側
sudo vi /etc/init.d/zabbix-server
で設定ファイルを開いてしたの赤字で書いてある部分を追加する。
PID=/var/run/zabbix-server/$NAME.pid
DIR=`/usr/bin/dirname "$PID"`
test -f $DAEMON || exit 0
@@ -21,6 +22,10 @@
case "$1" in
start)
rm -f $PID
if [ ! -d "$DIR" ]; then
/bin/mkdir -p "$DIR"
/bin/chown -R zabbix:zabbix "$DIR"
fi

echo "Starting $DESC: $NAME"
続いてAgentの方
sudo vi /etc/init.d/zabbix-agent
で起動スクリプトを開いて赤文字の部分を追加する。
PID=/var/run/zabbix-agent/$NAME.pid
DIR=`/usr/bin/dirname "$PID"`
test -f $DAEMON || exit 0
@@ -21,6 +22,10 @@
case "$1" in
start)
rm -f $PID
if [ ! -d "$DIR" ]; then
/bin/mkdir -p "$DIR"
/bin/chown -R zabbix:zabbix "$DIR"
fi

echo "Starting $DESC: $NAME" >;&2
これでUbuntuを再起動すればZabbixも起動する様になるはず。

2009年6月18日木曜日

Nginxが入っちゃった

Cloudとか仮想化とかClusterとか調べていく内によく見かけるNginx。Scalrでも標準でSupportというか対応してるっぽいWebServer。LoadBalancerの機能も持っている。
OpenNebulaみたいに楽に入るかなぁと思ってUbuntu9.04Serverで
sudo apt-get install nginx
と打ってみた。

そしたらあっさり入りやがった('A`)

やべぇApache2入ってるのに。
うおーScalerの画面が開かなくなったー('A`)

これはやばい。
Apache2に戻すか、Nginxの設定変更せねば。
取り敢えずNginxの設定ファイルみて、DocumentRoot変更するか・・・

/etc/nginx/sites-available/default

がApache2のhttpd.confに相当するっぽい。
ここでDocumentRootを変更して、Nginxを再起動すると・・・

だー。phpが動かん('A`)
仕方ないのでNginxを止めてApache2起動で対応。
Nginxは別環境でうまく動かそう。

2009年6月16日火曜日

ec2-api-toolsを動かすまでのメモ

利用環境は毎度おなじみUbuntu9.04 Server。そこにec2-api-toolsをインストールします。
まぁ相当古いネタだからググればそこら中のblogで引っかかるけど自分のメモとして。

さて、なんかよく分からないけどUbuntuにはOpenJDKとSunJavaのJDKの二種類があるみたい。
どっちがどういいんだか分からないけど、どっちでもヨサゲ。

sudo apt-get install sun-java6-jdk (Sun Java JDKの場合)
sudo apt-get install openjdk-6-jdk (OpenJDKの場合)
apt-get install ec2-api-toools
export JAVA_HOME=/usr
export EC2_HOME=/usr/lib
で基本インストール終了。ec2-api-toolsは「/usr/lib/ec2-api-tools」に入るっぽい。
次に本当に動くか簡単なコマンドを投げてみる。
ec2ver
このコマンドを投げて、「1.3-34128 2009-03-01」みたいな値が帰ってくればOK。

次に暗号鍵の設置。最終的に暗号鍵は環境変数に場所を書くので、実ファイルを置くのはどこでも良い。仮にUser名が「yutuki」だとして作業を進める。
mkdir /home/yutuki/ec2
// FTPでも何でも良いのでここに暗号鍵二つをUpする。
export EC2_PRIVATE_KEY=/home/yutuki/ec2/pk-XXX.pem
export EC2_CERT=/home/yutuki/ec2/cert-XXX.pem
以上で設置完了。
本当に動くかどうか下記コマンドで確認
ec2-describe-instances
このコマンドを投げると自分のAccountで現在動かしているInstanceのListが表示される。

2009年6月4日木曜日

呆気ないのも面白くない

Under the MOON: Dark horseか?で出てきたOpenNebulaのInstallを早速試みる。
今回もターゲットはUbuntu9.04。さて公式にいってInstallのマニュアルでもないか探してみる。

・・・あれ?

Ubuntu 9.04 (Jaunty Jackalope) has been released today bringing OpenNebula
Ubuntu 9.04 (Jaunty Jackalope) has been released today bringing highly interesting new features, specially in the Cloud Computing and Virtualization area. The new Ubuntu server distribution includes OpenNebula, so providing the technology required to build private and hybrid clouds.

トップページにあるこの言葉。
Ubuntu9.04 ServerはOpenNebulaを搭載してます

(;゚Д゚)

(゚Д゚)

apt-get install opennebula

終了。
あっけねぇ('A`)
Scalr並位の事は覚悟してたのに。
こちらにも被害者がいる様です。

ESXiにCentOS5.3を入れる迄

64bit版も32bit版もはいらない。
なぜかInstall途中の特定のRPMが壊れてるぞ( ゚Д゚)ゴルァ!ってERRORで止まってしまう。
CentOS5.3は公式からDLして来た奴をDVDに焼いてるんだけどこれが駄目なのか。念の為に別の鯖からISOを落とし直してMD5もCheckしてからやってみたけどやっぱり駄目だった。

同じくCentOS5.3を使ってる人に聞いてみたらどうやらその人はISOImageからInstallしたとの事。
むぅ。ISOとDVDで違うのか・・・

まぁそれで出来るならという事でGoogle様でESXiにファイルをアップロードする方法を尋ねて、ファイルをアップロード。
んでvSphereClientから新規仮想Machineの構築を開始。

どうやら今度は無事にInstall出来そう。
・・・この現象に出くわした人、います?

2009年6月3日水曜日

JavaScriptの圧縮

HTMLを綺麗にしないで高速化は出来ない。の中でJavaScriptやcssの圧縮の話がある訳ですが、ちょっとGoogle様に問うてみたらまぁ出る事でる事。

取りあえずまず本の中で紹介されてるJavaScript圧縮方法
■YUI Compressor

で続いてWEBで見つけた圧縮方法
■prototype.jsを10KBにする方法
■Makeを利用したJavaScriptファイルの結合・圧縮
■JavaScriptやCSSを動的にdeflate圧縮するのではなく、あらかじめ圧縮しておいたものを配信することでサーバーのCPUリソースを節約する

gzip圧縮したJavaScriptを配信しても大丈夫なんだな・・・当たり前か。
問題があるのはWebkit系で、一番面倒なIE6は対応してるという珍しいケース。
これは場合によっちゃ導入するかな

2009年6月2日火曜日

VMServerからESXiへUbuntuの引っ越し

をしたらIPがとれなくなってる('A`)。
Ubuntuだし先達は必ずいると信じてGoogle先生に問い合わせ。
あ、関係ないけどbingは意外とヨサゲ。

■vmwareのubuntuを別PCへ移動で eth0: ERROR
■Ubuntu 7.10を違うマシンにHDDごと移動したときのネットワーク設定

紹介先だとなんか二つ削除する事になってるけどUbuntu9.04だと一個しかなかった
sudo vi /etc/udev/rules.d/70-persistent-net.rules

でファイル開いて、SUBSYSTEM=="net"~で始まる箇所を全部コメントアウトか消す。
終わったら再起動。

2009年5月22日金曜日

Next Target KVM

LinuxがKernel-Levelで持つ仮想化機能。「Kernel-based Virtual Machine」

取り敢えずググったらもっさり出てきた。というわけでいつものようにメモ。
■Ubuntu で KVM (Kernel-based Virtual Machine)

2009年5月13日水曜日

Scalr公式のFAQ

Scalr(スケィラー)公式サイトにあるFAQの和訳を試みる。
ついでに解答を粉飾してみる。私の方で付け加えた情報は※の部分です。
■Frequently Asked Questions
間違ってたら指摘してくれると、泣いて喜びます。


Q1.Scalr使うのにAWSのAccountって必要なの?
A1.必須だよ。
Do I need an AWS account to use SCALR?
Yes, you do need to have an AWS account.


Q2.自分のAWSのAccountIDってどこみれば解る?
A2.AWSにアクセスしてログイン、その後「Your Account > Personal Information 」と移動。その後の画面の右上にある「Account Number」が「AccountID」。
※よく間違える人いるけどログインの時に使うIDじゃないよ。
Where do I get my AWS account ID?
It can be found in "Your AWS Profile" page inside http://aws-portal.amazon.com, find an "Account Number" field.


Q3.「Farm」て何?
A3.特定のApplicationを提供するのに必要な何個かのInstanceの集まりの事を「Farm」と呼ぶ。典型的な例でいえば下記のようなInstanceのSetを指す。
・LoadBalancerが入ったInstance・・・1~2個
・Applicationが入ったInstance・・・2~個
・DBが入ったInstance・・・1~個
What is "farm"?
Farm is a set of instances that are serving one or more applications. Typical farm consists of one or more www instances, two or more app instances and one or more mysql instances.


Q4.「Role」て何?
A4.「Role」は「とある特定の機能を提供する為のAMI」。Scalrの方で幾つかの「共有Role」を用意してあるよ。
・www - LoadBalancerが入ってる
・app - Apacheがはいってる
・mysql - MySQLが入ってる
・base - 何も手をつけていない綺麗なAMI。これを元に独自のRoleが作ってね。
これらのRoleを元に独自のRoleを作る事も出来るよ。
What is "role"?
Role is AMI that is built for specific task. Currently Scalr comes with the following pre-built "shared" roles:
• www - frontend web servers that are proxying HTTP requests to all instances of app role. It can also serve static files with minimal overhead.
• app - instances originally running Apache
• mysql - MySQL master or slave instances.
• base - a clean AMI that can be used to create new roles.
You can also create your own roles based on existing "shared" ones.


Q5.「Application」て何?
A5.「Farm」を利用して提供するWebサイト、或いはWebServiceの事。
What is "application"?
Application is basically a website that is running on a farm.


Q6.「Farm」が再構成された際、DNSって自動で書き換わるの?
A6.ネームサーバの設定をns1.scalr.net, ns2.scalr.net and ns3.scalr.netにしてくれれば、Scalrが巧くやってくれるよ。
※Scalr.netに登録した場合の話。自力で環境作る場合は自分で用意する必要あり。
How do I get my domain DNS zone updated when farm is reconfigured?
Just set nameservers for your domain to ns1.scalr.net, ns2.scalr.net and ns3.scalr.net. Scalr will take care of the rest.


Q7.AppInstanceで仮想ホストって使える?
A7.まだ使えません。1Farm上で複数個のアプリ使いたい時は自己責任で☆
Does Scalr configure virtual hosts on app instances?
Not yet, if you are going to host more than one application of one farm, you are responsible for this.


Q8.MySQLのReplicationってどうなるの?
A8.ScalrはMySQLのReplicationとか設定変更も監視してる。突然MySQL-Instanceが落ちても、他のMySQL-Instanceは動的にMaster/Slaveを切り替えてくれるよ。
How MySQL replication work?
Scalr takes care about MySQL replication and re-configuration. Instances of mysql role can become master or slave dynamically, if any of mysql instances suddenly crash.


Q9.おk。俺のアプリ完成、Farmも立ち上げた。次は?
A9.立ち上げたFarmの中のApplicationInstanceに作ったアプリをアップロードしれ。
OK, I created application, built and launched a farm. Now what?
Upload your application on app instances.


Q10.自分でファイル起きたいんだけど、どこに置けばいいの?
A10.AppRoleのInstanceなら「/var/www」。WWWRoleのInstanceなら「/var/www/nginx-default」。
まぁWWWRoleのInstanceになんか置くことないだろうけどね。
Where do I place my files? What are default directories?
/var/www for app
/var/www/nginx-default for www (you won't place anything here in most cases)


Q11.InstanceにSSH接続したいな
A11.Farmの一覧画面で、画面右のOptionの所から「Get Private Key」を押してダウンロードして。んでこの暗号鍵ファイルを使ってSSHClientとか、Puttyでつないでよ。
How do I SSH into my instance?
Go to the list of farms and click on Private key -> Download. Use this private key with OpenSSH client (-i switch) or Putty to authenticate on all instances in this farm.


Q12.ダウンロードした暗号鍵をPuttyで使うにはどうしたらええの?
A12.ここ見れ。Follow this manual
How do I use downloaded private key in Putty?
Follow this manual


Q13.「Synchronize to all」ってやるとどうなるの?
A13.とあるInstanceに加えた変更を、同一Roleの他のInstanceにも反映させたい時に使えばいい。押すとScalrがそのInstanceをAMIとして保存し直して、順次他の古いInstanceを落とし、新しいAMIを元にしたInstanceに切り替えてくれる。
※すいません。ここよく分からないです。
How "Synchronize to all" feature works?
Say you've made changes to files on some instance. Now you want to save them on all instances in this role, so they will not be lost upon instance crash and on newly created instances. You find the instance in the list and click "Synchronize to all".
• Scalr rebundles this instance
• Scalr terminates old instances one-by-one and replaces them with new ones.


Q14.App-InstanceとWWW-Instanceとの間のコンテンツの同期ってScalrは面倒見てくれるの?
A14.いいえ。自分でやってください。そういうScriptを準備するか、「Synchronize to all」を使ってね。
Does Scalr take care about synchronizing my content between my instances for www and app roles?
No, but you can either take care of this by yourself (a simple rsync script will do the job) or use "Synchronize to all" feature.


Q15.Instanceを制御するのにScalrとElasticFoxみたいのを組み合わせて使えない?
A15.Instance、EBS、ElasticIP等をScalr以外から操作する事は推奨出来ません。例えばElasticFoxからElasticIPの変更をした場合、Scalrはこの操作を殆ど追跡できないので意図しない結果を招く事になります。
Can I use Scalr and other tools like Elasticfox simultaneously to control my instances?
You are strongly advised to not do any changes on your instances, EBS volumes, Elastic IPs etc outside Scalr. Scalr is unable to track these changes in most cases and you can end up with unexpected behavior. Good example is assign of Elastic IP to an instance via Elasticfox.


Q16.「Min LA」と「Max LA」って何?
A16.LAは「LoadAverage」の略。Scalrは全Instanceの最後15分の負荷を元にInstanceの数を調整する。平均負荷が上限設定を超えたら新しいInstanceを立ち上げるし、下限設定を下回ったら一個Instanceを落とすよ。
What are "Min LA" and "Max LA" settings for roles?
LA is a common abbreviation for "Load Average". You can read more on this in this Wikipedia article . Scalr scales your role based on average LA on all instances for last 15 minutes. If LA grows higher than Max LA, new instance is started.If LA fails lower than Min LA, one instance is terminated.


Q17.「Min Instances」と「Max Instances」って何?
A17.Scalrは、LAの制限なんて無視してその二つで指定された範囲内でInstanceの数を調整するよ。
What are Min Instances and Max Instances?
Scalr will keep a number of running instances of particular role between Min and Max, regardless of LA limits.


Q18.Scalr.netから退会したら俺の作ったFarmとかInstanceって止まってくれるの?
A18.いいえ。Scalrから監視もされないでそのまま放置されます。
Will my farms/instances be stopped if I unsubscribe?
No, but you will no longer be able to control them from Scalr web interface and they will not be monitored anymore.


Q19.HTTPRequestなげると、全WWW-Instanceに伝わるの?
A19.ScalrはWWW-InstanceそれぞれにPublicIPを割り当てます。これはDNSラウンドロビンと呼ばれる機能です。別の利用者からのRequestは別のWWW-Instanceに届くでしょう。
How HTTP requests are spreaded across all www instances?
Scalr assigns public IP addresses of all www instances to your application domain name. This is called DNS round-robin. Different visitors/requests will go on different www instances.


Q20.WWWのRoleに入ってるロードバランサーって何?
A20.nginx
What software is running on www role instances?
nginx.


Q21.俺のAMIとかInstanceをScalrに登録出来る?
A21.ごめん。今だとScalrが提供してる「Base」Roleから作った奴じゃないと登録出来ないんだ。次のVersionからはどんなAMIでも登録出来る様になるよ。
※1.0RC5をInstallしたけど、Base以外のも登録できた気がする。
Can I add my existing AMI/instance into Scalr?
For now you can only use Scalr's "base" role AMI to create your custom one. A next version of scalr will allow you to "scalrize" any AMI.


Q22.独自でRoleを作るには?
A22.Base-Roleを一個含めて新規Farmを作成します。でそのBaseの所で「Synchronize to all」オプションを使います。するとどういう名前のRoleで保存するのか聞かれますからそこで作ってください。
※ここも解らん。
How do I create my custom role/AMI out of "base" one?
Include a base role when starting a new farm. Go to a base AMI and use "Synchronize to all" option. You will be asked for a new role name. The new AMI will be owned by you.


Q23.
A23.
I made changes on instance, clicked "Synchronize to all" and now it won't be recognized by Scalr or MySQL snaphsot not working or it hangs in "Synchronizing…..." state.
Make sure that you did not mess essential scalr programs on your instance.
Four things that you should never do when customizing your instance:
1. Deleting/disabling snmpd and snmptrapd
2. Disabling PermitRootLogin or PubkeyAuthentication, changing Port in sshd_config
3. Removing scalr public key from /root/.ssh/authorized_keys
4. Delete the following packages or invalidate their dependencies: ec2tools, s3cmd


Q24.独自で作ったRoleのInstanceでapt-getしたいだけど、絶対に上書きしちゃいけないProgramってある?
A24.apt-getした後、SNMPデーモンが動いてる事は確認してね。あと触らない方がいいDirectoryは「/etc/aws」と「/usr/local/aws」。後「/etc/rc.local」を編集する時は気を付けてね。
I want to run apt-get upgrade on an instance of my custom role. Is there any essential software on scalr AMI that I must keep intact?
Make sure that SNMPd is running after the upgrade. Some important dirs that must not be touched: /etc/aws, /usr/local/aws. Finally, be careful when modifying /etc/rc.local.


Q25.ファイルを利用してSession管理するアプリなんだけど、複数個App-Instanceある時に動作がおかしくならないかな?
A25.その心配はいらないよ。Nginxが利用者のIPとかUser-Agent等を元に特定して利用するServer割り当ててるからね。
※ここもよく分からん。
My application uses file-based sessions. What if my visitor's requests will be proxied to a different app instances?
This wont happen. Nginx is configured to keep visitors bundled to a specific backend server (based on his IP, User-Agent etc).


Q26.DNSゾーン編集しなきゃいけなくなんだけど?
A26.ログインした後、Applications->View->Edit DNS zoneって移動すれば編集画面あるよ
What if I need to edit my DNS zone?
You can do that in Applications->View->Edit DNS zone.


Q27.あるInstanceから、同じFarmで動いてる他のInstanceのIPしりたい時はどうしたらいい?
A27.そういった情報をScalrは「/etc/aws/hosts/」に保存してるよ。例えば「ls /etc/aws/hosts/www」ってコマンドを打つとWWW-Instance群のIP一覧が表示される。或いは「int-{ROLENAME}.domain」みたいな形でサブドメインを使ってもアクセス出来るよ。
How do I know IP adresses of all farm instances from any particular instance?
Scalr stores them in /etc/aws/hosts/ folder. For example
ls /etc/aws/hosts/www
will list all internal IPs of www instances. You can also access them as subdomains int-ROLENAME.domain.


Q28.Roleの外部IP知りたい
A28.「ext-{ROLENAME}.domain」でアクセス出来るよ。
How do I know external IP adresses of my roles?
You can use ext-ROLENAME.domain


Q29.App-InstanceからMySQL-InstanceのDBに接続するには?
A29.
How do I connect to MySQL servers from my application?
Like with any master-slave replication, it is important that your application writes only on master and reads from any. This is because slaves are only reading changes from master.
Here is a simple PHP code that will list your mysql master host (to write on) and all mysql hosts (to read from):
$mysql_masters = (array)@glob("/etc/aws/hosts/mysql-master/*");
$mysql_master_host = basename($mysql_masters[0]);
$mysql_all = (array) @glob("/etc/aws/hosts/mysql/*");
$mysql_all_hosts = array();
foreach ((array)$mysql_all as $h) {
array_push($mysql_all_hosts, basename($h));
}
Another, even simpler way is to use int-rolename.yourdomain dynamic hostnames that resolve to internal IP adresses. Say, you have launched application my.com. MySQL master in this case will be accessible as int-mysql-master.my.com and one random mysql instance will be int-mysql.my.com


Q30.nginxの設定をいぢりたいんだけど?
A30.「/etc/nginx/nginx.conf」を編集して。で「killall -HUP nginx」を投げて動いているnginxを全部止め。
※次から起動するnginxは新しい設定を読む。
How do I reconfigure nginx?
Edit /etc/nginx/nginx.conf and issue "killall -HUP nginx" command.


Q31.
A31.
My application tracks IP adresses of visitors. nginx substitutes visitor IP with it's own IP. How do I know client IP address?
nginx passes IPs in X-Real-IP HTTP header. Modify your application to use this header instead, or set up mod_rpaf Apache module (no code modifications will be needed in this case).


Q32.InstanceのOSって何?
A32.Ubuntu 7.04 GNU/Linux
What OS is running on instances?
Ubuntu 7.04 GNU/Linux


Q33.Scalr.netをやめるには?
A33.PayPalの支払いを停止すればOK。やめても最後の支払いの有効期限までは使えるよ。
How do I cancel my account?
Just cancel your PayPal subscription. You account will remain active until due date.

2009年5月12日火曜日

Scalr:Incorrect XMLってERRORがでる。

Scalr(スケィラー)のこの問題に関する情報をtomoさんからのScalr関連のエントリまとめにコメントとしていただきました。
どうやらApacheの設定の問題みたいです。ApacheのERRORログ見て、Apacheに少し気使ってれば気づいた問題だなこれは・・・。
まぁ何はともあれ早速チャレンジ。
参考:■Get A Sys Admin: Scalr errors after install

ERROR内容。
Scalrをインストールして使っていると所々の画面で下記のようなERRORがでる。
Error Type: LoadXML
Description: Incorrect XML

まず確認するのはApacheのログ。
今回私が使っているのはApache2で、特に素のままであれば下記の場所にログがある。
/var/log/apache2

でこのログの中に「farm_amis.xmlがないぞ( ゚Д゚)ゴルァ!」というERRORがあれば、それを修正します。

下記のファイルを編集する。
vi /etc/apache2/sites-available/default

書き換えるのは「DocumentRoot /var/www」の中の設定。書き換える内容は下記の通り。
AllowOverride None

AllowOverride All

続いてMod_RewriteをLoadする様に設定変更してApacheの再起動
cd /etc/apache2/mods-enabled
ln -s ../mods-available/rewrite.load
/etc/init.d/apache2 restart

動いたー!
tomoさんありがとうございました!

Scalr:phpのHttpRequestClassがないというエラーがでる。

Scalr(スケィラー)で事ある毎にphpの「HttpRequest」Classがねぇよ( ゚Д゚)ゴルァ!とERRORが出てくるのでその解決策を模索。
なんか色々足りない物がある様なのでインストールする。

php5-devをインストール(入っているならそれでおk)
apt-get install php5-dev

Zlibをインストール
wget -P /usr/local/src http://www.zlib.net/zlib-1.2.3.tar.gz
cd /usr/local/src
tar xzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local
make
make install

libcurl4-gnutls-devをインストール
apt-get install libcurl4-gnutls-dev

pecl_httpのインストール
pecl install pecl_http

でもってphp.iniにパラメータを追加して再起動
echo extension=http.so >> /etc/php5/apache2/php.ini
sudo /etc/init.d/apache2 restart


参考サイト
■Ubuntu PECL HttpRequest インストール
■PHPのHTTPRequestクラスを入れるのに一苦労
■zlib のインストール
■installing curl-devel on amd64

Scalrの構造図

簡単にいうと。ScalrとはAmazonEC2上で動作するWebServiceのスケーリングを自動で行ってくれるProgram。
「ScalrがあればEC2で動作する仮想PCの負荷監視が出来る!」って喜んでる人は一杯いると思う。勿論俺もそう。
でもそろそろその実態がどうなっているのかを把握しないといけない時期になってしまった。という事で調査してみる。
調べながらやってるし、どこか誤解して書いている可能性が十二分にあるんで、鵜呑みは危険です。
もしどこか間違っていたら教えてください。速攻で直します。

まずは分かり易い図から。という事でScalr(スケィラー)の図を和訳してみた。
■Scalr ProcessDiagrams


さて続いてScalr全体の構造の解説。
Scalrは特定のApplicationを提供するInstance群をFarmという単位で管理する。どんなFarmを作るかはScalr上で設定を行い、この設定をFarm定義と呼ぶ。
Farm定義は
このFarmではAPサーバとしてこのAMIを。DBサーバとしてこのAMIを使う。
という形で設定する。
この時の「APサーバ」「DBサーバ」等、ある特定の機能を提供する為の役割を「Role」と呼ぶ。
ScalrではこのRoleを予め幾つか用意しているので下記に紹介する。またRoleは自分達で新たに作り追加する事が出来る。
WWW Role・・・LoadBalancerの役割。Nginxを搭載。
App Role・・・APServerの役割。Apacheを搭載。
DB Role・・・DBServerの役割。MySQLを搭載。
Base Role・・・独自Role構築用


Farm内で「AP サーバ」RoleのAMIから作られたInstance群はAP サーバ「Role Group」と呼ぶ。
ScalrはこのRole Group毎に負荷を監視し、Role Group内のInstance全体の負荷が増加した場合、そのGroupにInstanceを追加する。
なお基本的にInstance の追加などに伴うIP 管理等はScalr がDNS サーバを書き換えて対応している。

さてScalrの最大の売りである自動負荷対応機能だが、特定のRoleGroupに所属する全Instanceの最後15分の平均負荷から判断する、というアルゴリズムを搭載している。
なお新規Instanceを立ち上げる平均負荷の基準値、Instanceを減らす平均負荷の基準値、及び最大Instance数、最低Instance数、Farm立上時の初期Instance数もScalrの画面から設定する事が出来る。

Scalrが想定しているのは
Client
Load Balancer/WWW Server・・・(Nginx)
Application Server・・・(Apache)
Database Server・・・(MySQL)

という4層構造。

APサーバのInstanceが増減した場合はScalrがDNSを更新する。
APサーバを担当するInstanceが増加した場合はLoadBalancerであるNginxがDNSに基づきAP
サーバInstance群を管理する。
DBサーバのInstanceが増減した場合はScalrがDNSを更新する。
ScalrではMySQLをDBとして採用しており、このMySQLの自動クラスタ機能(Master/Slave設定)
機能を利用してDBサーバをクラスタ化管理している。

恐らく企業用途ではOracleを使う機会が多くなると思うがMySQLの代わりにOracleを使ってこの辺りが巧くいくのか、現段階の私では解りません。
知っている方いたら教えてください。