查看libvirtd的状态:

[root@super67 ~]# /etc/init.d/libvirtd status

libvirtd (pid  2503) is running...

安装vnc:

[root@super67 ~]# yum install -y tigervnc

[root@super67 ~]# yum install -y virt-viewer

查看虚拟机状态:

[root@super67 ~]# virsh list --all

Id    Name                           State

----------------------------------------------------

-     www.linux1.cn                  shut off

准备镜像文件:

[root@super67 ~]# ll /var/lib/libvirt/images/ubuntu-16.04-desktop-amd64.iso

创建磁盘:

[root@super67 ~]# mkdir /var/lib/libvirt/disk/ -p

[root@super67 ~]# qemu-img create -f raw /var/lib/libvirt/disk/unbuntu16.raw 10G

Formatting '/var/lib/libvirt/disk/unbuntu16.raw', fmt=raw size=10737418240

安装虚拟机:

[root@super67 ~]# virt-install --name ubuntu16 --ram 1024 --vcpu=1 --disk path=/var/lib/libvirt/disk/unbuntu16.raw --accelerate --cdrom=/var/lib/libvirt/images/ubuntu-16.04-desktop-amd64.iso --network bridge=br0 --graphics vnc

"""

--name=ubuntu16 #指定guest的名字
--ram=1024 #指定内存大小
--vcpus=1 #指定cpu个数
--disk path=/xx/xx.xx #指定磁盘
--accelerate #加速
--cdrom /xx/xx.iso 指定镜像
--network bridge=br0 #bridge=xx , network:name ,user
--graphics vnc
--location= #directory ,nfs:host:/path ,http://host/path ,ftp://host/path

"""

配置vnc:

[root@super67 ~]# grep -Ev "^$|^#" /etc/libvirt/qemu.conf

vnc_listen = "0.0.0.0"

[root@super67 ~]# /etc/init.d/libvirtd restart

Stopping libvirtd daemon:                                  [  OK  ]

Starting libvirtd daemon:                                  [  OK  ]

[root@super67 ~]# netstat -antup|grep 5900

tcp        0      0 0.0.0.0:5900              0.0.0.0:*                   LISTEN      18413/qemu-kvm

(如果vnc只是监听127.0.0.1那么其他机器是无法使用vnc客户端连接进来的)

vnc远程连接:5900

[root@super67 ~]# vncviewer 127.0.0.1:5900

配置文件:

[root@super67 qemu]# pwd

/etc/libvirt/qemu

[root@super67 qemu]# ll

total 16

drwxr-xr-x 2 root root 4096 Sep  4 10:31 autostart            #开机启动相关

drwx------ 3 root root 4096 Sep  4 09:46 networks             #网络相关

-rw------- 1 root root 2290 Sep  4 13:13 ubuntu16.xml          #虚拟机配置文件  .xml

-rw------- 1 root root 2574 Sep  4 10:32 www.linux1.cn.xml

虚拟机配置文件:

[root@super67 ~]# vim /etc/libvirt/qemu/ubuntu16.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 ubuntu16

or other application using the libvirt API.

-->

<domain type='kvm'>                                                #虚拟机类型

<name>ubuntu16</name>                               #虚拟机名字

<uuid>729109f3-6bcc-2f44-b1d3-4f9f6bface83</uuid>

<memory unit='KiB'>1048576</memory>        #虚拟机最大内存

<currentMemory unit='KiB'>1048576</currentMemory>      #虚拟机当前内存

<vcpu placement='static'>1</vcpu>              #cpu个数

<os>

<type arch='x86_64' machine='rhel6.5.0'>hvm</type>     #全虚拟化

<boot dev='hd'/>                      #引导类型hd硬盘引导,cdrom光盘引导

</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='/var/lib/libvirt/disk/unbuntu16.raw'/>            #磁盘文件

<target dev='hda' bus='ide'/>

<address type='drive' controller='0' bus='0' target='0' unit='0'/>

</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'>

<address type='pci' domain='0x0000' bus='0x00' slot='0x01' 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:b0:48:17'/>      #mac地址

<source bridge='br0'/>              #网桥名

<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='-1' autoport='yes'/>

<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='0x04' function='0x0'/>

</memballoon>

</devices>

</domain>

