zoukankan      html  css  js  c++  java
  • OVS数据库操作

    说明

    • [Record]就是行对应的_uuid

    • [if-exists]当值不存在的是否会报错而不是返回False

    基本信息查询

    • 列举数据库
    # ovsdb-client list-dbs
    Open_vSwitch
    
    • 列举数据库表
    # ovsdb-client list-tables [DB]
    
    ### 列举数据库Open_vSwitch的所有表名
    # ovsdb-client list-tables Open_vSwitch
    Table
    -------------------------
    Controller
    Bridge
    Queue
    IPFIX
    NetFlow
    Open_vSwitch
    QoS
    Port
    sFlow
    SSL
    Flow_Sample_Collector_Set
    Mirror
    Flow_Table
    Interface
    AutoAttach
    Manager
    
    • 列举数据库列
    # ovsdb-client list-columns [DB] [Table]
    
    ### 列举数据库Open_vSwitch的Open_vSwitch表结构
    # ovsdb-client list-columns Open_vSwitch Open_vSwitch
    Column          Type
    --------------- ----------------------------------------------------------------------
    statistics      {"key":"string","max":"unlimited","min":0,"value":"string"}
    manager_options {"key":{"refTable":"Manager","type":"uuid"},"max":"unlimited","min":0}
    cur_cfg         "integer"
    next_cfg        "integer"
    iface_types     {"key":"string","max":"unlimited","min":0}
    datapath_types  {"key":"string","max":"unlimited","min":0}
    _uuid           "uuid"
    system_version  {"key":"string","min":0}
    db_version      {"key":"string","min":0}
    bridges         {"key":{"refTable":"Bridge","type":"uuid"},"max":"unlimited","min":0}
    _version        "uuid"
    external_ids    {"key":"string","max":"unlimited","min":0,"value":"string"}
    other_config    {"key":"string","max":"unlimited","min":0,"value":"string"}
    ovs_version     {"key":"string","min":0}
    ssl             {"key":{"refTable":"SSL","type":"uuid"},"min":0}
    system_type     {"key":"string","min":0}
    
    • 列举数据库数据
    ### 方式一
    # ovs-vsctl list [Table] [REC]
    
    ### 列举Open_vSwitch表数据
    # ovs-vsctl list Open_vSwitch表数据
    _uuid               : 7c18c5c5-f9ad-483d-84bb-5328707b9159
    bridges             : [7ab833e4-1454-41c0-8384-0e4086d50333, faec0c73-0c21-477e-a6dd-53b3303e4262]
    cur_cfg             : 36
    datapath_types      : [netdev, system]
    db_version          : []
    external_ids        : {ovn-encap-ip="92.0.0.12", ovn-encap-type="geneve,vxlan", ovn-remote="tcp:92.0.0.11:6642", system-id="c5e8ace3-24c5-4c6e-aed6-f9fc83c0a71e"}
    iface_types         : [geneve, gre, internal, ipsec_gre, lisp, patch, stt, system, tap, vxlan]
    manager_options     : [66e272e7-675d-4d3c-9b34-20fd427caed6]
    next_cfg            : 36
    other_config        : {}
    ovs_version         : []
    ssl                 : []
    statistics          : {}
    system_type         : []
    system_version      : []
    
    ### 方式二
    # ovsdb-client dump [DB] [Table]
    
    ### 列举数据库Open_vSwitch的Open_vSwitch表数据
    # ovsdb-client dump Open_vSwitch Open_vSwitch
    Open_vSwitch table
    _uuid                                bridges                                                                      cur_cfg datapath_types   db_version external_ids                                                                                                                                 iface_types                                                              manager_options                        next_cfg other_config ovs_version ssl statistics system_type system_version
    ------------------------------------ ---------------------------------------------------------------------------- ------- ---------------- ---------- -------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------ -------------------------------------- -------- ------------ ----------- --- ---------- ----------- --------------
    7c18c5c5-f9ad-483d-84bb-5328707b9159 [7ab833e4-1454-41c0-8384-0e4086d50333, faec0c73-0c21-477e-a6dd-53b3303e4262] 36      [netdev, system] []         {ovn-encap-ip="92.0.0.12", ovn-encap-type="geneve,vxlan", ovn-remote="tcp:92.0.0.11:6642", system-id="c5e8ace3-24c5-4c6e-aed6-f9fc83c0a71e"} [geneve, gre, internal, ipsec_gre, lisp, patch, stt, system, tap, vxlan] [66e272e7-675d-4d3c-9b34-20fd427caed6] 36       {}           []          []  {}         []          []
    
    • 列举数据库特定列数据
    # ovs-vsctl [--if-exists] [--columns=Column[,Column]...] list [Table] [Record]
    
    ### 查询Open_vSwitch表所有行的external_ids、iface_types列数据
    # ovs-vsctl --columns=external_ids,iface_types  list Open_vSwitch
    external_ids        : {ovn-encap-ip="92.0.0.12", ovn-encap-type="geneve,vxlan", ovn-remote="tcp:92.0.0.11:6642", system-id="c5e8ace3-24c5-4c6e-aed6-f9fc83c0a71e"}
    iface_types         : [geneve, gre, internal, ipsec_gre, lisp, patch, stt, system, tap, vxlan]
    
    ### 查询Open_vSwitch表对应行的external_ids列数据
    # ovs-vsctl --columns=external_ids  list Open_vSwitch 7c18c5c5-f9ad-483d-84bb-5328707b9159
    external_ids        : {ovn-encap-ip="92.0.0.12", ovn-encap-type="geneve,vxlan", ovn-remote="tcp:92.0.0.11:6642", system-id="c5e8ace3-24c5-4c6e-aed6-f9fc83c0a71e"}
    
    • 查询数据库表项值
    # ovs-vsctl [--if-exists] get [Table] [Record] [Column[:Key]]
    
    ### 查询Open_vSwitch表对应行的external_ids列的system-id键值
    # ovs-vsctl --if-exists get Open_vSwitch 7c18c5c5-f9ad-483d-84bb-5328707b9159  external_ids:system-id
    "c5e8ace3-24c5-4c6e-aed6-f9fc83c0a71e"
    # ovs-vsctl get open . external-ids:system-id
    
    • 设置数据库表项值
    # ovs-vsctl [--if-exists] set [Table] [Record] [Column[:Key]=Value]
    
    ### 设置Open_vSwitch表对应行的external_ids列的ovn-encap-type键值
    # ovs-vsctl --if-exists set Open_vSwitch 7c18c5c5-f9ad-483d-84bb-5328707b9159  external_ids:ovn-encap-type="geneve"
    
    • 删除数据库表项值
    # ovs-vsctl [--if-exists] remove [Table] [Record] [Column] [[Key]=Value]
    
    ### 删除Open_vSwitch表对应行的external_ids列的ovn-encap-type键
    # ovs-vsctl --if-exists remove Open_vSwitch 7c18c5c5-f9ad-483d-84bb-5328707b9159  external_ids ovn-encap-type="geneve"
    
    • 添加数据库表项
    # ovs-vsctl [--if-exists] add [Table] [Record] [Column] [[Key]=Value]
    
    ### 为Open_vSwitch表对应行的external_ids列添加ovn-encap-type键(不知道为啥不能添加"geneve,vxlan")
    # ovs-vsctl --if-exists add Open_vSwitch 7c18c5c5-f9ad-483d-84bb-5328707b9159  external_ids ovn-encap-type="geneve"
    
    • 清空数据库表行
    # ovs-vsctl [--if-exists] clear [Table] [Record] [Column]
    
    ### 为Open_vSwitch表对应行的external_ids列添加ovn-encap-type键(不知道为啥不能添加"geneve,vxlan")
    # ovs-vsctl --if-exists clear Open_vSwitch 7c18c5c5-f9ad-483d-84bb-5328707b9159  external_ids
    
  • 相关阅读:
    数据库基本操作
    守护线程
    线程使用的场景
    创建多线程
    用正则表达式去截取网页里文字的方法。参数为读取的网页源代码
    文章生成器,Split方法截取字符串。从硬盘读取文件,和向硬盘存储文件参考代码
    winform 阶段学习总结
    Windowform 窗体关联数据库存储,读取图片,参考代码
    windows form窗体应用程序,建一个记事本参考代码,重点是打开,保存,另存为
    js实现相册翻页,滚动,切换,轮播功能
  • 原文地址:https://www.cnblogs.com/silvermagic/p/7666058.html
Copyright © 2011-2022 走看看