Changes between Version 2 and Version 3 of Documentation/fSDN/aSwitchImage
- Timestamp:
- Jul 10, 2012, 6:09:22 AM (12 years ago)
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 = 2 This 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 = 5 OVS can be installed either from source or from binaries. 3 6 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: 7 For 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. 6 8 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 == 10 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). 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 == 14 1. 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 . 8 15 9 16 2. Install packages for Open Vswitch: … … 12 19 }}} 13 20 14 3. Fetch and untar Open vSwitch (don't do anything to it yet):21 3. Fetch OVS tarball and untar. the latest source can be found at http://openvswitch.org/download/ . 15 22 {{{ 16 23 cd ~/ 17 wget http://openvswitch.org/releases/openvswitch-1. 1.1.tar.gz24 wget http://openvswitch.org/releases/openvswitch-1.6.1.tar.gz 18 25 tar -xf openvswitch-1.1.1.tar.gz 19 26 }}} 20 27 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. 28 4. 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. 31 29 {{{ 32 30 cd ~/openvswitch-1.1.1 … … 37 35 }}} 38 36 39 Then,instantiate the kernel module:37 5. instantiate the kernel module: 40 38 {{{ 41 39 insmod datapath/linux-2.6/openvswitch_mod.ko 42 40 }}} 43 41 44 == 2.1. Sanity checks==45 If things are notwell, here are some things worth checking:42 === 1.2.2 Some Sanity Checks. === 43 If things don't go well, here are some things worth checking: 46 44 47 45 1. Check /usr/src/linux-headers-!`uname -r`/.config for the following kernel configs: … … 60 58 lrwxrwxrwx 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 61 59 }}} 62 This directory should contain (mostly) unbroken links. If not, repeat step 3 of the prerequisites with another kernel version .60 This 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: 63 61 62 {{{ 63 apt-get install linux-headers-2.6.35-30-generic linux-image-2.6.35-30-generic 64 reboot 65 apt-get install linux-source-2.6.35 66 }}} 67 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. 68 64 69 4. Modules may not get loaded properly; look for Open vSwitch modules with `lsmod`: 65 70 {{{ … … 70 75 5. In general, `dmesg` can be used to check for various anomalies when things e.g. insmod fail silently. 71 76 72 == References == 77 == 1.3 Method 2: from binaries == 78 79 == 1.4 Section I References == 73 80 The following links were referenced but aren't relevant overall; this is just for citation. 74 81 … … 77 84 * https://help.ubuntu.com/community/Kernel/Compile 78 85 * http://ubuntuguide.net/ubuntu-11-04-upgrade-linux-kernel-to-2-6-39-0 86 87 ---- 88 = II Running OVS. = 89 OVS 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 93 The 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 }}} 101 Note, 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]] 102 If 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 }}} 117 the `--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 }}} 122 The 'unix:...db.sock' specifies that the process attach to the socket opened by `ovsdb`. 123 124 == 2.2 Configuring OVS == 125 Once 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 === 128 The 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 }}} 133 The same steps can be used to add VLAN interfaces: 134 {{{ 135 ovs-vsctl add-port br0 eth0.222 136 }}} 137 In 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 === 143 The 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 == 146 OVS 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 150 A 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 {{{ 152 ovs-controller -v ptcp:6633 153 }}} 154 When ovs-controller is used, the controller IP is, unsurprisingly, 127.0.0.1. 155 2. Point ovs-vswitchd to the !OpenFlow controller. 156 {{{ 157 ovs-vsctl set-controller br0 tcp:172.16.0.14:6633 158 }}} 159 In 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 {{{ 161 root@node1-4:/opt/openvswitch-1.2.2# vswitchd/ovs-vswitchd unix:/usr/local/var/run/openvswitch/db.sock --pidfile --detach 162 Nov 07 17:37:02|00001|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock: connecting... 163 Nov 07 17:37:02|00002|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock: connected 164 Nov 07 17:37:02|00003|bridge|INFO|created port br0 on bridge br0 165 Nov 07 17:37:02|00004|bridge|INFO|created port eth0.101 on bridge br0 166 Nov 07 17:37:02|00005|bridge|INFO|created port eth0.102 on bridge br0 167 Nov 07 17:37:02|00006|ofproto|INFO|using datapath ID 0000002320b91d13 168 Nov 07 17:37:02|00007|ofproto|INFO|datapath ID changed to 000002972599b1ca 169 Nov 07 17:37:02|00008|rconn|INFO|br0<->tcp:172.16.0.14:6633: connecting... 170 }}} 171 The !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 {{{ 173 ovs-vsctl set bridge <mybr> other-config:datapath-id=<datapathid> 174 }}} 175 Where <datapathid> is a 16-digit hex value. For our network node, this becomes: 176 {{{ 177 ovs-vsctl set bridge br0 other-config:datapath-id=0000009900113300 178 }}} 179 Once running, all typical things applicable to an !OpenFlow switch applies to the running OVS switch.