kvm虚拟化学习笔记(七)之kvm虚拟机克隆

简介:

kvm虚拟机的克隆分为两种情况,本文也就通过以下两种情况进行克隆,克隆虚拟机为CentOS6.5x86_64。

(1) KVM主机本机虚拟机直接克隆。

(2) 通过复制配置文件与磁盘文件的虚拟机复制克隆(适用于异机的静态迁移)。

1.  本机虚拟机直接克隆

(1) 查看虚拟机配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
[root@node1 ~] # cat /etc/libvirt/qemu/CentOS6.5-01.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE 
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
   virsh edit CentOS6.5-01
or other application using the libvirt API.
-->
 
<domain  type = 'kvm' >
   <name>CentOS6.5-01< /name >
   <uuid>7d48f7b5-2fbf-91a9-2c3f-e52ba6079c8e< /uuid >
   <memory unit= 'KiB' >1048576< /memory >
   <currentMemory unit= 'KiB' >1048576< /currentMemory >
   <vcpu placement= 'static' >1< /vcpu >
   <os>
     < type  arch= 'x86_64'  machine= 'rhel6.6.0' >hvm< /type >
     <boot dev= 'hd' />
   < /os >
   <features>
     <acpi/>
     <apic/>
     <pae/>
   < /features >
   <clock offset= 'utc' />
   <on_poweroff>destroy< /on_poweroff >
   <on_reboot>restart< /on_reboot >
   <on_crash>restart< /on_crash >
   <devices>
     <emulator> /usr/libexec/qemu-kvm < /emulator >
     <disk  type = 'file'  device= 'disk' >
       <driver name= 'qemu'  type = 'raw'  cache= 'none' />
       < source  file = '/data/kvm/CentOS6.5-01.img' />
       <target dev= 'vda'  bus= 'virtio' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x05'  function = '0x0' />
     < /disk >
     <disk  type = 'block'  device= 'cdrom' >
       <driver name= 'qemu'  type = 'raw' />
       <target dev= 'hdc'  bus= 'ide' />
       < readonly />
       <address  type = 'drive'  controller= '0'  bus= '1'  target= '0'  unit= '0' />
     < /disk >
     <controller  type = 'usb'  index= '0'  model= 'ich9-ehci1' >
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x7' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci1' >
       <master startport= '0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x0'  multifunction= 'on' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci2' >
       <master startport= '2' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x1' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci3' >
       <master startport= '4' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x2' />
     < /controller >
     <controller  type = 'ide'  index= '0' >
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x01'  function = '0x1' />
     < /controller >
     <interface  type = 'bridge' >
       <mac address= '52:54:00:56:9a:7f' />
       < source  bridge= 'br0' />
       <model  type = 'virtio' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x03'  function = '0x0' />
     < /interface >
     <serial  type = 'pty' >
       <target port= '0' />
     < /serial >
     <console  type = 'pty' >
       <target  type = 'serial'  port= '0' />
     < /console >
     <input  type = 'mouse'  bus= 'ps2' />
     <graphics  type = 'vnc'  port= '5910'  autoport= 'no'  listen= '0.0.0.0' >
       <listen  type = 'address'  address= '0.0.0.0' />
     < /graphics >
     <video>
       <model  type = 'cirrus'  vram= '9216'  heads= '1' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x02'  function = '0x0' />
     < /video >
     <memballoon model= 'virtio' >
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x06'  function = '0x0' />
     < /memballoon >
   < /devices >
< /domain >
[root@node1 ~] #

虚拟机磁盘文件: /data/kvm/CentOS6.5-01.img

虚拟机名称:CentOS6.5-01

df9cb42d56fe9467ce61e968a1bdd8be.jpg-wh_

(2) 开始克隆

# virt-clone -o CentOS6.5-01 -n CentOS6.5-02 -f /data/kvm/CentOS6.5-02.img

说明:以CentOS6.5-01做为源,克隆CentOS6.5-01虚拟机,并创建名称为CentOS6.5-02虚拟机,使用磁盘文件/data/kvm/CentOS6.5-02.img

7654eb3950ddb314b8082d217e9ddd71.png-wh_

注:Domain with devices to clone must be paused or shutoff

(3) 启动虚拟机并配置主机名,IP地址等

9062e065d31a9a01fedea9bb0e5347b4.png-wh_

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
[root@node1 ~] # virsh console CentOS6.5-02
Connected to domain CentOS6.5-02
Escape character is ^]
            Welcome to CentOS 
Starting udev: G[  OK  ]
Setting  hostname  CentOS6.5-01:  [  OK  ]
Setting up Logical Volume Management:   No volume  groups  found
[  OK  ]
Checking filesystems
Checking all  file  systems.
[ /sbin/fsck .ext4 (1) -- /]  fsck .ext4 -a  /dev/vda3 
/dev/vda3 : clean, 64707 /413712  files, 435066 /1652480  blocks
[ /sbin/fsck .ext4 (1) --  /boot fsck .ext4 -a  /dev/vda1 
/dev/vda1 : Superblock last write  time  is  in  the future.
         (by  less  than a day, probably due to the hardware clock being incorrectly  set ).  FIXED.
/dev/vda1 : clean, 38 /51200  files, 36139 /204800  blocks
[  OK  ]
Remounting root filesystem  in  read -write mode:  [  OK  ]
Mounting  local  filesystems:  [  OK  ]
Enabling  local  filesystem quotas:  [  OK  ]
Enabling  /etc/fstab  swaps:  [  OK  ]
Entering non-interactive startup
Calling the system activity data collector (sadc)... 
ip6tables: Applying firewall rules: [  OK  ]
iptables: Applying firewall rules: [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  Device eth0 does not seem to be present, delaying initialization.
[FAILED]
Starting auditd: [  OK  ]
Starting system logger: [  OK  ]
Starting irqbalance: [  OK  ]
Starting kdump:[FAILED]
Starting system message bus: [  OK  ]
Mounting filesystems:  [  OK  ]
Starting acpi daemon: [  OK  ]
Starting HAL daemon: [  OK  ]
Retrigger failed udev events[  OK  ]
Adding udev persistent rules[  OK  ]
Starting sshd: [  OK  ]
Starting postfix: [  OK  ]
Starting abrt daemon: [  OK  ]
Starting crond: [  OK  ]
Starting atd: [  OK  ]
 
CentOS release 6.5 (Final)
Kernel 2.6.32-431.el6.x86_64 on an x86_64
 
CentOS6.5-01 login: root
Password: 
Last login: Wed Nov 22 13:10:59 from 192.168.21.128
[root@CentOS6 ~] #

(4) 修改主机名,IP地址等

修改主机名

1
2
3
4
5
[root@CentOS6 ~] # cat /etc/sysconfig/network
NETWORKING= yes
HOSTNAME=CentOS6.5-02
GATEWAY=10.10.172.1
[root@CentOS6 ~] # hostname CentOS6.5-02

修改IP地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@CentOS6 ~] # cat /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE=eth0
TYPE=Ethernet
UUID=77733023-71ab-41bf-9cfb-2a2a5510857a
ONBOOT= yes
NM_CONTROLLED= yes
BOOTPROTO=none
HWADDR=52:54:00:56:9A:7F
IPADDR=10.10.172.243
PREFIX=24
GATEWAY=10.10.172.1
DNS1=192.168.172.208
DNS2=192.168.172.209
DEFROUTE= yes
IPV4_FAILURE_FATAL= yes
IPV6INIT=no
NAME= "System eth0"
[root@CentOS6 ~] #

重启网卡服务:

1
2
3
4
5
6
[root@CentOS6 ~] # service network restart
Shutting down loopback interface:  [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  Device eth0 does not seem to be present, delaying initialization.
[FAILED]
[root@CentOS6 ~] #

2.  复制配置文件与磁盘文件克隆

(1) 导入kvm虚拟机配置文件

这里采用oeltest01做为模板,进行克隆。

# virsh shutdown CentOS6.5-01

4f51ef45eb86f3acf0c2e2a1e95d37f1.png-wh_

# virsh dumpxml CentOS6.5-01 > /etc/libvirt/qemu/CentOS6.5-03.xml

1982807fb27a2b3ccd3c7f6f3ee950d1.png-wh_

(2) 复制kvm虚拟机磁盘文件

本系列文章都是采用虚拟磁盘文件进行测试,没有使用lvm卷。

通过查看配置文件:虚拟磁盘位置<source file='/data/kvm/CentOS6.5-01.img'/>

5ef49381237d092146dbee8688051ef0.png-wh_

(3) 直接编辑修改配置文件

修改name,uuid,disk位置,vnc端口

此时还是将该配置文件注册进来,无法通过virsh edit进行编辑。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
[root@node1 kvm] # cat /etc/libvirt/qemu/CentOS6.5-03.xml 
<domain  type = 'kvm'  id = '17' >
   <name>CentOS6.5-03< /name >
   <uuid>7d48f7b5-2fbf-91a9-2c3f-e52ba6079c8d< /uuid >
   <memory unit= 'KiB' >1048576< /memory >
   <currentMemory unit= 'KiB' >1048576< /currentMemory >
   <vcpu placement= 'static' >1< /vcpu >
   <os>
     < type  arch= 'x86_64'  machine= 'rhel6.6.0' >hvm< /type >
     <boot dev= 'hd' />
   < /os >
   <features>
     <acpi/>
     <apic/>
     <pae/>
   < /features >
   <clock offset= 'utc' />
   <on_poweroff>destroy< /on_poweroff >
   <on_reboot>restart< /on_reboot >
   <on_crash>restart< /on_crash >
   <devices>
     <emulator> /usr/libexec/qemu-kvm < /emulator >
     <disk  type = 'file'  device= 'disk' >
       <driver name= 'qemu'  type = 'raw'  cache= 'none' />
       < source  file = '/data/kvm/CentOS6.5-03.img' />
       <target dev= 'vda'  bus= 'virtio' />
       < alias  name= 'virtio-disk0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x05'  function = '0x0' />
     < /disk >
     <disk  type = 'block'  device= 'cdrom' >
       <driver name= 'qemu'  type = 'raw' />
       <target dev= 'hdc'  bus= 'ide' />
       < readonly />
       < alias  name= 'ide0-1-0' />
       <address  type = 'drive'  controller= '0'  bus= '1'  target= '0'  unit= '0' />
     < /disk >
     <controller  type = 'usb'  index= '0'  model= 'ich9-ehci1' >
       < alias  name= 'usb0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x7' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci1' >
       < alias  name= 'usb0' />
       <master startport= '0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x0'  multifunction= 'on' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci2' >
       < alias  name= 'usb0' />
       <master startport= '2' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x1' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci3' >
       < alias  name= 'usb0' />
       <master startport= '4' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x2' />
     < /controller >
     <controller  type = 'ide'  index= '0' >
       < alias  name= 'ide0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x01'  function = '0x1' />
     < /controller >
     <interface  type = 'bridge' >
       <mac address= '52:54:00:56:9a:7f' />
       < source  bridge= 'br0' />
       <target dev= 'vnet1' />
       <model  type = 'virtio' />
       < alias  name= 'net0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x03'  function = '0x0' />
     < /interface >
     <serial  type = 'pty' >
       < source  path= '/dev/pts/2' />
       <target port= '0' />
       < alias  name= 'serial0' />
     < /serial >
     <console  type = 'pty'  tty = '/dev/pts/2' >
       < source  path= '/dev/pts/2' />
       <target  type = 'serial'  port= '0' />
       < alias  name= 'serial0' />
     < /console >
     <input  type = 'mouse'  bus= 'ps2' />
     <graphics  type = 'vnc'  port= '5913'  autoport= 'no'  listen= '0.0.0.0' >
       <listen  type = 'address'  address= '0.0.0.0' />
     < /graphics >
     <video>
       <model  type = 'cirrus'  vram= '9216'  heads= '1' />
       < alias  name= 'video0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x02'  function = '0x0' />
     < /video >
     <memballoon model= 'virtio' >
       < alias  name= 'balloon0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x06'  function = '0x0' />
     < /memballoon >
   < /devices >
< /domain >

(4) 定义新虚拟机配置文件

[root@node1 kvm]# virsh define /etc/libvirt/qemu/CentOS6.5-03.xml 

983c350c1fe4abbcd0cccbef6464b472.png-wh_

启动虚拟机

1
2
[root@node1 kvm] # virsh start CentOS6.5-03
Domain CentOS6.5-03 started

(5) 登录虚拟机进行主机名,IP等修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[root@node1 kvm] # virsh console CentOS6.5-03
Connected to domain CentOS6.5-03
Escape character is ^]
            Welcome to CentOS 
Starting udev: G[  OK  ]
Setting  hostname  CentOS6.5-01:  [  OK  ]
Setting up Logical Volume Management:   No volume  groups  found
[  OK  ]
Checking filesystems
Checking all  file  systems.
[ /sbin/fsck .ext4 (1) -- /]  fsck .ext4 -a  /dev/vda3 
/dev/vda3 : clean, 64734 /413712  files, 435081 /1652480  blocks
[ /sbin/fsck .ext4 (1) --  /boot fsck .ext4 -a  /dev/vda1 
/dev/vda1 : recovering journal
/dev/vda1 : clean, 38 /51200  files, 36139 /204800  blocks
[  OK  ]
Remounting root filesystem  in  read -write mode:  [  OK  ]
Mounting  local  filesystems:  [  OK  ]
Enabling  local  filesystem quotas:  [  OK  ]
Enabling  /etc/fstab  swaps:  [  OK  ]
Entering non-interactive startup
Calling the system activity data collector (sadc)... 
ip6tables: Applying firewall rules: [  OK  ]
iptables: Applying firewall rules: [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  Determining  if  ip address 10.10.172.241 is already  in  use  for  device eth0...
[  OK  ]
Starting auditd: [  OK  ]
Starting system logger: [  OK  ]
Starting irqbalance: [  OK  ]
Starting kdump:[FAILED]
Starting system message bus: [  OK  ]
Mounting filesystems:  [  OK  ]
Starting acpi daemon: [  OK  ]
Starting HAL daemon: [  OK  ]
Retrigger failed udev events[  OK  ]
Starting sshd: [  OK  ]
Starting postfix: [  OK  ]
Starting abrt daemon: [  OK  ]
Starting crond: [  OK  ]
Starting atd: [  OK  ]
 
CentOS release 6.5 (Final)
Kernel 2.6.32-431.el6.x86_64 on an x86_64
 
CentOS6.5-01 login: root
Password: 
Last login: Wed Nov 22 13:10:59 from 192.168.21.128
[root@CentOS6 ~]
[root@CentOS6 ~] #

修改主机名

1
2
3
4
5
6
7
[root@CentOS6 ~] # sed -i '/HOSTNAME/s/CentOS6.5-01/CentOS6.5-03/g' /etc/syscog/network
[root@CentOS6 ~] # cat /etc/sysconfig/network
NETWORKING= yes
HOSTNAME=CentOS6.5-03
GATEWAY=10.10.172.1
[root@CentOS6 ~] # hostname CentOS6.5-03
[root@CentOS6 ~] #

修改IP地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@CentOS6 ~] # vi /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE=eth0
TYPE=Ethernet
UUID=77733023-71ab-41bf-9cfb-2a2a5510857a
ONBOOT= yes
NM_CONTROLLED= yes
BOOTPROTO=none
HWADDR=52:54:01:56:9A:7F
IPADDR=10.10.172.243
PREFIX=24
GATEWAY=10.10.172.1
DNS1=192.168.172.208
DNS2=192.168.172.209
DEFROUTE= yes
IPV4_FAILURE_FATAL= yes
IPV6INIT=no
NAME= "System eth0"
[root@CentOS6 ~] #

重启网卡服务

1
2
3
4
5
6
7
[root@CentOS6 ~] # service network restart
Shutting down interface eth0:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  Determining  if  ip address 10.10.172.243 is already  in  use  for  device eth0...
[  OK  ]
[root@CentOS6 ~] #

修改70-persistent-net.rules文件

1
2
3
4
5
6
7
8
9
10
[root@CentOS6 ~] # cat /etc/udev/rules.d/70-persistent-net.rules 
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
 
# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM== "net" , ACTION== "add" , DRIVERS== "?*" , ATTR{address}== "52:54:01:56:9a:7f" , ATTR{ type }== "1" , KERNEL== "eth*" , NAME= "eth0"
[root@CentOS6 ~] #

本文到此通过两种方式进行kvm虚拟机克隆,其实各有用处。

再次说明:本文克隆的虚拟机是CentOS6.5,如果克隆的虚拟机是RHEL/CentOS/OEL6.x操作系统,需要修改/etc/udev/rules.d/70-persistent-net.rules文件。



本文转自 dengaosky 51CTO博客,原文链接:http://blog.51cto.com/dengaosky/1984068,如需转载请自行联系原作者

相关文章
|
Linux 虚拟化 数据安全/隐私保护
VMware使用 - 虚拟机克隆
如果已经安装了一台Linux操作系统,没有必要重新安装,只需要克隆就可以了,有两种方式。
23 0
|
4月前
|
存储 虚拟化 数据中心
如何操作VMware ESXi虚拟机的克隆?
如何操作VMware ESXi虚拟机的克隆?
86 1
|
5天前
|
Linux KVM 数据库
虚拟机数据恢复—误删除KVM虚拟机的数据恢复案例
虚拟化数据恢复环境&故障: KVM是Kernel-based Virtual Machine的简称,是一个开源的系统虚拟化模块,自Linux2.6.20版本之后集成在Linux的各个主要发行版本中。KVM使用Linux自身的调度器进行管理。 本案例中的服务器操作系统为Linux,文件系统为EXT4。操作系统上的部署的几台KVM虚拟机被删除,每台KVM虚拟机包含一个qcow2格式的磁盘文件和一个raw格式的磁盘文件,用户需要恢复的数据是raw格式的磁盘文件。这几台被误删除的虚拟机存放的是数据库,程序代码等数据。
|
1月前
|
存储 KVM 虚拟化
倚天产品介绍|倚天虚拟化:虚拟机热迁移特性介绍
热迁移分为热迁移和冷迁移,冷迁移过程中有一段明显的时间VM的服务不可用,而热迁移的服务的服务暂停时间非常短。热迁移过程中无需关闭或者长时间暂停VM,VM保持正常运行,只有在热迁移临近结束时有一个非常短暂的停机切换时间。热迁移可保证了VM服务的可用性,提升业务的连续性和用户体验。
|
6月前
|
监控 数据挖掘 虚拟化
VMWare 虚拟机 CPU 设置里针对 CPU 的 虚拟化 CPU 性能计数器(U) 选项功能介绍
VMWare 虚拟机 CPU 设置里针对 CPU 的 虚拟化 CPU 性能计数器(U) 选项功能介绍
537 0
|
6月前
|
安全 虚拟化
VMWare 虚拟机 CPU 设置里针对 CPU 的虚拟化 IOMMU(IO 内存管理单元) 选项功能介绍
VMWare 虚拟机 CPU 设置里针对 CPU 的虚拟化 IOMMU(IO 内存管理单元) 选项功能介绍
372 0
|
4月前
|
机器学习/深度学习 Ubuntu Linux
如何在Ubuntu 23.10部署KVM并创建虚拟机?
如何在Ubuntu 23.10部署KVM并创建虚拟机?
70 0
|
5月前
|
虚拟化
VMware Workstation批量克隆虚拟机
VMware Workstation批量克隆虚拟机
77 0
|
7月前
|
存储 KVM 虚拟化
倚天虚拟化:虚拟机热迁移特性介绍
热迁移分为热迁移和冷迁移,冷迁移过程中有一段明显的时间VM的服务不可用,而热迁移的服务的服务暂停时间非常短。热迁移过程中无需关闭或者长时间暂停VM,VM保持正常运行,只有在热迁移临近结束时有一个非常短暂的停机切换时间。热迁移可保证了VM服务的可用性,提升业务的连续性和用户体验。
|
8月前
|
虚拟化
虚拟化——成功解决ovirt修改ifcfg-ovirtmgmt的ip之后,重启虚拟机没有效果的问题
虚拟化——成功解决ovirt修改ifcfg-ovirtmgmt的ip之后,重启虚拟机没有效果的问题