Linux 使用libvirt/openvswitch在两台主机和两个虚拟机之间设置专用网络
我有两个节点和两个虚拟机Linux 使用libvirt/openvswitch在两台主机和两个虚拟机之间设置专用网络,linux,networking,debian,libvirt,openvswitch,Linux,Networking,Debian,Libvirt,Openvswitch,我有两个节点和两个虚拟机 kvm01 -nic1 123.123.123.1 VM1 -vnet1 123.123.123.2 (public) -vnet2 10.0.0.1 (private) kvm02 -nic1 123.123.123.2 VM2 -vnet1 123.123.123.4 (public) -vnet2 10.0.0.2 (private) 如何设置openvswitch网络,使VM1和VM2位于专用网络上,而主机位于两个不同的位置 编辑: 运行此命令: #
kvm01
-nic1 123.123.123.1
VM1
-vnet1 123.123.123.2 (public) -vnet2 10.0.0.1 (private)
kvm02
-nic1 123.123.123.2
VM2
-vnet1 123.123.123.4 (public) -vnet2 10.0.0.2 (private)
如何设置openvswitch网络,使VM1和VM2位于专用网络上,而主机位于两个不同的位置
编辑:
运行此命令:
# ovs-vsctl add-port br-private vxlan1 -- \
set Interface vxlan1 type=vxlan options:remote_ip=123.123.123.2
导致此OVS配置:
root@backup01:~# ovs-vsctl show
6276bd0a-920b-469d-a4e0-90d990dd8f94
Bridge "br-private1"
Port "vxlan1"
Interface "vxlan1"
type: vxlan
options: {remote_host="107.150.29.72"}
Port "br-private1"
Interface "br-private1"
type: internal
ovs_version: "2.3.0"
root@kvmssd01:~# ovs-vsctl show
da6399d4-1435-437d-90d7-3e75c443389b
Bridge br-private
Port "vxlan1"
Interface "vxlan1"
type: vxlan
options: {remote_host="107.150.29.68"}
Port br-private
Interface br-private
type: internal
ovs_version: "2.3.0"
使用此内核:
root@backup01:~# uname -r
3.16.0-4-amd64
使用此模块:
root@backup01:~# modinfo openvswitch
filename: /lib/modules/3.16.0-4-amd64/kernel/net/openvswitch/openvswitch.ko
license: GPL
description: Open vSwitch switching datapath
depends: libcrc32c,vxlan,gre
intree: Y
vermagic: 3.16.0-4-amd64 SMP mod_unload modversions
此版本的OVS:
root@backup01:~# ovs-vsctl --version
ovs-vsctl (Open vSwitch) 2.3.0
Compiled Dec 19 2014 03:59:10
DB Schema 7.6.0
导致以下错误:
root@backup01:~# ovs-vswitchd logs
2015-07-23T16:34:59Z|00001|reconnect|INFO|logs: connecting...
2015-07-23T16:34:59Z|00002|reconnect|INFO|logs: connection attempt failed
(Address family not supported by protocol)
2015-07-23T16:34:59Z|00003|reconnect|INFO|logs: waiting 1 seconds before reconnect
2015-07-23T16:35:00Z|00004|reconnect|INFO|logs: connecting...
2015-07-23T16:35:00Z|00005|reconnect|INFO|logs: connection attempt failed
(Address family not supported by protocol)
2015-07-23T16:35:00Z|00006|reconnect|INFO|logs: waiting 2 seconds before reconnect
lsmod
输出:
# lsmod | grep openvswitch
openvswitch 63932 0
gre 12777 1 openvswitch
vxlan 35053 1 openvswitch
libcrc32c 12426 1 openvswitch
一种选择是在两台主机上的OVS网桥之间建立VXLAN隧道 创建OVS桥 在每个主机上,创建一个OVS网桥,供专用网络使用:
ovs-vsctl add-br br-private
创建libvirt虚拟机时,将每个来宾的vnet2
连接到br private
网桥。使用virt install
这看起来像:
virt-install ... -w bridge=br-private,virtualport_type=openvswitch
如果使用其他机制创建来宾,则相应的XML如下所示:
<interface type='bridge'>
< source bridge='br-private'/>
< virtualport type='openvswitch'/>
< /interface>
并在kvm02上执行以下操作:
ovs-vsctl add-port br-private vxlan1 -- \
set Interface vxlan1 type=vxlan options:remote_ip=123.123.123.1
此隧道已就位,您的客人已连接到br private
,
您已经创建了一个跨多个主机的虚拟网络
请注意,VXLAN通过UDP端口4789运行,因此您可能需要修改防火墙配置以允许这些连接
完成的OVS配置如下所示:
# ovs-vsctl show
ac885d3d-b636-4bb1-a75e-37f361af87e3
Bridge br-private
Port "vxlan1"
Interface "vxlan1"
type: vxlan
options: {remote_ip="192.168.122.107"}
Port br-private
Interface br-private
type: internal
Port vnet2
Interface vnet2
ovs_version: "2.3.2"
…当然是使用您的主机ip地址,而不是我的测试环境中的此地址。太棒了!谢谢你的帮助。仍在试图抓住openvswitch。最后一个问题。我可能有多少个VLAN(例如,如果我在一台主机上有1000个虚拟机,所有主机都有专用网络,而在另一台主机上有1000个虚拟机,那么最好/可行的做法是拥有1000个VLAN吗?)。此外,我如何在openvswitch(或者可能通过libvirt?)上设置DHCP服务器,以便自动为libvirt/KVM上的主机分配专用IP。谢谢你的帮助!!您可以在单个VXLAN隧道上隧道多个VLAN,但这需要添加openflow规则,将VLAN标记转换为VXLAN隧道ID(并返回到另一端)。这两个问题都超出了原始问题的范围,因此我建议做一些研究,然后发布新的问题(可能在Serverfault上,这可能更适合这个主题)(为专用虚拟网络提供DHCP服务器,并通过VXLAN隧道隧道传输VLAN),因此您可能会在OpenStack文档/博客等中找到一些示例。我正在尝试设置此选项,但似乎一直出现错误“协议不支持地址族”当我输入端口信息时。有什么想法吗?
lsmod | grep openvswitch
在您的系统上显示了什么?root@kvmssd01:~#lsmod | grep openvswitch openvswitch 63932 0 gre 12777 1 openvswitch vxlan 35053 1 openvswitch libcrc32c 12426 1 openvswitch
hmmm在我设置vlan之前,它显示了这个错误。默认安装在debian 8上。可能是openvswitch的服务器出了问题?
# ovs-vsctl show
ac885d3d-b636-4bb1-a75e-37f361af87e3
Bridge br-private
Port "vxlan1"
Interface "vxlan1"
type: vxlan
options: {remote_ip="192.168.122.107"}
Port br-private
Interface br-private
type: internal
Port vnet2
Interface vnet2
ovs_version: "2.3.2"