Xen+DRBDでライブマイグレーション

| No TrackBacks
hpml115.jpg

仮想化技術にはまっています。

その中でもライブマイグレーションという仮想環境を動作させながら仮想環境が動作する物理マシンを変更する技術が気になっています。

ということで、HPのProLiant ML115 G5というサーバーマシンが1台12,000円弱で販売されていたので2台購入しました。メモリが512MBと仮想環境には心許ないので2GB*2のメモリ(Transcend JM4GDDR2-8K)を4,000円程度で購入し、1枚ずつ増設しました。それでも2台で3万円を切っています。

まずはそれぞれのマシンにベースとなるOSのインストール。CentOS 5.2のx86_64版を最小構成+仮想環境オプションのみ追加。HDDのボリュームは全体をLVMのVolumeGroupにし16GBのみベースとなるOSに割り当てました。

hp01 192.168.0.11
hp02 192.168.0.12
とします。

次にRBDのインストール
um -y install drbd82 kmod-drbd82-xen

DRBD用LogVolumeを作成
lvcreate --size 16G --name lv_image /dev/VolGroup00

それぞれのマシンで/etc/drbd.confを編集
global {
  usage-count no;
}
common {
  protocol C;
}
resource r0 {
  net {
    allow-two-primaries;
  }
  startup {
    become-primary-on both;
  }
  syncer {
    rate 20M;
  }
  device /dev/drbd0;
  disk /dev/VolGroup00/lv_image;
  meta-disk internal;
  on hp01.gracearrow.net {
    address 192.168.0.11:7789;
  }
  on hp02.gracearrow.net {
    address 192.168.0.12:7789;
  }
}
両方のマシンでボリュームの初期化
drbdadm create-md r0
drbdadm attach r0
drbdadm connect r0

hp01で
drbdadm -- --overwrite-data-of-peer primary r0

同期が完了したら(cat /proc/drbd で確認)hp02で
drbdadm primary r0

それぞれのマシンでXenの設定 etc/xen/xend-config.sxp
xend-relocation-server yes)
(xend-relocation-port 8002)
(xend-relocation-hosts-allow '')
#(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')

hp01で仮想OSのインストール
virt-install
What is the name of your virtual machine? vmtest
 How much RAM should be allocated (in megabytes)? 500
 What would you like to use as the disk (file path)? /dev/drbd0
 Would you like to enable graphics support? (yes or no) no
 What is the install location? http://ftp.riken.jp/Linux/centos/5.2/os/x86_64/

あとはウィザードに従ってインストールを完了させる

仮想OS動作確認(hp01)
xm list

ライブマイグレーション(hp01->hp02へ)
xm migrate --live vmtest 192.168.0.12

マイグレーション確認(hp01)
xm list

マイグレーション確認(hp02)
xm list

仮想OS上から外部へPingを打ち続けていましたが、パケットがロスすることなくマイグレーションが成功しました。しかし外からPingを打ち続けたときには、切り替わったタイミングで繋がらなくなりました。マイグレーションに失敗したかなと思いましたが、xm listでは問題なく動作している模様。xm console vmtestで入って内部から外へPingを打つとネットワークが疎通し、外からもアクセス出来るようになりました。どうやらスイッチ内のMACアドレスのキャッシュ更新が必要なようです。

今回はDRBDとXenを手動で構築しましたが、Google が公開しているganetiというソフトを使うとこのあたりをもっとインテリジェントにできそうな雰囲気です。しかしまだ情報が少ないです。

VMWareでライブマイグレーションを行うにはVMware Infrastructure(ライセンス費用ウン百万)とSANかiSCSIのストレージが必要になり、なかなか個人では試すことができません。しかしXenとDRBDを使うことで手軽にライブマイグレーション環境を作ることができます。

次回はkemariに挑戦してみます。


No TrackBacks

TrackBack URL: https://www.gracearrow.net/mt5/mt-tb.cgi/108

Recent Assets

  • marutoko2012_4.jpg
  • marutoko2012_3.jpg
  • marutoko2012_2.jpg
  • marutoko2012_1.jpg
  • marutoko2012_5.jpg
  • cgfesta2012_5.jpg
  • cgfesta2012_4.jpg
  • cgfesta2012_2.jpg
  • cgfesta2012_1.jpg
  • cgfesta2012_3.jpg

About this Entry

This page contains a single entry by gracearrow published on March 5, 2009 1:40 AM.

東京オートサロン2009 was the previous entry in this blog.

Z1000車検完了 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.