命令行安装KVM
查看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的更多相关文章
- 命令行安装kvm虚拟机、桥接网络、用virt-manager管理
宿主机CentOS Linux release 7.2.1511 (Core),内核3.10.0-327.el7.x86_64 1.配置宿主机网络桥接 想让虚拟机有自己的ip且外网可访问,需要在安装虚 ...
- 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 ...
- Linux下命令行安装weblogic10.3.6
Linux下命令行安装weblogic10.3.6 一.安装前准备工作: 1.创建用户useradd weblogic;创建用户成功linux系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...
- Oracle 图形化以及命令行安装
@(Oracle)[Install] Oracle 安装 相关版本说明 不同版本的Oracle需要安装在特定的系统版本之上. 如Oracle 11gR2的11.2.0.1.0需要安装在CentOS 5 ...
- Oracle 11gR2静默安装 & 命令行安装
静默安装 经常搭建Oracle测试环境,有时候觉得OUI(即图形界面)方式甚是繁琐,你得一步一步进行确认,所幸,Oracle支持静默安装.在我看来,它主要有两方面的好处:一.极大地提升了效率,尤其是批 ...
- VMware10中的CentOS6.5命令行安装VMwaretools工具启用windows与虚拟机中Linux系统的共享目录
VMware10中的CentOS6.5命令行安装VMwaretools工具启用windows与虚拟机中Linux系统的共享目录 一.描述 系统描述:win7旗舰版64位系统+VMware Workst ...
- Appium Mac 命令行安装
试过很多方法都失败,打算用命令行方式安装. 准备工作: 从 https://github.com/appium/appium下载appium版本的源码(.tar) 详见github_Appium1.6 ...
- macos 命令行安装 ipa
macos 命令行安装 ipa 苹果发神经后itunes已经无法在安装app了,如果有知道的兄弟可以告诉我啊 ideviceinstaller 使用这个开源项目可以在macos下安装app brew ...
- Linux系统--命令行安装weblogic10.3.6
Linux下命令行安装weblogic10.3.6 一.安装前准备工作: 1.创建用户useradd weblogic;创建用户成功linux系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...
随机推荐
- Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative. Example Given 1-> ...
- C++基础知识面试精选100题系列(1-10题)[C++ basics]
[原文链接] http://www.cnblogs.com/hellogiser/p/100-interview-questions-of-cplusplus-basics-1-10.html [题目 ...
- 【转】Python 代码调试技巧
转载自:http://www.ibm.com/developerworks/cn/linux/l-cn-pythondebugger/ Debug 对于任何开发人员都是一项非常重要的技能,它能够帮助我 ...
- iOS 端的第三方语音识别库
最近在看语音识别方面的库,主要看了2个收费的项目,一个是 At&t 的,一个是Nuance的.这2个项目虽然是收费的,但是仅仅测试的话,是免费的,连接如下 https://developer. ...
- Flash Player 19.0.0.124 Beta + IHTMLDocument3 IHTMLDocument2 ->get_innerHTML
安装 Flash Player 19 之后 有 flash 动画的网页中 IHTMLDocument3 IHTMLDocument2 ->get_innerHTML 获取的 html 内容都是空 ...
- js监听密码输入框type
1.密码输入框 <input class="oaInput oaText" type="text" placeholder="请输入用户名&qu ...
- 从几个方向进行Web渗透测试
渗透测试就是对系统安全性的测试,通过模拟恶意黑客的攻击方法,来评估系统安全的一种评估方法. 渗透测试可以包括各种形式的攻击,一般来说会有专门的公司提供这种服务,这里整理了几种常见的渗透测试方法,可以对 ...
- 使用javascript的stack数据结构,实现进制转换
function Stack() { var items = []; this.push = function(element){ items.push(element); } this.pop = ...
- Java Hour 9
有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. 本文作者Java 现经验约为7 Hour,请各位不吝赐教. Hour 9 方法 ...
- jquery 展开折叠效果
仅供参考 图片 jquery.js 自己处理 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"& ...