Jun 5

[原]执行nova migrate 的时候指定目标主机 雷阵雨

linuxing , 18:21 , 网络服务 » OpenStack , 评论(0) , 引用(0) , 阅读(6849) , Via 本站原创 | |
    通过修改nova 的源码,在nova client 和 nova server 支持 migrate 离线迁移指定目标主机。
   (仅适用于RDO icehouse openstack-nova-2014.1.3-3 版本更新)
※ 注意:在2015-06-10 前提供的patch 有Bug,打入patch 后,执行resize 会报“NoValidHost: No valid host was found.”。原因是 compute/api.py 中 resize() 方法参数顺序的问题,下面的 patch 已经修改。

1.修改代码
客户端patch:


服务端patch:


2.更新版本
客户端:
引用
[root@hh-yun-puppet-129021 ~]# yum update python-novaclient
Updated:
python-novaclient.noarch 1:2.17.0-3.el6
Complete!

服务端:
引用
[root@hh-yun-nova-129161 ~]# yum update openstack-nova* python-nova*
更新完毕:
openstack-nova-api.noarch 0:2014.1.3-4.el6 openstack-nova-cert.noarch 0:2014.1.3-4.el6 openstack-nova-common.noarch 0:2014.1.3-4.el6 openstack-nova-conductor.noarch 0:2014.1.3-4.el6
openstack-nova-console.noarch 0:2014.1.3-4.el6 openstack-nova-novncproxy.noarch 0:2014.1.3-4.el6 openstack-nova-scheduler.noarch 0:2014.1.3-4.el6 python-nova.noarch 0:2014.1.3-4.el6
python-novaclient.noarch 1:2.17.0-3.el6
完毕!
更新完毕:
[root@hh-yun-nova-129162 ~]# yum update openstack-nova* python-nova* -y
openstack-nova-api.noarch 0:2014.1.3-4.el6 openstack-nova-cert.noarch 0:2014.1.3-4.el6 openstack-nova-common.noarch 0:2014.1.3-4.el6 openstack-nova-conductor.noarch 0:2014.1.3-4.el6
openstack-nova-console.noarch 0:2014.1.3-4.el6 openstack-nova-novncproxy.noarch 0:2014.1.3-4.el6 openstack-nova-scheduler.noarch 0:2014.1.3-4.el6 python-nova.noarch 0:2014.1.3-4.el6
python-novaclient.noarch 1:2.17.0-3.el6

完毕!
3.使用及测试
帮助:
引用
[hyphen@hh-yun-puppet-129021 ~(keystone_admin)]$ nova help migrate
usage: nova migrate [--poll] []
Migrate a server. The new host will be selected by the scheduler.
Positional arguments:
    Name or ID of server.
      destination host name.
Optional arguments:
  --poll    Blocks while server migrates so progress can be reported.

自动调度进行离线迁移:
引用
[hyphen@hh-yun-puppet-129021 ~(keystone_admin)]$ nova migrate d8d7a852-21d1-461e-a286-2e83a1bfed9d --poll
Server migrating... 100% complete
Finished

指定目标主机进行离线迁移:
引用
[hyphen@hh-yun-puppet-129021 ~(keystone_admin)]$ nova migrate d8d7a852-21d1-461e-a286-2e83a1bfed9d hh-yun-compute-130144.vclound.com --poll
Server migrating... 100% complete
Finished

