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

2009年5月13日水曜日

Scalr:作業メモ

Scalrを使ってLocalに立てたEucalyptusを監視させたいんだが、画面上からAmazonEC2のURLを設定している場所が見あたらない。どこかの設定ファイルにあるのかな?と思って探したんだけど見つからず。
まさか、と思って探してみると案の定Programの中にべた書き('A`)。

あ、Eucalyptusのインストールに関しては
CentOS5.3にEucalyptus1.5.1をインストールしてみたに纏まってるんで割愛。
Scalrに関してはこっち
Under the MOON: ScalrをUbuntuにInstallする。

「class.AmazonEC2.php」ってファイルになってるから同じようにphpをかけばLocalのEucalyptusにもつながるかな・・・?
php書いた事ないから勉強しながらやらにゃ駄目だな

気になる文章発見。翻訳間違ってたら教えてください。
■scalr-discuss
I was asked if a thing like scalr was supposed to work outside Amazon Webservices.
I read once that version 2 of scalr was supposed to work on different cluster environments.
Is it still the case. I discovered Eucalyptus this week (http://eucalyptus.cs.ucsb.edu/) and
I still don't understand how this works and how this could work on a personnal cluster.
But if this is the case, would it be possible to use scalr to manage it?

Scalrの様な物がAWS以外の物に対応しているのかと聞かれたが、私はScalrのVersion2は別のクラスター環境にも対応するようになっていたと読んだ事がある。
しかしながら、今週Eucalyptusという物を見つけたが、これを個人クラスタ上でどうやって動かせば良いのか解らない。
仮に出来たとしても、ScalrでEucalyptusを運営する事は出来るのだろうか?

■Scalrに関係のあるものども
nginx
Gluster
安全・確実・大容量・高速なファイルシステム
こんなに簡単! Linuxでロードバランサ (1)

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を使ってこの辺りが巧くいくのか、現段階の私では解りません。
知っている方いたら教えてください。

2009年5月11日月曜日

Scalr関連のエントリまとめ

自分が見にくいので。Scalr(スケィラー)関係のエントリを纏めて見る。

■ScalrをUbuntuにInstallする。
■Scalrを日本語化したい
■Scalrの設定
■Scalrの構造図
■Scalr:phpのHttpRequestClassがないというエラーがでる。
■Scalr:Incorrect XMLってERRORがでる。
■Scalr公式のFAQ

残りの問題
・DNSの設定
・rrdtoolの設定

Scalrの設定

Scalr(スケィラー)の設定リスト

■Admin account
・Login: (任意の文字列)
・Password: (任意の文字列)
・E-mail: (任意の文字列)
・Name: (任意の文字列)

■eMail settings
・SMTP connection: (右記の形式で書く。user:password@host:port. Leave empty to use MTA)
・Scalr team emails: (送信先Addressを改行区切りで並べる):

■Log rotation settings
・Keep logs for: (任意の数値)

■DNS settings
・Dynamic A record TTL: (任意の数値)
・Default SOA owner: (URL)
・Default SOA parent: (URL)
・Default SOA TTL: (任意の数値)
・Default SOA Refresh: (任意の数値)
・Default SOA Retry: (任意の数値)
・Default SOA Expire: (任意の数値)
・Default SOA Minimum TTL: (任意の数値)
・Named.conf Zone template: (記載されているテンプレートに従った書式)

■AWS settings
・Account ID: (EC2にログインする際に利用するID)
・Key name:
・Access key: (Home > Your Account > Access Identifiers > Access Key ID and Secret Access Key > Your Secret Access Key)
・Access key ID: (Home > Your Account > Access Identifiers > Access Key ID and Secret Access Key > Your Access Key ID)
・Security groups prefix: (EC2にて自分が利用しているSecurityGroup)
・S3cfg template: (記載されているテンプレートに従った書式)
・Instances limit: (任意の数値)

■RRD statistics settings
・Path to rrdtool binary: (rrdtoolのDirectoryPath。「which rrdtool」で取得可能)
・Path to font (for rrdtool):
・Path to RRD database dir:
・Statistics URL: Allowed tags:
・Store graphics in:
・Path to graphics:

■Application settings
・Path to snmpinform:
・Event handler URL:
・Terminate instance if it doesn't send 'rebootFinish' event after reboot in (任意の数値) seconds.
・Terminate instance if it doesn't send 'hostUp' or 'hostInit' event after launch in (任意の数値) seconds.
・Cron processes number: (任意の数値)
・Server IP address: (IP)

■Apache settings
・Default document root: (DirectoryPath)
・Default logs dir: (DirectoryPath)

Scalrを日本語化したい

軽くググってみてもScalr(スケィラー)日本語化ファイル等は見あたらない。これはひょっとして自力でやれという事か?
という訳で日本語化する為のちょっと調査。
どうやら
/var/scalr/app/templates/
に各言語のファイルがある模様。でもja-JPファイルはない。

取り敢えずen-USをコピーして作らないと駄目か

ScalrをUbuntuにInstallする。

Scalr(スケィラー)をLinux族Debian系UbuntuにInstallする為のメモ。適宜内容は追加、修正していきます。
参考:Get A Sys Admin: How to install Scalr on Ubuntu 8.10 EC2 Instance

今回はUbuntu9.04Serverを利用。なぜかって?最新版が好きだから(゚Д゚)。

1.OS自体の準備。


まず最初にUbuntuをInstall。インストール途中の設定でLAMP機能、SSH2機能をインストール。
MySQLインストール時にパスワード設定するからお忘れなく。
インストールおわったらとりあえずシステム更新。Ubuntuでroot権限やる時は
sudo -i

更新おわったら再起動
apt-get update
apt-get upgrade
shutdown -hr now


2.追加パッケージのインストール


後から追加するよりも、本当ならOS入れる時に選択してるのがスマートなんだろうなぁ。
パッケージ入れ終わったらApache再起動を忘れずに。
apt-get install bind9 mysql-server mysql-client apache2 php5-cli libapache2-mod-php5 php5-mysql php5-mcrypt php5-mhash php5-snmp make rrdtool snmp php5-dev libcurl4-gnutls-dev php-pear libssh2-1 libssh2-1-dev

で次にApache再起動
/etc/init.d/apache2 restart


3.SSH関係のインストール


次に一番の難関SSH2周り。ここが難関。
取り敢えずまず下記のコマンドを打ってインストール試行
pecl install ssh2 "channel://pecl.php.net/ssh2-0.10"

もしこの状態でエラーが出ずにインストール出来たならラッキー。次へ進む。もしエラーが出たら(殆どの場合出ると思うけど・・・)下記の作業を実施する。
SSH2のSourceの一部を修正する。SSH2.Cファイルの480行目付近を変更する為にファイルを開いて
vi /tmp/pear/download/ssh2-0.10/ssh2.c

480行目辺りまで移動して下記の様に書き換える
#if LIBSSH2_APINO < 200412301450 ↓ #if false


再度インストール試行
configure
make
make install
echo extension=ssh2.so >> /etc/php5/apache2/php.ini
/etc/init.d/apache2 restart


4.Scalr本体のダウンロードと解凍


さてやっとScalr本体に手をつけます。
wget http://scalr.googlecode.com/files/scalr-1.0RC5.tar.gz
tar zxvf scalr-1.0RC5.tar.gz

解凍したファイルの中にあるMySQL用のSQLを実行する
mysqladmin -p create scalr
mysql -p scalr < scalr/sql/database.sql


SQL終わったらScalrを移動させて、各種パーミッション設定。
mkdir /var/scalr
cp -R scalr/* /var/scalr/
chmod 777 -R /var/scalr/app/cache /var/scalr/app/cron/cron.pid /var/scalr/app/etc/.passwd
chown www-data:www-data -R /var/scalr/app/templates/
chmod 777 -R /var/scalr/app/templates/
rm -rf /var/www/
ln -sf /var/scalr/app/www /var/
chmod a+rX -R /var/www

でインストール終了。

5.ScalrにMySQLの設定をする


次にScalrにMySQLの接続設定をする
/var/scalr/app/etc/config.ini を編集して
vi /var/scalr/app/etc/config.ini

下記の内容を追加する。
[db]
driver=mysql;
host = "localhost"
name = "scalr"
user = "root"
pass = "*YOUR PASS HERE*"


6.Cronを設定する


定時実行処理を設定するのでCron設定ファイルを開いて
vi /etc/crontab

下記内容を追記する。
* * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --Poller
1 1 * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --RotateLogs
*/15 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --MySQLMaintenance
*/6 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --DNSMaintenance
*/3 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --DNSZoneListUpdate
*/2 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --DBQueueEvent
*/11 * * * * /usr/bin/php -q /var/scalr/app/cron/cron.php --Cleaner


7.EC2接続用のファイルを設置する


XXXの部分は個々のAccountで違う値。certで始まるファイルとpkで始まるファイルの二つを下記の場所にアップロードする
/var/scalr/app/etc/cert-XXXXXXXXXXXX.pem
/var/scalr/app/etc/pk-XXXXXXXXXXXX.pem


8.Apacheの設定


Scalr:Incorrect 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


9.phpのpecl_httpのインストール


Scalr:phpのHttpRequestClassがないというエラーがでる。関係。
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

pecl_httpのインストール
pecl install pecl_http

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




最終更新
2009/05/13
・XMLのERRORと、httpRequestのERROR対応の為の内容を追記
・Templateファイルを画面上から設定する為のコマンドを追記。

2009年4月27日月曜日

Scalrの調査

■Scalr:自動的にスケーリングできるオープンソースのAmazon EC2実現努力
■How To Install EC2 Automatic Scaling App Scalr on Centos 5.2
■CentOS(yum)で"MySQL Cluster"

Scalrの読み方がワカラン。ググっても出てこない。
「スカルラー」でいいのか?
スリラーの親戚か・・・?

色々考えた結果、Scalr(スケィラー)と呼ぶ事に。