易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 4397|回复: 3
收起左侧

Neutron Linux Bridge + VLAN/VXLAN 虚拟网络

[复制链接]
发表于 2019-10-25 11:00:14 | 显示全部楼层 |阅读模式
购买主题 本主题需向作者支付 2 金钱 才能浏览
 楼主| 发表于 2019-10-25 11:22:20 | 显示全部楼层
修改配置文件 # ~! O1 ^. J8 m, l9 o% {
controller节点+ P+ w1 K2 f4 h' @3 {' D* V1 d6 V
3 W  Z, f# Y( Q# I
/etc/neutron/plugins/ml2/ml2_conf.ini* m$ U6 a- |2 B
, T8 L4 R- k0 k, q  M2 e! n
[ml2]4 @$ R; {, a" `0 g* j# Z% s3 c
type_drivers = flat,vxlan  ?8 u" n8 Z' }* e! P. a& f
tenant_network_types = vxlan8 u) Q+ a+ }5 ?* G' {7 Z
mechanism_drivers = openvswitch,l2population( D7 D5 F6 h  ]
extension_drivers = port_security
) x) T# `$ @  K) H2 y$ Q6 i5 t/ @4 \( t( O8 a0 _
[ml2_type_vxlan]
& Y0 b6 |2 i& j) ~' W( Evni_ranges = 1001:2000
1 p& }. L7 s! V
& U6 U# I  g. N# E+ x[securitygroup]7 Z4 T# P. e( t- x
enable_ipset = true2 H  v+ l+ `3 k$ @/ q. L% v
6 i+ Y2 q' \$ g2 _, e4 N( ^
/etc/neutron/l3_agent.ini; T! Y8 ~, M+ R: T
" m1 a. J6 W2 K6 c8 a/ \
[DEFAULT]
- F1 R. Y) z$ n3 H2 {3 ~" texternal_network_bridge = br-ex
5 s- e& ~- P7 @interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver  g- ~; A; K* O* U- `
! B# |$ d3 X, ^2 _
/etc/neutron/dhcp_agent.ini
* O2 J0 j$ p* D" ^5 R4 x
; r) ]9 @+ M6 p+ g2 N: `[DEFAULT]. z7 n" K) o2 h) D/ v* \
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver5 D% `! d% o' C, \$ a: R
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
% L4 s6 N! d4 N3 h7 Q# zenable_isolated_metadata = True0 c% u  W. u' ]( ]; x
9 e8 G  n" K) d
/etc/neutron/plugins/ml2/openvswitch_agent.ini3 V& p' l" ?1 Q: V, {' a5 v2 ^

