若能避开猛烈的欢喜,自然也不会有悲痛的来袭。

Centos6.x/7.x升级内核版本

前言

由于安装Docker时,Docker支持

  • CentOS 7 (64-bit)
  • CentOS 6.5 (64-bit) 或更高的版本

Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。
Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本

CentOS 7 的内核一般都是3.10的,而CentOS 6.X 的内核一般都是2.6,在2.6的内核下,Docker运行会比较卡,所以一般会选择升级到3.10版本。

升级内核的方式,网上有很多方法是下载内核然后编译,这样需要安装很多必备的环境和工具,比较麻烦,但是也有助于我们了解内核的编译

编译内核方式升级:
https://segmentfault.com/a/1190000000733628#articleHeader13

1. 查看当前内核版本

[root@linux-code.com ~]# more /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
[root@linux-code.com ~]# uname -a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

2. 导入public key

[root@linux-code.com ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

3. 安装ELRepo到CentOS

可以去http://elrepo.org/tiki/tiki-index.php 选择要安装的ELRepo

[root@linux-code.com ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm

4. 安装 kernel-lt(lt=long-term)

[root@linux-code.com ~]# yum --enablerepo=elrepo-kernel install kernel-lt -y

或者 安装kernel-ml(ml=mainline)

[root@linux-code.com ~]# yum --enablerepo=elrepo-kernel install kernel-ml -y

5. 编辑grub.conf文件,修改Grub引导顺序

[root@linux-code.com ~]# vim /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/vda1 console=ttyS0 console=tty0 printk.time=1 panic=5
# initrd /boot/initrd-[generic-]version.img
#boot=/dev/sda
default=1   ##此处为应该修改的值
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=3 console serial
title CentOS (2.6.32-696.6.3.el6.x86_64)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-696.6.3.el6.x86_64 ro root=/dev/vda1 console=ttyS0 console=tty0 printk.time=1 panic=5 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=C rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_NO_LVM crashkernel=auto rd_NO_DM
initrd /boot/initramfs-2.6.32-696.6.3.el6.x86_64.img
title CentOS (2.6.32-504.30.3.el6.x86_64)
root (hd0,0)

因为一般新安装的内核在第一个位置,所以设置default=0,表示启动新内核

6. 重启

查看此时内核版本:

[root@linux-code.com ~]# uname -r
3.10.105-1.el6.elrepo.x86_64

成功!

赞(12) 打赏
转载请注明出处:RokasYang's Blog » Centos6.x/7.x升级内核版本

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