Centos内核安装中如何进行yum使用及配置
发表于:2025-02-08 作者:千家信息网编辑
千家信息网最后更新 2025年02月08日,Centos内核安装中如何进行yum使用及配置,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。因安全问题,要将Linux内核2.6.X
千家信息网最后更新 2025年02月08日Centos内核安装中如何进行yum使用及配置
Centos内核安装中如何进行yum使用及配置,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
因安全问题,要将Linux内核2.6.X的内核升级到最新的版本。
以centos6.5为例,考虑下列问题:
(1). 查看当前内核版本,网上搜索现提供的最新版本;
(2). 测试服务器可以连接网络的情况下,如何升级内核?yum仓库指向镜像网站上
(3). 测试服务器不允许连接网络的情况下,如何升级内核?下载升级包,配置私有仓库
问题1:查看当前内核版本:[root@localhost ~]# uname -r2.6.32-431.el6.x86_64网络搜索:http://mirrors.aliyun.com/centos/6/updates/x86_64/Packages/ 内核最新版本:kernel-2.6.32-754.17.1.el6.x86_64.rpm
问题2:测试服务器可以连接网络的情况下,如何升级内核2.1先对测试服务器测试连接互联网情况:
[root@localhost yum.repos.d]# ping mirrors.aliyun.com PING mirrors.aliyun.com.w.alikunlun.com (183.2.199.240) 56(84) bytes of data.64 bytes from 183.2.199.240: icmp_seq=1 ttl=57 time=8.30 ms64 bytes from 183.2.199.240: icmp_seq=2 ttl=57 time=8.54 ms64 bytes from 183.2.199.240: icmp_seq=3 ttl=57 time=8.58 ms
若出现下列情况,则配置DNS
[root@status etc]# ping mirrors.aliyun.comping: unknown host mirrors.aliyun.com[root@status etc]# ping 183.2.199.240 ---- ping IP通,但ping网址不同,DNS未设置PING 183.2.199.240 (183.2.199.240) 56(84) bytes of data.64 bytes from 183.2.199.240: icmp_seq=1 ttl=57 time=13.7 ms64 bytes from 183.2.199.240: icmp_seq=2 ttl=57 time=7.46 ms[root@status etc]# vi /etc/resolv.conf ---- 设置DNS服务器就可以了nameserver 8.8.8.8
若IP也ping不通,请核查gw和route。
2.2 Linux程序包管理知识 yum : yellowdog update Modifier; 一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器(CS架构的软件),基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包。 原理: yum程序包管理器是类似CS架构的软件: server和client Server端:先对程序包进行分类后存储到不同repository容器中; 再通过收集到大量的rpm的数据库文件中程序包之间的依赖关系数据, 生成对应的依赖关系和所需文件在本地的存放位置的说明文件(.xml格式), 存放在本地的repodata目录下供Client端取用 ; Cilent端:通过yum命令安装软件时发现缺少某些依赖性程序包, Client会根据本地的配置文件(/etc/yum.repos.d/*.repo)找到指定的Server端, 从Server端repo目录下获取说明文件xxx.xml后存储在本地/var/cache/yum中方便以后读取, 通过xxx.xml文件查找到需要安装的依赖性程序包在Server端的存放位置, 再进入Server端yum库中的指定repository容器中获取所需程序包, 下载完成后在本地实现安装. yum repository : yum repo 存储了众多的rpm包,以及包的相关元数据文件(放在特定目录下,repsdata) yum客户端 安装了yumrpm包的系统; 查看其配置文件 [root@localhost mydata]# rpm -qc yum /etc/logrotate.d/yum /etc/yum.conf ---为仓库提供公共配置 /etc/yum/version-groups.conf 还有一个 /etc/yum.repso.d/*.repo 为仓库的指向提供配置(通过读取/etc/yum.conf里面的内容) 仓库客服端的配置格式:/etc/yum.repso.d/*.repo [repositoryid] name = baseurl= url://server1/path/to/repsoitory (可以多个url,但必须是同一种仓库,作为冗余) enable=(0|1) gpgcheck=(0|1) gpgkey=url enablegroups={0|1} failovermethod={roundrobin|priority} 默认roundrobin,为随机挑选 cost 默认1000 仓库客服端的配置可用变量: $releasever : 当前os的发行版本号; &arch : 平台; $basearch : 基础平台 yum命令: [options] [command] [package ...] 显示仓库列表: repolist [all|enabled|disabled] 显示程序包: list # yum list [all | glob_exp1] [glob_exp2] [...] # yum list [availabel | installed | updates] [glob_exp1] 安装程序包: install package1 [package2] [...] 升级程序包: upgrade [package1] [package2] [...] upgrade-to [package1] [package2] [...] 降级程序包: downgrade package1 [package2] [...] 检查升级程序包: check-update 卸载程序包:remove | erase package1 [package2] [...] 查看程序包: info [...] 查看指定的特性(可以是某文件)是由哪个程序包提供: provides | whatprovides feature1 [feature2] [...] 清理本地缓存:clean [ packages | metadata | expire-cache | rpmdb | plugins | all ] 搜索: search string1 [string2] [...] 查看指定包依赖的capabilities: 查看yum的事物历史: history [info|list|packages-list|packages-info|summary|addon-info|redo|undo|rollback|new|sync|stats] 包组管理: grouplist groupinfo groupinstall group1 groupupdata group1 groupremove group1
2.3 安装步骤 升级内核: 内核可以多个存在,所有选择安装新内核保留原内核,不进行直接升级 (1)rpm --import https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 包来源合法性验证和完整性验证 来源合法性验证: 私钥 | 程序包--->校验码--->特征码---->加密特征码---客户(拿到公钥,要确保公钥来源可靠)--->解密--->对比特征码 获取并导入信息的包制作者的密钥 对于centos发行版: rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 验证: (1.1): 安装此组织签名的程序时,会自动执行; (1.2): 手动验证 rpm -k PACKAGE_FILE
[root@status tmp]# rpm -K kernel-2.6.32-754.15.3.el6.x86_64.rpm kernel-2.6.32-754.15.3.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
(2) 配置客户仓库项目:
[root@status yum.repos.d]# vi CentOS-Base.repo[updates]name=CentOS-$releasever - Updatebaseurl=https://mirrors.aliyun.com/centos/6/updates/x86_64/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[root@status yum.repos.d]# yum repolistLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfileupdates | 3.4 kB 00:00 repo id repo name statusupdates CentOS-6 - Updates 559repolist: 559
安装:
[root@status /]# yum info kernel.x86_64 ----查看当前内核的信息及最新内核Loaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfileInstalled PackagesName : kernelArch : x86_64Version : 2.6.32Release : 431.el6Size : 121 MRepo : installedFrom repo : anaconda-CentOS-201311272149.x86_64Summary : The Linux kernelURL : http://www.kernel.org/License : GPLv2Description : The kernel package contains the Linux kernel (vmlinuz), the core of any : Linux operating system. The kernel handles the basic functions : of the operating system: memory allocation, process allocation, device : input and output, etc.Available PackagesName : kernelArch : x86_64Version : 2.6.32Release : 754.17.1.el6Size : 32 MRepo : updateSummary : The Linux kernelURL : http://www.kernel.org/License : GPLv2Description : The kernel package contains the Linux kernel (vmlinuz), the core of any : Linux operating system. The kernel handles the basic functions : of the operating system: memory allocation, process allocation, device : input and output, etc.
[root@status /]# yum deplist kernel.x86_64 -----查看内核安装的依赖包 package: kernel.x86_64 2.6.32-754.17.1.el6 dependency: dracut-kernel >= 004-408.el6 Unsatisfied dependency dependency: /sbin/new-kernel-pkg Unsatisfied dependency dependency: module-init-tools Unsatisfied dependency dependency: initscripts >= 8.11.1-1 Unsatisfied dependency dependency: fileutils Unsatisfied dependency dependency: kernel-firmware >= 2.6.32-754.17.1.el6 provider: kernel-firmware.noarch 2.6.32-754.17.1.el6 dependency: /bin/sh Unsatisfied dependency dependency: grubby >= 7.0.4-1 Unsatisfied dependency
[root@status /]# yum install -y kernel.x86_64 ----安装时报依赖包未安装!!Loaded plugins: fastestmirror, securityDetermining fastest mirrorsbase | 3.4 kB 00:00 base/primary_db | 5.2 MB 00:01 Setting up Install ProcessResolving Dependencies--> Running transaction check---> Package kernel.x86_64 0:2.6.32-754.17.1.el6 will be installed--> Processing Dependency: kernel-firmware >= 2.6.32-754.17.1.el6 for package: kernel-2.6.32-754.17.1.el6.x86_64--> Processing Dependency: dracut-kernel >= 004-408.el6 for package: kernel-2.6.32-754.17.1.el6.x86_64--> Running transaction check---> Package kernel.x86_64 0:2.6.32-754.17.1.el6 will be installed--> Processing Dependency: dracut-kernel >= 004-408.el6 for package: kernel-2.6.32-754.17.1.el6.x86_64---> Package kernel-firmware.noarch 0:2.6.32-431.el6 will be updated---> Package kernel-firmware.noarch 0:2.6.32-754.17.1.el6 will be an update--> Finished Dependency ResolutionError: Package: kernel-2.6.32-754.17.1.el6.x86_64 (base) Requires: dracut-kernel >= 004-408.el6 -----需要这个依赖包!! Installed: dracut-kernel-004-335.el6.noarch (@anaconda-CentOS-201311272149.x86_64/6.5) dracut-kernel = 004-335.el6You could try using --skip-broken to work around the problemYou could try running: rpm -Va --nofiles --nodigest
依赖包在哪里呢,不在update的Packege里面,难道在系统安装的Package里面? 于是再次修改仓库配置,加入base的指向为:https://mirrors.aliyun.com/centos/6/os/x86_64/
[root@status yum.repos.d]# vi CentOS-Base.repo ----增加base的配置项[base]name=CentOS-$releasever - Basebaseurl=https://mirrors.aliyun.com/centos/6/os/x86_64/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6[update]name=CentOS-$releasever - Updatebaseurl=https://mirrors.aliyun.com/centos/6/updates/x86_64/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[root@status /]# yum repolist ----查看仓库是否配置成功Loaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfilebase | 3.7 kB 00:00 Not using downloaded repomd.xml because it is older than what we have: Current : Thu Jul 25 00:22:12 2019 Downloaded: Fri Jun 29 23:37:23 2018update | 3.4 kB 00:00 repo id repo name statusbase CentOS-6 - Base 559update CentOS-6 - Update 559repolist: 1,118
再次执行yum install -y kernel.x86_64 依然报错!!??看看上面的yum repolist,base和update的Package包数目都是一样的,base没有更新仓库信息,晕死。
[root@status /]# yum clean all ----清空本地缓存Loaded plugins: fastestmirror, securityCleaning repos: base updateCleaning up EverythingCleaning up list of fastest mirrors[root@status /]# yum repolist ----查看仓库是否配置成功,这次仓库信息同步了Loaded plugins: fastestmirror, securityDetermining fastest mirrorsbase | 3.7 kB 00:00 base/primary_db | 4.7 MB 00:01 update | 3.4 kB 00:00 update/primary_db | 5.2 MB 00:00 repo id repo name statusbase CentOS-6 - Base 6,713update CentOS-6 - Update 559repolist: 7,272
[root@status /]# yum install -y kernel.x86_64Loaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfileSetting up Install ProcessResolving Dependencies ......Dependencies Resolved..... Installed: kernel.x86_64 0:2.6.32-754.17.1.el6 Dependency Updated: ----这几个依赖安装包被update了 dracut.noarch 0:004-411.el6 dracut-kernel.noarch 0:004-411.el6 kernel-firmware.noarch 0:2.6.32-754.17.1.el6 Complete!
查看引导内核项
[root@status etc]# cat grub.conf # grub.conf generated by anaconda## Note that you do not have to rerun grub after making changes to this file# NOTICE: You have a /boot partition. This means that# all kernel and initrd paths are relative to /boot/, eg.# root (hd0,0)# kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root# initrd /initrd-[generic-]version.img#boot=/dev/sdadefault=0timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle CentOS (2.6.32-754.17.1.el6.x86_64) ----新安装的内核,使用排头位的 root (hd0,0) kernel /vmlinuz-2.6.32-754.17.1.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-754.17.1.el6.x86_64.imgtitle CentOS (2.6.32-431.el6.x86_64) ----原来的内核 root (hd0,0) kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-431.el6.x86_64.img
reboot系统就可以使用新的内核。
问题3:测试服务器不允许连接网络的情况下,如何升级内核3.1 如何批量下载Packges。
[root@localhost tmp]#wget -nd -r -l1 -A.rpm --no-parent http://mirrors.aliyun.com/centos/6/updates/x86_64/Packages/ -e robots=off
-- 批量下载包,注意这里用用https会报错,要么根据提示修改参数,要么改成http
[root@localhost Pachages]# tar -zcf /mnt/data/update_pachages.tar.gz *.rpm ---打包updatePachages,用来上传到不能对外链接的服务器[root@localhost data]# watch -n 5 "du -h update_pachages.tar.gz " ---观察打包进度 Every 5.0s: du -h update_pachages.tar.gz Mon Jul 22 08:03:49 20195.7G update_pachages.tar.gz
用同样的方法可以打包安装介质(或者挂载安装光盘拷贝也可以),最后拷贝文件到本地移动存储设备,转存到yum私有仓库服务器。
3.2 Linux程序包管理知识 创建yum仓库: createrepo [OPTION]
[root@localhost ~]# yum list installed |grep createrepo ---未安装 [root@localhost etc]# yum install -y createrepo ---安装rpm
建立一个目录用于存放安装包,然后使用createrepo来创建repository仓库; 命令执行成功后会在该目录下创建一个repodata目录,客户端配置指向此处。
[root@localhost updates]# createrepo ./Spawning worker 0 with 1 pkgsWorkers FinishedGathering worker resultsSaving Primary metadataSaving file lists metadataSaving other metadataGenerating sqlite DBsSqlite DBs complete[root@localhost updates]# lsPackages repodata
关于Centos内核安装中如何进行yum使用及配置问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。
内核
程序
仓库
配置
文件
升级
服务器
服务
问题
情况
版本
目录
测试
管理
网络
软件
验证
信息
客户
指向
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
华为服务器h58尺寸
思科网络技术与基础知识
cache数据库连接工具
小孩网络安全手抄报
安徽网络技术服务建议
企业管理专业软件开发服务
ecc服务器内存能用普通主板吗
上海项目网络技术厂家批发价
qt软件开发工具最新正式版
网络安全和云计算双驱动
网络安全250字
网络安全进校园班会视频
react前端数据库
即墨区定制软件开发外包公司
我的世界网易特色服务器
某局网络安全应急预案
武汉地铁 国产数据库
鄂州市一鸣软件开发
小学生沉迷网络安全教育记录
公安类专业网络安全与执法咋样
数据库100个字段怎么设计
微商分级管理软件开发
网络安全教育课的效果
怎么做数据库
宜良第三方软件开发价格走势
网络安全学院国家队
数据库惯性的概念意味着
小区人口数据库作用
材料自然环境腐蚀数据库
潍坊bim软件开发工程