在配置yum前首先得說說rpm杆逗,在redhat和centos linux系統(tǒng)上学少,rpm作為軟件包管理工具剪个,可以方便的安裝、查詢版确、卸載軟件包扣囊。常見命令如下:
#安裝:
rpm -ivh jdk-7u25-linux-x64.rpm
#卸載:
rpm -e jdk-7u25-linux-x64.rpm
#升級:
rpm -Uvh jdk-7u25-linux-x64.rpm
#查詢軟件的安裝路徑:
rpm -ql yum-3.4.3-118.el7.noarch
#查詢所有安裝的包:
rpm -qa
#查詢某個文件是哪個rpm包產(chǎn)生:
rpm -qf /var/lib/yum/yumdb
但是在多個包組成的rpm包用rpm命令安裝時,其依賴包問題是超級繁瑣的绒疗。
yum是redhat和centos的軟件包管理工具侵歇,安裝軟件包時可以在網(wǎng)上遠(yuǎn)程倉庫或者本地自動下載所有依賴包,解決了rpm的痛點(diǎn)吓蘑。今天主要學(xué)習(xí)下遠(yuǎn)程yum源配置惕虑。由于redhat 自帶的 yum 源是需要注冊收費(fèi)才能更新下載軟件的,如果沒有注冊就使用,則會報(bào)下面的錯誤:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
所以我們需要把yum源修改為centos的源溃蔫。
查看自帶yum:
rpm -qa | grep yum
卸載自帶yum:
rpm -qa | grep yum | xargs rpm -e --nodeps
查看系統(tǒng)版本:
cat /etc/redhat-release
下載安裝軟件包:
#下載鏈接
http://mirrors.163.com/centos/7/os/x86_64/Packages/
#需要下載以下三個rpm包:
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-3.4.3-158.el7.centos.noarch.rpm
yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
執(zhí)行以下安裝命令報(bào)錯健提,依賴包的版本不符:
#執(zhí)行yum安裝
rpm -ivh yum*
這里升級python-urlgrabber和rpm包版本:
#升級rpm包到:
rpm-4.11.3-32.el7.x86_64.rpm
python-urlgrabber-3.10-8.el7.noarch.rpm
#下載
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-32.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
#升級
rpm -Uvh rpm-4.11.3-32.el7.x86_64.rpm --nodeps
rpm -Uvh python-urlgrabber-3.10-8.el7.noarch.rpm --nodeps
然后安裝:
新建配置文件:
vim /etc/yum.repos.d/CentOS-Base.repo
加入以下配置:
#CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
然后清理緩存:
yum clean all
生成緩存:
yum makecache
測試源:
yum update -y --skip-broken
可以看到已經(jīng)可以通過yum安裝相關(guān)軟件包更新。
最后酒唉,csdn資源矩桂,收集了海量學(xué)習(xí)資料,如果你準(zhǔn)備入IT坑痪伦,勵志成為優(yōu)秀的程序猿侄榴,那么這些資源很適合你,包括java网沾、go癞蚕、python、springcloud辉哥、elk桦山、嵌入式 、大數(shù)據(jù)醋旦、面試資料恒水、前端等資源。同時我們組建了一個技術(shù)交流群饲齐,里面有很多大佬钉凌,會不定時分享技術(shù)文章,如果你想來一起學(xué)習(xí)提高捂人,可以關(guān)注以下公眾號后回復(fù)【2】御雕,獲取。
我是小碗湯滥搭,我們一起學(xué)習(xí)酸纲,掃碼關(guān)注,精彩內(nèi)容第一時間推給你