First, the environment:
Host: Mac OS 10.10
Virtual machine: VirtualBox 4.3.20
Virtual machine operating system: centos7-1406
Openvswitch 2.3.0
Second, installation
1, install the dependency package: Yum-y Install openssl-devel wget kernel-devel
2. Installation and development tools: Yum Groupinstall "Development tools"
3. Add User: AddUser ovswitch, switch user and jump to user folder: Su-ovswitch
4, download Source: wget http://openvswitch.org/releases/openvswitch-2.3.0.tar.gz
5, Decompression: Tar xfz openvswitch-2.3.0.tar.gz
6, create the compilation directory: Mkdir-p ~/rpmbuild/sources
7. Remove the Openvswitch-kmod dependency package from the spec file and create a new spec file:
Sed ' s/openvswitch-kmod,//g ' Openvswitch-2.3.0/rhel/openvswitch.spec > Openvswitch-2.3.0/rhel/openvswitch_no_ Kmod.spec
8. Start compiling: rpmbuild-bb--without check ~/openvswitch-2.3.0/rhel/openvswitch_no_kmod.spec
The following error may have occurred:
Error:file/home/ovswitch/rpmbuild/sources/openvswitch-2.3.0.tar.gz:no such File or directory
WORKAROUND: CP openvswitch-2.3.0.tar.gz rpmbuild/sources
9, exit the current user to use Root:exit
10. Install the RPM files generated by the compilation:
Yum localinstall/home/ovswitch/rpmbuild/rpms/x86_64/openvswitch-2.3.0-1.x86_64.rpm
11. Start Service: Systemctl start Openvswitch.service
12. View service Status: Systemctl-l status Openvswitch.service
The following error may have occurred:
Openvswitch.service-lsb:open VSwitch Switch
Loaded:loaded (/etc/rc.d/init.d/openvswitch)
Active:activating (start) since four 2014-12-04 18:35:32 CST; 1min 30s ago
control:13694 (Openvswitch)
CGroup:/system.slice/openvswitch.service
├─13694/bin/sh/etc/rc.d/init.d/openvswitch start
├─13696/bin/sh/usr/share/openvswitch/scripts/ovs-ctl Start--system-id=random
├─13697 tee-a/var/log/openvswitch/ovs-ctl.log
├─13723 ovs-vswitchd unix:/var/run/openvswitch/db.sock-vconsole:emer-vsyslog:err-vfile:info--mlockall--no-chdir- -log-file=/var/log/openvswitch/ovs-vswitchd.log--pidfile=/var/run/openvswitch/ovs-vswitchd.pid--detach-- Monitor
├─13724 ovs-vswitchd unix:/var/run/openvswitch/db.sock-vconsole:emer-vsyslog:err-vfile:info--mlockall--no-chdir- -log-file=/var/log/openvswitch/ovs-vswitchd.log--pidfile=/var/run/openvswitch/ovs-vswitchd.pid--detach-- Monitor
└─13725 ovs-vswitchd unix:/var/run/openvswitch/db.sock-vconsole:emer-vsyslog:err-vfile:info--mlockall--no-chdir- -log-file=/var/log/openvswitch/ovs-vswitchd.log--pidfile=/var/run/openvswitch/ovs-vswitchd.pid--detach-- Monitor
December 18:35:33 localhost.localdomain openvswitch[13694]:/etc/openvswitch/conf.db does not exist ... (warning).
December 18:35:33 localhost.localdomain openvswitch[13694]: Creating empty database/etc/openvswitch/conf.db ovsdb-tool:i /O Error:/etc/openvswitch/conf.db:failed to lock Lockfile (Resource temporarily unavailable)
December 18:35:33 Localhost.localdomain openvswitch[13694]: [FAILED]
December 18:35:33 localhost.localdomain openvswitch[13694]: Inserting openvswitch module [OK]
Workaround:
Yum Install policycoreutils-python.x86_64 0:2.2.5-11.el7
Mkdir/etc/openvswitch
Semanage fcontext-a-T openvswitch_rw_t "/etc/openvswitch (/.*)?"
Restorecon-rv/etc/openvswitch
Re-use:
Systemctl Stop Openvswitch.service
Systemctl Start Openvswitch.service
Check Service status again: Systemctl-l status Openvswitch.service
Openvswitch.service-lsb:open VSwitch Switch
Loaded:loaded (/etc/rc.d/init.d/openvswitch)
Active:active (running) since four 2014-12-04 18:38:52 CST; 6s ago
process:13741 execstart=/etc/rc.d/init.d/openvswitch Start (code=exited, status=0/success)
CGroup:/system.slice/openvswitch.service
├─13724 ovs-vswitchd:monitoring pid 13725 (healthy)
├─13725 ovs-vswitchd unix:/var/run/openvswitch/db.sock-vconsole:emer-vsyslog:err-vfile:info--mlockall--no-chdir- -log-file=/var/log/openvswitch/ovs-vswitchd.log--pidfile=/var/run/openvswitch/ovs-vswitchd.pid--detach-- Monitor
├─13764 ovsdb-server:monitoring pid 13765 (healthy) , &NB Sp , &NB Sp , &NB Sp , &NB Sp , &NB Sp , &NB Sp , &NBSp , &NB Sp , &NB Sp
└─13765 Ovsdb-server/etc/openvswitch/conf.db-vconsole:emer-vsyslog:err-vfile:info--remote=punix:/var/run/ Openvswitch/db.sock--private-key=db:open_vswitch,ssl,private_key--certificate=db:open_vswitch,ssl,certificate- -bootstrap-ca-cert=db:open_vswitch,ssl,ca_cert--no-chdir--log-file=/var/log/openvswitch/ovsdb-server.log-- Pidfile=/var/run/openvswitch/ovsdb-server.pid--detach--monitor
December 18:38:51 Localhost.localdomain systemd[1]: Starting lsb:open vSwitch switch ...
December 18:38:51 localhost.localdomain openvswitch[13741]:/etc/openvswitch/conf.db does not exist ... (warning).
December 18:38:51 localhost.localdomain openvswitch[13741]: Creating empty database/etc/openvswitch/conf.db [OK]
December 18:38:52 Localhost.localdomain openvswitch[13741]: Starting Ovsdb-server [OK]
December 18:38:52 Localhost.localdomain openvswitch[13741]: Configuring Open vSwitch system IDs [OK]
December 18:38:52 localhost.localdomain openvswitch[13741]: Ovs-vswitchd is already running.
December 18:38:52 Localhost.localdomain openvswitch[13741]: Enabling remote OVSDB managers [OK]
December 18:38:52 localhost.localdomain systemd[1]: Started lsb:open vSwitch switch.
December 18:38:52 Localhost.localdomain openvswitch[13694]: Starting Ovs-vswitchd [OK]
December 18:38:52 Localhost.localdomain openvswitch[13694]: Enabling remote OVSDB managers [OK]
Installation is complete.
CentOS7 installing Openvswitch 2.3.0 LTS