2010年12月24日 星期五

Adding RBD support for Xen

Ceph 是近來新興的分散式檔案系統, 作者網站號稱可以到 peta-byte 的處理能力
看他的架構的確是不錯, 但目前還在開發階段, 不宜作為 production 使用!!
以下是小弟寫的小小 script 讓 xen 也能使用 Ceph 的 Rados

Adding the follow code in /etc/xen/scripts/block-rbd
#!/bin/bash

# Usage: block-rbd [monitor_server options pool_name image_name]

dir=$(dirname "$0")
. "$dir/block-common.sh"
rbd="/sys/bus/rbd/devices"

case "$command" in
add)
echo "$2 $3 $4 $5" > /sys/bus/rbd/add
sleep 0.5
for dev in `ls $rbd`; do
if [ "`cat $rbd/$dev/pool`" == $4 ] && [ "`cat $rbd/$dev/name`" == $5 ]; then
write_dev "/dev/rbd$dev"
xenstore_write "$XENBUS_PATH/rbd" "$dev"
exit 0
fi
done
exit 1
;;
remove)
dev=$(xenstore_read "$XENBUS_PATH/rbd")
echo $dev > /sys/bus/rbd/remove
;;
esac

Modify the last line of /etc/xen/scripts/block

--- block.org 2006-11-13 15:13:37.000000000 +0100
+++ block 2010-12-24 20:55:10.000000000 +0800
@@ -404,4 +404,4 @@

# If we've reached here, $t is neither phy nor file, so fire a helper script.
[ -x /etc/xen/scripts/block-"$t" ] && \
- /etc/xen/scripts/block-"$t" "$command" $node
+ /etc/xen/scripts/block-"$t" "$command" $p


Creating new config file for VM

The format of new block device is "rbd:monitor_server options pool_name image_name". example:

kernel = "/mnt/images/gentoo/kernel/boot/vmlinuz-2.6.32.26-domu"
extra = "root=/dev/xvda1 ro console=hvc0 ip=::::vm01::off"
memory = 1024
vcpus = 2
name = "vm01"
vif = [ '' ]
disk = [ 'rbd:192.168.15.1 name=admin rbd gentoo.2010-0.x86-64.img,xvda1,w' ]

1 則留言:

匿名 提到...

請問在 xen 4.0.2 上, 可以成功開機, 但 GuestOS 回應找不到硬碟, 請問是不是還有哪邊要修正?

Related Posts Plugin for WordPress, Blogger...