为Openstack基于主机copy迁移卷增加限速能力。
[root@controller ~(keystone_admin)]# cinder help migrate
usage: cinder migrate [--force-host-copy <True|False>] <volume> <host>
Migrate the volume to the new host.
Positional arguments:
<volume> ID of the volume to migrate
<host> Destination host
Optional arguments:
--force-host-copy <True|False>
Optional flag to force the use of the generic host-
based migration mechanism, bypassing driver
optimizations (Default=False).
支持两种类型的迁移:一种是基于Host的通用迁移方式,一种是基于driver的优化迁移方式。
第二种方式可以利用存储本身的能力,实现更为高效的迁移。
通过接口cinder卷的os-migrate_volume接口实现迁移功能。
CLI/Web(1)-----rest req--->cinder API(2)-------->volume API(3)----rpc--->scheduler(4)--rpc-->volume manager(5)
migratevolume_generic函数处理过程:
可以使用pv工具进行限速。
[root@controller ~(keystone_admin)]# dd if=/dev/sda | pv -L 3k |dd of=/home/bigfile
^C24kB 0:00:08 [3.02kB/s] [ <=> ]
记录了2+82 的读入
记录了50+0 的写出
25600字节(26 kB)已复制,8.3499 秒,3.1 kB/秒
[root@controller pipe]# more testpipe.py
import subprocess
if __name__=="__main__":
ddpipe = subprocess.Popen( ["-c", "dd if=/dev/vda count=100 bs=512 | pv -L 3k | dd of=/home/bigfile" ],
stdin= subprocess.PIPE, shell=True )
ddpipe.communicate( "input data\n" )
ddpipe.wait()
[root@controller pipe]# more testpipe2.py
import subprocess
if __name__=="__main__":
child1 = subprocess.Popen(["dd", "if=/dev/vda", "bs=512", "count=100"], stdout=subprocess.PIPE)
child2 = subprocess.Popen(["pv", "-L", "3k"], stdin=child1.stdout, stdout=subprocess.PIPE)
child3 = subprocess.Popen(["dd", "of=/home/bigfile"], stdin=child2.stdout)
out = child3.communicate()
主要有三种方案:
1. 通过接口传入
2. 通过volume metadata设置
3. 通过配置文件设置
原文:http://blog.csdn.net/halcyonbaby/article/details/19617319