openstack 冷迁移实例

一、冷迁移
1、在控制节点关闭虚拟机
2、在计算节点找到实例位置(/var/lib/nova/instances)
3、将计算节点的需要转移的实例文件copy到目标主机的相同位置下。
4、到目标主机,赋予实例权限
5、登录数据库更改mysql的host,node字段为新的物理主机名。
6、重启目标主机的nova-compute服务。

(1)、查看虚拟机

[root@controller ~]# nova list
+--------------------------------------+-----------+--------+------------+-------------+----------------------------------------------------------+
| ID                                   | Name      | Status | Task State | Power State | Networks                                                 |
+--------------------------------------+-----------+--------+------------+-------------+----------------------------------------------------------+
| f6849e17-a1db-4e2f-be42-2869a2eeec35 | examimage | ACTIVE | -          | Running     | int-net1=10.0.0.114                                      |
| 9ca6f0eb-557a-492d-9540-d4d237f5558f | iaas      | ACTIVE | -          | Running     | int-net2=10.0.1.105; int-net1=10.0.0.109, 192.168.50.103 |
+--------------------------------------+-----------+--------+------------+-------------+----------------------------------------------------------+

(2)、停止准备迁移的虚拟机

[root@controller ~]# nova stop f6849e17-a1db-4e2f-be42-2869a2eeec35
Request to stop server f6849e17-a1db-4e2f-be42-2869a2eeec35 has been accepted.

(3)、查看虚拟机现在的位置

[root@controller ~]# nova show 1f03d8ae-1190-49b5-9590-c7bee2912f69 | grep OS-EXT-SRV-ATTR:host
| OS-EXT-SRV-ATTR:host                 | compute                                                  |
| OS-EXT-SRV-ATTR:hostname             | iaas-all                                                 |

4、登录compute,将虚拟机数据拷贝到controller上

[root@compute ~]# cd /var/lib/nova/instances/
[root@compute instances]# ll
total 12
drwxr-xr-x. 2 nova nova   69 Dec 29 04:53 1f03d8ae-1190-49b5-9590-c7bee2912f69
drwxr-xr-x. 2 nova nova 4096 Dec 31  2019 _base
drwxr-xr-x. 2 nova nova   69 Dec 31  2019 cd68c869-cb71-4d8d-ab1a-1a616c204a76
-rw-r--r--. 1 nova nova   30 Dec 31  2019 compute_nodes
drwxr-xr-x. 2 nova nova 4096 Dec 31  2019 locks
drwxr-xr-x. 2 nova nova    6 Dec 29 09:50 snapshots
[root@compute instances]# scp -rp 1f03d8ae-1190-49b5-9590-c7bee2912f69/ controller:$PWD
root@controller's password: 
console.log                                                                                         100%   56KB  56.2KB/s   00:00    
disk.info                                                                                           100%   79     0.1KB/s   00:00    
disk                                                                                                100%  674MB  84.3MB/s   00:08    
libvirt.xml                                                                                         100% 2858     2.8KB/s   00:00    

5、登录到controller上赋予权限

[root@controller ~]# cd /var/lib/nova/instances/
[root@controller instances]# ll
total 8
drwxr-xr-x. 2 root root   69 Dec 29 04:53 1f03d8ae-1190-49b5-9590-c7bee2912f69
drwxr-xr-x. 2 nova nova   69 Dec 30 04:13 39236af9-bdef-45d1-b8f4-97f7d063284a
drwxr-xr-x. 2 nova nova   69 Dec 29 05:30 945de486-0ea4-49c6-a213-af6a73bae027
drwxr-xr-x. 2 nova nova  100 Dec 29 05:30 _base
-rw-r--r--. 1 nova nova   33 Dec 30 04:49 compute_nodes
drwxr-xr-x. 2 nova nova 4096 Dec 29 05:40 locks
drwxr-xr-x. 2 nova nova    6 Dec 30 04:56 snapshots
[root@controller instances]# chown nova:nova 1f03d8ae-1190-49b5-9590-c7bee2912f69/ -R

6、登录mysql数据库更改里面的host,node为新的物理主机名字

[root@controller instances]# mysql -uroot -p000000
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 347
Server version: 10.1.17-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use nova;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [nova]> update instances set host='controller', node='controller' where uuid='1f03d8ae-1190-49b5-9590-c7bee2912f69';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

7、重启controller节点的compute服务。

[root@controller ~]# systemctl restart openstack-nova-compute.service

8、启动虚拟机

[root@controller ~]# nova start  1f03d8ae-1190-49b5-9590-c7bee2912f69
Request to start server 1f03d8ae-1190-49b5-9590-c7bee2912f69 has been accepted.

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

[root@controller ~]# nova show 1f03d8ae-1190-49b5-9590-c7bee2912f69 | grep 'OS-EXT-SRV-ATTR:host'
| OS-EXT-SRV-ATTR:host                 | controller                                               |
| OS-EXT-SRV-ATTR:hostname             | iaas-all                                                 |
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值