设为首页 收藏本站
查看: 846|回复: 0

[经验分享] Some Insight into Open vSwitch Configuration

[复制链接]

尚未签到

发表于 2019-1-27 09:37:43 | 显示全部楼层 |阅读模式
  As you may already know, I’ve been working with Open vSwitch (OVS)  for a few weeks now, trying to wrap my head around how this open source  project works. One thing that I really struggled with—and still  struggle with, to a certain extent—is a lack of user-friendly  documentation. While there are a few posts that provide some basic  instructions, I haven’t found any good articles that provide a bit more  depth and more explanation. Maybe it’s just me, but I like to know why I’m typing certain commands, and how those commands work.
  What is>ovs-vsctl add-br or ovs-vsctl add-port.  These commands are pretty easy to understand, reasonably  well-documented in the help screens and the manpages, and provide decent  error messages back to the user if the syntax is wrong. What isn’t quite so well-documented are tasks like VLANs or LACP, and that’s where I was struggling.
  (OK, rant over.)
  Anyway, I think that I’ve finally made some progress, and I wanted to  share what I’ve found with you. (At some point in the near future, I  intend to post some “intro to OVS basics” posts to help others that  might be learning OVS for the first time like me.)
  So, let’s say that you want to set the VLANs that are allowed across  an OVS port. By default, all OVS ports are VLAN trunks, but based on my  experience you still need to set the VLANs that are allowed across the  trunk before they actually act like trunks. If you’re familiar with  Cisco switches, think of this process as using the switchport trunk allowed vlans command.
  To set the VLAN trunks for a given port, use this command:
  


  
ovs-vsctl set port  trunks=  

  Obviously, you’ll want to substitute the correct port name and VLAN >ovs-vsctl show to review the OVS configuration and determine which port(s) to configure.
  If you want to configure an OVS port as a VLAN access port, use this command:
  


  
ovs-vsctl set port  tag=  

  Again, it should go without stating, but you’ll want to substitute the correct values for your environment in the command above.
  Here’s one more example before I provide some explanation. Let’s say  that you have a bond (a NIC team or a link aggregate) and you want to  enable LACP on that bond. You’d run this command:
  

  
ovs-vsctl set port  lacp=active
  

  The “port name” in this case would be something like bond0, which is a bond you’ve created using ovs-vsctl add-bond  command. Your physical switch must be properly configured as well in  order to support LACP on the appropriate physical switch ports.
  What are these commands doing, exactly? This is the part that I  couldn’t find documented (well) anywhere. I saw lots of references to ovs-vsctl parameters like set interface or set port,  but no clear explanation of what these commands were doing, or why.  Almost every single example I saw also used these commands during the  process of creating a bridge, bond, port, or interface (not afterward).  What if you needed to modify the values after the object is created? Do  you have to delete the object and recreate it?
  Oddly enough, it was this post (which has nothing  to do with VLANs, trunks, or LACP, but instead focuses on sFlow) that  sparked my understanding. I was reading the post on how to configure OVS  for sFlow while also reviewing the manpage for ovs-vsctl when I had the epiphany: these objects (bridge, port, bond, interface) are tables in the OVSDB, so you need to use the OVSDB-related parameters for ovs-vsctl in order to modify their properties.
  Looking at the ovs-vsctl manpage (or the --help screen), you can see that there are several DB-related commands. Here’s the generic form:
  

  
ovs-vsctl   
  

  In this generic command,  would be something like set,  get, or list, and the  would be replaced by a  specific OVSDB table. For example, one such table is port. Let’s plug a specific command and a specific table into the generic form:
  

  
ovs-vsctl set port  
  

  (Did something just click with you?)
  We could continue plugging specific items into the generic form to arrive at a command like this:
  

  
ovs-vsctl set port bond0 trunks=10,20,30,40,50
  

  The trick, of course, is knowing what values to substitute into the  command to manipulate the OVS database in the right way. Fortunately,  there are a couple of commands that can help.
  To see all the OVS bridges and their settings, use this command:
  

  
ovs-vsctl list bridge
  

  To see all the OVS ports and their settings, use this command:
  

  
ovs-vsctl list port
  

  Finally, to see all the OVS interfaces and their settings, use this command:
  

  
ovs-vsctl list interface
  

  You can add a specific record to the above commands; for example, to see the settings for a port named bond0:
  

  
ovs-vsctl list port bond0
  

  This will show you the settings that are available for that particular record; you can then use ovs-vsctl set  as described earlier to set the value for a setting. This is how you  configure VLAN trunks (by setting the value of the trunks setting for a  particular port) or enable LACP (by setting the value of the LACP  setting for a particular port). These commands can be run when a record  is created, like this:
  

  
ovs-vsctl add-bond br0 bond0 eth0 eth1 lacp=active trunks=10,11,12
  

  Or you can run the commands after the record/object is created, like this:
  

  
ovs-vsctl set port bond0 lacp=active trunks=10,11,12
  

  Hopefully, this additional information and insight—which seems so simple now that I understand it—will prove helpful to others.
  If there are errors or inaccuracies in my information, please speak  up in the comments and correct me. This will also help other readers.  All courteous comments are welcome!



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-668107-1-1.html 上篇帖子: window.open參數 下篇帖子: Running Host Management on Open vSwitch
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

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