找回密码
 注册
查看: 4413|回复: 3

Neutron Linux Bridge + VLAN/VXLAN 虚拟网络

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2019-10-25 11:00:14 | 显示全部楼层 |阅读模式
购买主题 本主题需向作者支付 2 金钱 才能浏览

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-10-25 11:22:20 | 显示全部楼层
修改配置文件 ! A8 o$ i" Z, ?' `' e
controller节点4 y- U, A/ S; @6 w

! j% W' a0 j, O2 k0 I/ d+ c/etc/neutron/plugins/ml2/ml2_conf.ini
* ]9 R  R/ q9 [2 Z/ u
3 Q* k" L- o& u' T! R[ml2]6 k- U6 N4 ~4 b% Z6 H
type_drivers = flat,vxlan
$ j5 L' S. e5 q6 Ktenant_network_types = vxlan
: _" ^5 D& Q+ `1 x' r! ]mechanism_drivers = openvswitch,l2population
6 B* q- N6 d3 ]extension_drivers = port_security
! W0 c) y( t' @$ J' {; J. P# E( @9 I/ n5 R+ `  _
[ml2_type_vxlan]
" @( v' r2 V$ q6 K2 Uvni_ranges = 1001:2000
2 S: S: c1 S0 O9 s+ ?5 Q  @7 S8 Z0 ]- L4 d7 J2 _0 y1 Z6 ]
[securitygroup]# {7 @, `, Y5 t* P+ b9 r* U1 {
enable_ipset = true
( D) w; A4 t9 |9 j% E7 ~0 x# ~
7 O8 L  F! p/ g4 k" x* @/etc/neutron/l3_agent.ini
, q- {7 s/ p; k6 w7 K9 |' p, i5 X! s8 ]# ]( w/ }5 z* M
[DEFAULT]& }9 H) J0 l9 h, W8 }9 D" {
external_network_bridge = br-ex. {2 x6 `2 D8 L( b
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver" U) o. ?* `3 [( j1 g/ A1 K8 p
0 Q4 q* U: \0 F1 l$ P7 o
/etc/neutron/dhcp_agent.ini
! B, q% y2 i8 X& i$ C( X
* ?4 D7 C  ]. }6 s4 I/ p9 P0 L9 o[DEFAULT]
9 h3 ?! F8 w0 |7 A) N6 x3 Ainterface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
3 Z. \5 E8 c& \" E2 E- _( q7 Z/ kdhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
  M2 f' {! u3 D2 R- qenable_isolated_metadata = True
1 Z8 Y, Z/ I9 {. j" E: s) }
8 L" m) p2 n8 E$ K2 ^- N/etc/neutron/plugins/ml2/openvswitch_agent.ini) k. T5 ~8 q+ _8 X, n& Y2 C1 E% q

: x$ G% P6 b  L( I# A$ g[ovs]! L2 z5 }. u; W/ J, F
bridge_mappings =
5 o/ E" I2 Q0 w# ~tunnel_bridge = br-tun- B; z! C( N* I* t% i2 U2 t" }
local_ip = 10.10.10.10+ h) ^7 e$ \; Q, p. V
5 d/ m- T6 O* L7 c, t
[agent]
1 p6 E0 l& {# T  E3 @2 L+ q) s; jtunnel_types = vxlan
1 h( ^# |% x7 J7 al2_population = True3 E, w6 g# Y) y, z+ k

: e, x6 H- c" h# v[securitygroup]
/ o7 f( i: O- p) wfirewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver# f+ U* D2 @0 a
enable_security_group = true. l- a% Q3 C3 R- f

! o; G6 W. f( A5 |; X; A  T& kcompute1节点
$ |0 b* T. z3 o' G" r9 j1 w3 z9 w3 N3 }( c% K
/etc/neutron/plugins/ml2/openvswitch_agent.ini
. h8 v2 e  d* P- g5 A* C8 h' Y! L* ~. I
[ovs]
% m6 f/ c% b, Q4 W  Y& tbridge_mappings = # ~$ l. r. V* D$ o
tunnel_bridge = br-tun/ e/ F6 B0 d6 a
local_ip = 10.10.10.11
( @2 e% t# I/ y6 [/ G& c7 O. A2 g0 [
[agent]
9 v" H- @. U$ }' ntunnel_types = vxlan. g1 R2 w+ K, N+ _" \! k9 q
l2_population = True0 n" D  e# X) ~- R: B6 C

. V- l. ?+ G9 n- j[securitygroup]
6 W. @1 l5 r* K) E3 y% s2 O/ Pfirewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
  G) t% L1 m. [: r  u! `) t! menable_security_group = true
2 J3 h  b" q1 v8 t9 W0 x6 Y: P3 N- E& _( Y' e8 |
compute2节点4 A+ b1 v3 j1 Y- ^( h

( X: D4 o7 m3 }" B[ovs]4 }: V" i" G: H7 j# J  K1 R% H
bridge_mappings = 1 U4 T; \" Q4 s0 t
tunnel_bridge = br-tun
7 X) B- W* ~& h7 U7 Jlocal_ip = 10.10.10.12
& ~: O# j5 b5 w0 l. {( |9 F3 I( Z- u3 d* f6 H/ k; J
[agent]9 b, v1 a5 P2 O5 N7 ^3 A* H' X
tunnel_types = vxlan
9 W, c" U3 f2 y  o) kl2_population = True
( R6 Q  ?) h/ j( I( w0 J
* \1 A/ T4 V: }6 j2 h: u3 b[securitygroup]  q% u& w  r. `# C. F$ C
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
( `, ^" T4 G9 s- I* r# Y& Renable_security_group = true
3 ]2 F/ U  C4 a; I" G& ^# z& u; O" Z/ k" {: b" k# L
重启网络相关服务。2 H- g+ P  A/ v: ?% ^

. a1 }, j  I5 g$ T' c再次查看网络服务信息 ( h- S" U! K7 E/ Y$ }. }
————————————————
9 Q+ Q) J+ P/ X: m" S

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-10-25 11:23:29 | 显示全部楼层
虽然大部分的OpenStack 部署环境中,都会使用 Open vSwitch 来作为虚拟交换机来实现二层网络功能,但是Neutron 仍然支持使用 Linux bridge 作为虚拟交换机来实现二层网络。本文就此做些分析和说明。
% B# Q$ ?# t8 ?- a, W* R5 V- g8 `同时要指出的是,OpenStack 官方已经把 linux bridge 实现标记为 legacy 的了,文档从 2016 年后也没怎么更新了。这是因为,linux bridge 和 OVS 相比,只支持基本的网络功能即二层交换,但不支持VLAN 标签和隧道。因此,linux bridge agent 利用linux 内核功能(VLAN 子接口和 VXLAN 接口)来实现VLAN 标签和隧道。+ N$ W/ X" L; i- p; c0 h( C

: ?* Z% M! V9 M) F. j1 ]2 N 1. 测试环境
# P- v/ G, `* z6 j9 W2 j) F- J以下面的环境为例(网络节点上):
# J) m! t5 x5 D1 R) @2 H$ l( N(1)linux bridge; @6 N. }4 g" w- ]0 z) p1 {! D* f
7 @; G5 x; p  |: H
root@controller:/home/sammy# brctl show, Z- o" A  s8 i6 X
bridge name     bridge id               STP enabled     interfaces
3 ~% T. v. x! {/ Ebrq85925305-b4          8000.563534c8d02d       no              tap0bb8efeb-10
! L' w1 b  ~& T                                                        tap798c87d1-a29 k; l: R; f* E1 R6 V
                                                        vxlan-25# d# O1 ~! {# ]. f( ]7 M' }
brq96609bfa-0e          8000.0050569c4d94       no              ens224! f& g' D8 E6 @1 ?# |8 j+ y, a
                                                        tap60dbdc2f-a0
" R7 f; j* y0 zbrq971ffda2-e5          8000.a6acb08e4fd6       no              tapb1eaae00-e5. V7 q1 r$ C( z2 C  ]+ h) M
                                                        tapf70543dd-0f$ _4 l/ a8 M/ W  m
                                                        vxlan-10# r! t: j& r  H! f

, @2 ]. x5 m2 i0 E2 i(2)OpenStack 网络和 network namespace:
! K) j2 \) x& G! f$ ]/ e 1 x: Z0 p& h9 T' J6 \
root@controller:/home/sammy# neutron net-list
4 n. t7 j% `/ c6 W7 E% x5 ?  o% j+--------------------------------------+---------+-----------------------------------------------------+  r+ |5 ]- }5 |! \% Y
| id                                   | name    | subnets                                             |4 f; ?7 c+ w) t/ X7 ^) K
+--------------------------------------+---------+-----------------------------------------------------+
! b5 g, y3 }9 [1 z; v7 `| 96609bfa-0e22-4bb7-8dba-6ef532ea6076 | extnet  | afa7d205-3026-439f-aca7-295a9f9b2a71 10.62.227.0/24 |
' z' `* ], l' n( [8 y- G| 971ffda2-e567-40a0-a2c8-b31a577fd4d3 | appnet  | 4c68eacb-bf3e-408a-a941-94e93eddb22b 11.0.0.0/24    |
$ J. i6 _+ {9 u, b- b! b3 m3 z|                                      |         | 3d596991-de8f-4ae4-8913-89426a8abbd7 10.0.0.0/24    |
) E9 c, Y2 y4 q8 m| 85925305-b477-4cc6-9654-67d9bf1e7cd8 | appnet2 | 4575c7f1-7f08-4917-9904-ec65af38619b 20.0.0.0/24    |
# o  N6 c$ |/ `% m& l- t+--------------------------------------+---------+-----------------------------------------------------+
& }5 M( X- j9 y2 ~root@controller:/home/sammy# ip netns
: q) \2 [- a" _9 z( M- Mqdhcp-85925305-b477-4cc6-9654-67d9bf1e7cd8 (id: 2)
6 O2 R3 {( H/ Nqdhcp-971ffda2-e567-40a0-a2c8-b31a577fd4d3 (id: 1)
3 d& D* y6 y3 Iqrouter-39a77439-8a28-49c1-bf97-ac931510631b (id: 0)
: G6 D! B9 y; Z# }. ?( r* n: P5 k' m ) d6 S* `! t- C8 h$ `4 G0 \
(3)示意图:
, t2 f+ Y/ f3 M3 q1 l2 a3 X 1 h6 u; h4 Z: W
(4)说明:' D7 U& Y9 k; M4 N( c
•        qdhcp 和 qrouter 都是 linux network namespace 实例
) e' d9 Q" {& x* u8 @: ~4 o•        qdhcp network namespace 的数量等于启用了 DHCP 的 Neutron network 的数量。' b6 Q: k5 s5 R7 l: b; o
o        当一个 network 中存在至少一个 subnet 启用了 DHCP 之后,会有一个 qdhcp network namespace 被创建出来;  }* c* e; ^5 B0 S# o6 y
o        当一个 network 中多个 subnet 启用了 DHCP 时,它们共用一个 qdhcp,以及 dnsmasq。
$ U+ Q8 i9 ]& z$ R* ?- ^3 _% c# S9 @o        其 name 使用 network id,比如 qdhcp-85925305-b477-4cc6-9654-67d9bf1e7cd8- W2 E4 k  z! T" D; r2 x2 |
•        qrouter network namespace 的数目等于 router 的数目,也就是说,系统中一共有几个 router,那么就存在几个 qrouter network namespace
0 c+ j, g% [4 Y/ Y1 @•        brq linux bridge 的数目等于 neutron network 的数目,其 name 是 network id 的前几位,比如 brq96609bfa-0e
( y/ s6 I$ g7 _" r& j•        一个 network 的 qdhcp network namespace 和其 brq linux bridge 一定有连接
3 n9 y& `2 t# X+ o. l( C6 K•        qrouter 之内的 network interface 分两种,一种是 qr 开头的,每个连接到 router 之上的 subnet 都有一个;还有一个是 qg,每个连接到 router 的 external subnetwork 有一个* C" n; t) _( N
•        qrouter 的每个 network interface 都通过 veth 连接到所在网络的 qbr linux bridge 上
+ A; q: R6 j  L8 B% \  Y3 ]•        qbr linux bridge 连连接两种物理设备,一种是 vxlan interface,每个 tenant network 有一个,另一种是在 physical network 对应的物理网卡上创建的子接口(sub-interface)! M9 i( q1 p  b5 G% f3 c3 r
•        对于 physical network 的 qbr 来说,用户可以指定它,并且在linuxbridge_agent.ini 中通过 bridge_mappings = List of <physical_network>:<physical_bridge> 进行配置;也可以不指定,此时 agent 会创建它。当同时配置了 physical bridge 和 physical interface 时,前者优先。6 X2 ^, K# y$ _/ H3 Q- W! E
如果 external network 中有多个 subnet 的话:2 j# f0 y/ W. G+ ~5 k* d* W7 g
(1)每个 qrouter 只允许有一个 External Gateway,也就是说它只有一个 qg network interface。当 external network 添加多个 subnet 之后,只有第一个被当作 external subnet,其余的都会被当作 internal subnet。& y$ y- a0 H" J5 D2 T* Y
(2)在 qrouter 的路由表之中,/ Y7 F" J! V5 `

6 R4 V* C. J; x" v3 y3 Q, g! Q1 C9 proot@controller:/home/sammy# ip netns exec qrouter-39a77439-8a28-49c1-bf97-ac931510631b route, F3 |' w, Z8 J! Y0 a. w- P9 f
Kernel IP routing table
1 u; W3 c) ^! n. }Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
+ d( p6 d) Y! y; \2 L7 [default         10.62.227.1     0.0.0.0         UG    0      0        0 qg-e09fce07-cd+ r! U1 w8 Z( a
10.0.0.0        *               255.255.255.0   U     0      0        0 qr-b1eaae00-e5; D0 f( q2 V6 B' |6 o. R$ b
10.62.227.0     *               255.255.255.0   U     0      0        0 qg-e09fce07-cd% o" l& d/ ?+ o
10.62.228.0     *               255.255.255.0   U     0      0        0 qg-e09fce07-cd
. G/ A2 n* @4 _0 x. h$ N10.62.228.0     *               255.255.255.0   U     0      0        0 qr-124ff148-b78 E+ G9 _3 l1 o. \
11.0.0.0        *               255.255.255.0   U     0      0        0 qr-16d9b0cc-38
* w$ a5 T! ?6 q2 U# r* i20.0.0.0        *               255.255.255.0   U     0      0        0 qr-0bb8efeb-10
6 D& j- L) j& [
2 a( c3 E6 ?/ Q, E1 |) I0 F7 v+ f
7 s' x/ ]  e3 ^& j0 v8 Y2. linux-bridge-agent 工作过程分析& Y$ y' N0 f) G
(1)linuxbridge-agent 会启动一个循环,不断扫描上面红框中的 tap 设备
) j6 b/ A* |3 p0 b- Q
& P' x) O, `* _( E+ f3 B- }    def daemon_loop(self):5 g$ p) J, B/ w
...8 `) B& S, ~9 g
        while True:3 t& m# O9 V, z  s3 Q+ x6 N# U
            start = time.time(). G% m: R$ O6 b  H0 i, L
. ..
: ^5 I2 n; Y2 ^3 `! N3 ~) M3 T) E6 y; @
            device_info = self.scan_devices(previous=device_info, sync=sync)" Y% q# r2 |; A9 }$ ^6 a" ^
            sync = False
