yum源配置与详解

f-h-j-11-7 f-h-j-11-7     2022-12-20     617

关键词:

一、yum简介

yum是解决rpm软件包的依赖性而开发的一种软件包管理器。yum 的宗旨是自动化地升级,安装/移除rpm 包,收集rpm 包的相关信息,检查依赖性并自动提示用户解决。yum 的关键之处是要有可靠的repository,顾名思义,这是软件的仓库,它可以是http 或ftp 站点。

二、yum安装

CentOS 默认已经安装了yum,不需要另外安装

1、查看系统默认安装的yum

[[email protected] ~]# rpm -qa |grep yum
yum-utils-1.1.31-45.el7.noarch
yum-plugin-fastestmirror-1.1.31-45.el7.noarch
PackageKit-yum-1.1.5-1.el7.centos.x86_64
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-langpacks-0.4.2-7.el7.noarch
yum-3.4.3-158.el7.centos.noarch

三、yum配置文件

yum客户端配置文件:

/etc/yum.conf:为所有仓库提供公共配置

[[email protected] ~]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=
http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

/etc/yum.repos.d/*.repo:为仓库的指向提供配置

            [repoid]  仓库的名称,不能重复,独一无二
             name= 仓库的描述,可以不写,将会用repoid当作name
             enabled=1|0  激活或禁用仓库,若不写该行,则默认启用
             gpgcheck=1|0 是否在安装包是检测gpg签名,默认检测,即为1
             gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7  指定gpg key的路径

[[email protected] rpm-gpg]# ls
RPM-GPG-KEY-CentOS-7  RPM-GPG-KEY-CentOS-Debug-7  RPM-GPG-KEY-CentOS-Testing-7
[[email protected] rpm-gpg]# pwd
/etc/pki/rpm-gpg

四、yum仓库的创建

yum的repo配置文件中可用的变量:

$releasever: 当前OS的发行版的主版本号

$arch: 平台,i386,i486,i586,x86_64等

$basearch:基础平台;i386, x86_64

$YUM0-$YUM9:自定义变量

? 实例:

http://server/centos/$releasever/$basearch/

 http://server/centos/7/x86_64

http://server/centos/6/i384

[[email protected] ~]# vim /etc/yum.repos.d/fhj.repo
[[email protected] ~]# cat /etc/yum.repos.d/fhj.repo
[base]
name=Red Hat Enterprise Linux $releasever Repo
baseurl=
http://172.18.0.1/centos/$releasever
enabled=1                                                            #教师机yum源镜像
gpgcheck=0
[base]
name=Red Hat Enterprise Linux $releasever Repo
baseurl=file:///media                                          #本地yum源镜像
enabled=1
gpgcheck=0
[epel]
name=mage epel $releasever
baseurl=
http://172.18.0.1/fedora-epel/$releasever/$basearch
enabled=1
gpgcheck=0                                                            #第三方库文件
使用在线epel
[epel]
name=mage epel
baseurl=
https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/
enabled=1
gpgcheck=0

自动生成仓库

[[email protected] ~]# yum-config-manager --add "https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/"
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
adding repo from:
https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/

[mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_]
name=added from:
https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/
enabled=1

五、yum命令

用法:yum          选项                命令               包名

yum clean all  清空yum缓存
yum makecache 重建缓存,(没有缓存时,首次使用yum的任何命令都会自动重建)

显示仓库列表

[[email protected] ~]# yum repolist all
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Loading mirror speeds from cached hostfile
  * base: mirrors.huaweicloud.com
  * extras: mirrors.huaweicloud.com
  * updates: mirrors.huaweicloud.com
repo id                               repo name                              status
C7.0.1406-base/x86_64                 CentOS-7.0.1406 - Base                 disabled
C7.0.1406-centosplus/x86_64           CentOS-7.0.1406 - CentOSPlus           disabled
C7.0.1406-extras/x86_64               CentOS-7.0.1406 - Extras               disabled
C7.0.1406-fasttrack/x86_64            CentOS-7.0.1406 - CentOSPlus           disabled
C7.0.1406-updates/x86_64              CentOS-7.0.1406 - Updates              disabled
C7.1.1503-base/x86_64                 CentOS-7.1.1503 - Base                 disabled
C7.1.1503-centosplus/x86_64           CentOS-7.1.1503 - CentOSPlus           disabled
C7.1.1503-extras/x86_64               CentOS-7.1.1503 - Extras               disabled
C7.1.1503-fasttrack/x86_64            CentOS-7.1.1503 - CentOSPlus           disabled
C7.1.1503-updates/x86_64              CentOS-7.1.1503 - Updates              disabled
C7.2.1511-base/x86_64                 CentOS-7.2.1511 - Base                 disabled
C7.2.1511-centosplus/x86_64           CentOS-7.2.1511 - CentOSPlus           disabled
C7.2.1511-extras/x86_64               CentOS-7.2.1511 - Extras               disabled

[[email protected] ~]# yum repolist enabled
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Loading mirror speeds from cached hostfile
  * base: mirrors.huaweicloud.com
  * extras: mirrors.huaweicloud.com
  * updates: mirrors.huaweicloud.com
repo id                                   repo name                                   status
base/7/x86_64                             CentOS-7 - Base                              9,911
epel/7/x86_64                             mage epel 7                                 11,349
extras/7/x86_64                           CentOS-7 - Extras                              368
updates/7/x86_64                          CentOS-7 - Updates                           1,041
repolist: 22,669

显示程序包

yum list

               base 未安装的包,来自于base
                epel 未安装的包,来自于epel
                @base 该包已经安装,且是从base安装的
                @anaconda 该包已经安装,且是从操作系统的安装程序anaconda安装的
 
               all 默认 表示列出所有包
               updates 列出可更新的包
               installed 列出已安装的包
               @repoid 表示该包安装自指定的仓库
               installed 表示该包由rpm命令手工安装

安装程序包:

[[email protected] ~]# yum install samba

重新安装

[[email protected] ~]# yum reinstall tree             

检查可用升级

[[email protected] ~]# yum check-update      

升级程序包

[[email protected] ~]# yum update sudo   

卸载程序包

[[email protected] ~]# yum remove sudo          卸载时不会连同依赖包一同卸载

查看指定包的详细信息

[[email protected] ~]# yum info tree

搜索一个文件来自于哪个rpm包,可以是未安装的包
yum provides "*/rz"  

