巧妙设置yum软件库轻松解决软件包安装问题
很多朋友在使用Linux操作系統的時候,會覺得安裝軟件包是一件挺麻煩的事,主要緣由是(RedHat/CentOS):
1、RPM安裝方式很多情況下不能有效解決復雜的包依賴關系。
2、YUM安裝方式能夠有效解決包依賴關系,但需要連接到互聯網(不少使用者的理解)。
綜上所述,對RPM軟件包的安裝方式顯然我們有時不得不摒棄,要是能夠在沒有網絡連接的情況下也能使用YUM來安裝軟件包,則事情就變得簡單了。
默認情況下,yum的庫是指向互聯網的,在主機上網不是很方便的情況下,我們可以改變yum庫的指向,使其指向光盤媒介,從而輕松實現本地yum方式查詢、安裝應用軟件了。
下面據此給大家介紹其操作方法,讓你從此不再為安裝軟件煩惱(以Redhat 5.8為例):
1)用mkdir命令在/media目錄下新建一個cdrom目錄
[root@oracle ~]# mkdir /media/cdrom
2)將安裝光盤放入光驅,掛載到某目錄,然后將光盤內容全部復制到/media/cdrom目錄下
[root@oracle ~]# mount /dev/cdrom /mnt/iso
[root@oracle iso]# cp -r * /media/cdrom/
3)修改/etc/yum.repos.d/目錄下rhel-debuginfo.repo文件,編輯bashurl將自己的光盤路徑寫入
[root@oracle yum.repos.d]# cp rhel-debuginfo.repo rhel-debuginfo.repo.bak
[root@oracle yum.repos.d]# vi rhel-debuginfo.repo
[r5-media]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///media/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
4)用此命令查詢、安裝軟件包:yum --disablerepo=\* --enablerepo=r5-media [command] xxxx-xxxx ,其中command可以是info, install,groupinstall等等
5)如果覺得每次輸入這條命令太麻煩,你還可以用別名的方式來替代這條命令,以后用別名就簡單多了。
注釋:xxxx-xxxx為軟件包或軟件包名,--disablerepo=\*的意思是禁止其它所有的repo源,--enablerepo=r5-media表示啟用光盤repo源(它認為/media/cdrom是光盤掛載的目錄),這樣實際上是相當于我們在本地建立了一個YUM源的倉庫,每次安裝軟件的時候,它就會直接到這個倉庫來查找軟件,自動分析依賴關系,幫我們順利安裝軟件。
比如我要在主機上安裝一個網絡通訊報文捕捉軟件wireshark, 這個軟件默認是不安裝的,則可以
使用命令:yum --disablerepo=\* --enablerepo=r5-media info wireshark ,系統反饋軟件在庫r5-media中有此軟件,可以安裝。
[root@oracle ~]# yum --disablerepo=\* --enablerepo=r5-media info wireshark
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Available Packages
Name ? ? ? : wireshark
Arch ? ? ? : x86_64
Version ? ?: 1.0.15
Release ? ?: 1.el5_6.4
Size ? ? ? : 12 M
Repo ? ? ? : r5-media
Summary ? ?: 網絡交通分析器
URL ? ? ? ?: http://www.wireshark.org/
License ? ?: GPL
Description: Wireshark is a network traffic analyzer for Unix-ish operating
? ? ? ? ? : systems.
? ? ? ? ? :
? ? ? ? ? : This package lays base for libpcap, a packet capture and filtering
? ? ? ? ? : library, contains command-line utilities, contains plugins and
? ? ? ? ? : documentation for wireshark. A graphical user interface is packaged
? ? ? ? ? : separately to GTK+ package.
使用命令:yum --disablerepo=\* --enablerepo=r5-media install wireshark ,安裝自動解決依賴的問題并安裝完成,直接可以使用。
[root@oracle ~]# yum --disablerepo=\* --enablerepo=r5-media install wireshark
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package wireshark.x86_64 0:1.0.15-1.el5_6.4 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package ? ? ? ? ?Arch ? ? ? ? ?Version ? ? ? ? ? ? ? ? ? Repository ? ? ? Size
================================================================================
Installing:
wireshark ? ? ? ?x86_64 ? ? ? ?1.0.15-1.el5_6.4 ? ? ? ? ?r5-media ? ? ? ? 12 M
Transaction Summary
================================================================================
Install ? ? ? 1 Package(s)
Upgrade ? ? ? 0 Package(s)
Total download size: 12 M
Is this ok [y/N]:
以上方法針對Redhat5/6、CentOS5/6系列都有效,不過會略有點細節不同。
總結
以上是生活随笔為你收集整理的巧妙设置yum软件库轻松解决软件包安装问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: poj 踩方格
- 下一篇: Jena文档《An Introducti