2 v4 H+ S$ R* ?
! k: m7 B/ w# m* `9 S; M! D9 |            if (self._device_info_has_changes(device_info)
# C! F' p8 z5 K* I7 t. k( h( f                or self.sg_agent.firewall_refresh_needed()):
7 x% l: Q7 |( B' f( I                LOG.debug("Agent loop found changes! %s", device_info); ]2 ^* k. Z, j  w' w
                try:, T& Z1 Q( i5 r1 [5 M- i
                    sync = self.process_network_devices(device_info)  ]3 u$ T3 s$ j5 s1 L( P
                except Exception:, A8 i5 Y7 [7 _1 r. P$ e
                    LOG.exception(_LE("Error in agent loop. Devices info: %s"),
* O7 k/ }& d" L' v0 Z2 ~& ?- x                                  device_info)3 `- z  c/ p6 M. W1 T: Z& d9 f
                    sync = True" b9 j2 Y& O. l& ~) P$ R
3 W0 A* t7 ~4 h  @* f
这是它首先找到的 devices:7 E3 x2 N4 Z1 u
(Pdb) p bridge_lib.get_bridge_names()
/ W4 M9 L$ d1 v2 K['brq85925305-b4', 'virbr0', 'brq971ffda2-e5', 'virbr0-nic', 'tapb1eaae00-e5', 'tapf70543dd-0f', 'vxlan-25', 'vxlan-10', 'tap0bb8efeb-10', 'lo', 'tap60dbdc2f-a0', 'tap795e6e86-94', 'ens224', 'ens192', 'ens160', 'tap798c87d1-a2']7 A% m. j" G# G6 q+ X. r7 s9 K
然后过滤出 tap 设备:! e  B# F- o; e) ?) S8 q
get_all_devices()->set(['tap0bb8efeb-10', 'tap60dbdc2f-a0', 'tap795e6e86-94', 'tap798c87d1-a2', 'tapb1eaae00-e5', 'tapf70543dd-0f'])
7 n8 A3 m# ^) u4 Z4 x# e(2)根据 previous 中保存的历史数据,再接合服务器端和本地更新时间,计算出需要更新的tap设备列表:
/ m0 e3 S1 z4 K: r& ^5 D{'current': set(['tapf70543dd-0f', 'tap60dbdc2f-a0', 'tapb1eaae00-e5', 'tap795e6e86-94', 'tap0bb8efeb-10', 'tap798c87d1-a2']), 'timestamps': {'tapf70543dd-0f': 1476956816.672447, 'tap60dbdc2f-a0': None, 'tapb1eaae00-e5': 1476956816.672447, 'tap795e6e86-94': None, 'tap0bb8efeb-10': 1476689797.1378036, 'tap798c87d1-a2': 1476689701.1349163}, 'removed': set([]), 'added': set(['tapf70543dd-0f', 'tap60dbdc2f-a0', 'tapb1eaae00-e5', 'tap795e6e86-94', 'tap0bb8efeb-10', 'tap798c87d1-a2']), 'updated': set([])}
) p& d; s5 g# L( R& b7 X  (3) 通过 RPC 获取 tap 设备的详细信息! F* m' G$ A$ |' T2 d
& p: ]- p: Z: M2 N( l9 Z6 f
(Pdb) p devices
% T+ B! C% E5 @5 i6 r1 e; J$ qset(['tapf70543dd-0f', 'tap60dbdc2f-a0', 'tapb1eaae00-e5', 'tap795e6e86-94', 'tap798c87d1-a2', 'tap0bb8efeb-10'])
# U6 }" c, \2 c" A( V7 l2 O: G3 S$ f7 |# \

: G$ u) q( y9 |+ j8 E3 _4 g  pdevices_details_list = self.plugin_rpc.get_devices_details_list' ?; t$ D% q3 Y& C- L' S

% A2 e7 {; t+ U( b: e2 g(Pdb) p devices_details_list
7 K" k  Z% \1 }: o" x% U3 j  ~[{u'profile': {}, u'network_qos_policy_id': None, u'qos_policy_id': None, u'allowed_address_pairs': [], u'admin_state_up': True, u'network_id': u'971ffda2-e567-40a0-a2c8-b31a577fd4d3', u'segmentation_id': 10, u'device_owner': u'network:dhcp', u'physical_network': None, u'mac_address': u'fa:16:3e:5c:bf:11', u'device': u'tapf70543dd-0f', u'port_security_enabled': False, u'port_id': u'f70543dd-0f1b-4e1d-93c7-33f4f3d7a709', u'fixed_ips': [{u'subnet_id': u'3d596991-de8f-4ae4-8913-89426a8abbd7', u'ip_address': u'10.0.0.10'}], u'network_type': u'vxlan', u'security_groups': []}, {u'profile': {}, u'network_qos_policy_id': None, u'qos_policy_id': None, u'allowed_address_pairs': [], u'admin_state_up': True, u'network_id': u'96609bfa-0e22-4bb7-8dba-6ef532ea6076', u'segmentation_id': None, u'device_owner': u'network:router_gateway', u'physical_network': u'provider', u'mac_address': u'fa:16:3e:77:78:86', u'device': u'tap60dbdc2f-a0', u'port_security_enabled': False, u'port_id': u'60dbdc2f-a01b-446d-bb5b-26ffac19a045', u'fixed_ips': [{u'subnet_id': u'afa7d205-3026-439f-aca7-295a9f9b2a71', u'ip_address': u'10.62.227.151'}], u'network_type': u'flat', u'security_groups': []}, {u'profile': {}, u'network_qos_policy_id': None, u'qos_policy_id': None, u'allowed_address_pairs': [], u'admin_state_up': True, u'network_id': u'971ffda2-e567-40a0-a2c8-b31a577fd4d3', u'segmentation_id': 10, u'device_owner': u'network:router_interface', u'physical_network': None, u'mac_address': u'fa:16:3e:81:1b:37', u'device': u'tapb1eaae00-e5', u'port_security_enabled': False, u'port_id': u'b1eaae00-e504-41f8-93a4-643687155bea', u'fixed_ips': [{u'subnet_id': u'3d596991-de8f-4ae4-8913-89426a8abbd7', u'ip_address': u'10.0.0.1'}], u'network_type': u'vxlan', u'security_groups': []}, {u'profile': {}, u'network_qos_policy_id': None, u'qos_policy_id': None, u'allowed_address_pairs': [], u'admin_state_up': True, u'network_id': u'96609bfa-0e22-4bb7-8dba-6ef532ea6076', u'segmentation_id': None, u'device_owner': u'network:dhcp', u'physical_network': u'provider', u'mac_address': u'fa:16:3e:5f:94:7d', u'device': u'tap795e6e86-94', u'port_security_enabled': False, u'port_id': u'795e6e86-94af-4b72-ae1a-5a324a017774', u'fixed_ips': [{u'subnet_id': u'afa7d205-3026-439f-aca7-295a9f9b2a71', u'ip_address': u'10.62.227.150'}], u'network_type': u'flat', u'security_groups': []}, {u'profile': {}, u'network_qos_policy_id': None, u'qos_policy_id': None, u'allowed_address_pairs': [], u'admin_state_up': True, u'network_id': u'85925305-b477-4cc6-9654-67d9bf1e7cd8', u'segmentation_id': 25, u'device_owner': u'network:dhcp', u'physical_network': None, u'mac_address': u'fa:16:3e:25:27:99', u'device': u'tap798c87d1-a2', u'port_security_enabled': False, u'port_id': u'798c87d1-a2d8-4df7-b7fc-5ab30918a0de', u'fixed_ips': [{u'subnet_id': u'4575c7f1-7f08-4917-9904-ec65af38619b', u'ip_address': u'20.0.0.100'}], u'network_type': u'vxlan', u'security_groups': []}, {u'profile': {}, u'network_qos_policy_id': None, u'qos_policy_id': None, u'allowed_address_pairs': [], u'admin_state_up': True, u'network_id': u'85925305-b477-4cc6-9654-67d9bf1e7cd8', u'segmentation_id': 25, u'device_owner': u'network:router_interface', u'physical_network': None, u'mac_address': u'fa:16:3e:9f:18:a9', u'device': u'tap0bb8efeb-10', u'port_security_enabled': False, u'port_id': u'0bb8efeb-108f-409a-82e7-c4c20f0d4f69', u'fixed_ips': [{u'subnet_id': u'4575c7f1-7f08-4917-9904-ec65af38619b', u'ip_address': u'20.0.0.1'}], u'network_type': u'vxlan', u'security_groups': []}]- W0 V4 `6 g7 T' ~

/ e9 i: v4 h% m, f(4) 对需要处理的设备,调用 self.process_network_devices(device_info) 函数进行处理
0 G( _. R0 t" p  v. Q8 }! H(5). 调用 plug_interface
& m- W5 p' B) U% W  jinterface_plugged = self.mgr.plug_interface(network_id, segment,device, device_details['device_owner'])
* Y' K4 t8 I. q, K0 H5 U+ e(6). 需要的话,使用已经配置的或者新建 linux brige,并将 physical interface 设备加入其中
. }$ n* n, _0 g9 o! i* u/ }9 dbridge_name = self.get_existing_bridge_name(physical_network) #获取为 physical network 配置的 linux bridge: |4 o2 N- i6 f" i
bridge_name = self.get_bridge_name(network_id) #或者根据 network id 生成 bridge name1 Y% x! w' U- `6 A; x$ E
(7).根据不同的网络类型,分别处理 vxlan bridge,flat bridge 和 vlan bridge2 K' I9 c! s$ V+ A, c% \8 ~2 r

* Y; S+ F7 \: Q! n7 c( [$ X* t    def ensure_physical_in_bridge(self, network_id,
6 T: n: I( _5 K+ Y+ r                                  network_type,
8 c  C" R7 X/ j& |+ a                                  physical_network,
( R7 C" l1 _2 L) e8 G/ s0 L. d                                  segmentation_id):
) W0 \- Y% a; D: f; M9 I( T; n, o        if network_type == p_const.TYPE_VXLAN:  f  y" l9 \) U3 l* f3 }
            if self.vxlan_mode == lconst.VXLAN_NONE:
; v0 a' P/ a  n9 P                LOG.error(_LE("Unable to add vxlan interface for network %s"),, k1 i+ T9 z! Q# X& h
                          network_id)
0 m3 w% @# f" d4 h0 d  X5 n! x                return
) ^$ P, T- L! z# Q            return self.ensure_vxlan_bridge(network_id, segmentation_id)
+ U) V  c  i/ K( s* |% M0 X0 w& r0 C. e  D$ V- J
        # NOTE(nick-ma-z): Obtain mappings of physical bridge and interfaces
, C  ~4 k/ t# j9 \        physical_bridge = self.get_existing_bridge_name(physical_network)# u' ]4 D/ @, C5 T3 m
        physical_interface = self.interface_mappings.get(physical_network)1 [+ Z) P8 N5 \5 z  p1 M
        if not physical_bridge and not physical_interface:5 H& B* V6 t9 |
            LOG.error(_LE("No bridge or interface mappings"
$ n8 d! |, v2 P3 `" V                          " for physical network %s"),
: v" c8 H& [5 v- z# u. F: _$ ?                      physical_network)
; X4 e% b9 i. O: u            return1 x" d  _4 Q# J1 e
        if network_type == p_const.TYPE_FLAT:% G& Z, c4 Z* T) z- j8 z( ~# _8 Q  f/ c
            return self.ensure_flat_bridge(network_id, physical_bridge,
6 U  `( V! `/ A& X, S- g- G2 q/ Z                                           physical_interface)
9 t: z5 {. m. s        elif network_type == p_const.TYPE_VLAN:
& y4 [) Z) `" r4 i            return self.ensure_vlan_bridge(network_id, physical_bridge,0 E9 |' W5 K3 l/ E! R1 [& ]5 w$ z: J
                                           physical_interface,
$ \8 B, V6 R' M/ Z( N- j+ m+ Q! T                                           segmentation_id)) n: h3 ^# A9 D0 f# {) a* O
& z. q7 x4 ^- _% ^  Q, P
对于 flat 类型的网络,调用 ensure_physical_in_bridge
$ g6 b* \# a; Bdef ensure_physical_in_bridge(self, network_id,network_type,physical_network,segmentation_id)( N3 f/ T$ ]' m2 Z
  if network_type == p_const.TYPE_FLAT:
" d9 X& G" f4 I/ E    return self.ensure_flat_bridge(network_id, physical_bridge,physical_interface)! M+ i; b2 ~' U" Y0 G
如果有配置 physical bridge 的话,使用它;否则创建 bridge,并将物理网卡配置的 ip 地址和 gateway 从网卡挪到 linux bridge) m2 l$ D5 ]* b) {
7 ?5 N( v# R( ~
def ensure_flat_bridge(self, network_id, phy_bridge_name,physical_interface):
2 v; ^; ^" J3 X  """Create a non-vlan bridge unless it already exists."""3 u2 P  T" G8 ?3 n' Y4 M3 B
  if phy_bridge_name:
. q& H% _2 H0 K3 I( z* _1 H    return self.ensure_bridge(phy_bridge_name) #获取预先配置好的 linux bridge
( O- N9 u! R: }  else:
; \) B* T4 {9 R" v6 j( ?    bridge_name = self.get_bridge_name(network_id)
+ R/ Z/ q" ^& E9 K. A; y8 ?    ips, gateway = self.get_interface_details(physical_interface)
- {; o% ]+ }5 F0 G' _    if self.ensure_bridge(bridge_name, physical_interface, ips,gateway): #创建 bridge' t* K: o* ~* L1 a
    return physical_interface  U5 D8 b# E2 u2 B! q- M, `
+ e) L  N% z6 M& ]
对于 vxlan 类型的 network,需要创建 vxlan interface
: h4 M/ O8 j: K) V
4 A0 D& v- P6 t/ L  n6 n. a. L    def ensure_vxlan_bridge(self, network_id, segmentation_id):
5 M# m4 |  k. x( x& ~' J        """Create a vxlan and bridge unless they already exist."""
  v9 a: `1 _& i' U! O# \* T        interface = self.ensure_vxlan(segmentation_id)
/ u. O. J. l6 l; c% ^; P        if not interface:* l! h$ Y( d" }+ G
            LOG.error(_LE("Failed creating vxlan interface for "' m1 A7 E+ \' g6 l
                          "%(segmentation_id)s"),
+ `2 U8 ]( W! e8 F7 l/ e0 `                      {segmentation_id: segmentation_id})
$ _8 F  ^% R% Q$ e            return$ _+ H) ]! {& |7 m6 e7 F2 P
        bridge_name = self.get_bridge_name(network_id)
, E  C, ^5 P/ j5 p1 m; V1 j        self.ensure_bridge(bridge_name, interface)
$ \" B( O! B. p' T        return interface) E4 J- c$ E5 R1 T  H  v

' m0 {9 Z8 C" z1 T( }创建 vxlan interface:
# C3 M6 U4 r- v( d& j
* Y" h8 c* u) m* x/ ~0 M* ?' K% P    def ensure_vxlan(self, segmentation_id):! c( ?2 h9 p/ w, R& G. S, H' k
        """Create a vxlan unless it already exists."""5 q7 k+ F) N+ J# U  m  m: A2 t) G
        interface = self.get_vxlan_device_name(segmentation_id)2 u1 J0 C/ \$ O* [2 c! M' L1 h
        if not ip_lib.device_exists(interface):7 E9 H  v% M% y
            LOG.debug("Creating vxlan interface %(interface)s for "
: s7 T: J) b7 L9 Y# H4 Z4 f                      "VNI %(segmentation_id)s",
7 }# g9 s1 p: n! S, c                      {'interface': interface,
8 ]6 k* `$ b' L  J% x( C                       'segmentation_id': segmentation_id})
' J- t4 n8 s) i# }, X* p' S# j, X3 q            args = {'dev': self.local_int}
3 v2 x3 b# _! _- i6 K  q            if self.vxlan_mode == lconst.VXLAN_MCAST:
! F9 C6 h7 [& A7 D                args['group'] = self.get_vxlan_group(segmentation_id)
" m' [  a# |! D% `            if cfg.CONF.VXLAN.ttl:  R& k" E0 v8 O  W
                args['ttl'] = cfg.CONF.VXLAN.ttl7 x& w+ o5 J; U
            if cfg.CONF.VXLAN.tos:
0 i" p' b3 v) e) l! b; g+ A                args['tos'] = cfg.CONF.VXLAN.tos% {  o! E: l& f
            if cfg.CONF.VXLAN.l2_population:
5 T: V; n1 o# d8 S7 j, `3 M                args['proxy'] = cfg.CONF.VXLAN.arp_responder, B4 O6 a3 ~# u
            try:
+ K6 R2 y) J9 e/ p, |$ k2 j+ h/ q                int_vxlan = self.ip.add_vxlan(interface, segmentation_id,0 C5 O' F$ l! e5 m- q3 ^/ }( p' A/ x
                                              **args)% b9 }5 P6 x* h5 G* b6 [5 ^
: u1 ^) ?; `) T/ c1 R
(8). 将 tap 设备加入到 linux bridge 中/ c4 i  @$ Q; k" n) p- i! m
bridge_lib.BridgeDevice(bridge_name).addif(tap_device_name)
, n: E: K# q, {1 L) f5 |(9). 如果将一个 tap 设备被删除,那么 linux-bridge-agent 会发现:
  Q. o; P" K5 e  g+ K" m2016-10-26 10:29:58.347 30219 INFO neutron.agent.securitygroups_rpc [req-e3264065-6414-4b5a-8d2b-dfafad6fdde8 - - - - -] Remove device filter for set(['tap60dbdc2f-a0'])
2 u: E" H0 ?6 @. G7 E6 g2016-10-26 10:29:58.433 30219 INFO neutron.plugins.ml2.drivers.agent._common_agent [req-e3264065-6414-4b5a-8d2b-dfafad6fdde8 - - - - -] Attachment tap60dbdc2f-a0 removed, `, w$ l) x; d  C+ \  N
2016-10-26 10:29:58.536 30219 INFO neutron.plugins.ml2.drivers.agent._common_agent [req-e3264065-6414-4b5a-8d2b-dfafad6fdde8 - - - - -] Port tap60dbdc2f-a0 updated.* A8 x2 l0 @8 v" z
3. 关于上述工作过程的简单结论1 O, D; w' \0 f' Q, c4 ^# T/ d
3.1 简单结论
- G: U3 C1 `" r( s0 }* l& L- l1.        l3agent 和 dhcpagent 创建 network namespace 时创建 tap 设备,和 network namespace 中的 interface 是一对 veth pair。当手工删除 tap 设备时,相应的 veth endpoint 也会被删除。
$ F# Y$ D% i  \2.        linuxbridgeagent 不断扫描服务器端和本地的 tap 设备
5 R6 i2 ^7 R9 b8 T3.        linuxbridgeagent 获取需要增加和修改的tap设备列表! W; E( |. J# D" E
4.        对于需要增加的 tap 设备,获取其详细信息,主要是 network_id,network_type,physical_network,segmentation_id,device_owner 等,然后根据这些信息,创建 linux bridge,并加入所需要的 interface! e4 R# ?9 g+ [7 h3 F0 v- }2 S
5.        创建所需要的 linux bridge,并将 physical interface (provider network 的 physical interface 或者 tenant network 的 vxlan interface)加入 bridge,并且将 tap 设备也加入该 bridge
0 L+ \3 R" F5 N& Y7 o+ h- }  B6.        如果发现某个 linux bridge 没有创建出来,首先需要查看有没有相应的 tap 设备存在;如果 tap 设备不存在,则查看相应的 qdhcp 或者 qrouter 中时候有interface
' t( ~0 q9 i: e  q% \" x9 x 0 A( x/ @# w  p8 G& T
具有多个 VLAN 租户网络时候的网络元素示意图:& W' j3 u2 E# m  a! P
3 {5 ]3 \. X6 b( X( }
' X( p) q3 S# y7 Z( [5 Q
7 w+ S: V, a! I
0 C7 k: {* `5 Y3 T; P
3.2 关于 unnumber interface
* H9 I6 _- F- `4 ^OpenStack 官方的 host networking 配置中,连接外网的 interface 可以是 unnumbered 的,从字面意思理解,就是该 interface 上不需要配置 IP 地址。6 s# B( @* K1 m0 F( K. i  g$ [- P8 m
( L6 ?& o& w* v
配置的时候,修改 /etc/network/interfaces:* \( W$ F" D' u1 Y4 B' ~" z% F/ d  V
# The provider network interface
8 a- O& A! g6 `auto ens224! [: u2 l& m* E
iface ens224 inet manual
6 j6 k) K3 m; ^, ~) j5 r& B% u6 Hup ip link set dev $IFACE up" ?6 Y9 ?# l" S# O) u
down ip link set dev $IFACE down
; o9 p  [9 S0 o配置好以后:
+ {5 ]* v9 x. C. E. ?* v. i $ x8 R/ ~1 g7 Z$ ^7 P
root@controller:/home/sammy# ifconfig ens224% [" y: T6 ?, h2 M3 x
ens224    Link encap:Ethernet  HWaddr 00:50:56:9c:4d:94& C/ b/ b- M  M% J# v7 O
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1( k/ }8 a9 ^: }0 w0 [2 s$ e; }
          RX packets:27300737 errors:0 dropped:0 overruns:0 frame:0# x. p4 m2 U9 o: U2 R9 M( r% N
          TX packets:61547 errors:0 dropped:0 overruns:0 carrier:0# r& r' H2 q+ O* j% K% `3 f/ |
          collisions:0 txqueuelen:10006 J& ?; b3 L; K/ Y0 c  X
          RX bytes:31951077598 (31.9 GB)  TX bytes:5966060 (5.9 MB)
. n+ r% k7 \8 ~4 n3 j8 G/ q
& ~/ s9 S2 G6 `5 H! c  Q& u0 X" Qroot@controller:/home/sammy# ifconfig brq96609bfa-0e
- `2 e) p1 Z& v8 e( ~brq96609bfa-0e Link encap:Ethernet  HWaddr 00:50:56:9c:4d:94) [# g8 m; y2 C9 h
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1# ]7 d( G7 S* O) ^4 s5 k  W
          RX packets:32855 errors:0 dropped:0 overruns:0 frame:0  g. n3 Q" a7 w& l
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0% Q  u/ `( S  |' m
          collisions:0 txqueuelen:1000
$ f6 W( [6 b. G0 [4 g. [          RX bytes:2731030 (2.7 MB)  TX bytes:84 (84.0 B)* J; P4 C0 _7 S2 f

8 l- w. g; A! \8 ?具体原理不详,但是应该是因为 qrouter 的 qg network interface 和物理网络中的路由器的网卡之间是网络二层,因此中间的设备都是属于二层的,因此不需要处于网络三层的 IP 地址。/ T7 q3 x  d7 J* ~) [; z( f4 O
4. 使用 linux bridge 时的拓扑结构
1 M3 o" ^+ h* c4 Z  a8 H6 S: x! R4.1 网络节点上
& F5 v2 L' f9 [为了更清楚,我们来对比着看 linux bridge 和 ovs 的两种方案:" t5 X5 g7 A; z. K: C( s! C
linux 方案:
  B" [5 G/ U+ @  
/ P& c6 E5 t0 ]网络服务:
- i' t. Q* M3 X. m•        Linux bridge agent* Z5 S0 }4 Y  p5 m1 L
•        L3 agent2 f* {. K4 ~" O! X- b
•        DHCP agent
' W: |' ~$ `/ \' F  @/ a% w•        Metadata agent1 h' z! M  U4 q+ X  v/ \. e
Linux bridge agent 会为每个 VLAN 虚拟网络创建一个 VLAN Bridge,它连接多个网元:. W5 `" O- l$ K; |( V. Q
•        VLAN 子接口,从物理网卡(图中的 interface3)上创建,每个子接口对应一个VLAN ID,其名称格式为 device.sid,其中 device 是物理网卡名字比如 eth0,sid 是 vlan id。3 @2 h" {  N% e; z
•        连接虚拟机的 tap 接口5 @# A: o& R# E6 m; O
•        和 qrouter 连接的 tap 接口# i" X9 p& l' g5 I3 P4 W7 c
•        和该网络的 qdhcp 连接的 tap 接口
# Q) `/ n2 Z5 f- r3 m5 s如果同时有 VXLAN 虚拟网络的话(linux-bridge 不支持GRE 隧道模式),会为每个 VLAN 虚拟网络创建一个 Tunnel bridge。它连接多个网元:3 k0 O7 Y$ `3 S1 v% ?+ h" u; R, ^3 K
•        vxlan interface,这种接口每个虚拟网络一个,名字格式为 vxlan-sid,其中 sid 是分段ID。
" ~* O1 T5 ]. r- A' e•        连接虚拟机的 tap 接口% x& `6 z- T* l4 M
•        和 qrouter 连接的 tap 接口- o+ L3 b6 f( Y
•        和该网络的 qdhcp 连接的 tap 接口
2 a1 D# h8 {; H) A1 a& [安全组规则在 tunnel bridge 和 vlan bridge 上。$ f; M6 A* |. Q+ Y, F  J
OVS 方案:
6 b) E4 ]4 H! I5 \7 T4 f 5 \; Y( d! ]+ |. t
这里面,br-int 会负责加本地 VLAN 标签,br-tun 会负责将 VLAN ID 转换为 VXLAN ID。
" A% e  P) G; M; T+ l2 o- @
( u6 j( D/ W$ M& b6 i4.2 计算节点上
5 F, E; F1 ~8 J) e同样来对比着看。
) P2 I* u  d' O6 L! ^' H+ r9 k  mlinux bridge:( o) `% q1 n; I5 _  n0 M6 [

, ]- n" v" S: B- m! s3 t网络服务:/ z8 v' G8 V5 v. a- u
•        Linux bridge agent
. Z# P4 g) Y( x4 o: X* V( x1 V9 P" L和网络节点类似,只不过没有 qrouter 和 qdhcp,不在赘述。# D9 y6 _9 t' y2 S# m
OVS:
! \  e& U2 h. x+ m' |! B4 H
/ H3 K/ u7 p- i; B4 ~: v! _: u 5 R7 t# C7 U8 V
OVS 放在在 br-int 上实现 VLAN 标签,在 br-tun 上实现隧道,在 qbr linux bridge 上实现安全组。7 d9 x  X: p- k* i- }' U

+ P; N! L$ V" d0 s, m3 f4.3 网络路径 - 南北向网络流向
8 T4 c. r1 \0 l" G+ D! p$ @3 }
0 f5 o$ |7 w( z& \9 C5 ]# C% X0 {VLAN 网络和VXLAN 网络井水不犯河水。这图上的配置中,计算节点和网络节点上的物理网卡都分开了。
; E; r. t& y2 n. j! o: c4.4 网络路径 - 东西向(不同网络): j  t3 s5 p: U( e  i

' d  ^/ b) U3 _4.5 网络路径 - 东西向(同一个网络)! G1 K) E% b" m2 U4 a. V1 B4 p( Z
2 s0 ?: t1 b) r
* T  D: B! N8 V- V
请详细说明和配置,请参阅参考文档。
  h! B) b& F3 X' B5. 一点结论. t# D0 W; l1 O/ T. _2 A
和基于 OVS 的二层网络相比,
  }7 |& I# r- n& @: b$ Q•        功能和架构上:基于 linux bridge 的实现还是有一些短处,比如每个虚拟网络就需要一个网桥,这在大规模环境中会带领资源使用和管理上的问题。其好处是本身架构比较清晰。$ n% S8 W4 B. l3 K
•        性能上:基本上差不多,如下图所示,不管是 vxlan 还是 vlan。  z; ?- m2 q7 z! C, W' p
; q, I: T" i. e+ w- x4 R) \+ A" t

, V/ [' W/ H8 t

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-10-28 14:31:20 | 显示全部楼层
一.现状" E5 L; K' v# a& B8 X3 ~
部署节点为一个controller节点(包含网络节点),两个compute节点。controller节点有3个网卡,分别为eth0(管理和API网络,CIDR为192.168.128.0/24)、eth1(租户网络,CIDR为10.10.10.0/24)、eth2(外部网络,CIDR为11.11.11.0/24,不设置IP);compute节点有2个网卡,分别为eth0(管理和API网络,CIDR为192.168.128.0/24)、eth1(租户网络,CIDR为10.10.10.0/24)。
$ L( w6 F' }0 R5 Acontroller节点、compute节点的L2 agent 为 neutron-linuxbridge-agent . ?; P  U0 Z, p6 Z7 u# ]& N

% s& i0 K0 x0 I( A* ^3 P8 d& ?6 L/ {& U, d* i
Neutron网络方案为:
  U8 @- `  c: L* w! w
: |1 M' w7 q8 ANeutron ML2的Type Driver为vxlan
, g2 F  x5 |  S; D3 NNeutron ML2的Mechanism Driver为LinuxBridge& H$ b6 \; J4 b
Neutron L2 Agent为LinuxBridge
7 L$ {9 ]4 j0 d& U5 c. g: V1 y1 H
4 H/ p+ C/ ^- [5 N0 P5 z目前的网络服务信息为: - c5 k. ?2 @( z" h

8 Z* R0 h/ P# H
8 ?9 Q! b7 g" l# x( n二.替换5 @$ ^" s# f. a0 y" V9 d
controller节点、compute节点的L2 agent 替换为 neutron-openvswitch-agent
% x" a8 j7 L2 t! w! W' l3 ]$ O
7 q) f, J( i  ]% [# M4 j% Z, F$ b, l& N5 [6 J1 ~
Neutron网络方案替换为:
0 F# h0 b7 Y% }* p
+ _) z8 A0 Z- t" \/ [& N% PNeutron ML2的Type Driver为vxlan: Z8 D4 J6 Y8 `, H! E3 k
Neutron ML2的Mechanism Driver为Open vSwitch
4 ^' ^  Y. Y0 t. N' NNeutron L2 Agent为Open vSwitch + i) Y  H. ^& _' Y1 A

0 X2 G* g2 T8 I( Q1 L4 m, R& `(1). 删除已有的路由器、虚拟网络。0 e* ~- j+ ~, Y: I+ I: h

) |4 k0 G$ ]8 N8 z% x+ o$ [' s* ?1.当删除网络时,报如下错误
( W; h( R4 b4 u# f# |
" t8 [) w2 X# Y& O7 e$ B- V' `) d2 a! v3 A
查看日志:delete failed (client error): Unable to complete operation on network 02444a0c-47d1-48ef-9de7-a8614a5fd799. There are one or more ports still in use on the network.
1 R0 G+ V- M# k8 |+ [" F1 }表明有实例连接到这个网络,需要解除实例和网络port的绑定,然后再删除网络。9 h$ J3 ?* V, ^5 \

" a. \2 m! L3 k: M) C2 X2.删除外网时,也报类似错误 . Q" D" Q( {& R1 J( P1 x" P/ b
查看日志:Found port (3db7acca-71d4-4715-94d5-47ecc2e42b21, 11.11.11.11) having IP allocation on subnet 558ee6a0-1145-4e9f-9f12-5318b5fd4ac5, cannot delete
- \- x+ t) Q1 _0 Kdelete failed (client error): Unable to complete operation on subnet 558ee6a0-1145-4e9f-9f12-5318b5fd4ac5: One or more ports have an IP allocation from this subnet.
% M1 ~/ b& Y1 r& g3 X需要释放浮动IP,再删除外部网络。
, w, M# O8 K8 X+ g8 Z
( r, I0 Z) J* F, Y. t" m7 {(2). 卸载controller节点、compute1节点、compute2节点的 neutron-linuxbridge-agent
! R; ^8 H+ e: o9 g% f
% F0 H5 @0 n5 X. V' u; I先停止neutron-linuxbridge-agent服务; W5 u2 V. R  w1 B$ v

$ K2 H& b1 P* ~' troot@controller:~# service neutron-linuxbridge-agent stop
9 Z( t( t) x- s& k2 Y/ gneutron-linuxbridge-agent stop/waiting& f" H4 Y; l) q' J. w/ t) m
root@compute1:~# service neutron-linuxbridge-agent stop$ X: {3 i2 s. Q$ F- P
neutron-linuxbridge-agent stop/waiting
9 j! ^7 e/ {8 o/ F8 ]' Xroot@compute2:~# service neutron-linuxbridge-agent stop
1 y  z$ m3 t( {# Bneutron-linuxbridge-agent stop/waiting
" ^. i" z) A7 n7 p8 I0 i$ j- G5 o/ i, I6 D' X
再卸载软件
- ^3 N) Q) S$ `* {' V) J  I6 c: [! y8 t! L$ Y
root@controller:~# apt-get --purge remove neutron-linuxbridge-agent: o% i5 N- h& `8 z5 |0 [( T
root@compute1:~# apt-get --purge remove neutron-linuxbridge-agent
: i, F% B6 N# d2 u; Mroot@compute2:~# apt-get --purge remove neutron-linuxbridge-agent0 c1 ]' L6 R$ D. G' [/ C- B6 V
3 e+ `( e# x. C( D9 e/ k; m, e
(3). 安装controller节点、compute1节点、compute2节点的 neutron-openvswitch-agent
2 s& b7 m) E( r  V% Y; ]% C
  s& k* k- `8 f7 a. }0 Qroot@controller:~# apt-get install neutron-openvswitch-agent3 u$ o# O- I& o8 t1 Y
root@compute1:~# apt-get install neutron-openvswitch-agent
2 t  e- [! D, ^, T% U# ]root@compute2:~# apt-get install neutron-openvswitch-agent6 `! |! L0 K1 A4 W4 L
& c* _- g! z/ A4 C- K9 f. {
(4). 修改配置文件
2 A( l2 g, y7 F* }% O$ dcontroller节点
; G, t) {. Z3 @6 i
' t) W% n+ D9 z& z, D/ a& k/etc/neutron/plugins/ml2/ml2_conf.ini
( G* c0 C6 F/ w9 M; I
9 q! o* J  Y' a[ml2]
/ y( z2 a: N* M3 U: Ptype_drivers = flat,vxlan
, n1 B6 |  t" [% R8 }/ rtenant_network_types = vxlan! {; n7 }+ G. {7 c$ G
mechanism_drivers = openvswitch,l2population* Y7 a3 ?; F3 l- |1 t+ F  _. `
extension_drivers = port_security
* J5 `4 T% S$ _! I- N* t
6 @! b0 A& G& C/ B5 n. z[ml2_type_vxlan]: ]& L, i( m* x/ X  R" e
vni_ranges = 1001:2000
, F  R* X( v, d0 i! F4 r, G$ E
. H: o6 V9 d" J0 S# c$ x[securitygroup]
& ]) f; v! n" c+ s! \. _  |enable_ipset = true. w+ H4 c( \5 w' I" g3 ]
. D1 j. v7 R5 _, s
/etc/neutron/l3_agent.ini8 C3 Q5 Z; c! \5 B: K9 q' m! p
% C* f( L2 a/ V% J
[DEFAULT]" h3 \* \( I. }
external_network_bridge = br-ex
, f# x4 X1 v; j! p7 t& \$ U7 K; j2 S3 Kinterface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
3 y2 S# r- Y3 L; R( D8 W- T1 T3 E# V9 X0 V! B( i1 d
/etc/neutron/dhcp_agent.ini  o2 z; ]. ^% L' w/ {
8 m1 m7 @3 Q2 V
[DEFAULT]% o3 B6 X6 R- P0 d
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver) W' \8 q% g0 c$ a1 z! }* Z( h0 s
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
5 F/ K( e6 i7 A5 K4 h* tenable_isolated_metadata = True% u- I- a- L$ H( T  Z, r

8 q" ~- q4 }4 ~/etc/neutron/plugins/ml2/openvswitch_agent.ini
1 D% B" `. X- q8 N/ F- S6 @7 l" h9 K1 N- G! y( A' W
[ovs]
2 g' R$ `' R4 W+ F1 Dbridge_mappings = , ^+ A: B1 i- i; X  P
tunnel_bridge = br-tun
. n  N4 E# q  ^local_ip = 10.10.10.10
1 n" Z# R0 d+ x% Z& t! y1 j& v# o% V+ ~( y* e, w  V: J
[agent]
- V; o4 y+ @! L2 D) @  B  ]tunnel_types = vxlan
: Z: T8 a' S9 a0 x8 X% J4 K- Il2_population = True3 S- Z$ s2 m" s& N* H& p3 O# V

  N5 x, |! c4 O3 q5 g[securitygroup]
3 W$ ^; Q0 \' m# A# e" N+ P. vfirewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver( Y$ ^/ E4 h1 c9 y
enable_security_group = true" ^" d! m7 K% J. a( j) u, T( u& Z

+ v% g1 j) d6 d$ Bcompute1节点
( O2 X9 M" l- a, D+ t+ |+ ~$ s5 o  {$ _% j8 n
/etc/neutron/plugins/ml2/openvswitch_agent.ini
  T3 i, K! P" R& {/ w% Y" }) ?+ s, k% v1 z" x: O$ c4 ~
[ovs]% n4 m3 v! D) [5 d) A, N' d
bridge_mappings =
# {& F% x- F7 H& T, Htunnel_bridge = br-tun7 Y$ v" b# I) Z+ |5 b2 S& o# y4 S5 U; Y
local_ip = 10.10.10.11
& |' e- l6 R1 @. l. f
0 z/ u: B2 l5 r8 F  Y[agent]- u) R+ D& x$ }0 b1 M0 f; T1 R+ M5 ?
tunnel_types = vxlan* f" N2 N8 r4 n2 U9 N7 X
l2_population = True# W* Y3 a# a7 m! n

/ I( M# }0 Y) H! c1 s% |0 q% y# u+ y[securitygroup]
. q* J+ y, F$ Pfirewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver! K% Z- D) S2 g
enable_security_group = true
$ I% U- L$ q$ _8 u6 e7 ]- h% o7 q' ]. ]$ y
compute2节点" N9 c: D. B' J/ M# _

$ l- S/ c  g$ ^9 h# Z, x[ovs]
' O6 n) {8 j0 F$ ybridge_mappings = # K9 B3 B( _1 p# h/ [
tunnel_bridge = br-tun
4 Z: s" }, W% _1 D1 ilocal_ip = 10.10.10.12* P) g$ t* R- V3 k

/ s& U7 H( H" l  ~3 o' `1 @* {[agent]
" K3 f* }, \6 u1 Y+ K" Ctunnel_types = vxlan
2 s! z+ H, I2 o: I# Y; H" ~l2_population = True8 V  L4 {; e0 [
0 F1 Y9 s- p9 a- M& i8 C
[securitygroup]. I% V0 ^+ `5 O( ]0 S
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver0 P+ @6 i: S* x$ p5 K% W" u( q2 ^2 \
enable_security_group = true6 U* i* G( e& j+ e, G5 h& l$ {; x

3 h" k9 A, J. x- e1 x9 a( @重启网络相关服务。) Y" g9 K9 ~5 Z; C4 ~

  G) a; P5 n0 y4 o. J# l( B再次查看网络服务信息 . _1 ?5 F( I  Z! ^( q1 \! z" \

, Z: d8 q- o- j' S! I
2 u4 _& R( f! j/ Z* t1 A% r把已关闭的 neutron-linuxbridge-agent 删除; X! ~7 P  v  E

4 y( A& C3 {0 E/ Jroot@controller:~# neutron agent-list) L5 L+ D' G+ \
+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+/ B) p) [/ N8 S5 k3 B3 e
| id                                   | agent_type         | host       | availability_zone | alive | admin_state_up | binary                    |* F, U* O4 k6 h0 Z& {! s& f. ^
+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
( J: f, J+ K6 t- W7 I7 E8 r0 X" ?| 21af963d-003d-455e-8723-8b78d201a684 | L3 agent           | controller | nova              | :-)   | True           | neutron-l3-agent          |
0 ~! T8 j! F5 q2 x9 ]* U/ d, || 25229052-f0cb-4f04-b819-375fc55c510f | Linux bridge agent | controller |                   | xxx   | True           | neutron-linuxbridge-agent |( j9 K9 j2 g7 Z
| 80607c88-5c98-4491-839d-0ce715ec3e4d | Open vSwitch agent | compute2   |                   | :-)   | True           | neutron-openvswitch-agent |
/ R- v3 ^0 y" N) J0 W| aab52c21-8c14-4568-89c6-20e70400da38 | Open vSwitch agent | compute1   |                   | :-)   | True           | neutron-openvswitch-agent |/ _, }0 ~3 e5 A  X/ h
| d51f6d6c-eda0-4179-9fce-f9c24ef20824 | DHCP agent         | controller | nova              | :-)   | True           | neutron-dhcp-agent        |/ B; F" `7 g, ?6 i) u
| d666c263-ba6d-4f09-a09d-72c214787e08 | Loadbalancer agent | controller |                   | :-)   | True           | neutron-lbaas-agent       |7 ]4 Q. e( h# H/ o/ z
| e17d1ecf-35d2-49f5-a7c9-206b0c9e2ce4 | Linux bridge agent | compute2   |                   | xxx   | True           | neutron-linuxbridge-agent |
" Q" C4 t- L4 F3 \| e26dc52e-7827-463b-8ee7-202a19d5c3dc | Metadata agent     | controller |                   | :-)   | True           | neutron-metadata-agent    |& t! U/ }  G" T/ b& i7 {1 Z, x
| fba23722-9439-4289-bd17-5b69c43f88da | Linux bridge agent | compute1   |                   | xxx   | True           | neutron-linuxbridge-agent |+ i! }/ j" p3 I7 U
| fe4a9cf3-9a08-4837-b74f-787118ce57db | Open vSwitch agent | controller |                   | :-)   | True           | neutron-openvswitch-agent |
( p& m: J) h1 g2 n$ r5 f+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
. l0 t  S3 X4 u, E1 n# S3 N
# d9 B- A: c  h" m; t( D- Broot@controller:~# neutron agent-delete 25229052-f0cb-4f04-b819-375fc55c510f; E: c* e  P& b1 }; D
Deleted agent: 25229052-f0cb-4f04-b819-375fc55c510f! b, L8 U# H: n" \
root@controller:~# neutron agent-delete e17d1ecf-35d2-49f5-a7c9-206b0c9e2ce4
' e/ W+ n" x5 j2 s2 \Deleted agent: e17d1ecf-35d2-49f5-a7c9-206b0c9e2ce45 I, e! `" u3 _, U
root@controller:~# neutron agent-delete fba23722-9439-4289-bd17-5b69c43f88da
: X0 l* b" P* ]$ EDeleted agent: fba23722-9439-4289-bd17-5b69c43f88da
& k5 W/ u6 J) y: x6 U7 E0 n' O: ]3 U- @% g* I+ J+ N8 f
再次查看网络服务信息,已经没有linuxbridge的agent了
" h6 L$ d* i4 B% `2 W2 R6 [) i. r2 S7 m8 r( G3 }
) x- \3 J& f' w1 l& U4 f+ C
三.验证8 s0 R4 a6 K+ v; z- `) N. W1 \
验证修改是否成功。   x+ u5 H# D% o: x
先创建一个vxlan100网络 " h% \3 x  {. F& H, ^, g  Z

4 m7 i8 V# Q6 ?0 X1 F( \# A1 v- Y
6 t" t/ S( ]- A, h把已有虚拟机test1、test2和vxlan100网络关联起来
+ i  X1 I( N1 Y/ t* m
* s& l$ g# S" }! ^
2 p) m& {" y) ]/ o1 T0 s0 F6 rtest1、test2重启,然后查看是否获取IP地址 / W% R& R5 x, m( v4 P6 {& U$ V
再互ping . C; s0 E: p# D( N8 U$ `7 U
; }. u6 E) Z3 f% `3 h( T4 w

( O! m5 D) i1 r7 E7 a至此,L2 agent替换并验证成功!) F0 s$ N5 O3 t( w6 A

7 e' M/ P7 ?* K" b6 Y0 ^( b
2 h! |' e# l* s( a————————————————* b* p% L; V7 J6 G1 j2 }1 c6 s7 m

2 Q9 X. ?8 x+ @+ Q+ w: e* |( u  w
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 03:27 , Processed in 0.055048 second(s), 32 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表