CentOS 6.x 安装和配置KVM虚拟化环境

CentOS osetc 605℃ 0评论

如何在centos 6.x系统上配置给予内核的虚拟化环境呢?如何使用KVM安装并管理虚机?
KVM是CentOS或RHEL系统的一部分,我们仍然需要安装一下KVM包相关的一些软件包。
kvm

CentOS 安装kvm相关软件包

输入下面的命令:

1
2
yum groupinstall "Virtualisation Tools" "Virtualization Platform"
yum install python-virtinst

或者

1
 yum install kvm qemu-kvm python-virtinst libvirt libvirt-python virt-manager libguestfs-tools

命令输出:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Loaded plugins: fastestmirror, refresh-packagekit, security, versionlock
Loading mirror speeds from cached hostfile
 * base: mirrors.pubyun.com
 * extras: mirrors.pubyun.com
 * updates: mirrors.pubyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package libguestfs-tools.x86_64 1:1.20.11-11.el6 will be installed
--> Processing Dependency: libguestfs-tools-c = 1:1.20.11-11.el6 for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64
--> Processing Dependency: libguestfs = 1:1.20.11-11.el6 for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64
--> Processing Dependency: perl(Win::Hivex) >= 1.2.7 for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64
--> Processing Dependency: perl(XML::Writer) for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64
--> Processing Dependency: perl(Sys::Virt) for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64
--> Processing Dependency: perl(Sys::Guestfs::Lib) for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64
--> Processing Dependency: perl(Sys::Guestfs) for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64
...

启动libvirtd 服务

libvirtd 程序是一个服务器端的进程组件,用来做虚拟化的管理。 输入下面的命令来设置libvirtd服务系统自启动:

1
chkconfig libvirtd on

输入下面的命令启动libvirtd服务:

1
service libvirtd start

命令输出:

1
Starting libvirtd daemon:                                  [  OK  ]

使用下面的命令来检测libvirtd服务的状态:

1
service libvirtd status

命令输出:

1
2
3
4
libvirtd (pid  31128) is running...
# virsh -c qemu:///system list
 Id    Name                           State
----------------------------------------------------

安装并配置网桥

所有的VM虚机会通过一个私有网络来进行网络通信。所以你需要创建一个网桥让各主机之间进行互相通信。输入下面的命令来装网桥组件:

1
yum install birdge-utils

命令输出:

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
[root@devops Desktop]# yum install bridge-utils
Loaded plugins: fastestmirror, refresh-packagekit, security, versionlock
Loading mirror speeds from cached hostfile
 * base: mirrors.pubyun.com
 * extras: mirrors.pubyun.com
 * updates: mirrors.pubyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package bridge-utils.x86_64 0:1.2-9.el6 will be updated
---> Package bridge-utils.x86_64 0:1.2-10.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch            Version              Repository     Size
================================================================================
Updating:
 bridge-utils          x86_64          1.2-10.el6           base           30 k

Transaction Summary
================================================================================
Upgrade       1 Package(s)

Total download size: 30 k
Downloading Packages:
bridge-utils-1.2-10.el6.x86_64.rpm                       |  30 kB     00:00    
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : bridge-utils-1.2-10.el6.x86_64                               1/2
  Cleanup    : bridge-utils-1.2-9.el6.x86_64                                2/2
  Verifying  : bridge-utils-1.2-10.el6.x86_64                               1/2
  Verifying  : bridge-utils-1.2-9.el6.x86_64                                2/2

Updated:
  bridge-utils.x86_64 0:1.2-10.el6                                              

Complete!

配置网桥
编辑网卡配置文件/etc/sysconfig/network-scripts/ifcfg-eth0 :

1
2
3
DEVICE=eth0
ONBOOT=yes
BRIDGE=br0

创建一个网桥文件ifcfg-br0:”/etc/sysconfig/network-scripts/ifcfg-br0″,并进入下面的内容:

1
2
3
4
5
6
7
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.192
DELAY=0

重启网络服务
输入下面的命令:

1
service network restart

转载请注明:osetc.com » CentOS 6.x 安装和配置KVM虚拟化环境

喜欢 (0)or分享 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址