kvm安装及虚拟机创建
环境介绍:
redhat6.5_x64 basic_server安装
iptables及selinux禁用
光盘作为yum源
1、BIOS开启虚拟化
Linux中x64的环境中才能使用kvm(如果是vmware,需要在CPU那里启用虚拟化)
2、检测是否支持虚拟化
1
|
egrep --color "(vmx|svm)" /proc/cpuinfo
|
VMX:它是Intel处理器虚拟机技术标志;
SVM:它是AMD处理器虚拟机技术的标志;
3、加载并查看内核模块
1
2
3
|
modprobe kvm
modprobe kvm_intel(AWD加载kvm_amd)
lsmod| grep kvm
|
4、安装kvm 和虚拟化管理软件包
1
2
3
|
yum -y install kvm virt-* libvirts bridge-utils qemu-img
service libvirtd start;chkconfig libvirtd on
service acpid start; chkconfig acpid on
|
5、配置网络桥接
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-br0
做相应修改
#cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT= yes
TYPE=Ethernet
BRIDGE=br0
#cat ifcfg-br0
DEVICE=br0
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT= yes
TYPE=Bridge
IPADDR=192.168.1.2
NETMASK=255.255.255.0
GATEWAY=192.168.1.253
|
配置桥接网卡br0后,物理网卡eth0不需要获得ip地址,其功能被br0取代,因此在配置的时候无论是静态ip还是动态获取都用br0取代eth0的ip地址,
而实际上数据发送还是通过本机的物理网卡。
6、复制安装光盘镜像
1
2
|
mkdir /iso
dd if = /dev/cdrom of= /iso/centos6 .5.iso
|
7、创建虚拟磁盘存放目录
1
|
mkdir /data/vmdisk -p
|
8、开启VNC监听IP
1
2
|
sed -i 's/^#vnc_listen.*/vnc_listen = "0.0.0.0"/' /etc/libvirt/qemu .conf
/etc/init .d /libvirtd restart
|
9、创建磁盘镜像文件
1
2
|
#virt-install --name=centos6.5-01 --ram=4096 --vcpus=2 --disk=/data/vmdisk/centos6.5-01.raw,size=40,bus=virtio,cache=writeback --network bridge=br0\
--accelerate --cdrom= /iso/centos6 .5.iso --vnc --vncport=5900 -d
|
默认镜像文件为raw格式,可用qemu-img info IMG 查看
--name 指定虚拟机名字
--ram 内存,单位M
--vcpus 分配虚拟机cpu个数
--disk 指定虚拟机安装文件路径
size 虚拟机文件大小,单位G
bus 虚拟机网卡驱动类型
cache 虚拟机磁盘cache类型
--network bridge 指定桥接网卡
--accelerate 使用内核加速功能
--cdrom 安装镜像全路径
--vnc 可以用vnc连接
--vncport 指定vnc端口,-1表示随机生成
-d debug打印调试信息到终端
VNC连接192.168.1.2:5900端口进行后续安装
Other:
kvm安装Windows与装linux类似,但是Windows需要安装额外的驱动文件,一个是硬盘的,一个是网卡的
分别为virtio-win-0.1.96_amd64.vfg和virtio-win-0.1-100.iso
不同的版本与架构,名称也不一样,可在这两个地址下载
硬盘驱动 https://fedoraproject.org/wiki/Windows_Virtio_Drivers#Direct_download.com
网卡驱动 https://fedorapeople.org/groups/virt/virtio-win/deprecated-isos/
1、创建磁盘镜像
1
|
qemu-img create -f qcow2 windows7.qcow2 40G
|
2、创建xml文件(/etc/libvirt/qemu)
xml内容如末尾所示
3、定义虚拟机,让kvm来管理
1
|
virsh define windows7.xml
|
4、启动虚拟机
1
|
virsh start windows7
|
下边是windows的xml文件,重点在于两个virto文件的加载。当然,也可以用命令生产xml文件,不过我更喜欢复制修改xml
一般主要修改或注释UUID、虚拟机名字及配置、MAC地址、网桥名字、磁盘类型、镜像或驱动或iso路径、vnc或spice端口号
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
[root@controller1 ~] # cat /etc/libvirt/qemu/win7-02.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 windows7
or other application using the libvirt API.
-->
<domain type = 'kvm' >
<name>windows7< /name >
<uuid>6ce14f21-33ac-dc79-5444-f64ccc80ea17< /uuid >
<memory unit= 'KiB' >2097152< /memory >
<currentMemory unit= 'KiB' >2097152< /currentMemory >
<vcpu placement= 'static' >1< /vcpu >
<os>
< type arch= 'x86_64' machine= 'rhel6.5.0' >hvm< /type >
<boot dev= 'cdrom' />
< /os >
<features>
<acpi/>
<apic/>
<pae/>
< /features >
<cpu mode= 'host-passthrough' >
<topology sockets= '1' cores= '4' threads= '1' />
< /cpu >
<clock offset= 'localtime' />
<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 = 'qcow2' />
< source file = '/data/vmdisk/win7-02.qcow2' />
<target dev= 'vda' bus= 'virtio' />
<address type = 'pci' domain= '0x0000' bus= '0x00' slot= '0x04' function = '0x0' />
< /disk >
<disk type = 'file' device= 'cdrom' >
<driver name= 'qemu' type = 'raw' />
< source file = '/iso/win7.iso' />
<target dev= 'hda' bus= 'ide' />
< readonly />
<address type = 'drive' controller= '0' bus= '0' target= '0' unit= '0' />
< /disk >
<disk type = 'file' device= 'cdrom' >
<driver name= 'qemu' type = 'raw' />
< source file = '/iso/virtio-win-0.1-100.iso' />
<target dev= 'hdb' bus= 'ide' />
< readonly />
<address type = 'drive' controller= '0' bus= '0' target= '0' unit= '1' />
< /disk >
<disk type = 'file' device= 'floppy' >
<driver name= 'qemu' type = 'raw' />
< source file = '/iso/virtio-win-0.1.96_amd64.vfg' />
<target dev= 'fda' bus= 'fdc' />
< readonly />
<address type = 'drive' controller= '0' bus= '0' 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 >
<controller type = 'fdc' index= '0' />
<controller type = 'virtio-serial' index= '0' >
<address type = 'pci' domain= '0x0000' bus= '0x00' slot= '0x05' function = '0x0' />
< /controller >
<interface type = 'bridge' >
<mac address= 'fa:c6:3e:a3:e4:a7' />
< source bridge= 'br0' />
<model type = 'virtio' />
<address type = 'pci' domain= '0x0000' bus= '0x00' slot= '0x03' function = '0x0' />
< /interface >
<serial type = 'file' >
< source path= '/tmp/console.log' />
<target port= '0' />
< /serial >
<serial type = 'pty' >
<target port= '1' />
< /serial >
<console type = 'file' >
< source path= '/tmp/console.log' />
<target type = 'serial' port= '0' />
< /console >
<channel type = 'spicevmc' >
<target type = 'virtio' name= 'com.redhat.spice.0' />
<address type = 'virtio-serial' controller= '0' bus= '0' port= '1' />
< /channel >
<input type = 'tablet' bus= 'usb' />
<input type = 'mouse' bus= 'ps2' />
<graphics type = 'spice' port= '6789' autoport= 'no' listen= '0.0.0.0' keymap= 'en-us' >
<listen type = 'address' address= '0.0.0.0' />
<channel name= 'main' mode= 'insecure' />
<channel name= 'display' mode= 'insecure' />
<channel name= 'inputs' mode= 'insecure' />
<channel name= 'cursor' mode= 'insecure' />
<channel name= 'playback' mode= 'insecure' />
<channel name= 'record' mode= 'insecure' />
<channel name= 'smartcard' mode= 'insecure' />
<channel name= 'usbredir' mode= 'insecure' />
<image compression= 'auto_glz' />
<streaming mode= 'all' />
<clipboard copypaste= 'yes' />
< /graphics >
<video>
<model type = 'qxl' ram = '65536' vram= '65536' heads= '1' >
<acceleration accel3d= 'yes' accel2d= 'yes' />
< /model >
<address type = 'pci' domain= '0x0000' bus= '0x00' slot= '0x02' function = '0x0' />
< /video >
<memballoon model= 'virtio' >
<address type = 'pci' domain= '0x0000' bus= '0x00' slot= '0x06' function = '0x0' />
< /memballoon >
< /devices >
< /domain >
[root@controller1 ~] #
|
kvm安装及虚拟机创建相关推荐
- KVM 安装windows 虚拟机
KVM 安装windows 虚拟机 家里有台linux电脑, 一直当文件服务器和下载机使用. 所谓下载机就是装1个xware用迅雷远程下载, 但是最近迅雷关闭了第三方机器的远程下载功能, 简单来将就是 ...
- Win10系统通过VMware安装Centos7,部署KVM安装WIN7虚拟机
Win10系统通过VMware安装Centos7,部署KVM安装WIN7虚拟机 一.环境准备 本机Win10系统 下载Centos7镜像,Win7镜像,VMWare软件,XShell软件,VNCVie ...
- KVM安装、镜像创建(一)
环境准备 VMware Workstation Pro启动虚拟化 查看启动的系统是否支持vmx或svm grep -E '(vmx|svm)' /proc/cpuinfo 备注:操作系统centos ...
- kvm 安装 windows 虚拟机
作者:SRE运维博客 博客地址: https://www.cnsre.cn/ 文章地址:https://www.cnsre.cn/posts/211108848062/ 相关话题:https://ww ...
- kvm安装ubuntu虚拟机错误总结
知识点:kvm的使用,vnc的使用,和错误总结 一,安装虚拟机 1,查看已经安装的虚拟机列表及状态 virsh -c qemu:///system list --all 2,定义虚拟机映像 qemu- ...
- 第一讲 VMware 软件安装和虚拟机创建
一.为什么需要虚拟机 嵌入式Linux开发需要在Linux系统下进行,我们选择了Ubuntu. 1.双系统安装 有问题,一次只能使用一个系统.Ubuntu基本只做编译用,Windows查找资料. 需求 ...
- VMware下载安装、虚拟机创建、CentOS8镜像下载配置的具体步骤
写在前面:网上参考了很多资料没有写得特别全的,于是乎自己就把一系列下载安装步骤记录下来,方便大家相互学习,对自己来说也算是一种记录吧,往后还会在虚拟机里下载nutch.webcollecter.jav ...
- kernel 3.10代码分析--KVM相关--虚拟机创建\VCPU创建\虚拟机运行
分三部分:一是KVM虚拟机创建.二是VCPU创建.三是KVM虚拟机运行 第一部分: 1.基本原理 如之前分析,kvm虚拟机通过对/dev/kvm字符设备的ioctl的System指令KVM_CREAT ...
- KVM安装Win系列虚拟机学习笔记
要在KVM虚拟化上面安装一台windows 2003服务器,在格式化分区完后重启后的安装界面出现下面的错误信息,提示说:安装程序无法访问文件,不能继续.这可能是由于CD媒体上的错误或者CD不再于驱动中 ...
最新文章
- 用电线来传网络信号的黑科技?AirGig究竟是什么
- 时间戳服务——信息安全(二)
- spark的python开发安装方式_python 安装spark_Spark环境搭建 (Python)
- jQuery获取HTML标签自定义属性值或data值
- 编译py-faster-rcnn的问题汇总及解决方法
- (八)linux驱动之ioctl的使用
- UI设计摘要背景素材|简单分层PSD格式化模板,为项目增加背景
- 开源 java CMS - FreeCMS2.7 移动端栏目页静态化
- Android View之布局加载流程
- bzoj3275: Number
- ORACLE 数据泵之NETWORK_LINK
- Java 基础类型 —— Short
- 软交换总结之二-七号信令
- (转载)如何跟踪一个报错消息
- 护眼台灯哪个牌子最好?被央视315表扬的护眼灯
- 单代号网络图计算例题_双代号时标网络图用Excel画
- 网络营销技巧:有必要为移动端专门做站吗?
- 破窗理论:搜索引擎暗规则之三(转)
- 20190820美团视频一面面经
- 渗透测试神器AWVS使用教程
热门文章
- 趣图:老手调试多线程,666
- API 面试四连杀:接口如何设计?安全如何保证?签名如何实现?防重如何实现?...
- Java打造一款SSH客户端,而且已开源
- Oracle慌了!华为终于对JDK下手了!
- ArrayList集合为什么不能使用foreach增加、删除、修改元素
- 现金奖励+实习offer!数据库大赛来了
- Datawahle文化衫来了!
- 天池算法赛:数据挖掘经典赛事!DCIC 2020 数字中国创新大赛启动!
- 阿里大佬总结的算法进阶指南,助你进大厂!
- 一档博士40万年薪+70万房补!引进224人!​这所大学2021年公开招聘专任教师公告...