OpenVSwitch基础-安装、配置、Simple Topology Test Case.
OVS Build and Install
Download source code
1
$wget http://openvswitch.org/releases/openvswitch-2.7.0.tar.gz
Build
1
2
3
4
5$tar zxvf openvswitch-2.7.0.tar.gz
$cd openvswitch-2.7.0
$./boot.sh
$./configure --with-linux=/lib/modules/`uname -r`/build 2>/dev/null
$make && make installInsmod openvswitch.ko
1
2
3
4
5
6$modprobe datapath/linux/openvswitch
root@dev:~# lsmod |grep open
openvswitch 70005 0
vxlan 30555 1 openvswitch
gre 4796 1 openvswitch
libcrc32c 1212 2 dm_persistent_data,openvswitchStart
Create ovsdb1
2$mkdir -p /usr/local/etc/openvswitch
$ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
Launch ovsdb-server1
$ovsdb-server -v --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --pidfile --detach --log-file
Init ovsdb1
$ovs-vsctl --no-wait init
Start ovs-vswitchd1
$ovs-vswitchd --pidfile --detach --log-file
OVS Commands
ovs-vsctl
Open vSwitch commands:1
2init //initialize database, if not yet initialized
show //print overview of database contents
Bridge commands:1
2
3add-br BRIDGE //create a new bridge named BRIDGE
del-br BRIDGE //delete BRIDGE and all of its ports
list-br //print the names of all the bridges
Port commands:1
2
3list-ports BRIDGE //print the names of all the ports on BRIDGE
add-port BRIDGE PORT //add network device PORT to BRIDGE
del-port [BRIDGE] PORT //delete PORT (which may be bonded) from BRIDGE
1 | ovsdb-tool show-log |
Simple Topology
Configure for using OVS
1 | ovs-vsctl add-br br0 |
1 | ip netns add beijing |
1 | ip link set veth-b up |
1 | ip link set eth0-b netns beijing |
1 | ip netns exec beijing ping 10.0.0.2 |
1 |
|
1 | ovs-vsctl show |