命令行安装KVM的更多相关文章

  1. 命令行安装kvm虚拟机、桥接网络、用virt-manager管理

    宿主机CentOS Linux release 7.2.1511 (Core),内核3.10.0-327.el7.x86_64 1.配置宿主机网络桥接 想让虚拟机有自己的ip且外网可访问,需要在安装虚 ...

  2. 04.ubuntu下kvm 命令行安装64位ubuntu报"Couldn't find hvm kernel for Ubuntu tree."的问题

    1.安装ubuntu时使用的virt-install的配置: virt-install \ --name test4 \ --ram 1024 \ --disk path=/data/01_ubunt ...

  3. Linux下命令行安装weblogic10.3.6

    Linux下命令行安装weblogic10.3.6 一.安装前准备工作: 1.创建用户useradd weblogic;创建用户成功linux系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...

  4. Oracle 图形化以及命令行安装

    @(Oracle)[Install] Oracle 安装 相关版本说明 不同版本的Oracle需要安装在特定的系统版本之上. 如Oracle 11gR2的11.2.0.1.0需要安装在CentOS 5 ...

  5. Oracle 11gR2静默安装 & 命令行安装

    静默安装 经常搭建Oracle测试环境,有时候觉得OUI(即图形界面)方式甚是繁琐,你得一步一步进行确认,所幸,Oracle支持静默安装.在我看来,它主要有两方面的好处:一.极大地提升了效率,尤其是批 ...

  6. VMware10中的CentOS6.5命令行安装VMwaretools工具启用windows与虚拟机中Linux系统的共享目录

    VMware10中的CentOS6.5命令行安装VMwaretools工具启用windows与虚拟机中Linux系统的共享目录 一.描述 系统描述:win7旗舰版64位系统+VMware Workst ...

  7. Appium Mac 命令行安装

    试过很多方法都失败,打算用命令行方式安装. 准备工作: 从 https://github.com/appium/appium下载appium版本的源码(.tar) 详见github_Appium1.6 ...

  8. macos 命令行安装 ipa

    macos 命令行安装 ipa 苹果发神经后itunes已经无法在安装app了,如果有知道的兄弟可以告诉我啊 ideviceinstaller 使用这个开源项目可以在macos下安装app brew ...

  9. Linux系统--命令行安装weblogic10.3.6

    Linux下命令行安装weblogic10.3.6 一.安装前准备工作: 1.创建用户useradd weblogic;创建用户成功linux系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...

随机推荐

  1. encode和decode

    Python字符串的encode与decode研究心得乱码问题解决方法 为什么会报错“UnicodeEncodeError: 'ascii' codec can't encode characters ...

  2. iOS 中通过使用Google API获得Google服务

    最近使用了google drive这个云存储,官方指导网址为 https://developers.google.com/drive/ios/ . 官方库代码网址为 http://code.googl ...

  3. IOS多线程(GCD)

    简介 Grand Central Dispatch 简称(GCD)是苹果公司开发的技术,以优化的应用程序支持多核心处理器和其他的对称多处理系统的系统.这建立在任务并行执行的线程池模式的基础上的.它首次 ...

  4. iOS开发——开发实战篇&版本控制SVN和Git使用详解

     版本控制SVN和Git使用详解     公司的实际开发中,在天朝使用较多的还是SVN,因为SVN是集中式的,在天朝上班你们都懂的!     -----------------svn--------- ...

  5. 矩形覆盖(codevs 1101)

    题目描述 Description 在平面上有 n 个点(n <= 50),每个点用一对整数坐标表示.例如:当 n=4 时,4个点的坐标分另为:p1(1,1),p2(2,2),p3(3,6),P4 ...

  6. [hihoCoder] 博弈游戏·Nim游戏

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 今天我们要认识一对新朋友,Alice与Bob.Alice与Bob总是在进行各种各样的比试,今天他们在玩一个取石子的游戏.在 ...

  7. PHP多文件上传类

    <?php class Upload{ var $saveName;// 保存名 var $savePath;// 保存路径 var $fileFormat = array('gif','jpg ...

  8. BroadcastReceiver应用详解(转)

    转自: http://blog.csdn.net/liuhe688/article/details/6955668 問渠那得清如許?為有源頭活水來.南宋.朱熹<觀書有感> 据说程序员是最爱 ...

  9. Android调用WebService(转)

    Android调用WebService WebService是一种基于SOAP协议的远程调用标准,通过 webservice可以将不同操作系统平台.不同语言.不同技术整合到一块.在Android SD ...

  10. 【bzoj2002】[Hnoi2010]Bounce 弹飞绵羊 分块

    [bzoj2002][Hnoi2010]Bounce 弹飞绵羊 2014年7月30日8101 Description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀 ...