声明:
本博客欢迎转发,但请保留原作者信息!
博客地址:http://blog.csdn.net/halcyonbaby
内容系本人学习、研究和总结,如有雷同,实属荣幸!
Openstack卷迁移限速
为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)
- CLI/Web产生卷的os-migrate_volume操作消息。
- API层获取rest消息,提取消息内容
- 过滤有快照的卷(不支持迁移),检查host有效性(可用,与源host不是一个)
- 进行filter过滤确定host适合迁移
- 对--force-host-copy为true的情况,使用migratevolume_generic函数。
对--force-host-copy为false的情况,使用cinder driver的migrate_volume接口。
migratevolume_generic函数处理过程:
- 在remote host上创建volume
- copy volume
a. 卷被挂载在正在运行的虚拟机上:利用虚拟机存储迁移功能
b. 卷未被挂载在正在运行的虚拟机上:参考driver的copy_volume_data接口,内部为dd命令拷贝卷(volume_utils.copy_volume)
dd限速手段(利用pv工具)
可以使用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/秒
python中多级管道的例子
[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. 通过配置文件设置
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)