Open vSwitch
安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
| # 安装依赖
yum install -y autoconf automake libtool git python3
# 升级 pip
python3 -m pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple pip
# 下载源码及编译
git clone https://github.com/ovn-org/ovn.git
./boot.sh
cd ovs
./boot.sh
./configure
make
make install
cd ..
./configure
make
make install
# 环境变量
vi /etc/profile
export PATH=$PATH:/usr/local/share/ovn/scripts
# 启动(自动)
ovn-ctl start_northd
ovn-ctl start_controller
# 启动(手动)
mkdir -p /usr/local/etc/ovn
ovsdb-tool create /usr/local/etc/ovn/ovnnb_db.db \
ovn-nb.ovsschema
ovsdb-tool create /usr/local/etc/ovn/ovnsb_db.db \
ovn-sb.ovsschema
mkdir -p /usr/local/var/run/ovn
ovsdb-server /usr/local/etc/ovn/ovnnb_db.db --remote=punix:/usr/local/var/run/ovn/ovnnb_db.sock \
--remote=db:OVN_Northbound,NB_Global,connections \
--pidfile=/usr/local/var/run/ovn/ovnnb-server.pid --detach --log-file=/usr/local/var/log/ovn/ovnnb-server.log
ovsdb-server /usr/local/etc/ovn/ovnsb_db.db --remote=punix:/usr/local/var/run/ovn/ovnsb_db.sock \
--remote=db:OVN_Southbound,SB_Global,connections \
--pidfile=/usr/local/var/run/ovn/ovnsb-server.pid --detach --log-file=/usr/local/var/log/ovn/ovnsb-server.log
ovn-nbctl --no-wait init
ovn-sbctl --no-wait init
ovn-northd --pidfile --detach --log-file
|
OVN Sandbox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| # 创建第一个交换机
ovn-nbctl ls-add sw0
ovn-nbctl lsp-add sw0 sw0-port1
ovn-nbctl lsp-set-addresses sw0-port1 "50:54:00:00:00:01 192.168.0.2"
# 创建第二个交换机
ovn-nbctl ls-add sw1
ovn-nbctl lsp-add sw1 sw1-port1
ovn-nbctl lsp-set-addresses sw1-port1 "50:54:00:00:00:03 11.0.0.2"
# 创建路由器并连接到两个交换机
ovn-nbctl lr-add lr0
ovn-nbctl lrp-add lr0 lrp0 00:00:00:00:ff:01 192.168.0.1/24
ovn-nbctl lsp-add sw0 lrp0-attachment
ovn-nbctl lsp-set-type lrp0-attachment router
ovn-nbctl lsp-set-addresses lrp0-attachment 00:00:00:00:ff:01
ovn-nbctl lsp-set-options lrp0-attachment router-port=lrp0
ovn-nbctl lrp-add lr0 lrp1 00:00:00:00:ff:02 11.0.0.1/24
ovn-nbctl lsp-add sw1 lrp1-attachment
ovn-nbctl lsp-set-type lrp1-attachment router
ovn-nbctl lsp-set-addresses lrp1-attachment 00:00:00:00:ff:02
ovn-nbctl lsp-set-options lrp1-attachment router-port=lrp1
# ovn-trace
使用ovn-trace查看OVN怎样处理packet
ovn-trace --minimal sw0 'inport == "sw0-port1" && eth.src == 50:54:00:00:00:01 && ip4.src == 192.168.0.2 && eth.dst == 00:00:00:00:ff:01 && ip4.dst == 11.0.0.2 && ip.ttl == 64'
|
参考文档: https://docs.ovn.org/en/stable/intro/install/general.html#general-bootstrapping
参考文档: https://docs.openvswitch.org/en/latest/intro/install/fedora/