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  

你可能感兴趣的:(虚拟机,云计算,openstack,迁移,nova)