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

 

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