码迷,mamicode.com
首页 > 其他好文 > 详细

[原创]KVM虚拟化环境安装

时间:2016-08-04 17:34:51      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:

 

宿主机系统:Centos6.8

下面是安装过程记录:

 

1.操作系统环境安装

(1)修改内核模式为兼容内核启动

[root@ops ~]# uname -a
Linux openstack 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

[root@ops ~]#vim /boot/grub/grub.conf

......

default=1     #由默认的0改为1,内核兼容模式

 

(2)关闭selinux,重启后生效

[root@ops ~]#vim /etc/sysconfig/selinux
......
SELINUX=disabled

[root@ops ~]#setenforce 0
setenforce: SELinux is disabled
[root@ops ~]#getenforce
Disabled

(3)关闭防火墙
[root@ops ~]#chkconfig ip6tables off
[root@ops ~]#chkconfig iptables off

(4)重启
[root@ops ~]#reboot

 

2.虚拟化环境配置

(1)查看是否支持虚拟机
说明1:半虚拟化是不能运行与安装KVM虚拟机的。
[root@ops ~]#egrep ‘(vmx|svm)‘ --color=always /proc/cpuinfo          #出现vmx的信息就说明执行kvm虚拟化

技术分享

 

 

(2)配置yum环境,确认yum源是好使的。(这一步骤省略,可以用默认yum源,也可以换用163或阿里的yum源,只要能正常使用就行)

 

(3)安装kvm软件包
[root@ops ~]#yum -y install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v

补充安装kvm虚拟化一些管理工具包
[root@ops ~]#yum -y install libguestfs-tools

 

3.查看虚拟化环境

(1)查看虚拟机环境
[root@ops ~]# /etc/init.d/libvirtd restart
Stopping libvirtd daemon: [ OK ]
Starting libvirtd daemon: [ OK ]

[root@ops ~]# virsh -c qemu:///system list
Id Name State
----------------------------------------------------

(2)查看kvm模块支持
[root@ops ~]# lsmod |grep kvm
kvm_intel 54285 0
kvm 333172 1 kvm_intel

(3)查看虚拟工具版本
[root@ops ~]# virsh --version
0.10.2
[root@ops ~]# virt-install --version
0.600.0
[root@ops ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm

 

4.手动配置虚拟网桥

(1)关闭networkmanager服务
[root@ops ~]# chkconfig NetWorkManager off
[root@ops ~]# /etc/init.d/NetWorkManager stop

(2)创建br0网桥
[root@ops ~]#cd /etc/sysconfig/network-scripts/
[root@ops ~]#cp ifcfg-em2 ifcfg-br0 #em2是本机内网网卡
[root@ops ~]# cat ifcfg-em2
DEVICE=em2
HWADDR=44:A8:42:21:A6:01
TYPE=Ethernet
BRIDGE="br0"
UUID=6dbfbd49-b6b9-4c51-b2d2-b3ecbead82e9
ONBOOT=yes
IPADDR=192.168.1.17
NM_CONTROLLED=yes
BOOTPROTO=static


[root@ops ~]# cat ifcfg-br0
DEVICE=br0
HWADDR=44:A8:42:21:A6:01
TYPE=Bridge
UUID=6dbfbd49-b6b9-4c51-b2d2-b3ecbead82e9
ONBOOT=yes
IPADDR=192.168.1.17
NM_CONTROLLED=yes
BOOTPROTO=static

 

(3)关闭了networkmanager服务之后,才能通过重启网卡服务管理网络。
[root@ops ~]# /etc/init.d/network restart

(4)查看网桥br0信息
[root@ops ~]# ifconfig
br0 Link encap:Ethernet HWaddr 44:A8:42:21:A6:01
inet addr:192.168.1.17 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::46a8:42ff:fe21:a601/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6642 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2146342 (2.0 MiB) TX bytes:720 (720.0 b)

em1 Link encap:Ethernet HWaddr 44:A8:42:21:A6:00
inet addr:116.15.186.17 Bcast:103.10.86.63 Mask:255.255.255.192
inet6 addr: fe80::46a8:42ff:fe21:a600/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5877878 errors:0 dropped:0 overruns:0 frame:0
TX packets:175381 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:921486122 (878.7 MiB) TX bytes:22894696 (21.8 MiB)
Interrupt:35

em2 Link encap:Ethernet HWaddr 44:A8:42:21:A6:01
inet6 addr: fe80::46a8:42ff:fe21:a601/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2412349 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:314457702 (299.8 MiB) TX bytes:872 (872.0 b)
Interrupt:38

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:238 errors:0 dropped:0 overruns:0 frame:0
TX packets:238 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:58469 (57.0 KiB) TX bytes:58469 (57.0 KiB)

virbr0 Link encap:Ethernet HWaddr 52:54:00:5F:95:B7
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)


(5)查看网桥
[root@ops ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.44a84221a601 no em2
virbr0 8000.5254005f95b7 yes virbr0-nic

 

 

到此kvm虚拟化环境安装完毕。

 

[原创]KVM虚拟化环境安装

标签:

原文地址:http://www.cnblogs.com/kevingrace/p/5737487.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!