kvm虚拟化管理平台WebVirtMgr部署-完整记录(0)

时间:2023-03-08 17:39:31
kvm虚拟化管理平台WebVirtMgr部署-完整记录(0)

打算部署kvm虚拟机环境,下面是虚拟化部署前的一些准备工作:

操作系统环境安装
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

虚拟化环境配置
1)查看是否支持虚拟机
说明1:半虚拟化是不能运行与安装KVM虚拟机的。
[root@ops ~]#egrep '(vmx|svm)' --color=always /proc/cpuinfo

kvm虚拟化管理平台WebVirtMgr部署-完整记录(0)

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

---------------------------------------如果是centos7,操作如下---------------------------------------
yum install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install virt-manager python-virtinst libvirt-client virt-viewer 
systemctl enable libvirtd && systemctl start libvirtd
-----------------------------------------------------------------------------------------------------

查看虚拟化环境
1)查看虚拟机环境
[root@ops ~]# /etc/init.d/libvirtd restart
Stopping libvirtd daemon: [ OK ]
Starting libvirtd daemon: [ OK ]
----------------------------------------------------------------------------------------------------------------------------------------------
启动的时候报错如下:
Starting libvirtd daemon: libvirtd: relocation error: libvirtd: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference [FAILED]

解决办法:
yum upgrade device-mapper-libs
----------------------------------------------------------------------------------------------------------------------------------------------
[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

手动配置虚拟网桥
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                                                            #将em2添加到网桥br0内
UUID=6dbfbd49-b6b9-4c51-b2d2-b3ecbead82e9
ONBOOT=yes
IPADDR=192.168.1.17
GATEWAY=192.168.1.1
NM_CONTROLLED=no                                               #一定设置为no!让em2不受networkmanager的控制
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
GATEWAY=192.168.1.1
NM_CONTROLLED=no
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:111.101.186.163 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            #virbr0虚拟网卡有没有都不影响虚拟机的使用,有办法可以将其删除,但是保留也不影响~
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虚拟化环境安装完毕。
-----------------------------------------------------------------------------------
关闭虚拟网卡virtbr0的方法:http://www.cnblogs.com/kevingrace/p/5772589.html
-----------------------------------------------------------------------------------