yum安装、使用以及第三方源配置

本文详细介绍了yum工具的用途,包括它的安装过程,源配置文件的参数解析,常用命令的使用,以及如何设置代理和配置第三方源,如阿里云镜像。此外,还提到了yum源的配置文件位置/etc/yum.repos.d,并提供了配置示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、yum简介(Yellow dog Udater Modified)

Python写的一套包管理工具,用于自动化升级、安装/移除rpm包,收集rpm包的相关信息,检查依赖性并自动提示用户解决。根据rpm的header自动化完成安装任务,能从指定的服务器自动下载RPM包并且安装,自动处理依赖性关系。本身也可做yum服务器。

二、yum安装

下载压缩包,解压安装

wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz

然后当前目录解压

tar xvf yum-3.2.28.tar.gz  

cd进目录

cd yum-3.2.28  

开始安装

yummain.py install yum  

安装完了更新下系统

yum check-update  
yum update  
yum clean all  

三、 源配置文件/etc/yum.repo.d/Centos-Base.repo.d文件参数解释

[Centos] (标识,无要求,但唯一)
name=CentOS (名字,无要求,但唯一)
baseurl=file:///media/Server/ (本地的路径)
enabled=1 (为1则是打开仓库,为0则是关闭仓库)
gpgcheck=1 (公钥值)
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 (检测公钥值的文件路径)
[ ]内的是仓库的名字
name是仓库的描述也可以说是名字
baseurl 仓库的位置
enabled 是否启用这个仓库,1为起用,0为禁用
gpgcheck 是否检查GPG签名(用来验证要安装的包是不是REDHAT官方的)
gpgcheck的存放地址我们需要用下面的命令导入这个签名,才能使用这项功能。

四、yum的常用命令:

yum check-update

显示全部能update的软件list

·

yum -y install <package_name> 

根据特定包名安装软件
·

yum list  <package_name>

不加<package_name>:显示出全部安裝的软件清单;加了:列出相关

·

yum -y remove <package_name> 

删除软件
·

yum search <package_name>   

根据包名查找相关软件
·

yum list installed  

显示全部已装的软件包
·

yum list extras   

列出所有已安装但不在 Yum Repository 內的软件包
·

yum info <package_name>

不加<package_name>显示全部信息,加了显示指定的
·

yum provides <package_name>

显示软件包提供哪些文件
·

yum clean packages

清除缓存目录(/var/cache/yum)下的软件包
·

yum clean all    

清除缓存目录(/var/cache/yum)下的软件包及旧的headers
·

五、yum设置代理,

yum设置第三方源(nexus私服)
CentOS-Base.repo 是yum 网络源的配置文件
yum源的文件位置都是在/etc/yum.repos.d

[base] name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=第三方仓库源地址(以aliyun为例)

#baseurl=http://mirrors.aliyun.com/centos/ r e l e a s e v e r / o s / releasever/os/ releasever/os/basearch/
http://mirrors.aliyuncs.com/centos/ r e l e a s e v e r / o s / releasever/os/ releasever/os/basearch/
http://mirrors.cloud.aliyuncs.com/centos/ r e l e a s e v e r / o s / releasever/os/ releasever/os/basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates [updates] name=CentOS- r e l e a s e v e r − U p d a t e s − m i r r o r s . a l i y u n . c o m f a i l o v e r m e t h o d = p r i o r i t y b a s e u r l = h t t p : / / m i r r o r s . a l i y u n . c o m / c e n t o s / releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/ releaseverUpdatesmirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/releasever/updates/ b a s e a r c h / h t t p : / / m i r r o r s . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.aliyuncs.com/centos/ basearch/http://mirrors.aliyuncs.com/centos/releasever/updates/ b a s e a r c h / h t t p : / / m i r r o r s . c l o u d . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.cloud.aliyuncs.com/centos/ basearch/http://mirrors.cloud.aliyuncs.com/centos/releasever/updates/KaTeX parse error: Expected 'EOF', got '#' at position 85: …KEY-CentOS-7 #̲additional pack…releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/ r e l e a s e v e r / e x t r a s / releasever/extras/ releasever/extras/basearch/
http://mirrors.aliyuncs.com/centos/ r e l e a s e v e r / e x t r a s / releasever/extras/ releasever/extras/basearch/
http://mirrors.cloud.aliyuncs.com/centos/ r e l e a s e v e r / e x t r a s / releasever/extras/ releasever/extras/basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages [centosplus] name=CentOS- r e l e a s e v e r − P l u s − m i r r o r s . a l i y u n . c o m f a i l o v e r m e t h o d = p r i o r i t y b a s e u r l = h t t p : / / m i r r o r s . a l i y u n . c o m / c e n t o s / releasever - Plus - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/ releaseverPlusmirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/releasever/centosplus/ b a s e a r c h / h t t p : / / m i r r o r s . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.aliyuncs.com/centos/ basearch/http://mirrors.aliyuncs.com/centos/releasever/centosplus/ b a s e a r c h / h t t p : / / m i r r o r s . c l o u d . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.cloud.aliyuncs.com/centos/ basearch/http://mirrors.cloud.aliyuncs.com/centos/releasever/centosplus/KaTeX parse error: Expected 'EOF', got '#' at position 95: …KEY-CentOS-7 #̲contrib - packa…releasever - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/ r e l e a s e v e r / c o n t r i b / releasever/contrib/ releasever/contrib/basearch/
http://mirrors.aliyuncs.com/centos/ r e l e a s e v e r / c o n t r i b / releasever/contrib/ releasever/contrib/basearch/
http://mirrors.cloud.aliyuncs.com/centos/ r e l e a s e v e r / c o n t r i b / releasever/contrib/ releasever/contrib/basearch/
gpgcheck=1 enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
以aliyun源为例子,如果搭建私服的话,需要将所有的配置都写进去,否则私服仓库无法缓存。当然如果是个人想提高下载速度而直接使用国内源就无所谓啦。

如果想通过proxy使用Yum的话:
打开/etc/yum.conf 配置文件进行编辑
在后面添加以下内容(ip号+端口后无认证连接)
proxy=http://host:port
如果需要认证连接则输入以下内容
proxy=http://host:port
proxy_username=代理服务器用户名
proxy_password=代理服务器密码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值