OVSDB

news/2024/11/25 13:33:41/

OVS组件

OVS包含三个重要的组件:ovsdb-server、ovs-vswitchd、以及OVS内核模块。

  1. ovsdb-server:OVS的数据库服务进程,持久化存储的数据库,用于记录的网桥、端口、QOS等网络配置信息,为控制器和ovs-vswitchd提供OVSDB操作接口。
  2. ovs-vswitchd:OVS的核心组件,负责保存和管理控制器下发的所有流表,为OVS的内核模块提供流表查询功能,并为控制器提供OpenFlow协议的操作接口。
  3. OVS内核模块:缓存某些常用流表,并负责数据包转发,当遇到无法匹配的报文,该模块将向ovs-vswitchd发送pack-in请求,获取报文处理指令。
#ps -ef | grep ovs-vswitchd
root         987       1  0 Jan24 ?        02:43:11 ovs-vswitchd unix:/var/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --mlockall --no-chdir --log-file=/var/log/openvswitch/ovs-vswitchd.log --pidfile=/var/run/openvswitch/ovs-vswitchd.pid --detach

ovs-vswitchd监听了一个本机的db.sock文件,这个socket就是openvswitch的ovsdb的链接,ovs-vswitchd可以通过这个socket把配置信息写到ovsdb

默认数据库:Open_vSwitch
默认db路径:/etc/openvswitch/conf.db
默认schema:/usr/share/openvswitch/vswitch.ovsschema
默认socket:/var/run/openvswitch/db.sock
ovs-vsctl add-br br-int
ovs-vsctl add-port ovs-veth10

1、Insert:插入,无任何关联项

ovsdb-client transact '["Open_vSwitch",{"op":"insert","table":"xxx","row":{"name":"xxx","value":"xxx"}}]'

2、Selsect:根据where条件筛选

ovsdb-client transact '["Open_vSwitch",{"op":"select","table":"xxx","where":[["name","==","xxx"]]}]'

3、Update:更新表项

ovsdb-client transact '["Open_vSwitch",{"op":"update","table":"xxx","where":[["name","==","xxx"]],"row":{'name':"xxx"}}]'

4、Delete:删除表项

ovsdb-client transact '["Open_vSwitch",{"op":"delete","table":"xxx","where":[["name","==","xxx"]]}]'

5、Mutate:联合操作在table1里insert数据,where里找到关联table2的元素,uuid-name和set保持一致即可,mutations里的第一个参数是table2的column在table1里作为uuid

