KVM安装部署
实验环境:
一台IBM服务器作为KVM服务器
系统:RedHat Enterprise Linux Server release 6.1 (Santiago)
一台本地虚拟机作为KVM管理端
系统:RedHat Enterprise Linux Server release 6.1 (Santiago)
网络拓扑:
eth0 作为管理接口不做其他配置
eth1 作为桥接端口
br10 vlan10的桥接接口
br3 vlan3的桥接接口
br30 为了测试添加的vlan
eth1在交换机上的对联接口已经设置成了trunk接口,并且在交换机上已经做了vlan间路由(没有加上vlan30)
vlan3的IP地址为192.168.211.1
vlan10的IP地址为192.168.212.1
vlan30在交换机上没有配置
Virt-manager服务器:
192.168.211.175
实验目的:
添加四台虚拟机:
vlan10:
VirHost1 #192.168.212.10
VirHost2 #192.168.212.20
vlan3:
VirHost3 #192.168.211.30
VirHost4 #192.168.211.40
vlan30:
VirHost5 #192.168.212.30
通过在KVM服务器上划分vlan3、vlan10、vlan30来实现和交换机vlan的对接的效果
一.安装配置KVM服务器
略…
二.部署Vlan
Kvm服务器上进行操作:
1. 添加和配置vlan
[root@localhostlibvirt]# lsmod | grep 802
[root@localhostlibvirt]#
貌似不支持,加载模块
[root@localhostlibvirt]# modprobe 8021q
[root@localhostlibvirt]# lsmod | grep 802
8021q 24413 0
garp 7310 1 8021q
添加vlan3、vlan10、vlan30
[root@localhostnetwork-scripts]# vconfig add eth1 3
Added VLAN withVID == 3 to IF -:eth1:-
[root@localhostnetwork-scripts]# vconfig add eth1 10
Added VLAN withVID == 10 to IF -:eth1:-
[root@localhostnetwork-scripts]# vconfig add eth1 30
Added VLAN withVID == 30 to IF -:eth1:-
相应的网络配置文件列表:
ifcfg-br3
ifcfg-br10
ifcfg-br30
ifcfg-eth1.3
ifcfg-eth1.10
ifcfg-eth1.30
配置内容以br3和eth1.3为例
----vi ifcfg-br3----
DEVICE="br3"
TYPE=Bridge
HWADDR="5C:F3:FC:0C:2B:C6"
ONBOOT="yes"
----viifcfg-eth1.3----
DEVICE="eth1.3"
BRIDGE=br3
HWADDR="5C:F3:FC:0C:2B:C6"
ONBOOT="yes"
其他配置文件类似
重启网络服务:
#/etc/init.d/newrorkrestart
添加对应关系
默认新添加的虚拟机都是属于br0的,这里要先删除掉br0之后再建立对应关系,
删除的步骤如下:
1. ifdown br0
2. brctl delbr br0
3. 删除配置文件ifcfg-br0(如果有)
注:
1. 每次添加一个虚拟机在KVM服务器上都会出现相应的虚拟网卡(vnet0、vnet1…)与之对应,
2. 默认新添加的虚拟机都是属于br0,所以为了彻底更改新建立的虚拟机使用的桥接端口,需要修改每个虚拟机对应的配置文件(/etc/libvirt/qemu/VirHost1.xml,VirHost2.xml等)中的
<source bridge='br0'/>,修改之后要在KVM服务器端重新定义一下客户端,
“virsh define /etc/libvirt/qemu/VirHost5.xml”,之后重启虚拟机客户端
每一个虚拟网卡的MAC地址和新添加的虚拟机的MAC是一样的
在不更改配置文件的情况下临时添加对应关系的命令如下
#brctl addbr br3b10 br30 #添加桥接端口
#brctl addif br10vnet0 vnet1 #对应的是VirHost1 VirHost1
#brctl addif br10vnet2 vnet3 #对应的是VirHost3 VirHost4
#brctl show
分别设置五台虚拟机的IP地址
VirHost1:
IP:192.168.212.10GW:192.168.212.1
VirHost2:
IP:192.168.212.20GW:192.168.212.1
VirHost3:
IP:192.168.211.30GW:192.168.211.1
VirHost4:
IP:192.168.211.40GW:192.168.211.1
切换到Virhost5:
在KVM服务器上将VirHost5加入到br10
切换到VirHost5:
将VirHost1,VirHost5加入到br30
切换到VirHost1:
因为VirHost1在vlan30所以平vlan10的地址不通
VirHost1和VirHost5现在同一个vlan30中所以互通