您好,登錄后才能下訂單哦!
Centos內核安裝中如何進行yum使用及配置,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
因安全問題,要將Linux內核2.6.X的內核升級到最新的版本。
以centos6.5為例,考慮下列問題:
(1). 查看當前內核版本,網上搜索現提供的最新版本;
(2). 測試服務器可以連接網絡的情況下,如何升級內核?yum倉庫指向鏡像網站上
(3). 測試服務器不允許連接網絡的情況下,如何升級內核?下載升級包,配置私有倉庫
問題1: 查看當前內核版本: [root@localhost ~]# uname -r 2.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 ms 64 bytes from 183.2.199.240: icmp_seq=2 ttl=57 time=8.54 ms 64 bytes from 183.2.199.240: icmp_seq=3 ttl=57 time=8.58 ms
若出現下列情況,則配置DNS
[root@status etc]# ping mirrors.aliyun.com ping: 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 ms 64 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 - Update baseurl=https://mirrors.aliyun.com/centos/6/updates/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[root@status yum.repos.d]# yum repolist Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile updates | 3.4 kB 00:00 repo id repo name status updates CentOS-6 - Updates 559 repolist: 559
安裝:
[root@status /]# yum info kernel.x86_64 ----查看當前內核的信息及最新內核 Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile Installed Packages Name : kernel Arch : x86_64 Version : 2.6.32 Release : 431.el6 Size : 121 M Repo : installed From repo : anaconda-CentOS-201311272149.x86_64 Summary : The Linux kernel URL : http://www.kernel.org/ License : GPLv2 Description : 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 Packages Name : kernel Arch : x86_64 Version : 2.6.32 Release : 754.17.1.el6 Size : 32 M Repo : update Summary : The Linux kernel URL : http://www.kernel.org/ License : GPLv2 Description : 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, security Determining fastest mirrors base | 3.4 kB 00:00 base/primary_db | 5.2 MB 00:01 Setting up Install Process Resolving 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 Resolution Error: 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.el6 You could try using --skip-broken to work around the problem You 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 - Base baseurl=https://mirrors.aliyun.com/centos/6/os/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [update] name=CentOS-$releasever - Update baseurl=https://mirrors.aliyun.com/centos/6/updates/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[root@status /]# yum repolist ----查看倉庫是否配置成功 Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile base | 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 2018 update | 3.4 kB 00:00 repo id repo name status base CentOS-6 - Base 559 update CentOS-6 - Update 559 repolist: 1,118
再次執行yum install -y kernel.x86_64 依然報錯!!?? 看看上面的yum repolist,base和update的Package包數目都是一樣的,base沒有更新倉庫信息,暈死。
[root@status /]# yum clean all ----清空本地緩存 Loaded plugins: fastestmirror, security Cleaning repos: base update Cleaning up Everything Cleaning up list of fastest mirrors [root@status /]# yum repolist ----查看倉庫是否配置成功,這次倉庫信息同步了 Loaded plugins: fastestmirror, security Determining fastest mirrors base | 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 status base CentOS-6 - Base 6,713 update CentOS-6 - Update 559 repolist: 7,272
[root@status /]# yum install -y kernel.x86_64 Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile Setting up Install Process Resolving 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/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title 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.img title 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 2019 5.7G update_pachages.tar.gz
用同樣的方法可以打包安裝介質(或者掛載安裝光盤拷貝也可以),最后拷貝文件到本地移動存儲設備,轉存到yum私有倉庫服務器。
3.2 Linux程序包管理知識 創建yum倉庫: createrepo [OPTION] <DIRECTORY>
[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 pkgs Workers Finished Gathering worker results Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@localhost updates]# ls Packages repodata
關于Centos內核安裝中如何進行yum使用及配置問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。