ovsdb-client transact '["Open_vSwitch",{"op":"insert","table":"xxx1","row":{'name':"xxx"},"uuid-name":"abc"},{"op":"mutate","table":"xxx2","where":[["name","==","xxx"]],"mutations":[["name","insert",["set",[["named-uuid","abc"]]]]]}]'
查看ovsdb里对ovs的操作,可以看到Open_vSwitch表里增加一条记录,Bridge表增加一条记录,Port表增加两条记录
ovsdb-tool show-log -m
record 0: "Open_vSwitch" schema, version="8.2.0", cksum="xxx"
record 1: 2022-07-11 06:42:10.679 "compacting database online"
table Interface insert row "ovs-veth10" (92dee19b):
table Port insert row "br-int" (ccfd1042):
table Port insert row "ovs-veth10" (751976fd):
table Bridge insert row "br-int" (64043d26):
table Open_vSwitch insert row 097bf88c:
列出ovsdb里的所有数据库,默认是Open_vSwitch
ovsdb-client list-dbs
Open_vSwitch
列出ovsdb里的所有table
ovsdb-client list-tables Open_vSwitch
Table
Controller
Bridge
Queue
IPFIX
NetFlow
Open_vSwitch
CT_Zone
QoS
Datapath
SSL
Port
sFlow
Flow_Sample_Collector_Set
CT_Timeout_Policy
Mirror
Flow_Table
Interface
AutoAttach
Manager
查看Open_vSwitch表新增内容,bridges会不断更新网桥id,同时会记录cur_cfg和next_cfg
ovsdb-client dump Open_vSwitch Open_vSwitch
Open_vSwitch table
_uuid                                bridges                                                                      cur_cfg datapath_types   datapaths db_version dpdk_initialized dpdk_version external_ids                                                                                       iface_types                                                                              manager_options next_cfg other_config ovs_version ssl statistics system_type system_version
--------------------------------------------------------------------------------
097bf88c-b5c3-4e62-b795-51ea0f0c0053 [64043d26-8311-4a68-837a-f58b6bd3293c] 183     [netdev, system] {}        "8.2.0"    false            none         {hostname=ubuntu, rundir="/var/run/openvswitch", system-id="e73b1ede-9e48-4412-9665-c0f998fec762"} [erspan, geneve, gre, internal, ip6erspan, ip6gre, lisp, patch, stt, system, tap, vxlan] []              183      {}           "2.13.3"    []  {}         ubuntu      "20.04"
查看数据库Open_vSwitch中Bridge表内容,看到一个br-int网桥
ovsdb-client dump Open_vSwitch Bridge
Bridge table
_uuid                                auto_attach controller datapath_id        datapath_type datapath_version external_ids fail_mode flood_vlans flow_tables ipfix mcast_snooping_enable mirrors name    netflow other_config ports                                                                                                                                                                                          protocols                rstp_enable rstp_status sflow status stp_enable
--------------------------------------------------------------------------------
64043d26-8311-4a68-837a-f58b6bd3293c []          []         "0000263d0464684a" ""            "<unknown>"      {}           []        []          {}          []    false                 []      br-int  []      {}           [28e2a8cf-5bad-43c1-a6e9-b6bb635295bb, 751976fd-0cec-42bc-ada2-cf7bee05453d, 9f4d9f67-5b0e-4cbd-ba8b-9386dcbf3c65, c0e09899-3197-4763-9bf0-a1de941f0d32, ccfd1042-55f4-4af6-9bc7-49ddb29c09de] []                       false       {}          []    {}     false
查看数据库Open_vSwitch中Port表内容,看到一个网桥同名接口br-int和自建接口ovs-veth10,每个port都关联一个interface
ovsdb-client dump Open_vSwitch Port
Port table
_uuid                                bond_active_slave bond_downdelay bond_fake_iface bond_mode bond_updelay cvlans external_ids fake_bridge interfaces                             lacp mac name       other_config protected qos rstp_statistics rstp_status statistics status tag trunks vlan_mode
--------------------------------------------------------------------------------
ccfd1042-55f4-4af6-9bc7-49ddb29c09de []                0              false           []        0            []     {}           false       [58c5bd1a-6165-46d5-bd74-b5879874ed28] []   []  br-int     {}           false     []  {}              {}          {}         {}     []  []     []
751976fd-0cec-42bc-ada2-cf7bee05453d []                0              false           []        0            []     {}           false       [92dee19b-7042-4ec4-81eb-2b8f10095c5c] []   []  ovs-veth10 {}           false     []  {}              {}          {}         {}     []  []     []
监控数据库Open_vSwitch中Port表变动
ovsdb-client monitor Open_vSwitch Port
查看数据库Open_vSwitch中Interface表内容,看到port关联的interface里对应的ofport就是网桥的编号
ovsdb-client dump Open_vSwitch Interface
Interface table
_uuid                                admin_state bfd bfd_status cfm_fault cfm_fault_status cfm_flap_count cfm_health cfm_mpid cfm_remote_mpids cfm_remote_opstate duplex error                                                       external_ids ifindex ingress_policing_burst ingress_policing_rate lacp_current link_resets link_speed  link_state lldp mac mac_in_use          mtu  mtu_request name       ofport ofport_request options other_config statistics                                                                                                                                                                                                      status                                                        type
--------------------------------------------------------------------------------
58c5bd1a-6165-46d5-bd74-b5879874ed28 down        {}  {}         []        []               []             []         []       []               []                 []     []                                                          {}           137     0                      0                     []           0           []          down       {}   []  "26:3d:04:64:68:4a" 1500 []          br-int     65534  []             {}      {}           {collisions=0, rx_bytes=0, rx_crc_err=0, rx_dropped=66459, rx_errors=0, rx_frame_err=0, rx_missed_errors=0, rx_over_err=0, rx_packets=0, tx_bytes=0, tx_dropped=0, tx_errors=0, tx_packets=0}                   {driver_name=openvswitch}                                     internal
92dee19b-7042-4ec4-81eb-2b8f10095c5c up          {}  {}         []        []               []             []         []       []               []                 full   []                                                          {}           138     0                      0                     []           1           10000000000 up         {}   []  "f2:85:c5:5c:e2:8e" 1500 []          ovs-veth10 2      []             {}      {}           {collisions=0, rx_bytes=57076, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_missed_errors=0, rx_over_err=0, rx_packets=722, tx_bytes=22453284, tx_dropped=0, tx_errors=0, tx_packets=66450}      {driver_name=veth, driver_version="1.0", firmware_version=""} ""

自建数据库

1、创建schema文件amber.schema

