dl528888
作者dl528888·2015-05-15 09:49
系统运维工程师·游戏公司

Centos7升级内核到3.18的方法

字数 3340阅读 769评论 0赞 0

默认centos7的内核版本是3.10,升级的原因是为了测试openvswitch的vlan技术,默认openvswitch的2.3版本是允许centos7默认内核3.10支持,下面是软件与内核版本对比

1
2
3
4
5
6
7
8
9
10
11
12
13
   Open vSwitch   Linux kernel
   ------------   -------------
       1.4.x      2.6.18 to 3.2
       1.5.x      2.6.18 to 3.2
       1.6.x      2.6.18 to 3.2
       1.7.x      2.6.18 to 3.3
       1.8.x      2.6.18 to 3.4
       1.9.x      2.6.18 to 3.8
       1.10.x     2.6.18 to 3.8
       1.11.x     2.6.18 to 3.8
       2.0.x      2.6.32 to 3.10
       2.1.x      2.6.32 to 3.11
       2.2.x      2.6.32 to 3.14

但如何想使用gre与vxlan的话,需要内核3.12以上的

1
2
3
4
5
   Protocol    Linux Kernel
   --------    ------------
     GRE           3.11
     VXLAN         3.12
     LISP      <not upstream>

所以得升级内核,下面是升级方法

更新前,内核版本为

1
2
[root@ip-10-10-17-4 tmp]# uname -r
3.10.0-123.el7.x86_64

目前最新的内核是3.18.3为stable,是2015年1月18日更新,具体信息查看https://www.kernel.org/

下面是升级的方法:

1、导入key

1
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

如果你修改了repo的gpgcheck=0也可以不导入key

2、安装elrepo的yum源

1
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

3、安装内核

在yum的ELRepo源中,有mainline(3.18.3)这个内核版本

1
yum --enablerepo=elrepo-kernel install  kernel-ml-devel kernel-ml -y

选择了使用新安装的repo来安装3.18的内核,如果使用其他的repo,看不到3.18版本内核

更新后查看内核版本

1
2
[root@ip-10-10-17-4 tmp]# uname -r
3.10.0-123.el7.x86_64

重要:目前内核还是默认的版本,如果在这一步完成后你就直接reboot了,重启后使用的内核版本还是默认的3.10,不会使用新的3.18,想修改启动的顺序,需要进行下一步

查看默认启动顺序

1
2
3
4
awk -F' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (3.18.3-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux, with Linux 3.10.0-123.el7.x86_64
CentOS Linux, with Linux 0-rescue-893b160e363b4ec7834719a7f06e67cf

默认启动的顺序是从0开始,但我们新内核是从头插入(目前位置在0,而3.10的是在1),所以需要选择0,如果想生效最新的内核,需要

1
grub2-set-default 0

以上问题可以参考https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sec-Customizing_GRUB_2_Menu.html#sec-Changing_the_Default_Boot_Entry

然后reboot重启,使用新的内核,下面是重启后使用的内核版本

1
2
[root@ip-10-10-17-4 ~]# uname -r
3.18.3-1.el7.elrepo.x86_64

完成后内核已经是最新的了。

目前我升级后测试了2周没有发现有问题,大家如果升级过程或者升级后有问题我们可以互相沟通。

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广