投稿日 2009年7月21日 火曜日 カテゴリ Amazon EC2, EC2 投稿者 sugimotoコメント(0) » 

Amazon EC2 でインスタンスをいつでも複製/復元できるよう自分用のAMIを作成していたところ、ec2-bundle-vol に失敗しました。

-bash-3.2# ec2-bundle-vol -d /mnt -k xxxxx.pem -c xxxxx.pem  -u xxxx-xxxxx-xxxx
 Please specify a value for arch [i386]:
 Copying / into the image file /mnt/image...
 Excluding:
          /sys
          /proc
          /dev/pts
          /proc/sys/fs/binfmt_misc
          /dev
          /media
          /mnt
          /proc
          /sys
          /mnt/image
          /mnt/img-mnt
 1+0 records in
 1+0 records out
 1048576 bytes (1.0 MB) copied, 0.001797 seconds, 584 MB/s
 mke2fs 1.39 (29-May-2006)
 ERROR: execution failed: "rsync -rlpgoD -t -r -S -l --exclude /sys --exclude /proc --exclude /dev/pts --exclude /proc/sys/fs/binfmt_misc --exclude /dev --exclude /media --exclude /mnt --exclude /proc --exclude /sys --exclude /mnt/image --exclude /mnt/img-mnt -X /* /mnt/img-mnt 2>&1 > /dev/null"

つい1日前には同じインスタンスから実行できたのに。。。

rsync コマンドが実行エラーってなってます。 ec2-bundle-vol がrsyncコマンドを実行して、途中で失敗したようです。

ネットで調べてみると、rsyncコマンドの実行エラーで失敗する理由として、2つのパターンがあるようです。

1. volume保存用の領域が足りない

AMI保存用のイメージファイルを作成中にインスタンスのディスク領域を使いきった場合、エラーとなるようです。 この場合は、インスタンス内のいらないファイルを削除するしかないですね。。

2. rsync実行中にファイルが削除されたりしてしまった

rsyncコマンドの途中で対象となっているファイルやディレクトリが変更されると、コマンドが失敗します。

プログラムの動作中に ec2-bundle-vol を起動すると、rsyncコマンドが失敗してしまうことがあるということ。

エラーメッセージの中にあるrsyncコマンドを直接実行すると、どちらが原因かわかるようです。

-bash-3.2# rsync -rlpgoD -t -r -S -l --exclude /sys --exclude /proc --exclude /dev/pts --exclude /proc/sys/fs/binfmt_misc --exclude /dev --exclude /media --exclude /mnt --exclude /proc --exclude /sys --exclude /mnt/image --exclude /mnt/img-mnt -X /* /mnt/img-mnt
file has vanished: "/var/nagios/spool/checkresults/check1n3woE"
rsync warning: some files vanished before they could be transferred (code 24) at main.c(892) [sender=2.6.8]

/var/nagios/spool にあるファイルがなくなったということです。

nagiosはサーバー監視用のサービスですね。確かに昨日インストールしました。AMIを作成する間は、止めてしまいましょう。

sudo /etc/init.d/nagios stop

nagiosを止めたら ec2-bundle-vol コマンドが成功し、無事にAMIが作成できました。めでたしめでたし。

Daemon のようなプログラムは実行しているという認識が低いので、要注意ですね。

投稿日 2009年7月9日 木曜日 カテゴリ Xen 投稿者 sugimotoコメントは受け付けていません。 

sugimotoです。ひさしぶりにxenを使っています。

xm console dom-u でdom-u のコンソールにログインしようとすると、

xenconsole: Could not read tty from store: No such file or directory

とエラーになって、ログインできない。

> xm create dom-u -c

で起動時にログインしようとしてもログインできなかった。

検索してもなかなか出てこなかったので、書いておきます。

/usr/sbin/xenconsoled

でxenconsoled を起動するとconsole が使えるようになりました。

投稿日 2008年10月22日 水曜日 カテゴリ Xen 投稿者 sugimotoコメント(0) » 

何もする必要はありませんでした。。

xenの仮想サーバーでDom-U(ゲスト)をインターネット向けのサーバーとして利用することになりました。

Dom-0(ホスト)用のハードウェアにはインターフェイスがeth0, eth1の2つあり、そのうち、eth1を内部LAN向けのインターフェイスとして使っています。

Dom-Uもネットワークインターフェイスを2つ作り、eth1を内部LAN向け、eth0をインターネット向けとして、それぞれ、Dom-0のブリッジとつなげました。

VMware では、ホストOSのインターフェイスを停止させると、そのインターフェイスを使っているゲストOSのインターフェイスも使えなくなってしまいます。

そのため、xenでもDom-0のeth0インターフェイスはあげておく必要があると思いましたが、落とした状態でもDom-Uの外向けインターフェイスは利用可能でした。

こんな状態と思っていましたが

INTERNET
  --+------------------------------
    |
    |
    |  +-------------------------------+
    |  | +---------------------------+ |
    |  | |       Dom-U (ゲスト)      | |
    |  | | +--------+     +--------+ | |
    |  | | |  eth0  |     |  eth1  | | |
    |  | | +--------+     +---+----+ | |
    |  | +-----|--------------|------+ |
    |  |       |              |        |
    |  |   +---+----+     +---+----+   |
    |  |   | vifbr0 |     | vifbr1 |   |
    |  |   +---+----+     +---+----+   |
    |  |       |              |        |
    |  |   +---+----+     +---+----+   |
    +------+  eth0  |     |  eth1  +------+ < < eth0 が停止状態だとDom-Uも外にいけない
       |   +--------+     +--------+   |  |
       |        Dom-0 (ホスト)         |  |
       +-------------------------------+  |
                                          |
