Changes between Version 2 and Version 3 of Documentation/fSDN/aSwitchImage


Ignore:
Timestamp:
Jul 10, 2012, 6:09:22 AM (12 years ago)
Author:
akoshibe
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/fSDN/aSwitchImage

    v2 v3  
    1 = Installing Open vSwitch on a node =
    2 This page describes how to install Open vSwitch on a sandbox node. Open vSwitch is a software !OpenFlow switch implementation designed to run on a PC. More information about the software can be found [http://openvswitch.org/ here]. The docs provided online are a bit outdated at this point; The installation steps followed here is INSTALL.Linux, included with the Open vSwitch tarball (but attached to this page for your convenience).   
     1= Installation and Usage of Open vSwitch =
     2This page describes how to install and use OpenVSwitch (OVS). OVS is a software switch implementation designed to run on Linux. More information about the software can be found [http://openvswitch.org/ here].
     3----
     4= I Installation =
     5OVS can be installed either from source or from binaries. 
    36
    4 == 1.Prerequisites ==
    5 The node used here is a NetFPGA cube, the standard node for !SandBox9. The node was imaged with ubuntu.ndz, based on Ubuntu 10.10 (Maverick). A few steps are needed before we begin fetching the install file or any of its dependencies. On the node:
     7For installation from source, the steps followed here are based on the contents of INSTALL.Linux, included with the OVS tarball and also found [http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.Linux;hb=HEAD here](also attached at the end of this page for your convenience). It should be found under the OVS root directory.     
    68
    7 1. Run 'apt-get update'. If this fails, repeat after replacing all instances of 'apt:9999' with 'us.archive.ubuntu.com' in /etc/apt/sources.list .
     9== 1.1 Prerequisites ==
     10The node used here is a NetFPGA cube, the standard node for !SandBox9. The node was imaged with ubuntu.ndz, based on Ubuntu 10.10 (Maverick). The steps have been tested successfully with up to Ubuntu 12.04.
     11
     12== 1.2 Method 1: from source ==
     13== 1.2.1 Fetch source and dependencies ==
     141. If your Ubuntu install is still fresh, run 'apt-get update'. If this fails, repeat after replacing all instances of 'apt:9999' with 'us.archive.ubuntu.com' in /etc/apt/sources.list .
    815
    9162. Install packages for Open Vswitch:
     
    1219}}}
    1320
    14 3. Fetch and untar Open vSwitch (don't do anything to it yet):
     213. Fetch OVS tarball and untar. the latest source can be found at http://openvswitch.org/download/ .
    1522{{{
    1623cd ~/
    17 wget http://openvswitch.org/releases/openvswitch-1.1.1.tar.gz
     24wget http://openvswitch.org/releases/openvswitch-1.6.1.tar.gz
    1825tar -xf openvswitch-1.1.1.tar.gz
    1926}}}
    2027
    21 4. Upgrade the kernel to 2.6.35-30, as 2.6.35-25's kernel header packages are broken (otherwise '2.6.35-30-generic' in the following commands can be replaced with !`uname -r`).
    22 {{{
    23 apt-get install linux-headers-2.6.35-30-generic linux-image-2.6.35-30-generic
    24 reboot
    25 apt-get install linux-source-2.6.35
    26 }}}
    27 When linux-image is installed, grub is updated so that the newest kernel is loaded automatically upon next reboot. Re-installing linux-source after reboot should install the proper version for the new kernel.
    28 
    29 == 2. Installation ==
    30 On Debian (and its variants), Open vSwitch must be built as a kernel module. If everything is sound, installing Open vSwitch should be little more than following the steps in INSTALL.Linux, found under the untarred Open vSwitch root directory.
     284. Build. On Debian (and its variants), Open vSwitch must be built as a kernel module. If everything is sound, installing OVS should be little more than following the steps in INSTALL.Linux.
    3129{{{
    3230cd ~/openvswitch-1.1.1
     
    3735}}}
    3836
    39 Then, instantiate the kernel module:
     375. instantiate the kernel module:
    4038{{{
    4139insmod datapath/linux-2.6/openvswitch_mod.ko
    4240}}}
    4341
    44 == 2.1. Sanity checks ==
    45 If things are not well, here are some things worth checking:
     42=== 1.2.2 Some Sanity Checks. ===
     43If things don't go well, here are some things worth checking:
    4644
    47451. Check /usr/src/linux-headers-!`uname -r`/.config for the following kernel configs:
     
    6058lrwxrwxrwx 1 root root 40 2011-07-26 13:41 /lib/modules/2.6.35-30-generic/build -> /usr/src/linux-headers-2.6.35-30-generic
    6159}}}
    62 This directory should contain (mostly) unbroken links. If not, repeat step 3 of the prerequisites with another kernel version.
     60This directory should contain (mostly) unbroken links. If not, repeat step 3 of the prerequisites with another kernel version, e.g. by upgrading the kernel as follows:
    6361
     62{{{
     63apt-get install linux-headers-2.6.35-30-generic linux-image-2.6.35-30-generic
     64reboot
     65apt-get install linux-source-2.6.35
     66}}}
     67When linux-image is installed, grub is updated so that the newest kernel is loaded automatically upon next reboot. Re-installing linux-source after reboot should install the proper version for the new kernel.
     68 
    64694. Modules may not get loaded properly; look for Open vSwitch modules with `lsmod`:
    6570{{{
     
    70755. In general, `dmesg` can be used to check for various anomalies when things e.g. insmod fail silently. 
    7176
    72 == References ==
     77== 1.3 Method 2: from binaries ==
     78
     79== 1.4 Section I References ==
    7380The following links were referenced but aren't relevant overall; this is just for citation.
    7481
     
    7784 * https://help.ubuntu.com/community/Kernel/Compile
    7885 * http://ubuntuguide.net/ubuntu-11-04-upgrade-linux-kernel-to-2-6-39-0
     86
     87----
     88= II Running OVS. =
     89OVS has three main components that must be initialized:
     90 * openvswitch_mod.ko, the OVS kernel module
     91 * ovsdb, the database containing configurations
     92 * ovs-vswitchd, the OVS switch daemon
     93The daemon configures itself using the data provided by the database; `ovs-vsctl` is used to modify the contents of the database in order to configure the OVS switch at runtime.
     94
     95== 2.1 Initialization ==
     96 1. Load openVswitch kernel module
     97{{{
     98 cd datapath/linux/
     99 insmod openvswitch_mod.ko
     100}}}
     101Note, OVS and Linux bridging may not be used at the same time. This step will fail if the bridge module (bridge.ko) is loaded. You may need to reboot the node in order to unload bridge.ko.[[BR]]   
     102If this is the first time OVS is being run, make am openvswitch directory in /usr/local/etc/ and run `ovsdb-tool` to create the database file:
     103{{{
     104 mkdir -p /usr/local/etc/openvswitch
     105 ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
     106}}}
     107 2. Start ovs-db:
     108{{{
     109 ovsdb/ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
     110        --remote=db:Open_vSwitch,manager_options \
     111        --pidfile --detach
     112}}}
     113 3. Initialize the database:
     114{{{
     115 utilities/ovs-vsctl --no-wait init
     116}}}
     117the `--no-wait` allows the database to be initialized before ovs-vswitchd is invoked.
     118 4. Start ovs-vswitchd:
     119{{{
     120 vswitchd/ovs-vswitchd unix:/usr/local/var/run/openvswitch/db.sock --pidfile --detach
     121}}}
     122The 'unix:...db.sock' specifies that the process attach to the socket opened by `ovsdb`. 
     123
     124== 2.2 Configuring OVS ==
     125Once OVS is running, virtual switches may be created and configured. In general, a virtual switch is comprised of a bridge interface (usually named br''x''), and one or more interfaces associated with it. A single vswitchd can control multiple virtual switches with arbitrary number of ports each.   
     126 
     127=== 2.2.1 Creating virtual switches ===
     128The following steps create a bridge interface (br0) and associate an interface to it:
     129{{{
     130 ovs-vsctl add-br br0
     131 ovs-vsctl add-port br0 eth0
     132}}}
     133The same steps can be used to add VLAN interfaces:
     134{{{
     135 ovs-vsctl add-port br0 eth0.222
     136}}}
     137In this case, the ports added to the bridge interface are trunked by default. Using the option tag=VLAN ID makes the interfaces behave as access ports for the VLAN ID specified:
     138{{{
     139 ovs-vsctl add-port br0 eth0.111 tag=111
     140 ovs-vsctl add-port br0 eth0.222 tag=222
     141}}}
     142=== 2.2.2 Network configuration ===
     143The bridge interface can be configured like any other *nic interface. Its configurations may be stored in /etc/network/interfaces for persistence.
     144
     145== 2.3 OVS with !OpenFlow ==
     146OVS switches may be run as !OpenFlow switches. The following steps describe how to run OVS in !OpenFlow mode.
     147 
     148 1. If it has not been done already, fire up an !OpenFlow controller. The procedures for this step differ according to the controller in use, and are discussed in the pages for each respective controller. [[BR]]
     149
     150A sanity check for this step is to test your virtual switch with the OVS built-in controller, `ovs-controller`, which may be initialized on the same node running OVS:
     151{{{
     152ovs-controller -v ptcp:6633
     153}}}   
     154When ovs-controller is used, the controller IP is, unsurprisingly, 127.0.0.1.
     155 2. Point ovs-vswitchd to the !OpenFlow controller.
     156{{{
     157ovs-vsctl set-controller br0 tcp:172.16.0.14:6633
     158}}}
     159In this example, the OVS process is pointed to a BSN controller (kvm-big) on 172.16.0.14, listening on port 6633. With a properly initialized and configured database, `ovs-vswitchd` will spit out a bunch of messages as it attempts to connect to the controller. Its output should look something similar to this:
     160{{{
     161root@node1-4:/opt/openvswitch-1.2.2# vswitchd/ovs-vswitchd unix:/usr/local/var/run/openvswitch/db.sock --pidfile --detach
     162Nov 07 17:37:02|00001|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock: connecting...
     163Nov 07 17:37:02|00002|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock: connected
     164Nov 07 17:37:02|00003|bridge|INFO|created port br0 on bridge br0
     165Nov 07 17:37:02|00004|bridge|INFO|created port eth0.101 on bridge br0
     166Nov 07 17:37:02|00005|bridge|INFO|created port eth0.102 on bridge br0
     167Nov 07 17:37:02|00006|ofproto|INFO|using datapath ID 0000002320b91d13
     168Nov 07 17:37:02|00007|ofproto|INFO|datapath ID changed to 000002972599b1ca
     169Nov 07 17:37:02|00008|rconn|INFO|br0<->tcp:172.16.0.14:6633: connecting...
     170}}}
     171The !OpenvSwitch !OpenFlow switch should be functional as soon as it finds and connects to the controller. As you can see above, a DPID is chosen at random; if a random DPID does not suit your needs, a DPID may be specified manually using ovs-vsctl:
     172{{{
     173ovs-vsctl set bridge <mybr> other-config:datapath-id=<datapathid>
     174}}} 
     175Where <datapathid> is a 16-digit hex value. For our network node, this becomes:
     176{{{
     177ovs-vsctl set bridge br0 other-config:datapath-id=0000009900113300
     178}}}
     179Once running, all typical things applicable to an !OpenFlow switch applies to the running OVS switch.