[[email protected] ~]# yum provides "*/rz"
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Loading mirror speeds from cached hostfile
  * base: mirrors.huaweicloud.com
  * extras: mirrors.huaweicloud.com
  * updates: mirrors.huaweicloud.com
mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_                          | 3.2 kB  00:00:00    
(1/3): mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_/group_gz          |  88 kB  00:00:00    
(2/3): mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_/updateinfo        | 932 kB  00:00:00    
(3/3): mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_/primary           | 3.6 MB  00:00:00    
mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_                                     12629/12629
base/7/x86_64/filelists_db                                           | 6.9 MB  00:00:00    
epel/7/x86_64/filelists_db                                           | 7.6 MB  00:00:00    
extras/7/x86_64/filelists_db                                         | 588 kB  00:00:00    
mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_/filelists                |  10 MB  00:00:01    
updates/7/x86_64/filelists_db                                        | 2.4 MB  00:00:00    
lrzsz-0.12.20-36.el7.x86_64 : The lrz and lsz modem communications programs
Repo        : base
Matched from:
Filename    : /usr/bin/rz

lrzsz-0.12.20-36.el7.x86_64 : The lrz and lsz modem communications programs
Repo        : @anaconda
Matched from:
Filename    : /usr/bin/rz

模糊搜索 软件包和描述

yum search 关键字

[[email protected] ~]# yum search samba

列出指定包所依赖的所有包

yum deplist php 

yum history       列出所有的yum历史
             info # 查看某条历史的详细信息
             redo # 重做某条历史
             undo # 撤消某条历史
                     如果该历史为install,则undo 是remove
                     如果该历史为remove,则undo 是install

注意:撤销某条历史(某个包的安装),安装的包会连同它的依赖包一同删除

