文档章节

virtualization-with-kvm-on-a-centos-6.4

异类深呼吸
 异类深呼吸
发布于 2014/07/04 08:52
字数 650
阅读 69
收藏 3

<h2 style="margin: 1.5em 0px 1em; padding: 0.5em 0px 0px; -webkit-print-color-adjust: exact; border-width: 4px 0px 0px; border-top-style: solid; border-top-color: #e0e0e0; font-size: 20px; font-family: helvetica, arial, freesans, clean, sans-serif; line-height: 18px;">1、Preliminary Note</h2> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">看了许多文章,觉得这篇比较通俗易懂,摘抄原文地址 <a style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; color: #4183c4; text-decoration: none;" href="http://www.howtoforge.com/virtualization-with-kvm-on-a-centos-6.4-server">virtualization-with-kvm-on-a-centos-6.4-server</a></p> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">I'm using a CentOS 6.4 server with the hostname server1.example.com and the IP address 192.168.0.100 here as my KVM host.</p> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">I had SELinux disabled on my CentOS 6.4 system. I didn't test with SELinux on; it might work, but if not, you better switch off SELinux as well:</p> </blockquote> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">vi /etc/selinux/config <br />Set SELINUX=disabled... <br /><br /># enforcing - SELinux security policy is enforced. <br /># permissive - SELinux prints warnings instead of enforcing. <br /># disabled - No SELinux policy is loaded. </code></pre> <h2 style="margin: 1.5em 0px 1em; padding: 0.5em 0px 0px; -webkit-print-color-adjust: exact; border-width: 4px 0px 0px; border-top-style: solid; border-top-color: #e0e0e0; font-size: 20px; font-family: helvetica, arial, freesans, clean, sans-serif; line-height: 18px;">2、Installing KVM</h2> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">First check if your CPU supports hardware virtualization</p> </blockquote> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">egrep '(vmx|svm)' --color=always /proc/cpuinfo </code></pre> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">If nothing is displayed, then your processor doesn't support hardware virtualization, and you must stop here.</p> </blockquote> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">To install KVM and virtinst (a tool to create virtual machines)</p> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">yum install kvm libvirt python-virtinst qemu-kvm </code></pre> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">Then start the libvirt daemon:</p> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">/etc/init.d/libvirtd start </code></pre> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">To check if KVM has successfully been installed, run</p> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">virsh -c qemu:///system list </code></pre> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">[root@server1 ~]# virsh -c qemu:///system list <br />Id Name State <br />---------------------------------- </code></pre> <h2 style="margin: 1.5em 0px 1em; padding: 0.5em 0px 0px; -webkit-print-color-adjust: exact; border-width: 4px 0px 0px; border-top-style: solid; border-top-color: #e0e0e0; font-size: 20px; font-family: helvetica, arial, freesans, clean, sans-serif; line-height: 18px;">3、Install bridge</h2> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">Next we need to set up a network bridge on our server so that our virtual machines can be accessed from other hosts as if they were physical systems in the network.</p> </blockquote> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">yum install bridge-utils </code></pre> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">and configure a bridge. Create the file /etc/sysconfig/network-scripts/ifcfg-br0 (please use the IPADDR, PREFIX, GATEWAY, DNS1 and DNS2 values from the /etc/sysconfig/network-scripts/ifcfg-eth0 file); make sure you use TYPE=Bridge, not TYPE=Ethernet:</p> </blockquote> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">vi /etc/sysconfig/network-scripts/ifcfg-br0 <br /> DEVICE="br0" <br /> NM_CONTROLLED="yes" <br /> ONBOOT=yes <br /> TYPE=Bridge <br /> BOOTPROTO=none <br /> IPADDR=192.168.0.100 <br /> PREFIX=24 <br /> GATEWAY=192.168.0.1 <br /> DNS1=8.8.8.8 <br /> DNS2=8.8.4.4 <br /> DEFROUTE=yes <br /> IPV4_FAILURE_FATAL=yes <br /> IPV6INIT=no <br /> NAME="System br0" </code></pre> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">vi /etc/sysconfig/network-scripts/ifcfg-eth0<br /> DEVICE="eth0" <br /> #BOOTPROTO=none <br /> NM_CONTROLLED="yes" <br /> ONBOOT=yes <br /> TYPE="Ethernet" <br /> UUID="73cb0b12-1f42-49b0-ad69-731e888276ff" <br /> HWADDR=00:1E:90:F3:F0:02 <br /> #IPADDR=192.168.0.100 <br /> #PREFIX=24 <br /> #GATEWAY=192.168.0.1 <br /> #DNS1=8.8.8.8 <br /> #DNS2=8.8.4.4 <br /> DEFROUTE=yes <br /> IPV4_FAILURE_FATAL=yes <br /> IPV6INIT=no <br /> NAME="System eth0" <br /> BRIDGE=br0 #这里使用桥接模式 </code></pre> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">/etc/init.d/network restart </code></pre> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">[root@server1 ~]# ifconfig <br />br0 Link encap:Ethernet HWaddr 00:1E:90:F3:F0:02 <br /> inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0 <br /> inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link <br /> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 <br /> RX packets:8 errors:0 dropped:0 overruns:0 frame:0 <br /> TX packets:27 errors:0 dropped:0 overruns:0 carrier:0 <br /> collisions:0 txqueuelen:0 <br /> RX bytes:460 (460.0 b) TX bytes:2298 (2.2 KiB) <br /><br />eth0 <br /> Link encap:Ethernet HWaddr 00:1E:90:F3:F0:02 <br /> inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link <br /> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 <br /> RX packets:18455 errors:0 dropped:0 overruns:0 frame:0 <br /> TX packets:11861 errors:0 dropped:0 overruns:0 carrier:0 <br /> collisions:0 txqueuelen:1000 <br /> RX bytes:26163057 (24.9 MiB) TX bytes:1100370 (1.0 MiB) <br /> Interrupt:25 Base address:0xe000 <br /></code></pre> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">如果能成功看到此,KVM基础环境安装就完成了,也就是这台机器上安装好了KVM套件,可以被一些虚拟化套件直接来管理这台机器,下面就应该安装一些KVM的管理工具,或者相关套件,比如virt-manager管理工具,或者convirture图形化管理等等,后期将结合covirture进行简单的一个虚拟化的生产环境的应用</p>

