centos7升级内核(5.0.5)并开启ipvs
设置网桥包经IPTables,core文件生成路径
echo """
vm.swappiness = 0
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
""" > /etc/sysctl.conf
sysctl -p
升级内核
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm ;yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y
调整grub2
查看启动列表:
[root@node03 ~]# awk -F \' '=="menuentry " {print i++ " : " ' /etc/grub2.cfg
0 : CentOS Linux (5.0.5-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (4.20.4-1.el7.elrepo.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-957.1.3.el7.x86_64) 7 (Core)
3 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
4 : CentOS Linux (0-rescue-e330e4a1694b45aeb2e5a389909f12d9) 7 (Core)}
查看当前entry:
[root@node03 ~]# grub2-editenv list
saved_entry=CentOS Linux (4.20.4-1.el7.elrepo.x86_64) 7 (Core)
修改默认entry,重启以更换内核:
[root@node03 ~]# grub2-set-default 0
[root@node03 ~]# grub2-editenv list
saved_entry=0
[root@node03 ~]# sync
[root@node03 ~]# reboot
确认内核版本后,开启IPVS 注意有$符号被html渲染掉了
uname -a
cat > /etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
ipvs_modules="ip_vs ip_vs_lc ip_vs_wlc ip_vs_rr ip_vs_wrr ip_vs_lblc ip_vs_lblcr ip_vs_dh ip_vs_sh ip_vs_fo ip_vs_nq ip_vs_sed ip_vs_ftp nf_conntrack"
for kernel_module in ${ipvs_modules}; do
/sbin/modinfo -F filename ${kernel_module} > /dev/null 2>&1
if [ $? -eq 0 ]; then
/sbin/modprobe ${kernel_module}
fi
done
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep ip_vs
脚本实现:
#!/bin/bash
cd `dirname $0`
GRUB_CFG=/boot/grub2/grub.cfg
if rpm -q kernel-4.14.49 &> /dev/null; then
exit
fi
cp $GRUB_CFG{,.bak}
rpm -ivh kernel-4.14.49-1.x86_64.rpm
# rpm -ivh kernel-devel-4.14.49-1.x86_64.rpm
sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=0/g' /etc/default/grub
grub2-mkconfig -o $GRUB_CFG
mv /boot/grub2/grubenv{,.bak}
https://github.com/sealyun/kernel/releases/tag/v4.14.49