查看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. MyBatis3: Could not find SQL statement to include with refid ‘

    错误: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.Incompl ...

  2. HDU 5514 Frogs (容斥原理+因子分解)

    题目链接 题意:有n只青蛙,m个石头(围成圆圈).第i只青蛙每次只能条ai个石头,问最后所有青蛙跳过的石头的下标总和是多少? 题解:暴力肯定会超时,首先分解出m的因子,自己本身不用分,因为石头编号是0 ...

  3. 【读书笔记】读《JavaScript模式》 - 对象创建模式

    JavaScript是一种简洁明了的语言,其中并没有在其他语言中经常使用的一些特殊语法特征,比如命名空间(namespace).模块(module).包(package).私有属性(private p ...

  4. grep -C n "匹配字符串" 匹配字符串上下N行

    [root@xxxxx ~]# grep -C 'ip_whitelist' /etc/gitlab/gitlab.rb # 'PATH' => "/opt/gitlab/bin:/o ...

  5. 【ASP.NET MVC】个人复习整理

    1.为 Action 标注 Attribute 限制访问 public class HomeController : Controller { [HttpPost] public ActionResu ...

  6. laravel框架session使用教程

    laravel是一款php框架了,在使用laravel时会碰到session使用问题了,在使用过程中碰到一些问题与一些应用的例子. 用Laravel开发应用,把原有的代码copy过来,以前的代码ses ...

  7. (六)WebRTC手记之WebRtcVideoEngine2模块

    转自:http://www.cnblogs.com/fangkm/p/4401143.html 终于讲到视频数据的编码发送模块了,不容易.总体来说也看了不少时间WebRTC的源码了,最大的感触就是各个 ...

  8. ER-STUDIO 6.5工具使用帮助的中文翻译

    转自于:http://yujingwang.blog.sohu.com/63362979.html 1       资料 ER-STUDIO的帮助(英文) 2       内容 2.1         ...

  9. HDU 4612 Warm up tarjan缩环+求最长链

    Warm up Problem Description   N planets are connected by M bidirectional channels that allow instant ...

  10. windows脚本定时执行

    linux下可以直接用cron定时任务,window下可以使用schtasks 命令代替. 第一次在win7 cmd输入: schtasks 如果出现错误:“错误:无法加载列表资源” 的问题原因很简单 ...