• 追加された行はこの色です。
  • 削除された行はこの色です。
[[さくらのVPS]]

ミラーサーバで負荷分散

#contents

*Apache VertualDomain を使用したコンテンツミラーサーバ [#gd6fb097]
http://blog.livedoor.jp/naka_cya/archives/51760954.html

【サーバの用意】
3/15日現在、複数の企業からVPSやレンタルサーバが無償で貸し出されているのでこれを使おう。
詳しくは、ライブドア第九研究室だより 【東北地方太平洋沖地震】無償サーバリストを見て申し込んで欲しい。
http://blog.livedoor.jp/koichiise/archives/1406232.html

【OS選択】
自分の使いやすいOSを選択してください。
#今回はCentOS を基準にしてます

【Apacheの用意】
yum や apt で apache を導入します。

【config】
/etc/httpd/conf.d/ に houshasen-pref-ibaraki.nakacya.jp.conf など適当な名称のファイルを作成し以下の内容を記述する。

    NameVirtualHost *:80

 
    <VirtualHost *:80>
        ServerName houshasen-pref-ibaraki.nakacya.jp
        ErrorLog logs/houshasen-pref-ibaraki_error_log
        TransferLog logs/houshasen-pref-ibaraki_access_log
        DocumentRoot /var/www/html/houshasen-pref-ibaraki.nakacya.jp/www.houshasen-pref-ibaraki.jp
        AddDefaultCharset Shift_JIS
    </VirtualHost>


[Name Base VirtualHost の宣言]

    NameVirtualHost *:80


[VirtualDomain の宣言]

    ServerName houshasen-pref-ibaraki.nakacya.jp


[DocumentRoot の宣言]

    DocumentRoot /var/www/html/houshasen-pref-ibaraki.nakacya.jp/www.houshasen-pref-ibaraki.jp


[DefaultCharset の宣言]

    Shift_JIS


【コンテンツの取得】

    wget -v -m -r http://www.houshasen-pref-ibaraki.jp/ -P /var/www/html/houshasen-pref-ibaraki.nakacya.jp

この作業は結構時間が掛かることがある。
もし、別のミラーサーバやキャッシュサーバが存在する場合は本家では無く、ミラーから取得するのがよい!

ちなみに wget では JavaScript のコンテンツなどは上手く取得できないので少し工夫が必要である。
取得できないコンテンツ一覧をファイルに列挙する(Javascript.txtなど)

    http://www.houshasen-pref-ibaraki.jp/present/1HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/2HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/3HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/5HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/6HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/4HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/22HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/23HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/28HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/29HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/30HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/31HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/34HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/7HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/12HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/13HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/19HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/26HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/27HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/20HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/32HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/21HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/33HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/36HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/35HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/8HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/37HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/10HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/11HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/38HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/39HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/42HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/43HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/9HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/25HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/40HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/41HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/24HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/14HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/54HP30grf.html
    http://www.houshasen-pref-ibaraki.jp/present/55HP30grf.html

その後 、以下を実行する。

    wget -q -m -P /var/www/html/houshasen-pref-ibaraki.nakacya.jp -i /var/www/html/houshasen-pref-ibaraki.nakacya.jp/Javascript.txt


【crontab の設定】
30分間隔でコンテンツを再取得する

    0,30 * * * *    wget -q -m http://www.houshasen-pref-ibaraki.jp/  -P /var/www/html/houshasen-pref-ibaraki.nakacya.jp


【Apache の再起動】
service httpd restart を実行する。

【動作確認】
telnet サーバIP 80 を実行した後、以下の内容を入力し、コンテンツが表示されることを確認する。

    GET / HTTP/1.1
    Host: houshasen-pref-ibaraki.nakacya.jp



【DNS の更新】
該当ドメインの Aレコード に以下のような宣言を行い DNS を Reload する
#シリアル番号の更新をお忘れなく。

    a houshasen-pref-ibaraki 59.106.176.102



トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS