CentOS 下 KVM QEMU 虚拟机 安装 配置 详解(2)

[root@localhost network-scripts]# ifconfig
br0      Link encap:Ethernet  HWaddr F8:BC:12:60:99:86  //有这个就OK
          inet addr:192.168.10.103  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::fabc:12ff:fe60:9986/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:36416 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28648 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:13151508 (12.5 MiB)  TX bytes:5962449 (5.6 MiB)

eth0      Link encap:Ethernet  HWaddr F8:BC:12:60:99:86
          inet6 addr: fe80::fabc:12ff:fe60:9986/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1360857 errors:0 dropped:0 overruns:0 frame:0
          TX packets:902173 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1913592871 (1.7 GiB)  TX bytes:72387220 (69.0 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:176842 errors:0 dropped:0 overruns:0 frame:0
          TX packets:176842 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:880282316 (839.5 MiB)  TX bytes:880282316 (839.5 MiB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:1A:B6:F1
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:4651 (4.5 KiB)

[root@localhost network-scripts]#  brctl show
bridge name    bridge id        STP enabled    interfaces
br0          8000.f8bc12609986    no        eth0    //有这个就OK
virbr0        8000.5254001ab6f1    yes        virbr0-nic

六,用virt-install生成.img文件

# virt-install --name=Ubuntu1 \ 
--ram 1024 --vcpus=1 \ 
--disk path=/root/ubuntu1.img,size=10 \ 
 --accelerate --cdrom /root/ubuntu-14.04-desktop-amd64.iso \ 
--graphics vnc,port=5920 --network bridge=br0 

如果报以下错误:

could not open disk image  : Permission denied

解决方法:

[root@localhost ~]# cat /etc/libvirt/qemu.conf |awk '{if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}'
vnc_listen = "0.0.0.0"
user = "root"              //去掉注释
group = "root"              //去掉注释
dynamic_ownership = 0      //去掉注释,把1改为0

dynamic_ownership = 0      //去掉注释,把1改为0 

这一步做完,系统文件就好了。

七,启动虚拟机

如果报以下错误

[root@localhost ~]# virsh start ubuntu1 
错误:域已经活跃 

解决办法:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/16039.html