命令行安装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系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...
随机推荐
- 【leetcode】Palindrome Partitioning
Palindrome Partitioning Given a string s, partition s such that every substring of the partition is ...
- cocos2dx混合模式应用
//Opacity 0完全透明 255完全不透明 //ALPHA 0完全透明 1完全不透明 CCRenderTexture* pRT = CCRenderTexture::create(480,320 ...
- Codebook model 视频抠像 xp sp3 + vs2005 + OpenCV 2.3.1
Codebook model 视频抠像 xp sp3 + vs2005 + OpenCV 2.3.1 源码及详细文档下载 svn checkout http://cvg02.googlecode.co ...
- [MACOS] Mac上的抓包工具Charles
转载自: http://blog.csdn.net/jiangwei0910410003/article/details/41620363 今天就来看一下Mac上如何进行抓包,之前有一篇文章介绍了使用 ...
- PHP使用七牛云存储之图片的上传、下载、303重定向教程,CI框架实例
网上关于七牛云存储的教程除了官网上的API文档,其他的资料太少了.研究了下API之后,现在已经能实现图片的上传和下载及上传之后的重定向. http://blog.csdn.net/cqcre/arti ...
- gitlab+TortoiseGit中使用SSH
1.在文件夹空白位置右键打开"Git Bash" 2.按 https://gitlab.yourhost.com/help/ssh/ssh.md 中的说明,输入命令 ssh-k ...
- h5 canvas 小球移动
h5 canvas 小球移动 <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- poj 2236 并查集
并查集水题 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring& ...
- 理解ASP.NET 5的中间件
今天推荐的这篇文章,讲述了如何实现和使用ASP.NET 5的中间件. 虽然在ASP.NET 5中,微软没有再强调OWIN(Open Web Interface for .NET)及其微软官方的OWIN ...
- x264_param_t结构体参数分析
转自:http://blog.chinaunix.net/uid-17053077-id-1987955.html 参考网上的一些资料,结合个人的理解,对x264中x264_param_t结构体作了初 ...