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

CentOS osetc 842℃ 0评论

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

CentOS 安装kvm相关软件包

输入下面的命令:
[cc lang=”bash”]
yum groupinstall “Virtualisation Tools” “Virtualization Platform”
yum install python-virtinst
[/cc]

或者
[cc lang=”bash”]
yum install kvm qemu-kvm python-virtinst libvirt libvirt-python virt-manager libguestfs-tools
[/cc]

命令输出:
[cc lang=”bash”]
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

[/cc]

启动libvirtd 服务

libvirtd 程序是一个服务器端的进程组件,用来做虚拟化的管理。 输入下面的命令来设置libvirtd服务系统自启动:
[cc lang=”bash”]
chkconfig libvirtd on
[/cc]
输入下面的命令启动libvirtd服务:
[cc lang=”bash”]
service libvirtd start
[/cc]
命令输出:
[cc lang=”bash”]
Starting libvirtd daemon: [ OK ]
[/cc]

使用下面的命令来检测libvirtd服务的状态:
[cc lang=”bash”]
service libvirtd status
[/cc]
命令输出:
[cc lang=”bash”]
libvirtd (pid 31128) is running…
# virsh -c qemu:///system list
Id Name State
—————————————————-
[/cc]

安装并配置网桥

所有的VM虚机会通过一个私有网络来进行网络通信。所以你需要创建一个网桥让各主机之间进行互相通信。输入下面的命令来装网桥组件:
[cc lang=”bash”]
yum install birdge-utils
[/cc]

命令输出:
[cc lang=”bash”]
[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!
[/cc]

配置网桥
编辑网卡配置文件/etc/sysconfig/network-scripts/ifcfg-eth0 :
[cc lang=”bash”]
DEVICE=eth0
ONBOOT=yes
BRIDGE=br0
[/cc]

创建一个网桥文件ifcfg-br0:”/etc/sysconfig/network-scripts/ifcfg-br0″,并进入下面的内容:
[cc lang=”bash”]
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.192
DELAY=0
[/cc]

重启网络服务
输入下面的命令:
[cc lang=”bash”]
service network restart
[/cc]

转载请注明:OSETC 技术网 » CentOS 6.x 安装和配置KVM虚拟化环境

喜欢 (0)or分享 (0)

您必须 登录 才能发表评论!