安装本地的包
yum [local]install /path/*.rpm

[[email protected] ~]# yum install /media/Packages/php-5.4.16-45.el7.x86_64.rpm


 







































































































































yum源配置及详解(代码片段)

...意:有repodata的目录的子目录为yum源的路径 二、yum源配置yum的配置文件cachedir=/var/cache/yum/$basearch/$releasever#yum下载后的缓存目录keepcache=0#是否缓存,0为不缓存,1为缓存debuglevel=2logfile=/var/log/yum.log#yum的安装日志exactarch=1obsoletes=... 查看详情

yum源配置与使用方法

Cen YUM源配置与使用方法一、YUM简介 yum,是YellowdogUpdater,Modified的简称,是杜克大学为了提高RPM软件包安装性而开发的一种软件包管理器。起初是由yellowdog这一发行版的开发者TerraSoft研发,用python写成,那时还叫做yup... 查看详情

yum详解(代码片段)

目录YUM安装yum相关命令控制yum安装的配置文件YUM安装1.必须有网络,通过网络获取软件2.管理RPM包3.自动解决依赖4.命令简单好记5.生产最佳实践yum相关命令-使用阿里源的base源,可将baseurl中三个路径删除下面两个路径,路径为阿... 查看详情

linux挂载本地yum源详解(代码片段)

学习目标:挂载本地yum源在Linux下挂载下本地yum源对yum源有认识学习内容:1、认识yum源2、掌握挂载本地的yum源3、清除yum源的原有信息命令4、显示所有yum源的软件包yum挂载的的前提:已经挂载了本地光盘(我们在... 查看详情

centos6.x本地yum源配置与使用

系统默认已经安装了可使用yum的软件包,所以可以直接配置:#mount /dev/cdrom /mnt                挂载镜像,可以写到配置文件,开机自动挂载#echo"mount /dev/c 查看详情

1软件源配置与学习建议

默认使用centos6.8默认aliyun的源备份mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup下载阿里云源配置文件(针对centos6版本)wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos- 查看详情

redhat怎么配置yum?

centos的yum是自带的,很方便。我想把redhat的yum配置一下。。。。。参考技术Acentos中yum客户端配置:yum客户端的其中一个配置文件是/etc/yum.repos.d/*.repo,其中这一文件中一个*.repo文件就是一个yum源。yum.repo文件内容结构。[yumtest]#YUM... 查看详情

centos配置163的yum源

通常我们安装好Linux后,使用yum安装和更新的时候,大部分的URL都是国外的地址,所以导致进度比较慢。其实,我们可以自己修改yum源,使用国内的yum源,这样效率会更高。以163yum源为例,其他与之类似:1、首先下载好yum文件wge... 查看详情

yum源仓库的安装及配置

...依赖性问题,便于管理大量系统的更新问题。yum可以同时配置多个资源库,简介的配置文件,保持与rpm数据库的一致性。二,yum的安装默认已经安装,这里简要提一下。基础安装包包括:yumyum-fastestmirroryum-metadata-parser三.yum的配... 查看详情

centos7yum源配置(代码片段)

文章目录一、配置阿里云的yum源1.备份当前yum源配置文件2.下载源配置文件3.更新yum源配置文件4.测试结尾一、配置阿里云的yum源1.备份当前yum源配置文件进入/etc/yum.repos.d目录将该目录下的源配置文件备份:cd/etc/yum.repos.d/mkdirbk... 查看详情

centos7yum源配置(代码片段)

文章目录一、配置阿里云的yum源1.备份当前yum源配置文件2.下载源配置文件3.更新yum源配置文件4.测试结尾一、配置阿里云的yum源1.备份当前yum源配置文件进入/etc/yum.repos.d目录将该目录下的源配置文件备份:cd/etc/yum.repos.d/mkdirbk... 查看详情

centos8yum源配置(代码片段)

文章目录一、配置阿里云的yum源1.备份当前yum源配置文件2.下载源配置文件3.修改yum源配置文件4.更新yum源配置文件5.测试结尾一、配置阿里云的yum源1.备份当前yum源配置文件进入/etc/yum.repos.d目录将该目录下的源配置文件备份:... 查看详情

centos8yum源配置(代码片段)

文章目录一、配置阿里云的yum源1.备份当前yum源配置文件2.下载源配置文件3.修改yum源配置文件4.更新yum源配置文件5.测试结尾一、配置阿里云的yum源1.备份当前yum源配置文件进入/etc/yum.repos.d目录将该目录下的源配置文件备份:... 查看详情

如何配置centos6.5的yum源

...,就自带多社区的yum源,已经够你使用的了。如果你非要配置其它第三方yum源,只要把配置文件放到/etc/yum.repos.d/这个目录下就可以了。配置格式可以参考http://mirrors.163.com/.help/CentOS6-Base-163.repo参考技术A 无论是使用哪一个版本... 查看详情

linux搭建yum仓库源详解

基于ISO镜像构建YUM本地源1.yuminstallhttpd:安装httpd软件包、yumremovehttpd:卸载httpd软件包、yumerasehttpd:删除httpd程序包。2.首先将光驱iso镜像加载至虚拟机CD/DVD,创建挂在目录mkdir-p/mnt/cdrom。3.备份/etc/yum.repos.d/CentOS-Base.repo文件为Cent... 查看详情

网易yum源配置

[1]首先备份yum源默认配置文件[2]进入yum源配置文件所在文件夹[3]下载yum源配置文件[4]运行yummakecache生成缓存[[email protected]yum.repos.d]#yummakecache[5]更新系统[[email protected]yum.repos.d]#yum-yupdate Centos6 网络Yum源&nbs 查看详情

配置yum源

进入配置yum源目录编辑yum源PS:yum源可以来自本地,也可以来自网页。挂载yum源PS:第一次挂在失败是因为光盘没有连接上,在虚拟机配置中把光盘选项里连接即可。这样就配置完成了。可以通过命令下载服务了。比如FTP 查看详情

配置yum源

配置yum源yum源正常请忽略这一步01.在安装完RedHatEnterpriseLinux系统后,由于redhat的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用,请配置其他YUM源,以下为详细过程。(此过程不需卸载RedHatEnterpriseLinux(RHEL)自己的... 查看详情