1. 安裝依賴
yum -y install make gcc openssl-devel autoconf automake rpm-build redhat-rpm-config
yum -y install python-devel openssl-devel kernel-devel kernel-debug-devel libtool wget
2.下載openvswitch
wget https://www.openvswitch.org/releases/openvswitch-2.12.0.tar.gz
3.處理
mkdir -p ~/rpmbuild/SOURCES
cp openvswitch-2.12.0.tar.gz rpmbuild/SOURCES/
cd rpmbuild/SOURCES
tar xf openvswitch-2.12.0.tar.gz
sed 's/openvswitch-kmod, //g' openvswitch-2.12.0/rhel/openvswitch.spec > openvswitch-2.12.0/rhel/openvswitch_no_kmod.spec
4. 構建rom包
rpmbuild -bb --nocheck openvswitch-2.12.0/rhel/openvswitch_no_kmod.spec
4.1構建rpm包報錯
[root@kubernetes ~/rpmbuild/SOURCES]# rpmbuild -bb --nocheck openvswitch-2.12.0/rhel/openvswitch_no_kmod.spec
error: Failed build dependencies:
python-six is needed by openvswitch-2.12.0-1.x86_64
selinux-policy-devel is needed by openvswitch-2.12.0-1.x86_64
python-sphinx is needed by openvswitch-2.12.0-1.x86_64
unbound-devel is needed by openvswitch-2.12.0-1.x86_64
解決:
yum -y install python-six selinux-policy-devel python-sphinx unbound-devel
4.2 報錯信息
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.W9I5fj (%build)
解決:
yum groupinstall "Development Tools"
5. 安裝
yum localinstall ~/rpmbuild/RPMS/x86_64/openvswitch-2.12.0.x86_64.rpm
6. 啓動
systemctl start openvswitch