openstack手工迁移虚拟机方法

作者:【吴业亮】云计算开发工程师
博客:http://blog.csdn.net/wylfengyujiancheng
说明:本次实验有两台物理机controller和computer1,虚拟机demo开始运行在computer1上,目标:手工迁移到controller上
1、查看虚拟机:

[root@controller ~]# source admin-openrc.sh 
[root@controller ~]# nova list --all-te
+--------------------------------------+------+----------------------------------+--------+------------+-------------+--------------------------------------+
| ID                                   | Name | Tenant ID                        | Status | Task State | Power State | Networks                             |
+--------------------------------------+------+----------------------------------+--------+------------+-------------+--------------------------------------+
| 89efece8-0e49-484d-9aaf-7d567ea304b4 | demo | 6e373d2433684b62938a4ad9d14322ac | ACTIVE | -          | Running     | demo-net=213.168.124.4, 213.168.8.12 |
+--------------------------------------+------+----------------------------------+--------+------------+-------------+--------------------------------------+

2、停止待迁移虚拟机

[root@controller ~]# nova stop 89efece8-0e49-484d-9aaf-7d567ea304b4
Request to stop server 89efece8-0e49-484d-9aaf-7d567ea304b4 has been accepted.

3、查看demo虚拟机所在的宿主机

[root@controller ~]# nova show  89efece8-0e49-484d-9aaf-7d567ea304b4 | grep 'OS-EXT-SRV-ATTR:hos'
| OS-EXT-SRV-ATTR:host                 | computer1

4、登录computer1上,将虚拟机数据拷贝到待迁移的宿主机controller上

[root@computer1 instances] cd /var/lib/nova/instances
[root@computer1 instances] scp -rp 89efece8-0e49-484d-9aaf-7d567ea304b4/ controller:$PWD

5、登录到controller上给与权限

[root@controller ~]# cd  /var/lib/nova/instances
[root@controller instances]# chown nova:nova 89efece8-0e49-484d-9aaf-7d567ea304b4/ -R

6、登录数据库更改MySQL中的host、node字段为新的物理主机名字

[root@controller instances]# mysql -uroot -p数据库密码
MariaDB [(none)]> use nova ;
MariaDB [nova]> update instances set host='controller', node='controller' where uuid='89efece8-0e49-484d-9aaf-7d567ea304b4';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

7、现在就可以在目标节点上启动虚拟机了,启动前重启一下controller的compute服务:

[root@controller ~]# service openstack-nova-compute restart
Redirecting to /bin/systemctl restart  openstack-nova-compute.service

8、启动虚拟机:

[root@controller ~]#  nova start 89efece8-0e49-484d-9aaf-7d567ea304b4

9、验证虚拟机所在的宿主机

[root@controller ~]# nova show  89efece8-0e49-484d-9aaf-7d567ea304b4 | grep 'OS-EXT-SRV-ATTR:hos'
| OS-EXT-SRV-ATTR:host                 | controller  
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值