© 著作权归作者所有

共有 人打赏支持
异类深呼吸
粉丝 5
博文 46
码字总数 42368
作品 0
朝阳
系统管理员
私信 提问
[linux][KVM]

How to Create Virtual Machines in Linux Using KVM (Kernel-based Virtual Machine) – Part 1 by Mohammad Dosoukey | Published: January 12, 2015 | Last Updated: February 26, 2015 ......

active_health
2016/08/03
6
0
在 Centos7 的KVM上启用嵌套虚拟化

嵌套虚拟化意味着在虚拟机内配置虚拟化环境。换句话说,我们可以说嵌套虚拟化是虚拟机管理程序hypervisor的一个特性,它允许我们通过虚拟化管理程序(宿主机)的硬件加速在虚拟服务器内安装和...

linux-tao
01/13
0
0
在centos 7系统中制作kvm镜像

项目的需求,需要制作kvm虚拟机镜像。在网上查找了一些资料并经过实际的配置操作。下面简单说明一下步骤,以供参考。 准备iso镜像 目前制作镜像考虑不考虑从无到有,只是在已有镜像的基础上加...

Endzzz
2017/12/08
0
0
KVM(一) Centos 安装KVM

简介: Kernel-based Virtual Machine的简称,是一个开源的系统虚拟化模块,自Linux 2.6.20之后集成在Linux的各个主要发行版本中。它使用Linux自身的调度器进行管理,所以相对于Xen,其核心源...

vincent927
2016/03/10
138
0
Linux中KVM虚拟机是什么

概念: Kernel-based Virtual Machine的简称,是一个开源的系统虚拟化模块,自Linux 2.6.20之后集成在Linux的各个主要发行版本中。它使用Linux自身的调度器进行管理,所以相对于Xen,其核心源...

easonjim
01/27
0
0

没有更多内容

加载失败,请刷新页面

加载更多

我的Linux系统九阴真经

我的Linux系统九阴真经 在今天,互联网的迅猛发展,科技技术也日新月异,各种编程技术也如雨后春笋一样,冒出尖来了。各种创业公司也百花齐放百家争鸣,特别是针对服务行业,新型互联网服务行...

linuxCool
34分钟前
5
0
Python程序员需要知道的30个技巧

1 直接交换两个数字位置 1x, y = 10, 202print(x, y)3x, y = y, x4print(x, y)5#1 (10, 20)6#2 (20, 10) 2 比较运算符的链接 1n = 102result = 1 < n < 203print(result)4# True5result = 1 ......

糖宝lsh
35分钟前
2
0
[LintCode] Linked List Cycle(带环链表)

描述 给定一个链表,判断它是否有环。 样例 给出 -21->10->4->5, tail connects to node index 1,返回 true。 这里解释下,题目的意思,在英文原题中,tail connects to node index 1 表示的...

honeymose
46分钟前
6
0
Android :报错Your project path contains non-ASCII characters.

报错内容如下 Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a different directory. See ht......

lanyu96
57分钟前
6
0
Nginx平滑添加模块

Nginx已经编译安装并运行了一段时间, 然后某一天, 发现需要用到某个模块但当初没有编译, 这个时候怎么办呢? 卸载重新安装肯定可以的, 如果Nginx版本没有变更的话, 则有一个相对平滑的方法来添...

老菜鸟0217
今天
8
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部