Centos7.4安裝openvswitch
openvSwitch是一種基於開源Apache 2許可證的多層軟件交換機。openvSwitch非常適合在VM環境中用作虛擬交換機。除了將標準控制和可視化接口暴露給虛擬網絡層之外,它還旨在支持跨多個物理服務器的分發。Open vSwitch支持多種基於Linux的虛擬化技術,包括Xen / XenServer,KVM和VirtualBox。
其主要組成部分是:
ovs-vswitchd,一個實現交換機的守護程序,以及用於基於流的切換的配套Linux內核模塊。
ovsdb-server是一個輕量級數據庫服務器,ovs-vswitchd查詢以獲取其配置。
ovs-dpctl是配置交換機內核模塊的工具。用於構建Citrix XenServer和Red Hat Enterprise Linux的RPM的腳本和規範。XenServer RPM允許將Open vSwitch安裝在Citrix XenServer主機上,作為替代其交換機的附加功能。
ovs-vsctl,用於查詢和更新ovs-vswitchd的配置的實用程序。
ovs-appctl,一個向運行Open vSwitch守護程序發送命令的實用程序。
1.安裝openvswitch相關的軟件包
[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[[email protected] ~]# yum install gcc pkgconfig autoconf automake libtool git make python-devel openssl-devel kernel-devel kernel-debug-devel -y
2.克隆openvswitch源
[[email protected] ~]# git clone https://github.com/openvswitch/ovs.git
3.運行boot.sh以構建“configure”腳本
[[email protected] ovs]# ./boot.sh
4.編譯並安裝源碼包
[[email protected] ovs]# ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
[[email protected] ovs]# ./configure CC=gcc
[[email protected] ovs]# ./configure --with-linux=/lib/modules/$(uname -r)/build
在這裏安裝報錯了:configure: error: source dir /lib/modules/3.10.0-693.el7.x86_64/build doesn‘t exist
我們把它的軟連接刪除,重新生成一個新的鏈接。
[[email protected] 3.10.0-693.el7.x86_64]# rm build
[[email protected] 3.10.0-693.el7.x86_64]# ln -s /usr/src/kernels/3.10.0-693.2.2.el7.x86_64/ build
在執行以下剛才編譯的命令。
[[email protected] ovs]# make -j 4 && make install
5.加載所需的內核模塊
[[email protected] ovs]# modprobe openvswitch
[[email protected] ovs]# lsmod | grep openvswitch
6.啟動openvswitch相關應用程序
[[email protected] ovs]# export PATH=$PATH:/usr/local/share/openvswitch/scripts
[[email protected] ovs]# ovs-ctl start
7.創建數據庫
[[email protected] ovs]# mkdir -p /usr/local/etc/openvswitch
[[email protected] ovs]# ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
[[email protected] ovs]# ovsdb-server /usr/local/etc/openvswitch/conf.db \
> --remote=punix:/usr/local/var/run/openvswitch/db.sock \
> --remote=db:Open_vSwitch,manager_options \
> --private-key=db:SSL,private_key \
> --certificate=db:SSL,certificate \
> --bootstrap-ca-cert=db:SSL,ca_cert --pidfile --detach --log-file
[[email protected] ovs]# ovs-vsctl --no-wait init
[[email protected] ovs]# ovs-vswitchd --pidfile --detach --log-file
8.創建br0
[[email protected] ovs]# ovs-vsctl add-br br0
[[email protected] ovs]# ifconfig ens33 0
[[email protected] ovs]# ovs-vsctl add-port br0 ens33
[[email protected] ovs]# ifconfig br0 192.168.3.101 netmask 255.255.255.0
[[email protected] ovs]# route add default gw 192.168.3.1 br0
[[email protected] ovs]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
link/ether 00:0c:29:30:31:a1 brd ff:ff:ff:ff:ff:ff
inet6 fe80::99d:9685:6ef2:750c/64 scope link
valid_lft forever preferred_lft forever
3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:30:31:ab brd ff:ff:ff:ff:ff:ff
inet 10.10.10.20/24 brd 10.10.10.255 scope global ens34
valid_lft forever preferred_lft forever
inet6 fe80::3133:4e5c:41dc:a507/64 scope link
valid_lft forever preferred_lft forever
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether fa:49:7c:ae:d8:c8 brd ff:ff:ff:ff:ff:ff
5: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
link/ether 00:0c:29:30:31:a1 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.101/24 brd 192.168.3.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe30:31a1/64 scope link
valid_lft forever preferred_lft forever
[[email protected] ovs]# ovs-vsctl show
ffad5abb-4aab-42e5-a6bc-29dd5fb86352
Bridge "br0"
Port "br0"
Interface "br0"
type: internal
Port "ens33"
Interface "ens33"
ovs_version: "2.8.90"
本文出自 “若不奮鬥,何以稱王” 博客,請務必保留此出處http://wangzc.blog.51cto.com/12875919/1968227
Centos7.4安裝openvswitch