通过命令行安装虚拟机

root@ok Desktop]# mkdir /home/virhost
[root@ok Desktop]# virt-install --name centos01 \  #虚拟机名
> --ram=256 \ #内存大小以MB为单位(好像512才能成功)
> --arch=x86_64 \#模拟CPU架构
> --vcpus=1 \#配置虚拟机的vcpu个数
> --check-cpu \#检查确定vcpu是否超过cpu的个数,如果超过则发警报
> --disk path=/home/virhost/centos01.img,device=disk,bus=virtio,size=10,sparse=true  \#虚拟机所用磁盘或镜像文件,以G为单位
> --bridge=br0 \#指定网络,采用网桥(如果不加这个参数默认为NET模式)*******重点!!!!*******)
> --noautoconsole \#自动开启控制台
> --pxe#通过网络安装 注意:如果是本地镜像要指定镜像路径 -c /home/ISO/CentOS-6.7-x86_64-bin-DVD1.iso(注意一个‘-’不是‘--’)

 

[root@ok virhost]# virt-install --name centos01 --ram=512 --arch=x86_64 --vcpus=1 --check-cpu --os-type=linux --disk path=/home/virhost/centos01.img,device=disk,bus=virtio,size=10,sparse=true  --bridge=br0 --noautoconsole -c /home/ISO/CentOS-6.7-x86_64-bin-DVD1.iso

Starting install...
Creating storage file centos01.img                                                                                                               |  10 GB     00:00     
Creating domain...                                                                                                                               |    0 B     00:00     
Domain installation still in progress. You can reconnect to 
the console to complete the installation process.

通过vnc管理虚拟机 加参数--vnc --vncport=6003 --vnclisten=0.0.0.0

[root@ok Downloads]# virt-install --name centos03 --ram=512 --arch=x86_64 --vcpus=1 --check-cpu --os-type=linux --disk path=/home/virhost/centos03.img,device=disk,bus=virtio,size=10,sparse=true  --bridge=br0 --noautoconsole -c /home/ISO/CentOS-6.7-x86_64-bin-DVD1.iso --vnc --vncport=6003 --vnclisten=0.0.0.0

Starting install...
Creating storage file centos03.img                       |  10 GB     00:00     
Creating domain...                                       |    0 B     00:00     
Domain installation still in progress. You can reconnect to 
the console to complete the installation process.

 

[root@ok Downloads]# virsh list
 Id    Name                           State
----------------------------------------------------
 1     centos01                       running
 2     centos02                       running
 4     centos03                       running

 

[root@ok Downloads]# ifconfig
br0       Link encap:Ethernet  HWaddr 54:EE:75:4E:37:D9  
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::56ee:75ff:fe4e:37d9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:505928 errors:0 dropped:0 overruns:0 frame:0
          TX packets:548443 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:31995146 (30.5 MiB)  TX bytes:785482623 (749.0 MiB)

eth0      Link encap:Ethernet  HWaddr 54:EE:75:4E:37:D9  
          inet6 addr: fe80::56ee:75ff:fe4e:37d9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:509163 errors:0 dropped:0 overruns:0 frame:0
          TX packets:548459 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:41995034 (40.0 MiB)  TX bytes:787743184 (751.2 MiB)
          Interrupt:20 Memory:f2600000-f2620000 

 

[root@ok Downloads]# vncviewer 192.168.1.10:6003

TigerVNC Viewer for X version 1.1.0 - built Oct 30 2014 12:44:50
Copyright (C) 1999-2011 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.

Sun Apr 24 09:49:28 2016
 CConn:       connected to host 192.168.1.10 port 6003
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
 TXImage:     Using default colormap and visual, TrueColor, depth 24.
 CConn:       Using pixel format depth 24 (32bpp) little-endian rgb888
 CConn:       Using Tight encoding

 成功链接!!!!

推荐文章:http://blog.chinaunix.net/uid-26941022-id-3509161.html

 命令行安装windows:(装win7测试成功)注意:内存最好在2G;

[root@ok virhost]# virt-install --name win7 --ram 1024 --vcpus=4 \ 
--disk path=/home/virhost/win7.img,size=40 --network bridge=br0  \ 
--cdrom=/home/ISO/Windows.7.ISO --vnclisten=0.0.0.0 --vncport=6904 --vnc

 

 ######################################################

发现:在桥接的情况下,安装虚机不需加--bridge=br0 ,默认就是桥接模式!

###########################################################

问题解决!!!

 

+++++++++++++++++++++++++++++

XP的密钥:MRX3F-47B9T-2487J-KWKMF-RPWBY

WIN2003密钥:JB94D-F976D-6HWGH-JT8T6-8R4DY

posted @ 2016-04-23 10:29  bass  阅读(810)  评论(1编辑  收藏  举报