LAN/INTRANET                              |
  ----------------------------------------+---

そういうわけではなく、virtual interfaceで外と通信している

INTERNET
  --+------------------------------
    |
    |
    |  +-------------------------------+
    |  | +---------------------------+ |
    |  | |       Dom-U (ゲスト)      | |
    |  | | +--------+     +--------+ | |
    |  | | |  eth0  |     |  eth1  | | |
    |  | | +--------+     +---+----+ | |
    |  | +-----|--------------|------+ |
    |  |       |              |        |
    |  |   +---+----+     +---+----+   |
    +------+ vifbr0 |     | vifbr1 +------+
       |   +---+----+     +---+----+   |  |
       |       |              |        |  |
       |   +---+----+     +---+----+   |  |
       |   |  eth0  |     |  eth1  |   |  | < < eth0 が停止状態でもDom-Uには関係なし
       |   +--------+     +--------+   |  |
       |        Dom-0 (ホスト)         |  |
       +-------------------------------+  |
                                          |
LAN/INTRANET                              |
  ----------------------------------------+---

状態のようでした。

投稿日 2008年10月16日 木曜日 カテゴリ VMware 投稿者 sugimotoコメント(0) » 

自分のPC (Wndows XP Pro)のVMware Server を1.0.7から2.0にしたら、vmware-hostd.exe がアプリケーションエラーとなってしまった。。

Googleで検索した、こんな方法や、サポートページを調べたが、解決しませんでした。

解決方法は、以下でした。

Documents and Settings/All Users/Application Data/VMware/VMware Server/vm-list

を見てみると、次のような感じ。

# This file is automatically generated. 
# Hand-editing this file is not recommended. 
config "C:\Virtual Machines\xxxxx-dev\Other Linux 2.6.x kernel.vmx"
config "C:\Virtual Machines\xxxxx-test\Other Linux 2.6.x kernel.vmx" < < これは削除したはず

前のバージョンで削除していたゲストOSのイメージがリストされていました。
この行を削除して、サービスから、VM Host Agent を再起動すると、うまくいきました。

投稿日 2008年6月2日 月曜日 カテゴリ Xen, kickstart 投稿者 sugimotoコメントは受け付けていません。 

CentOS 5.1にインストールしたxenでDomUをkickstartを使って自動的に作成する設定をしていたら、その問題が起きました。

>sudo /usr/sbin/virt-install
    --extra-args='ks=http://ks-server/kickstart.php?host=myhost&ip=192.168.1.151&mac=00:00:00:00:01:51'

What is the name of your virtual machine? myhost
 How much RAM should be allocated (in megabytes)? 512
 What would you like to use as the disk (path)? /var/xen/myhost.img
 How large would you like the disk (/var/xen/myhost.img) to be (in gigabytes)? 8
 Would you like to enable graphics support? (yes or no) no
 What is the install location? ftp://ftp.riken.jp/Linux/centos/4/os/i386/


Starting install...
Retrieving CentOS...                                             310 B 00:00
Retrieving vmlinuz...     100% |=========================| 1.0 MB    00:00
Retrieving initrd.img...  100% |=========================| 853 kB    00:00
Creating storage file...  100% |=========================| 8.0 GB    00:00
libvir: XML error : line 10: EntityRef: expecting ';'
libvir: XML error : line 10: EntityRef: expecting ';'
libvir: Xen Daemon error : XML description for domain is not well formed or invalid
Traceback (most recent call last):
  File "/usr/sbin/virt-install", line 633, in ?
    main()
  File "/usr/sbin/virt-install", line 578, in main
    dom = guest.start_install(conscb,progresscb)
  File "/usr/lib/python2.4/site-packages/virtinst/Guest.py", line 649, in start_install
    return self._do_install(consolecb, meter)
  File "/usr/lib/python2.4/site-packages/virtinst/Guest.py", line 666, in _do_install
    self.domain = self.conn.createLinux(install_xml, 0)
  File "/usr/lib/python2.4/site-packages/libvirt.py", line 503, in createLinux
    if ret is None:raise libvirtError('virDomainCreateLinux() failed', conn=self)
libvirt.libvirtError: virDomainCreateLinux() failed XML description for domain is not well formed or invalid

virt-install では、extra-argsに”ks=”を設定して、kickstartの設定ファイルを読み込むことができます。 このとき、リモートの設定ファイルを変更することなく設定ファイルを読み込むために、設定ファイルをPHPにして、Query Stringで設定ファイルのパラメータを変更できるようにしていました。

この場合、host/ip/macを引数として渡しています。

Googleに聞いたところ、CentOS 5.1のlibvirtに問題があるようでした。

ここでは、install locationにシングルクォートが入っている場合を指摘していますが、設定全体でXMLのspecial characterのエスケープがされていないため、今回のようにextra-argsにアンパサンド(&)が入っている場合も同様の問題が起こりました。

問題を回避するため、kickstartの設定をおいているサーバーのapacheの設定を修正し、kickstartの設定ファイルのURIを変更しました。

http://ks-server/kickstart/myhost/192.168.1.151/00:00:00:00:01:51 でkickstartの設定ファイルを取得する

    RewriteLogLevel 9
    RewriteLog "/var/log/apache2/www-local-rewrite.log"
    RewriteRule ^/kickstart/(.*?)/(.*?)/(.*)$ /kickstart.php?host=$1&ip=$2&mac=$3 [L]

これで自動インストールすることができました。

このバグはCentOS 5.2のlibvirtでは修正されているらしく、修正もすでに公開されています。

参考