4.注意事项
1)更新后的版本仍支持不指定目标主机的情况,若不指定目标主机,会由过滤器 Filter 执行选择目标主机;
2)按openstack nova 的执行逻辑,nova migrate 执行后,nova api 接受请求就会返回成功,而迁移及调度都是在后台才进行的。
所以,执行nova migrate uuid host 后,还需要通过 nova show uuid 查看迁移是否开始,再次确认;
若没有开始,可查看 nova 控制节点的api/conductor/scheduler 服务日志;
3)为避免破坏nova 虚拟化比例的调度策略,在指定目标主机后,若过滤器 Filter 仍会对实例和目标主机进行审计,若资源不足,迁移不会继续;
scheduler 提示:Filter ComputeFilter returned 0 hosts
引用
2015-06-04 12:03:31.131 111251 INFO nova.filters [req-762997fa-a4a3-4d38-b784-e30148582b91 226e71f1c1aa4bae85485d1d17b6f0ae bb0b51d166254dc99bc7462c0ac002ff] Filter ComputeFilter returned 0 hosts
2015-06-04 12:04:09.128 111251 AUDIT nova.scheduler.host_manager [req-ae4b6ef2-e36b-4158-84a5-6e1fd36b2172 226e71f1c1aa4bae85485d1d17b6f0ae bb0b51d166254dc99bc7462c0ac002ff] Host filter ignoring hosts:
conductor 提示:NoValidHost: No valid host was found.
2015-06-04 12:03:31.136 111333 WARNING nova.scheduler.utils [req-762997fa-a4a3-4d38-b784-e30148582b91 226e71f1c1aa4bae85485d1d17b6f0ae bb0b51d166254dc99bc7462c0ac002ff] Failed to compute_task_migrate_server: No valid host was found.
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/oslo/messaging/rpc/server.py", line 139, in inner
return func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/nova/scheduler/manager.py", line 298, in select_destinations
filter_properties)
File "/usr/lib/python2.6/site-packages/nova/scheduler/filter_scheduler.py", line 140, in select_destinations
raise exception.NoValidHost(reason='')
NoValidHost: No valid host was found.
2015-06-04 12:03:31.137 111333 WARNING nova.scheduler.utils [req-762997fa-a4a3-4d38-b784-e30148582b91 226e71f1c1aa4bae85485d1d17b6f0ae bb0b51d166254dc99bc7462c0ac002ff] [instance: d8d7a852-21d1-461e-a286-2e83a1bfed9d] Setting instance to ACTIVE state.
2015-06-04 12:03:31.201 111333 WARNING nova.conductor.manager [req-762997fa-a4a3-4d38-b784-e30148582b91 226e71f1c1aa4bae85485d1d17b6f0ae bb0b51d166254dc99bc7462c0ac002ff] [instance: d8d7a852-21d1-461e-a286-2e83a1bfed9d] No valid host found for cold migrate

4)按 Nova Filter 的策略,调度的目标主机所在zone 必须与实例所在的zone 一致,例如都是qa-zone 。
实例的 zone 记录在instances 表中:
引用
mysql> select uuid,hostname,availability_zone,launched_on,host,node from instances where uuid='d8d7a852-21d1-461e-a286-2e83a1bfed9d'\G;
*************************** 1. row ***************************
uuid: d8d7a852-21d1-461e-a286-2e83a1bfed9d
hostname: hyphen-demo
availability_zone: qa-zone
launched_on: hh-yun-compute-130142.vclound.com
host: hh-yun-compute-130144.vclound.com
node: hh-yun-compute-130144.vclound.com
1 row in set (0.00 sec)

通过 nova show uuid 也会显示 zone 的位置:
引用
[hyphen@hh-yun-puppet-129021 ~(keystone_admin)]$ nova show d8d7a852-21d1-461e-a286-2e83a1bfed9d|grep zone
| OS-EXT-AZ:availability_zone | qa-zone |

但该值显示的是实例宿主机所对应的 zone 位置,若这时宿主机的zone 改变了,那么,显示的结果就与实例数据库中的值不一致了,务必小心。
所以,迁移的实例 zone 应该与目标主机所在的zone 一致,并且以实例数据库中记录的 availability_zone 位置为准;
5)已经被disable 或者 down 的主机不能作为目标主机
调度器会自动屏蔽 disable 或者 down 的主机:
引用
2015-06-04 12:03:31.113 111251 INFO nova.scheduler.host_manager [req-762997fa-a4a3-4d38-b784-e30148582b91 226e71f1c1aa4bae85485d1d17b6f0ae bb0b51d166254dc99bc7462c0ac002ff] Removing dead compute node hh-yun-compute-130143.vclound.com:hh-yun-compute-130143.vclound.com from scheduler

所以,即使目标主机指定这些宿主机,迁移也不会进行的。
6)离线迁移会转换实例的磁盘文件
所以,只能从宿主机为低版本的qemu-img 往高版本的宿主机迁移,即CentOS 6 往CentOS 7迁移;反向是失败的,并提示下面的错误:
引用
| Stderr: u\"'image' uses a qcow2 feature which is not supported by this qemu versio", "code": 500, "details": " File \"/usr/lib/python2.6/site-packages/nova/compute/manager.py\", line 290, in decorated_function |

这是由于存在不同qemu-img 版本宿主机的原因。
万一发生该问题,无法回退或撤销revert 迁移,只能手动处理,务必注意。
Tags: ,
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]