9 p% h) w  G% C7 P+ p# ^5 }[ovs]
0 f; T" V  a) @% Tbridge_mappings =
3 W1 l: {* g& e0 P6 htunnel_bridge = br-tun
  j; B4 Z7 n+ T  Q4 O  A( @' clocal_ip = 10.10.10.10! R3 u. g0 h) ^7 L; \) Y2 F/ U

  F0 M% y: f$ `[agent]
6 S: L  h/ ]8 r- R/ Otunnel_types = vxlan
& c: e: W( M' k# C4 C/ sl2_population = True! d1 i% S+ p; m7 e
$ q/ v# W$ ^+ u# O+ X/ D
[securitygroup]  D7 A9 p3 n1 X
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver( r- T. D* |: T- z
enable_security_group = true: u5 `. f& m% O

" h0 C0 C+ [( l* h# B! y$ \2 d6 R% h' x$ A1 hcompute1节点
0 N6 x' ]: C9 [5 c( b- \3 x  v7 T# U# X' n7 Y; C# N9 `- o5 J& F
/etc/neutron/plugins/ml2/openvswitch_agent.ini7 Z( T2 u" }. T9 U3 {- z) [/ u7 O
: _1 b' y9 Q( W" Z
[ovs]- K6 t/ I' |" e! o3 G, s' s7 ]0 X
bridge_mappings =
8 j- W! G+ [6 R; Etunnel_bridge = br-tun1 T* F$ h- v- g5 Q9 Y, K: y
local_ip = 10.10.10.11
; t& U# _- E2 l+ m! d+ p/ P! R& e- H. _8 B1 ]. t
[agent]
" X, ~3 y. [; ?+ `0 ytunnel_types = vxlan: y4 P; d7 ^# e1 j3 x2 Z3 u1 j
l2_population = True6 H- v/ I+ A& w9 d- B& k: m8 U
- D8 s0 B/ C* J! Q/ W
[securitygroup]7 F+ d! ]$ Y5 `  ?
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver# ?& k9 ~' e! `8 F* W4 a
enable_security_group = true5 w: }  N1 d% s, s& i

) B& r9 U+ f- w+ v4 V: }, S& Hcompute2节点
0 y$ q9 m1 D4 V! ^0 s' H- \& }: h. |2 F8 U% p% x
[ovs]; V" U- c6 n$ k6 Q3 a
bridge_mappings = + \9 G( P8 A8 k( x1 s6 _1 t
tunnel_bridge = br-tun
4 d0 e5 G% O3 m4 e% B/ h9 Flocal_ip = 10.10.10.12+ r. |8 H5 A% c* O1 u+ ^0 D2 z
. k0 }+ u6 w  h7 P
[agent]
" Y5 p2 K$ a. m7 ~$ }  k. rtunnel_types = vxlan4 \8 G' A; L7 {; @) p1 S' S1 Q- O$ k& z
l2_population = True
4 k  p- S0 z6 x3 I% u0 N1 x, J( n; E- L# \* @
[securitygroup]% ?2 [2 d6 G* ?
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver2 @+ @. ?- L4 B5 J
enable_security_group = true& ^, o/ F9 M. ~* X+ k& D

8 ?# w, u" N9 {) i- i! h重启网络相关服务。2 W" G& W7 l6 F  C3 {% b( y
0 g* h" `2 g: w. L
再次查看网络服务信息
" e( j/ D; ~+ j4 s" M4 u————————————————' ^: b; ]/ u3 P% r& F' g4 N
 楼主| 发表于 2019-10-25 11:23:29 | 显示全部楼层
虽然大部分的OpenStack 部署环境中,都会使用 Open vSwitch 来作为虚拟交换机来实现二层网络功能,但是Neutron 仍然支持使用 Linux bridge 作为虚拟交换机来实现二层网络。本文就此做些分析和说明。
( \( g; c8 [/ W. N: s2 V. c) p同时要指出的是,OpenStack 官方已经把 linux bridge 实现标记为 legacy 的了,文档从 2016 年后也没怎么更新了。这是因为,linux bridge 和 OVS 相比,只支持基本的网络功能即二层交换,但不支持VLAN 标签和隧道。因此,linux bridge agent 利用linux 内核功能(VLAN 子接口和 VXLAN 接口)来实现VLAN 标签和隧道。3 b  G! x/ P/ d& M# d

, T8 ]9 C# M. }. I4 A! q' E3 i 1. 测试环境
+ O- M& w3 k" P% X6 y8 G4 Y以下面的环境为例(网络节点上):
+ N. L/ {0 V" w* ?( y( u: ~4 T(1)linux bridge
! ]# d0 P9 j. E' {9 h% [' j: N 6 l; j# _( X' s4 P$ A6 c
root@controller:/home/sammy# brctl show- y. A5 E& E6 u1 a
bridge name     bridge id               STP enabled     interfaces1 s! X  O5 a- o* F7 t; g: t
brq85925305-b4          8000.563534c8d02d       no              tap0bb8efeb-10
" }( q9 {" l3 \: G5 R                                                        tap798c87d1-a2* H7 ~1 t1 T% u; q# J9 j4 L4 W) l
                                                        vxlan-25
( Z/ m- C/ m8 B8 Wbrq96609bfa-0e          8000.0050569c4d94       no              ens224
5 X% J; p/ M% G, H; ^                                                        tap60dbdc2f-a0
; u; x- J% Y" m, P* t" dbrq971ffda2-e5          8000.a6acb08e4fd6       no              tapb1eaae00-e5
* i* V& x1 |3 d                                                        tapf70543dd-0f* l7 m6 W. m# q" f
                                                        vxlan-10
9 T: h2 C2 Q0 w. a) R
, [  u3 \! }6 W4 w4 f* ?1 ?(2)OpenStack 网络和 network namespace:
1 i' N; N7 ?/ ]: A. j$ H
+ S0 ~, M, `0 Q1 yroot@controller:/home/sammy# neutron net-list
- ^' x* C6 x( _: E  X6 M+--------------------------------------+---------+-----------------------------------------------------+! ^. [; t4 L; o7 h9 S" \+ Z! `
| id                                   | name    | subnets                                             |8 e% B$ T9 C: N
+--------------------------------------+---------+-----------------------------------------------------+
: Y% T: d8 H9 e. V6 ~; a1 O6 S! Q8 N| 96609bfa-0e22-4bb7-8dba-6ef532ea6076 | extnet  | afa7d205-3026-439f-aca7-295a9f9b2a71 10.62.227.0/24 |
* G7 R2 p3 F- _+ f| 971ffda2-e567-40a0-a2c8-b31a577fd4d3 | appnet  | 4c68eacb-bf3e-408a-a941-94e93eddb22b 11.0.0.0/24    |0 C) ?. K2 j9 A
|                                      |         | 3d596991-de8f-4ae4-8913-89426a8abbd7 10.0.0.0/24    |6 b  _4 a& k( z7 f, m
| 85925305-b477-4cc6-9654-67d9bf1e7cd8 | appnet2 | 4575c7f1-7f08-4917-9904-ec65af38619b 20.0.0.0/24    |
/ ]2 z$ C3 h7 G2 ^1 a5 n/ b, [+--------------------------------------+---------+-----------------------------------------------------+
- I( T8 ], L) i+ groot@controller:/home/sammy# ip netns
( V, @  E& H5 Eqdhcp-85925305-b477-4cc6-9654-67d9bf1e7cd8 (id: 2)8 o+ Z7 H/ S: G% r
qdhcp-971ffda2-e567-40a0-a2c8-b31a577fd4d3 (id: 1)
& u/ Y9 N/ P" p" u8 Aqrouter-39a77439-8a28-49c1-bf97-ac931510631b (id: 0)4 y6 b6 x+ r0 E% Z& [3 d8 c# P

& |' w0 Z- V6 W* ?+ @(3)示意图:
7 Y! x- ^$ I: W/ Y1 c
) X* e& i* f( @- s9 W(4)说明:
! W) N9 a2 C% n# h4 g•        qdhcp 和 qrouter 都是 linux network namespace 实例
% U1 m4 ^$ s0 B: m" L$ W7 K•        qdhcp network namespace 的数量等于启用了 DHCP 的 Neutron network 的数量。' d6 W' v7 A* q$ w4 |
o        当一个 network 中存在至少一个 subnet 启用了 DHCP 之后,会有一个 qdhcp network namespace 被创建出来;
" C' }* ]# L4 {, h: y, Y2 s% \o        当一个 network 中多个 subnet 启用了 DHCP 时,它们共用一个 qdhcp,以及 dnsmasq。
  `  b- c& n5 O  f# C5 [, K' D$ ko        其 name 使用 network id,比如 qdhcp-85925305-b477-4cc6-9654-67d9bf1e7cd8  K! w- ^( b: n' q: }$ x
•        qrouter network namespace 的数目等于 router 的数目,也就是说,系统中一共有几个 router,那么就存在几个 qrouter network namespace
: q8 c3 f8 k9 o8 ~% n- o•        brq linux bridge 的数目等于 neutron network 的数目,其 name 是 network id 的前几位,比如 brq96609bfa-0e$ z3 ^) L3 O6 J* ]. t- n
•        一个 network 的 qdhcp network namespace 和其 brq linux bridge 一定有连接# B' b& ]' ?' v
•        qrouter 之内的 network interface 分两种,一种是 qr 开头的,每个连接到 router 之上的 subnet 都有一个;还有一个是 qg,每个连接到 router 的 external subnetwork 有一个( W6 N! U" G( N! o/ J
•        qrouter 的每个 network interface 都通过 veth 连接到所在网络的 qbr linux bridge 上
$ c: e0 X/ M, w•        qbr linux bridge 连连接两种物理设备,一种是 vxlan interface,每个 tenant network 有一个,另一种是在 physical network 对应的物理网卡上创建的子接口(sub-interface)
' s" j# k* f) ~- ]: d; N' G•        对于 physical network 的 qbr 来说,用户可以指定它,并且在linuxbridge_agent.ini 中通过 bridge_mappings = List of <physical_network>:<physical_bridge> 进行配置;也可以不指定,此时 agent 会创建它。当同时配置了 physical bridge 和 physical interface 时,前者优先。' J+ \8 g2 @: R/ ?! o, E9 n
如果 external network 中有多个 subnet 的话:
, T1 |+ F# E8 S: [& L: z(1)每个 qrouter 只允许有一个 External Gateway,也就是说它只有一个 qg network interface。当 external network 添加多个 subnet 之后,只有第一个被当作 external subnet,其余的都会被当作 internal subnet。4 J" a# Q% z# Q' V' l8 r
(2)在 qrouter 的路由表之中,
' Q0 a+ ^" M4 J: C0 \
( H# z% |: B9 U  W# V, _4 b* d! L7 L; {root@controller:/home/sammy# ip netns exec qrouter-39a77439-8a28-49c1-bf97-ac931510631b route1 \  f9 I: n9 R) c  @) n* O
Kernel IP routing table
- _% g# h/ B+ u" j; S7 Y+ W# WDestination     Gateway         Genmask         Flags Metric Ref    Use Iface6 y% |7 Z% |% e" B
default         10.62.227.1     0.0.0.0         UG    0      0        0 qg-e09fce07-cd0 J+ j! ]; [) \5 M8 [+ B3 h
10.0.0.0        *               255.255.255.0   U     0      0        0 qr-b1eaae00-e5
) p  X; K  ^7 E0 d: }10.62.227.0     *               255.255.255.0   U     0      0        0 qg-e09fce07-cd4 o  |' O7 P# r" Q4 D0 F
10.62.228.0     *               255.255.255.0   U     0      0        0 qg-e09fce07-cd
1 U0 O* d' Y7 S10.62.228.0     *               255.255.255.0   U     0      0        0 qr-124ff148-b7
- v9 p. c; b9 w. C11.0.0.0        *               255.255.255.0   U     0      0        0 qr-16d9b0cc-38; e) ~2 C7 @6 m( W5 o  B2 u" y5 C5 M
20.0.0.0        *               255.255.255.0   U     0      0        0 qr-0bb8efeb-10
- R+ e& w3 D- O# c2 P
/ W) |8 S( h4 D  C  P) w  G
6 q5 K! q8 X( s3 \2. linux-bridge-agent 工作过程分析" }% t# L9 }( U  P) @; s4 g& M, o  n
(1)linuxbridge-agent 会启动一个循环,不断扫描上面红框中的 tap 设备  M% L" @3 u1 {

  @& e3 R& B) H  z( i9 t, q) v    def daemon_loop(self):
3 E. }" v' _% {0 u' O1 u..., P1 Y" d# B7 J8 ]( l1 y! h
        while True:
4 M! Q+ z# b0 d& h. x            start = time.time()
: x' q4 b2 P( k' |8 Q. .., u3 M7 D! g$ Q8 P9 f
/ k  b$ c! t8 i* }3 [' N
            device_info = self.scan_devices(previous=device_info, sync=sync). m2 `7 |2 t% O5 x$ e3 S% a4 v8 z
            sync = False
. z, m  ^' B3 y5 m! r! f  o& r# J5 H: U' y/ Y
            if (self._device_info_has_changes(device_info)
  u) R; b* I, o3 K& }                or self.sg_agent.firewall_refresh_needed()):( y9 L3 t' r, g  \
                LOG.debug("Agent loop found changes! %s", device_info)
. n. C) q, w5 B# V                try:# t- g) B: X5 ]% O
                    sync = self.process_network_devices(device_info)5 j2 h4 y$ J# ?" l4 {5 F
                except Exception:8 c7 N1 q' X9 m9 |9 [) O0 P8 I
                    LOG.exception(_LE("Error in agent loop. Devices info: %s"),' b& S+ m; H' Z9 \
                                  device_info)7 l. H2 v" P) B* b2 y6 R/ o2 v
                    sync = True- y3 E. M7 \9 p2 L$ A* g) }
