ioband使用

ioband

   dm-ioband is an I/O bandwidth controller implemented as a device-mapper driver. Several jobs using the same block device have to share the bandwidth of the device. dm-ioband gives bandwidth to each job according to its weight, which each job can set its own value to.

dm-ioband是一个有效的磁盘I/O调控工具。它位于磁盘和应用层之间,并以设备的形式呈现,主要为上层的任务分配权重,通过令牌的方式进行任务间的I/O调控。

 

+     +------+ +------+ +------+   +------+ +------+ +------+
+     |cgroup| |cgroup| | the  |   | pid  | | pid  | | the   jobs
+      A   | |  B   | |others|    X   | |  Y   | |others|
+     +--|---+ +--|---+ +--|---+   +--|---+ +--|---+ +--|---+
+     +--V----+---V---+----V---+   +--V----+---V---+----V---+
+     | group | group | default|   | group | group | default|  ioband groups
+     |       |        group |   |       |        group |
+     +-------+-------+--------+   +-------+-------+--------+
+     |        ioband1         |   |       ioband2           ioband devices
+     +-----------|------------+   +-----------|------------+
+     +-----------V--------------+-------------V------------+
+     |                          |                          |
+     |          sdb1            |           sdb2            block devices
+     +--------------------------+--------------------------+
+


安装

dm-ioband并没有集成在mainstream kernel里,需要打patch才能用,而且必须是kernel社区的源码。下载patch并完成打补丁,然后make menuconfig,在lvm/raid/devicemapper下面把ioband模块勾选上,重新编译安装内核,重启之后lsmod | grep ioband,如果能看到ioband,说明安装成功了。

+     Build a kernel with these options enabled:
+
+     CONFIG_MD
+     CONFIG_BLK_DEV_DM
+     CONFIG_DM_IOBAND
+
+
+     If compiled as module, use modprobe to load dm-ioband.
+
+     # make modules
+     # make modules_install
+     # depmod -a
+     # modprobe dm-ioband
+
+
+     "dmsetup targets" command shows all available device-mapper targets.
+   "ioband" and the version number are displayed when dm-ioband has been
+   loaded.
+
+     # dmsetup targets | grep ioband
+     ioband           v1.0.0

 

如果重启之后,发现没有ioband模块,使用modprobe加载,如果仍失败,试使用modprobe -f dm-ioband。

 

使用

逻辑卷创建:

# lvcreate -L size(eg. 100G) -n name(eg. LVM1) vgname(eg. vg0)

# mkfs.ext3 name      逻辑卷上创建ext3文件系统格式

另外pv和vg创建如下所示:

# pvcreate /dev/sdb

# pvcreate /dev/sdc

# vgcreate vg0 /dev/sdb /dev/sdc


ioband使用命令:

1.         创建ioband

#echo "0 $(blockdev --getsize /dev/domu/test) ioband /dev/domu/test 1 0 0 none weight 0 :80" | dmsetup create ioband1

#echo "0 $(blockdev --getsize /dev/domu/test02) ioband /dev/domu/test02 1 0 0 none weight 0 :20" | dmsetup create ioband2

以上两条命令,分别为逻辑卷/dev/domu/test/de/domu/test02创建ioband1ioband2,带宽权重为80:20,即任务通过testtest02使用磁盘资源时,其I/O带宽分配比例为80:20=4:1

 

2.         调节权重

# dmsetup message ioband1 0 weight 60

# dmsetup message ioband2 0 weight 40

以上两条命令,将ioband1ioband2的权重调节为60:40

 

3.         查看状态

# dmsetup table --target ioband

# dmsetup status --target ioband

以上两条命令,可以查看当前系统中各ioband的状态信息。


4.   删除ioband
# dmsetup remove ioband1

参照以下资料:

http://lwn.net/Articles/332934/

http://blog.csdn.net/majieyue/article/details/7298218

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章