{
"name": "Amber",
"version": "1.0.1",
"cksum": "xxx",
"tables": {
"Information": {
"columns":{
"name": {
"type": {
"key": "string",
"max": 1,
"min": 0
}
},
"age": {
"type": {
"key": "integer",
"max": 1,
"min": 0
}
},
"number": {
"type": {"key": {"type": "string", "minLength": 17, "maxLength": 17}}}
},
"isRoot": true,
"maxRows": 1
},
"Score": {
"columns": {
"math":{
"type": {
"key": {
"type": "integer",
"max": 1,
"min": 1
}
},
"mutable": false
},
"chinese": {
"type": {
"key": {
"type": "integer",
"max": 1,
"min": 1
}
},
"mutable": false
},
"english": {
"type": "integer"
"max": 1,
"min": 1
},
"isRoot": true
},}

注意,名称值可选性说明“columns”{: , …}必选包含的表格的UUID、版本信息等“maxRows”可选表格的最大行数“isRoot”可选表格内是否存在强依赖关系“indexes”[*]可选用于标识表格列”type”必选列的类型“ephemeral”< boolean >可选数据是否持久化“mutable”可选数据是否可修改

2、创建ovsdb数据库:ovsdb-tool create amber.db amber.schema

3、启动ovsdb数据库:ovsdb-server -vconsole:off -vfile:info --log-file=/root/amberd.log --remote=punix:/var/run/amber/amberd.sock --pidfile=/var/run/amberd.pid --unixctl=/var/run/amberd.ctl --detach --monitor /root/sdn/platform/src/ctrlplane/ovsdb/amber.db
4、查看数据库Table时要指定socket

ovsdb-client list-tables unix:/var/run/amber/amberd.sock DP_Option
ovsdb-client dump unix:/var/run/amber/amberd.sock DP_Option DP_Option
ovsdb-client transact unix:/var/run/amber/amberd.sock '["DP_Option",{"op":"select","table":"DP_Option","where":[]}]'

http://www.ppmy.cn/news/507316.html

相关文章

HDU6161

hdu6161 Big binary tree 多校1001 题目链接 题目是给一棵完全二叉树&#xff0c;从上到下从左到右给每个节点标号&#xff0c;每个点有权值&#xff0c;初始权值为其标号&#xff0c;然后有两种操作&#xff1a; 1、把u点权值改为x 2、查询所有经过u点的路径中&#xff0…

[已解决] MySQL: Error Code: 3065和Error Code: 1055

文章目录 环境问题分析解决方法一方法二扩展sql_mode属性含义sql_mode 三种作用域 环境 windows系统 问题 程序运行时遇到下面的问题&#xff1a; Error Code: 3065 Expression #1 of ORDER BY clause is not in SELECT list, references column xxxx which is not in SELE…

hdu 6165

题解&#xff1a;先找出所有的强连通分量&#xff0c;再判断各分量能否满足要求(方法&#xff1a;不断地除去入度为0的分量&#xff0c;若出现两个入度为0的分量则不合法) #include<iostream> #include<stdio.h> #include<vector> #include<stack> #in…

code 6101 和 code 6111的解决办法

<<<< code 6101 和 code 6111的解决办法 <<<< <<<< kdbchk: row locked by non-existent transaction <<<< table0 slot0 <<<< lockid2 ktbbhitc2 <<<< Block 96081 failed with…

IEC61850 总结

1. 抽象层次 自己理解&#xff0c;这个是61850的精华所在。在文档中多次提到“面向对象”的概念&#xff0c;在61850的配置文件xml文件中也可以看到对象的概念&#xff0c;可以清楚的看出所抽象出来的对象的之间的关系。 一个SCL文件&#xff0c;最顶层有三个节点&#xff0c;C…

LibreOJ - 6165 欧拉筛法+最小质因子

题目&#xff1a;一天&#xff0c;szb 在上学的路上遇到了灰太狼。 灰太狼&#xff1a;帮我们做出这道题就放了你。 szb&#xff1a;什么题&#xff1f; 灰太狼&#xff1a;求一个能被 [1,n] 内所有数整除的最小数字&#xff0c;并对 100000007 取模。 szb&#xff1a;这题太水…

hdu6165

题目链接&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid6165 题意&#xff1a;一张有向图&#xff0c;n个点&#xff0c;m条边&#xff0c;保证没有重边和自环。询问任意两个点能否满足任何一方能够到达另外一方。 思路&#xff1a;枚举每个点&#xff0c;预处理搜…

ActiveMQ配置wss

最近把前端页面由原来的http升级为了https&#xff0c;发现之前ActiveMQ提供的ws不能强求了&#xff0c;https服务下要求升级到wss。全网搜索了下&#xff0c;没有找到一个靠谱的文档 一、 证书准备 使用wss连接服务必须使用域名端口&#xff0c;而不能使用ip端口&#xff0c;这…