# x% _9 L3 V" o: ]
这是它首先找到的 devices:0 D9 W0 ^8 b. t9 ^4 C& \3 E$ |
(Pdb) p bridge_lib.get_bridge_names()
; H! n8 |! L/ g' N0 r['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']3 U" P% r: E  H* D" o
然后过滤出 tap 设备:
2 E) w) g. L4 y/ ?& C  o8 Oget_all_devices()->set(['tap0bb8efeb-10', 'tap60dbdc2f-a0', 'tap795e6e86-94', 'tap798c87d1-a2', 'tapb1eaae00-e5', 'tapf70543dd-0f'])
' }3 @+ {2 V% f2 H$ j(2)根据 previous 中保存的历史数据,再接合服务器端和本地更新时间,计算出需要更新的tap设备列表:+ }! {. ^1 n5 {9 x8 ?  i  H1 C7 A! X
{'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([])}
+ r% U' f' g# K* m- ]" j& L: \% W2 K  (3) 通过 RPC 获取 tap 设备的详细信息
$ U+ X7 ^5 x+ A" t1 x) L
( y7 V& I5 o1 m( i(Pdb) p devices
! s: a& l/ Y4 ~6 g: Lset(['tapf70543dd-0f', 'tap60dbdc2f-a0', 'tapb1eaae00-e5', 'tap795e6e86-94', 'tap798c87d1-a2', 'tap0bb8efeb-10'])
$ [0 Z1 T( V; ~, Y0 E) \' u/ u
/ V+ U3 U7 L9 w7 h6 b+ _  B' R5 q' j2 |5 g
devices_details_list = self.plugin_rpc.get_devices_details_list  T+ H. s, Z2 B& b+ V5 F( b( n

( \( V$ m4 Z0 ~; m; J8 p(Pdb) p devices_details_list1 T, w+ l+ |, k7 D, G
[{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': []}]. j1 p; r# C/ o( K' {% R
$ w7 b' ^+ @; x8 h( S4 r
(4) 对需要处理的设备,调用 self.process_network_devices(device_info) 函数进行处理2 d1 S; d5 s! s4 B8 Q
(5). 调用 plug_interface
; [' Z. W7 k1 C3 Q% g$ dinterface_plugged = self.mgr.plug_interface(network_id, segment,device, device_details['device_owner'])
3 D. a1 l3 z( p3 V6 |7 H4 ](6). 需要的话,使用已经配置的或者新建 linux brige,并将 physical interface 设备加入其中  p. v% P2 j6 p, o
bridge_name = self.get_existing_bridge_name(physical_network) #获取为 physical network 配置的 linux bridge' G! W  v' @/ w9 g2 x8 y
bridge_name = self.get_bridge_name(network_id) #或者根据 network id 生成 bridge name
1 c1 Z: o' e; u5 g! J$ U(7).根据不同的网络类型,分别处理 vxlan bridge,flat bridge 和 vlan bridge
5 x: b4 I. E5 }) @( Z
! ~4 s! \6 }, F) V. Z+ ]7 J    def ensure_physical_in_bridge(self, network_id,& V# s- d& V6 @$ i
                                  network_type,
: G; `/ I5 b! P+ ?9 Q                                  physical_network,* L$ D3 Y, {9 _4 E- n: \
                                  segmentation_id):
) A' k1 L8 c7 `0 ]: y        if network_type == p_const.TYPE_VXLAN:8 ^8 v: o9 M; _, p0 b
            if self.vxlan_mode == lconst.VXLAN_NONE:" w5 L5 g7 A* z/ e; t  F
                LOG.error(_LE("Unable to add vxlan interface for network %s"),
3 y: h% D  m& G2 I0 J( i                          network_id)( x" N- z' F8 D1 v8 g# {
                return
7 f5 x& Y5 _& d! O5 _# W            return self.ensure_vxlan_bridge(network_id, segmentation_id)
( a" Y4 r3 z+ |& Y! ?7 D! f; w0 g3 P4 C8 E: y  R/ P
        # NOTE(nick-ma-z): Obtain mappings of physical bridge and interfaces' d) y- L( R4 }2 S
        physical_bridge = self.get_existing_bridge_name(physical_network)% p3 D! m& h6 N; N. j& E, q
        physical_interface = self.interface_mappings.get(physical_network)2 K5 O# W0 m9 O; k! O/ h
        if not physical_bridge and not physical_interface:0 H/ t6 b  E6 [! z: M8 h
            LOG.error(_LE("No bridge or interface mappings"
6 w" S" @) Y- e8 c9 n  J% h                          " for physical network %s"),
) e' t) D* T* {4 d7 D3 Q                      physical_network)5 f' G# i" ]3 S  y. O  O
            return; V. Z; I2 \; V1 D
        if network_type == p_const.TYPE_FLAT:& \5 u8 {, A7 f" a; H- p+ b
            return self.ensure_flat_bridge(network_id, physical_bridge,& I) l9 T# j, L! T
                                           physical_interface)
4 [! G& o. O* }: B4 O4 Z        elif network_type == p_const.TYPE_VLAN:
4 X% g/ L4 ^" X' S0 W9 N& Z            return self.ensure_vlan_bridge(network_id, physical_bridge,1 B9 M/ `& W: S2 y! D8 p( g
                                           physical_interface,
, G) I/ M/ q8 G                                           segmentation_id)
0 `- H7 F+ D* a - K' D5 J* C: }7 _8 ^
对于 flat 类型的网络,调用 ensure_physical_in_bridge
" c# J5 z2 d' [def ensure_physical_in_bridge(self, network_id,network_type,physical_network,segmentation_id)6 N1 ]& |8 ?& A+ h; g9 Q4 `6 p
  if network_type == p_const.TYPE_FLAT:
) G7 g: z- N) C5 C    return self.ensure_flat_bridge(network_id, physical_bridge,physical_interface)
+ x. o4 o1 L' n* P+ r2 S& y. K* n如果有配置 physical bridge 的话,使用它;否则创建 bridge,并将物理网卡配置的 ip 地址和 gateway 从网卡挪到 linux bridge% k! F: @8 U* _
( n( a3 r% p7 P$ A, I/ F: b1 u
def ensure_flat_bridge(self, network_id, phy_bridge_name,physical_interface):1 m: Z; D! x# b, q
  """Create a non-vlan bridge unless it already exists."""
5 G/ f, v" W1 R9 E/ P  if phy_bridge_name:; n$ ?! ]; f' q8 [* {
    return self.ensure_bridge(phy_bridge_name) #获取预先配置好的 linux bridge! Y1 M4 |" z0 ]7 V1 |0 L
  else:
2 V) o# t) g* ?7 M! E% f7 m    bridge_name = self.get_bridge_name(network_id)
- V9 O* d- U: T) n, W0 Z2 V    ips, gateway = self.get_interface_details(physical_interface)$ f. f4 ?. k; h* h9 N& u
    if self.ensure_bridge(bridge_name, physical_interface, ips,gateway): #创建 bridge( n: Q/ F: _6 |/ }8 Z. A. i. n8 U
    return physical_interface3 H; d! c0 t+ ^3 r+ y  _7 f3 s; \
+ e* C5 a$ E* Y6 i2 a3 [& g& |
对于 vxlan 类型的 network,需要创建 vxlan interface2 k+ v: m1 ~$ ^- w' g. m
% [9 ]. F+ F3 S3 d* e
    def ensure_vxlan_bridge(self, network_id, segmentation_id):) c6 r# t7 Q5 w, t
        """Create a vxlan and bridge unless they already exist."""
3 L6 D0 F; ]8 T! n4 M        interface = self.ensure_vxlan(segmentation_id)7 A2 k2 ~, S4 m$ Q) p
        if not interface:' L( r' G1 K& o. x
            LOG.error(_LE("Failed creating vxlan interface for "
0 @0 D# ]$ [& b/ c0 ]/ f                          "%(segmentation_id)s"),
8 G9 T. n" w: A$ D                      {segmentation_id: segmentation_id})
* T( m( o4 Z% `' v, A! l% L" b$ i0 |            return' }& C. E$ I# F
        bridge_name = self.get_bridge_name(network_id)' B+ L! o; H+ i+ h
        self.ensure_bridge(bridge_name, interface)5 l+ ~  p. P* g) k1 R
        return interface
) B" i! j5 Y9 E+ a" ^1 l! @+ B
4 X4 i0 N! K# [6 y' ]创建 vxlan interface:# A0 ]3 s6 t; J, p

. c! p9 w: T$ d& b- G" e$ r1 m    def ensure_vxlan(self, segmentation_id):
, e( B) F& @0 ^) l        """Create a vxlan unless it already exists.""") C. X7 c+ j) w" B
        interface = self.get_vxlan_device_name(segmentation_id)
, @; U; c' N& i/ S* e        if not ip_lib.device_exists(interface):, n$ y; S" A2 d  g
            LOG.debug("Creating vxlan interface %(interface)s for "+ U6 @/ `6 a$ L/ p# u6 B
                      "VNI %(segmentation_id)s",  G/ u5 |! z% @6 N& O8 S  ~
                      {'interface': interface,
& F8 z, c8 X, b) `0 U                       'segmentation_id': segmentation_id})
$ w: T% |  c1 j3 U            args = {'dev': self.local_int}
/ o9 j; F; h8 b& Z0 q0 m) M            if self.vxlan_mode == lconst.VXLAN_MCAST:1 t' f. H4 N1 S8 w4 K. ^; Y
                args['group'] = self.get_vxlan_group(segmentation_id)3 E. `6 Y4 J& B. Q3 I( q
            if cfg.CONF.VXLAN.ttl:
2 V) m0 u- V- Q+ E) t; f5 ?                args['ttl'] = cfg.CONF.VXLAN.ttl& t1 x& H  Y: G" r  }0 \; C
            if cfg.CONF.VXLAN.tos:
4 M$ W' l. M: z+ a* p' b9 ?  j                args['tos'] = cfg.CONF.VXLAN.tos# g' N0 K# r8 E: d
            if cfg.CONF.VXLAN.l2_population:
% x& i2 h1 {3 ?" a; a; w- Z4 N: S) u                args['proxy'] = cfg.CONF.VXLAN.arp_responder: I# ^# M7 }6 `- q4 Y8 f8 S
            try:
& U" n4 g9 k+ X! E% d, c# ]: V6 m                int_vxlan = self.ip.add_vxlan(interface, segmentation_id,4 S$ j2 e4 Y* a$ a; _
                                              **args), n9 y2 r$ x) u/ _6 @

- w# U7 v, E) q4 `6 p# ?% W; Z& Y(8). 将 tap 设备加入到 linux bridge 中! o4 l  t- i& F
bridge_lib.BridgeDevice(bridge_name).addif(tap_device_name)% @* b8 y0 q# u8 o
(9). 如果将一个 tap 设备被删除,那么 linux-bridge-agent 会发现:; x- l+ v* r' f5 D5 y$ N
2016-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'])
/ l& Y6 k3 ?& F; o' n& U# K( w2016-10-26 10:29:58.433 30219 INFO neutron.plugins.ml2.drivers.agent._common_agent [req-e3264065-6414-4b5a-8d2b-dfafad6fdde8 - - - - -] Attachment tap60dbdc2f-a0 removed2 y- a6 t& U+ w: L. X0 y0 G
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.
4 U4 r1 e% D$ m, |2 j3. 关于上述工作过程的简单结论. ?* P( K, b/ O# ]( S: q, X
3.1 简单结论3 R' Y0 g& Y3 t; k8 F/ E
1.        l3agent 和 dhcpagent 创建 network namespace 时创建 tap 设备,和 network namespace 中的 interface 是一对 veth pair。当手工删除 tap 设备时,相应的 veth endpoint 也会被删除。; e  c! Y  q: v# g# g* a
2.        linuxbridgeagent 不断扫描服务器端和本地的 tap 设备& v5 f2 S+ c8 \  P% K: K
3.        linuxbridgeagent 获取需要增加和修改的tap设备列表
* |1 x1 Y( I6 U: m4.        对于需要增加的 tap 设备,获取其详细信息,主要是 network_id,network_type,physical_network,segmentation_id,device_owner 等,然后根据这些信息,创建 linux bridge,并加入所需要的 interface
- V- I, T# }8 m. y5 _5 m; `5.        创建所需要的 linux bridge,并将 physical interface (provider network 的 physical interface 或者 tenant network 的 vxlan interface)加入 bridge,并且将 tap 设备也加入该 bridge2 S' t/ i; n$ z- P! A6 K
6.        如果发现某个 linux bridge 没有创建出来,首先需要查看有没有相应的 tap 设备存在;如果 tap 设备不存在,则查看相应的 qdhcp 或者 qrouter 中时候有interface
2 U  F& K. K$ h7 R% O
& s. W9 N9 b7 H) ]具有多个 VLAN 租户网络时候的网络元素示意图:' M* j$ @& x" r. I. g. |
3 y- |# k* E  {7 x9 Z4 j: z
. e6 T% k4 A3 g
9 e; P- F/ L+ O( R
4 `+ j7 V8 U2 b# C9 S* c2 `' z) g
3.2 关于 unnumber interface# ]- U8 V( J  m
OpenStack 官方的 host networking 配置中,连接外网的 interface 可以是 unnumbered 的,从字面意思理解,就是该 interface 上不需要配置 IP 地址。0 Z, S# k6 [$ p3 C
& j- @7 v3 \# ]5 b1 `8 B2 P
配置的时候,修改 /etc/network/interfaces:. ~- A& ~8 {" p& \; ?% P& U5 ?
# The provider network interface
8 I$ e, _: ^2 u# x# v% A" vauto ens2249 E; b2 C4 Y; M% B3 @
iface ens224 inet manual
1 E/ K0 O6 j  z. q  hup ip link set dev $IFACE up- w6 I" t9 f0 M5 g
down ip link set dev $IFACE down" u. ~( y0 h6 _- u
配置好以后:" N, a  I5 p) R& J
' Y& S+ k% Q- _  j; f: ^
root@controller:/home/sammy# ifconfig ens224
! x3 C$ X$ c' U$ c7 Q/ y# C+ Iens224    Link encap:Ethernet  HWaddr 00:50:56:9c:4d:94
4 G9 m) |0 F# K5 m5 k2 h$ A          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
9 L; ?* K$ L$ ^3 l/ X1 a# g          RX packets:27300737 errors:0 dropped:0 overruns:0 frame:06 _% e% p# T: v0 N
          TX packets:61547 errors:0 dropped:0 overruns:0 carrier:0" I8 g1 G0 N' Z5 Y! ~# y1 }
          collisions:0 txqueuelen:1000* |) d! K2 E  u# \. x
          RX bytes:31951077598 (31.9 GB)  TX bytes:5966060 (5.9 MB)# T: b: V$ ^. x4 L1 X) Y
' \* m+ w& W- M3 P! f9 a0 D" z
root@controller:/home/sammy# ifconfig brq96609bfa-0e0 l4 ~  z8 z2 i
brq96609bfa-0e Link encap:Ethernet  HWaddr 00:50:56:9c:4d:94
- i) C# Q- r- J6 L9 }          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1/ S% l' L/ ?7 U% k5 i1 }
          RX packets:32855 errors:0 dropped:0 overruns:0 frame:0( h' n0 N8 w6 t/ x( u
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:06 Z3 t. r, T6 b5 Z3 a. R
          collisions:0 txqueuelen:1000% N( W5 r& [8 b4 |8 c8 I
          RX bytes:2731030 (2.7 MB)  TX bytes:84 (84.0 B)/ d! g+ c* k) w4 k# j$ G

) j3 j. e7 V, F4 o2 }* y0 N( O具体原理不详,但是应该是因为 qrouter 的 qg network interface 和物理网络中的路由器的网卡之间是网络二层,因此中间的设备都是属于二层的,因此不需要处于网络三层的 IP 地址。$ {8 G) ]8 S0 H2 s; R* y9 H, b6 ]
4. 使用 linux bridge 时的拓扑结构5 U8 X& [2 Q0 a1 ^
4.1 网络节点上
; }( |7 H4 F7 j. r. F为了更清楚,我们来对比着看 linux bridge 和 ovs 的两种方案:  s/ g$ w* ~- I
linux 方案:" G; P" w% d/ d% |1 [; x. z* l* P
  ' G& W" g5 }; |5 T
网络服务:
/ B+ b  p$ F; U# ?( M, L+ {8 y•        Linux bridge agent& Q/ M0 e& `$ _* e3 o' c! a
•        L3 agent
2 g/ T4 p3 L3 {3 H* U: A•        DHCP agent7 U$ t: o* I  F2 E! B
•        Metadata agent. g+ s6 b$ K  K0 z
Linux bridge agent 会为每个 VLAN 虚拟网络创建一个 VLAN Bridge,它连接多个网元:
2 `4 t: h: [! \2 P•        VLAN 子接口,从物理网卡(图中的 interface3)上创建,每个子接口对应一个VLAN ID,其名称格式为 device.sid,其中 device 是物理网卡名字比如 eth0,sid 是 vlan id。
9 K& ]  m# N- y, M! c3 U) ]! F' q•        连接虚拟机的 tap 接口+ o! ^- g4 q. [" s9 S6 `" E6 [
•        和 qrouter 连接的 tap 接口
- `/ J7 Z( J, y8 j•        和该网络的 qdhcp 连接的 tap 接口% E) |$ x0 ]' ?, U  r9 n! u
如果同时有 VXLAN 虚拟网络的话(linux-bridge 不支持GRE 隧道模式),会为每个 VLAN 虚拟网络创建一个 Tunnel bridge。它连接多个网元:
9 B2 O4 y# b! a% C. T•        vxlan interface,这种接口每个虚拟网络一个,名字格式为 vxlan-sid,其中 sid 是分段ID。- p: r. d7 S$ S/ {" |) P
•        连接虚拟机的 tap 接口
( r! K9 Y7 }; z+ ]% D* ^•        和 qrouter 连接的 tap 接口
3 J# }4 f( D3 \1 Q•        和该网络的 qdhcp 连接的 tap 接口9 [" q: h) g* j- T
安全组规则在 tunnel bridge 和 vlan bridge 上。# V9 `/ }3 Q) b9 ~# \
OVS 方案:2 `3 e( V4 S" X) f" y

' P0 p5 V! w% C' l这里面,br-int 会负责加本地 VLAN 标签,br-tun 会负责将 VLAN ID 转换为 VXLAN ID。
3 J7 g+ G: H! e& a& ?! } 9 A/ ~5 P% c* v& k& w  B6 {
4.2 计算节点上
0 m5 |& t! E0 p8 x( }) |" Y9 U同样来对比着看。9 t' ~6 n. t  o$ i
linux bridge:3 ?5 t* b3 S5 W) R* z. s: m

0 A! P+ {2 Y' A0 _" b0 t网络服务:2 z6 ]' ~7 I+ ~1 J9 f, i* N- _
•        Linux bridge agent4 v! b( Q! C+ K" U
和网络节点类似,只不过没有 qrouter 和 qdhcp,不在赘述。, e) ]% S* m8 A# Q) j# u9 [
OVS:
, J, @# |) P( O' U6 H# |! r
9 \- u- m; i0 y( }) Z
; b. Z  k2 ?9 k0 v0 @2 {OVS 放在在 br-int 上实现 VLAN 标签,在 br-tun 上实现隧道,在 qbr linux bridge 上实现安全组。
& w: |3 K. {4 O
; B" q( r. ]% n& Y  t6 m4.3 网络路径 - 南北向网络流向
- h( P" N7 A' d
5 y6 L- c$ u' e4 E- ]' oVLAN 网络和VXLAN 网络井水不犯河水。这图上的配置中,计算节点和网络节点上的物理网卡都分开了。
0 E2 r8 n% t; p5 w( e6 ~4.4 网络路径 - 东西向(不同网络)" |; m5 E* O0 `' ]& C7 Z' G1 H# w
  j7 _% W4 `/ h5 E
4.5 网络路径 - 东西向(同一个网络): ~- Q9 ~- M. g5 v7 G3 F; S" \

/ k- ?2 l# x2 T' M 5 p6 S' S2 `) B8 {1 n9 m  y# B) ^5 C
请详细说明和配置,请参阅参考文档。
! J9 Y" v" u& ^9 L; K1 ?5. 一点结论
, y$ {. M. h6 P和基于 OVS 的二层网络相比,
9 ]# p" ^$ t* Z( @) z! l•        功能和架构上:基于 linux bridge 的实现还是有一些短处,比如每个虚拟网络就需要一个网桥,这在大规模环境中会带领资源使用和管理上的问题。其好处是本身架构比较清晰。. U+ V; o, i# Q4 C
•        性能上:基本上差不多,如下图所示,不管是 vxlan 还是 vlan。
8 a. ?" a6 J$ }# }8 D
4 T# b: y' ~# C  ]4 g6 }( F4 y( `
 楼主| 发表于 2019-10-28 14:31:20 | 显示全部楼层
一.现状( ?# K+ M; C1 r9 O# C, d+ l
部署节点为一个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)。 8 R4 j( E- m5 [+ B) V+ j  R; `
controller节点、compute节点的L2 agent 为 neutron-linuxbridge-agent # r. G; B4 N+ j* \" L- ?

0 E5 p5 j; B7 k' x( a. [# m, I- e7 z
Neutron网络方案为:
- L" i( e2 x: j5 N0 K  G% j4 m( U5 g
  Q" p0 c; W' C7 jNeutron ML2的Type Driver为vxlan
9 L2 G. B# K' t, L0 J( z  HNeutron ML2的Mechanism Driver为LinuxBridge$ O8 z3 ], S% g, M. A2 l" z
Neutron L2 Agent为LinuxBridge
% s+ u$ t5 n, M8 i; J7 m% Z& h* Y, C+ y2 G. @) J5 ~/ L
目前的网络服务信息为: & O( B, c5 l: t' O8 j% R5 v- S
6 J1 f) F' ^) a; d' f( j
+ w( {8 i% U7 ]2 G
二.替换
6 a+ R/ J, c5 Bcontroller节点、compute节点的L2 agent 替换为 neutron-openvswitch-agent * w5 |5 f2 P3 N3 A( ?

: @& @4 b# Y6 n- z3 u, U6 V- N' M8 z; c
Neutron网络方案替换为:
- f$ b  F! V$ p& \# }0 [/ M/ ?
4 s8 b8 g5 ~( ~0 L! |0 DNeutron ML2的Type Driver为vxlan
7 S- O) {) v7 Q* j( `) ONeutron ML2的Mechanism Driver为Open vSwitch
8 g/ u5 f( \8 K1 o$ p  [' wNeutron L2 Agent为Open vSwitch ; p+ Y& q4 ?, V% s4 Y

! K5 u7 v: j1 r(1). 删除已有的路由器、虚拟网络。3 w( F! E7 o$ ^7 N# |" t" k
  z3 |: n8 s" U" N+ u6 @
1.当删除网络时,报如下错误
/ J! F/ e: B2 V, d; K
$ A. {8 T. r( [0 N3 s) r
0 Q; s( c% h( f; ]6 G- X9 P查看日志: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. , r! ]: O" Q* E' K# J7 \8 K& R0 I
表明有实例连接到这个网络,需要解除实例和网络port的绑定,然后再删除网络。/ ]0 P+ {3 R; B# N% Z5 G

$ a; ?, T: _/ U7 p2.删除外网时,也报类似错误 - _5 D/ D2 J- N3 W/ e% f2 r
查看日志:Found port (3db7acca-71d4-4715-94d5-47ecc2e42b21, 11.11.11.11) having IP allocation on subnet 558ee6a0-1145-4e9f-9f12-5318b5fd4ac5, cannot delete ; d- H0 G2 V" \6 y- H( ?/ ?
delete 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.
. m+ q+ I9 Z; I* R需要释放浮动IP,再删除外部网络。
9 {! I! [  i  C7 `+ n+ Y2 D" \  n- H8 A  y9 g3 j1 D1 f; f) z+ {
(2). 卸载controller节点、compute1节点、compute2节点的 neutron-linuxbridge-agent' c- O5 p; ~3 ^) e# G/ m, w) r
$ j" b4 ?" `& o: C4 K, }6 U4 L( J
先停止neutron-linuxbridge-agent服务
0 n( @5 I6 k' ~+ _2 _. ^& X. V
! P( D9 X: _" p4 L2 I9 zroot@controller:~# service neutron-linuxbridge-agent stop
* z" }' k; }4 Oneutron-linuxbridge-agent stop/waiting1 p5 k3 a' V3 y3 T5 D! M& I
root@compute1:~# service neutron-linuxbridge-agent stop; n) c% y- J- s9 Q3 g
neutron-linuxbridge-agent stop/waiting
. N$ f. G4 ?, I! v9 Hroot@compute2:~# service neutron-linuxbridge-agent stop
. Z+ u+ o6 g4 _! c$ a2 Rneutron-linuxbridge-agent stop/waiting
% e" l8 q2 H" S8 ^
3 V% y+ D( L: L3 V: P% D' X- I7 K再卸载软件
) m- p6 u$ l9 L- \: V8 G+ C, Z6 P8 W) `6 ]' Y& }& v
root@controller:~# apt-get --purge remove neutron-linuxbridge-agent
- S2 U& _7 `0 w! R$ xroot@compute1:~# apt-get --purge remove neutron-linuxbridge-agent4 `7 `; W3 T' u. `
root@compute2:~# apt-get --purge remove neutron-linuxbridge-agent
2 k8 Y8 ?& B0 s' Q- Y. G- t
4 k0 V6 I/ b1 n# c( s(3). 安装controller节点、compute1节点、compute2节点的 neutron-openvswitch-agent
6 b1 p* C' G% q1 K! O* h1 V" t7 ^. \- p% ~" Z0 i0 ~- N& X; {( h
root@controller:~# apt-get install neutron-openvswitch-agent2 T. G& }5 z! X8 x  p
root@compute1:~# apt-get install neutron-openvswitch-agent) J4 Q: x+ B! y1 w9 G, j
root@compute2:~# apt-get install neutron-openvswitch-agent
( i$ n# L+ U  Y6 k* F
7 C- ]  O; D1 L6 X. x0 I(4). 修改配置文件
+ H1 ]; b# [& Y! s/ z; ?controller节点$ m2 n3 |. k$ W; I5 ]

! h5 K. {  {, U$ h+ ]: R4 g/etc/neutron/plugins/ml2/ml2_conf.ini
, F" Q7 X. R. b3 G
9 D) [& o, I1 L( t[ml2]
* M) U. L7 f' P/ ^$ v. ?type_drivers = flat,vxlan
9 X# t* ]( N  [% M2 mtenant_network_types = vxlan* x; U0 p9 M$ J8 P! Z7 s# M
mechanism_drivers = openvswitch,l2population
8 d* [5 I2 _# }- J5 N& Iextension_drivers = port_security
  T- c9 x! Q2 d  z# h; a. E8 `( B" I5 e, S/ \) u
[ml2_type_vxlan]9 t  P8 C5 j9 F" t! t$ x
vni_ranges = 1001:2000
5 q1 H0 G( J( r) L& @" f/ g6 G
/ b, t9 j7 D% I1 U[securitygroup]. T: v0 Y8 Q3 |
enable_ipset = true
' {- X$ z$ ^/ h* Z& g; a" d  @. z8 }7 C! u+ {& t3 s. L9 E: i( `- h
/etc/neutron/l3_agent.ini  W7 L; l- v& _: R

6 {9 B9 e1 Z( o9 [2 D; }6 C: l[DEFAULT]9 C$ w1 l' ?: y2 l: E3 U8 R
external_network_bridge = br-ex. j8 j. l6 u, p9 t4 Y- }) A) k
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver1 S) H' h1 S: Y' [% J& T
, n8 j# G1 D0 p8 r. r
/etc/neutron/dhcp_agent.ini$ T) ]- c. \1 x) e4 L  `! F
9 Z) f' a0 t* p9 H3 \5 x" ^) z
[DEFAULT]" j* d( q' j- r8 Z
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver% j' x4 b/ Y, U- |' H: z0 z8 t' C) t
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq* N- ]$ ?% T4 x, @( O
enable_isolated_metadata = True
6 P$ ]9 |6 ~! n. N8 P' a
! Q2 m# m" s8 {* ^4 D5 O/ z/etc/neutron/plugins/ml2/openvswitch_agent.ini
+ V9 Q( D% @0 t
9 l- Y2 N! n$ _. a( A[ovs]
5 z- q/ y' c: [1 Tbridge_mappings =
- X; r4 L) f' ltunnel_bridge = br-tun
+ L4 y8 Y) y+ Mlocal_ip = 10.10.10.10% V3 \( w; j3 S/ u7 Q
$ u% S0 C" S, o; l
[agent]
. k" U5 j; w+ ^) V, a7 b, n& d  ^tunnel_types = vxlan! A( X. X+ i) W; g6 \
l2_population = True" k8 o6 g7 y& h2 o

6 ^' k8 k) Z7 ^3 ~& ]" B# T[securitygroup]
* A) \9 |* g% L/ l& z" Kfirewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver3 A5 |/ ?% ?8 A9 x: X
enable_security_group = true
2 y" U, s4 Q/ Q! _  f
& x. P( `  W+ _; Rcompute1节点6 {* u$ \- S, W+ I  ?

( p% a- H% \. X8 _, R/etc/neutron/plugins/ml2/openvswitch_agent.ini
+ w7 G: S9 M) f1 O1 `: [9 ]  ]' w+ i8 z% ]
[ovs]/ y+ M5 Q, ^6 C
bridge_mappings =
! G7 i' A- F/ T( W/ wtunnel_bridge = br-tun4 ~8 D: Z: y: M
local_ip = 10.10.10.11
+ k; y& s/ \2 [# M' h
2 _3 d& Y/ d- }6 X[agent]) ~* J2 K$ _% s8 Q! D5 ~
tunnel_types = vxlan0 N" p$ F; x/ U1 d( [
l2_population = True
4 l+ l! K3 v2 ?3 {8 ^
. w5 o, m' D$ d7 f4 e2 |0 i[securitygroup]
2 Z. Y/ h; M) n5 L- rfirewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
3 S2 i( f& V! z/ G) B  G2 Genable_security_group = true9 T5 L) N( {8 p7 T. s6 _" o7 O

' R# _2 _3 {, G# w# U6 z8 Acompute2节点$ `  a0 U1 B$ g/ g* s, R: }
' p* p4 U4 o* l# b
[ovs]$ T* p" O& B; k
bridge_mappings =
5 B% s/ x  Y. X, Utunnel_bridge = br-tun
- Y5 F/ a" z+ a( h2 G$ Zlocal_ip = 10.10.10.129 T$ a2 w# i: |: V' `5 r- C

- @8 q. a& Z8 {, ~  B( z% Z% Y[agent]6 Y. k! g7 G+ ?% D( r
tunnel_types = vxlan) Z7 G9 a1 _2 T2 N* r) @6 H  a
l2_population = True
7 V( }$ i& F7 \( }; ^% u* s6 \$ u, Z4 c3 g" @  n# W3 k0 r
[securitygroup]
# j  ^+ W4 E  }) P. C# Vfirewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
/ M  |5 I: Y* _9 X# ?! Henable_security_group = true
2 |$ X* j( a; S1 {: F
7 z0 G1 ^' m$ \. V2 b+ {重启网络相关服务。
0 I. J& p0 P  ~$ Y6 `! D% e# W; l: g. ^
再次查看网络服务信息
! s8 Q. |" Q% X2 ]8 e- G3 `+ D: D/ U" D4 P8 n

- A- l+ u7 d" D7 W. t$ |" G把已关闭的 neutron-linuxbridge-agent 删除
, O6 u! T8 \# g7 f$ z6 I( ~7 L/ Q- ?& z  ~
root@controller:~# neutron agent-list
. z1 t4 p+ a; Y4 k: e- L5 m* c! g. |+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+" `* f( \$ S/ ^
| id                                   | agent_type         | host       | availability_zone | alive | admin_state_up | binary                    |
8 ^& N# X5 Q9 f) w, o+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
. S/ v6 n% c9 ?; `| 21af963d-003d-455e-8723-8b78d201a684 | L3 agent           | controller | nova              | :-)   | True           | neutron-l3-agent          |
7 a& [. k9 |% p0 b/ w9 O; ~: V| 25229052-f0cb-4f04-b819-375fc55c510f | Linux bridge agent | controller |                   | xxx   | True           | neutron-linuxbridge-agent |6 u/ }8 r$ U7 k- ]. ?
| 80607c88-5c98-4491-839d-0ce715ec3e4d | Open vSwitch agent | compute2   |                   | :-)   | True           | neutron-openvswitch-agent |6 x1 @! T: T! b/ U' g2 k* G. B( l
| aab52c21-8c14-4568-89c6-20e70400da38 | Open vSwitch agent | compute1   |                   | :-)   | True           | neutron-openvswitch-agent |- @5 J# J9 ~1 m# y9 l
| d51f6d6c-eda0-4179-9fce-f9c24ef20824 | DHCP agent         | controller | nova              | :-)   | True           | neutron-dhcp-agent        |# c5 U2 T5 T; L+ ~2 A
| d666c263-ba6d-4f09-a09d-72c214787e08 | Loadbalancer agent | controller |                   | :-)   | True           | neutron-lbaas-agent       |
, B9 k2 H$ p0 I- z$ j- n| e17d1ecf-35d2-49f5-a7c9-206b0c9e2ce4 | Linux bridge agent | compute2   |                   | xxx   | True           | neutron-linuxbridge-agent |; i" b7 |# |: o$ V% s
| e26dc52e-7827-463b-8ee7-202a19d5c3dc | Metadata agent     | controller |                   | :-)   | True           | neutron-metadata-agent    |0 d% r9 J7 J* h/ q# R3 u
| fba23722-9439-4289-bd17-5b69c43f88da | Linux bridge agent | compute1   |                   | xxx   | True           | neutron-linuxbridge-agent |9 U7 z1 ]' t" c" M
| fe4a9cf3-9a08-4837-b74f-787118ce57db | Open vSwitch agent | controller |                   | :-)   | True           | neutron-openvswitch-agent |0 }' _+ M& ?7 ?0 ~
+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
; t4 z/ w" z6 K( c4 D, m! e" ~! @' d: `; a$ G1 @6 D) E+ R5 h
root@controller:~# neutron agent-delete 25229052-f0cb-4f04-b819-375fc55c510f. n& \) t; b7 N0 x8 Q' S
Deleted agent: 25229052-f0cb-4f04-b819-375fc55c510f8 U! t. y. ]+ b0 c
root@controller:~# neutron agent-delete e17d1ecf-35d2-49f5-a7c9-206b0c9e2ce4/ y; b; J2 L) m. C
Deleted agent: e17d1ecf-35d2-49f5-a7c9-206b0c9e2ce47 g' ^" N1 M5 B+ D
root@controller:~# neutron agent-delete fba23722-9439-4289-bd17-5b69c43f88da. w) ?% K( o, v6 c2 y) H
Deleted agent: fba23722-9439-4289-bd17-5b69c43f88da
) n! C. W- t0 _; y7 T1 g3 W1 Y' }  a0 O2 c7 e0 h* a" T
再次查看网络服务信息,已经没有linuxbridge的agent了 ! r% M/ P% V- D5 t# [7 b8 U3 B

0 H# n  q% R* O- D' t2 @
5 i+ J* r1 a4 a0 F  M  s% y# }三.验证. o9 _6 ]- U9 r7 _
验证修改是否成功。 7 x- ^$ E6 a8 a; }$ ]8 R+ h* h
先创建一个vxlan100网络 0 y) b  Q9 f* o
/ R1 A5 [+ ]0 ^
. O. y; m# m! K' O, Q
把已有虚拟机test1、test2和vxlan100网络关联起来 . X1 a8 ^4 ]" W2 g
6 S5 w% I3 ?  C) ^9 O
- w0 T2 }5 z5 X- b4 T7 S8 `- R8 {# T& l
test1、test2重启,然后查看是否获取IP地址
) ?3 @0 Y) O& V, f2 `( r0 @- t再互ping ! o1 i( c$ B: B+ r# }
& ]: a, k# N7 C, e( O/ z% _
8 I! q. T& F! }
至此,L2 agent替换并验证成功!
9 ^/ S  d4 O9 e6 ]/ m! h% O% m, v! Y) ~0 p
8 O0 c# G4 A* a6 L2 w$ J! B/ b
————————————————1 u, ~$ r1 r2 c+ ^

& J" o" f- N. e& J
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 21:36 , Processed in 0.065552 second(s), 29 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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