• 升级Centos7的Linux内核


    启用elrepo仓库
    [root@localhost ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
    [root@localhost ~]# yum install -q -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
    
    列出可用的系统内核相关包
    [root@localhost ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
    elrepo-kernel                                                                                                        | 2.9 kB  00:00:00     
    elrepo-kernel/primary_db                                                                                             | 1.9 MB  00:00:00     
    Available Packages
    kernel-lt.x86_64                                                      4.4.218-1.el7.elrepo                                     elrepo-kernel
    kernel-lt-devel.x86_64                                                4.4.218-1.el7.elrepo                                     elrepo-kernel
    kernel-lt-doc.noarch                                                  4.4.218-1.el7.elrepo                                     elrepo-kernel
    kernel-lt-headers.x86_64                                              4.4.218-1.el7.elrepo                                     elrepo-kernel
    kernel-lt-tools.x86_64                                                4.4.218-1.el7.elrepo                                     elrepo-kernel
    kernel-lt-tools-libs.x86_64                                           4.4.218-1.el7.elrepo                                     elrepo-kernel
    kernel-lt-tools-libs-devel.x86_64                                     4.4.218-1.el7.elrepo                                     elrepo-kernel
    kernel-ml.x86_64                                                      5.6.2-1.el7.elrepo                                       elrepo-kernel
    kernel-ml-devel.x86_64                                                5.6.2-1.el7.elrepo                                       elrepo-kernel
    kernel-ml-doc.noarch                                                  5.6.2-1.el7.elrepo                                       elrepo-kernel
    kernel-ml-headers.x86_64                                              5.6.2-1.el7.elrepo                                       elrepo-kernel
    kernel-ml-tools.x86_64                                                5.6.2-1.el7.elrepo                                       elrepo-kernel
    kernel-ml-tools-libs.x86_64                                           5.6.2-1.el7.elrepo                                       elrepo-kernel
    kernel-ml-tools-libs-devel.x86_64                                     5.6.2-1.el7.elrepo                                       elrepo-kernel
    perf.x86_64                                                           5.6.2-1.el7.elrepo                                       elrepo-kernel
    python-perf.x86_64                                                    5.6.2-1.el7.elrepo                                       elrepo-kernel
    
    安装最新主线内核
    [root@localhost ~]# yum --enablerepo=elrepo-kernel install kernel-ml -y
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * elrepo: mirrors.tuna.tsinghua.edu.cn
     * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    elrepo                                                                                                               | 2.9 kB  00:00:00     
    elrepo/primary_db                                                                                                    | 394 kB  00:00:00     
    Resolving Dependencies
    --> Running transaction check
    ---> Package kernel-ml.x86_64 0:5.6.2-1.el7.elrepo will be installed
    --> Finished Dependency Resolution
    Dependencies Resolved
    ============================================================================================================================================
     Package                       Arch                       Version                                   Repository                         Size
    ============================================================================================================================================
    Installing:
     kernel-ml                     x86_64                     5.6.2-1.el7.elrepo                        elrepo-kernel                      49 M
    Transaction Summary
    ============================================================================================================================================
    Install  1 Package
    Total download size: 49 M
    Installed size: 222 M
    Downloading packages:
    kernel-ml-5.6.2-1.el7.elrepo.x86_64.rpm                                                                              |  49 MB  00:00:06     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : kernel-ml-5.6.2-1.el7.elrepo.x86_64                                                                                      1/1 
      Verifying  : kernel-ml-5.6.2-1.el7.elrepo.x86_64                                                                                      1/1 
    Installed:
      kernel-ml.x86_64 0:5.6.2-1.el7.elrepo                                                                                                     
    Complete!
    [root@localhost ~]# reboot
    启动时,选择新安装的内核进入系统
    [root@localhost ~]# uname -r
    5.6.2-1.el7.elrepo.x86_64
    
    启动系统时,系统默认选择老版本作为默认内核启动,所以我们需要设置一下GRUB,重新创建启动引导内核的配置
    [root@localhost ~]# grub2-mkconfig -o /boot/grub2/grubenv 
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-5.6.2-1.el7.elrepo.x86_64
    Found initrd image: /boot/initramfs-5.6.2-1.el7.elrepo.x86_64.img
    Found linux image: /boot/vmlinuz-3.10.0-1062.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-1062.el7.x86_64.img
    Found linux image: /boot/vmlinuz-0-rescue-8679e5dcfe0f4c3fabae0e455da948d1
    Found initrd image: /boot/initramfs-0-rescue-8679e5dcfe0f4c3fabae0e455da948d1.img
    done
    [root@localhost ~]# reboot
    
    =========================================
    如果需要删除多余的老内核版本,操作接下来的操作步骤
    Last login: Sat Apr  4 00:24:08 2020 from gateway
    [root@localhost ~]# cat /proc/version 
    Linux version 5.6.2-1.el7.elrepo.x86_64 (mockbuild@Build64R7) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)) #1 SMP Thu Apr 2 10:55:54 EDT 2020 
    
    查看安装的内核
    [root@localhost ~]# rpm -qa kernel
    kernel-3.10.0-1062.el7.x86_64
    [root@localhost ~]# uname -r
    5.6.2-1.el7.elrepo.x86_64
    
    卸载老版本内核
    [root@localhost ~]# yum remove -y -q kernel-3.10.0-1062.el7.x86_64         
    
    重新生成开机应对
    [root@localhost ~]# grub2-mkconfig -o /boot/grub2/grubenv 
    /usr/bin/grub2-editenv: error: invalid environment block.
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-5.6.2-1.el7.elrepo.x86_64
    Found initrd image: /boot/initramfs-5.6.2-1.el7.elrepo.x86_64.img
    Found linux image: /boot/vmlinuz-0-rescue-8679e5dcfe0f4c3fabae0e455da948d1
    Found initrd image: /boot/initramfs-0-rescue-8679e5dcfe0f4c3fabae0e455da948d1.img
    done
    [root@localhost ~]# reboot
    重启的时候可以看到老版本内核已经看不见了
    [root@localhost ~]# uname -r
    5.6.2-1.el7.elrepo.x86_64
    
    有趣的事,有趣的人,有趣的灵魂!
  • 相关阅读:
    04_web基础(六)之请求转发与重定向
    04_web基础(五)之cookie与session
    04_web基础(四)之servlet详解
    04_web基础(三)之进一步理解web
    04_web基础(二)之web构建
    本地密码提取工具-LAZAGNE
    免杀工具汇总
    流量取证-提取文件
    CA证书安装以及sslh协议转发
    ssh 端口转发
  • 原文地址:https://www.cnblogs.com/alusss/p/12630082.html
Copyright © 2020-2023  润新知