How to update the kernel on CentOS?
Jul 02, 2025 am 12:30 AM更新 CentOS 內(nèi)核的關(guān)鍵在于使用 ELRepo 倉庫并正確設(shè)置啟動項(xiàng)。1. 首先運(yùn)行 uname -r 查看當(dāng)前內(nèi)核版本;2. 安裝 ELRepo 倉庫并導(dǎo)入密鑰;3. 使用 yum 安裝 kernel-lt(長期支持版)或 kernel-ml(主線版);4. 安裝完成后通過 awk 命令查看可用內(nèi)核并使用 grub2-set-default 設(shè)置默認(rèn)啟動項(xiàng);5. 生成新的 GRUB 配置文件 grub2-mkconfig -o /boot/grub2/grub.cfg;6. 最后重啟系統(tǒng)并再次運(yùn)行 uname -r 確認(rèn)內(nèi)核版本是否生效。整個過程需注意選擇合適內(nèi)核、確保默認(rèn)啟動項(xiàng)正確,避免系統(tǒng)無法啟動或重復(fù)安裝。
更新 CentOS 的內(nèi)核其實(shí)不算太難,但需要注意幾個關(guān)鍵點(diǎn)。很多人在升級內(nèi)核時擔(dān)心系統(tǒng)不穩(wěn)定或者啟動失敗,其實(shí)只要按照標(biāo)準(zhǔn)流程操作,問題不大。
查看當(dāng)前內(nèi)核版本
更新之前,第一步是確認(rèn)你現(xiàn)在的內(nèi)核版本,這樣方便對比是否真的更新成功了。
你可以運(yùn)行下面這條命令查看:
uname -r
輸出結(jié)果類似這樣:
3.10.0-1160.el7.x86_64
這個信息能告訴你目前用的是哪個內(nèi)核版本,也方便后面判斷是否需要更新。
使用 ELRepo 倉庫安裝新內(nèi)核
CentOS 默認(rèn)的軟件源里提供的內(nèi)核版本可能不是最新的,所以推薦使用 ELRepo 這個第三方倉庫來安裝更新的內(nèi)核版本。
步驟如下:
安裝 ELRepo 倉庫密鑰和倉庫配置:
rpm --import http://www.miracleart.cn/link/718d59ade166b11b3ec4ef5c4e6abfe6RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-7-5.el7.elrepo.noarch.rpm
啟用 ELRepo 并安裝長期支持版(LTS)或主線版(mainline)內(nèi)核:
如果你想安裝長期支持的穩(wěn)定內(nèi)核,可以運(yùn)行:
yum --enablerepo=elrepo-kernel install kernel-lt
如果想要最新功能、不介意稍微冒險一點(diǎn),可以選擇主線版本:
yum --enablerepo=elrepo-kernel install kernel-ml
安裝完成后不會立即生效,需要重啟系統(tǒng)并選擇新內(nèi)核啟動。
修改默認(rèn)啟動內(nèi)核
CentOS 使用 GRUB2 管理啟動菜單,安裝完新內(nèi)核后,你需要設(shè)置它為默認(rèn)啟動項(xiàng)。
首先查看可用的內(nèi)核選項(xiàng):
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
輸出大概像這樣:
0 : CentOS Linux (5.4.123-1.el7.elrepo.x86_64) 7 (Core) 1 : CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)
設(shè)置默認(rèn)啟動項(xiàng)為新安裝的內(nèi)核:
grub2-set-default 0
最后生成新的 GRUB 配置文件(有些系統(tǒng)不需要這一步,但加上更保險):
grub2-mkconfig -o /boot/grub2/grub.cfg
完成這些之后就可以重啟了:
reboot
重啟后再次運(yùn)行 uname -r
來確認(rèn)是否已經(jīng)切換到新內(nèi)核。
基本上就這些。整個過程不復(fù)雜,但有幾個容易忽略的地方:比如忘記修改默認(rèn)啟動項(xiàng)、沒檢查當(dāng)前內(nèi)核版本導(dǎo)致重復(fù)安裝,或者誤選了不太穩(wěn)定的主線內(nèi)核。只要你按上面的步驟一步步來,一般不會出錯。
The above is the detailed content of How to update the kernel on CentOS?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

Software preparation I am using a virtual machine with CentOS-6.6, with the host name repo. Refer to the steps to install a Linux virtual machine in Windows, I installed JDK in that virtual machine, refer to the guide to installing JDK in Linux. In addition, the virtual machine is configured with a key-free login itself, and the settings for configuring key-free login between each virtual machine are referenced. The download address of Hadoop installation package is: https://mirrors.aliyun.com/apache/hadoop/common/. I am using hadoop 2.6.5 version. Upload the Hadoop installation package to the server and unzip [root@repo~]#tarzxv

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

1. The Origin of .NETCore When talking about .NETCore, we must not mention its predecessor .NET. Java was in the limelight at that time, and Microsoft also favored Java. The Java virtual machine on the Windows platform was developed by Microsoft based on JVM standards. It is said to be the best performance Java virtual machine at that time. However, Microsoft has its own little abacus, trying to bundle Java with the Windows platform and add some Windows-specific features. Sun's dissatisfaction with this led to a breakdown of the relationship between the two parties, and Microsoft then launched .NET. .NET has borrowed many features of Java since its inception and gradually surpassed Java in language features and form development. Java in version 1.6

Common problems and solutions for Hadoop Distributed File System (HDFS) configuration under CentOS When building a HadoopHDFS cluster on CentOS, some common misconfigurations may lead to performance degradation, data loss and even the cluster cannot start. This article summarizes these common problems and their solutions to help you avoid these pitfalls and ensure the stability and efficient operation of your HDFS cluster. Rack-aware configuration error: Problem: Rack-aware information is not configured correctly, resulting in uneven distribution of data block replicas and increasing network load. Solution: Double check the rack-aware configuration in the hdfs-site.xml file and use hdfsdfsadmin-printTopo

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size
