yum is it? Detailed explanation of repo file, introduction to epel, replacement of yum source, difference between repo and epel

=

yum is it? Detailed explanation of repo file, introduction to epel, replacement of yum source, difference between repo and epel

Brief summary:

The relationship between repo and epel

A repo is a configuration source, that is, where to download packages (and dependencies).

Epel is used as a bridge. Enterprise Linux such as centos does not have the functions of repo and yum, so it is necessary to install epel to make it have the function of yum.

 

centos needs epel and repo

Centos is an open source version of redhat, an enterprise linux series, without yum function.

So you need to configure epel.

After configuring epel, you need to configure repo, so that the software source has software, and the software is newer and more complete.

 

=

yum

yum (full name Yellow dog Updater, Modified) is a shell front-end package manager in Fedora and RedHat and SUSE. Based on RPM package management, it can automatically download and install RPM packages from a specified server, and can automatically handle dependencies, and install all dependent software packages at one time, without the need to download and install tediously again and again. yum provides commands to find, install, delete a certain, a group or even all packages, and the commands are concise and easy to remember.

The command form of yum is generally as follows: yum [options] [command] [package ...]
where [options] is optional, options include -h (help), -y (when the installation process prompts, select all "" yes"), -q (do not show the installation process), etc. [command] is the operation to be performed, and [package...] is the object of the operation.

An overview of some commonly used commands include:

Automatically search for the fastest mirror plugin: yum install yum-fastestmirror
Install the yum graphical window plugin: yum install yumex
See a list of possible batch installations: yum grouplist

1 Install
yum install Install all
yum install package1 Install the specified installation package package1
yum groupinsall group1 Installer group group1

2 Update and upgrade
yum update Update all
yum update package1 Update specified package package1
yum check-update Check for updatable programs
yum upgrade package1 Upgrade specified package package1
yum groupupdate group1 Upgrade program group group1

3 Find and display
yum info package1 Display installation package information package1
yum list Display all installed and installable packages
yum list package1 Display the installation status of a specified package package1
yum groupinfo group1 Display program group group1 information yum search string Search by keyword string Installation package

4 Delete program
yum remove | erase package1 Delete package package1
yum groupremove group1 Delete program group group1
yum deplist package1 View program package1 dependencies

5 清除缓存
yum clean packages 清除缓存目录下的软件包
yum clean headers 清除缓存目录下的 headers
yum clean oldheaders 清除缓存目录下旧的 headers
yum clean, yum clean all (= yum clean packages; yum clean oldheaders) 清除缓存目录下的软件包及旧的headers

比如,要安装游戏程序组,首先进行查找:
#:yum grouplist
可以发现,可安装的游戏程序包名字是”Games and Entertainment“,这样就可以进行安装:
#:yum groupinstall "Games and Entertainment"
所 有的游戏程序包就自动安装了。在这里Games and Entertainment的名字必须用双引号选定,因为linux下面遇到空格会认为文件名结束了,因此必须告诉系统安装的程序包的名字是“Games and Entertainment”而不是“Games"。

此外,还可以修改配置文件/etc/yum.conf选择安装源。可见yum进行配置程序有多方便了吧。更多详细的选项和命令,当然只要在命令提示行下面:man yum

 

yum工作原理

         YUM的工作原理并不复杂,每一个 RPM软件的头(header)里面都会纪录该软件的依赖关系,那么如果可以将该头的内容纪录下来并且进行分析,可以知道每个软件在安装之前需要额外安装 哪些基础软件。也就是说,在服务器上面先以分析工具将所有的RPM档案进行分析,然后将该分析纪录下来,只要在进行安装或升级时先查询该纪录的文件,就可 以知道所有相关联的软件。所以YUM的基本工作流程如下:
        服务器端:在服务器上面存放了所有的RPM软件包,然后以相关的功能去分析每个RPM文件的依赖性关系,将这些数据记录成文件存放在服务器的某特定目录内。
        客户端:如果需要安装某个软件时,先下载服务器上面记录的依赖性关系文件(可通过WWW或FTP方式),通过对服务器端下载的纪录数据进行分析,然后取得所有相关的软件,一次全部下载下来进行安装。

 

yum配置文件分析:vi /etc/yum.conf

vi /etc/yum.conf
[main]
cachedir=/var/cache/yum
#cachedir:yum缓存的目录,yum在此存储下载的rpm包和数据库,一般是/var/cache/yum。
debuglevel=2
#debuglevel:除错级别,0──10,默认是2 貌似只记录安装和删除记录
logfile=/var/log/yum.log
pkgpolicy=newest
#pkgpolicy: 包的策略。一共有两个选项,newest和last,这个作用是如果你设置了多个repository,而同一软件在不同的repository中同时存 在,yum应该安装哪一个,如果是newest,则yum会安装最新的那个版本。如果是last,则yum会将服务器id以字母表排序,并选择最后的那个 服务器上的软件安装。一般都是选newest。
distroverpkg=centos-release
#指定一个软件包,yum会根据这个包判断你的发行版本,默认是redhat-release,也可以是安装的任何针对自己发行版的rpm包。
tolerant=1
#tolerent,也有1和0两个选项,表示yum是否容忍命令行发生与软件包有关的错误,比如你要安装1,2,3三个包,而其中3此前已经安装了,如果你设为1,则yum不会出现错误信息。默认是0。
exactarch=1
#exactarch,有两个选项1和0,代表是否只升级和你安装软件包cpu体系一致的包,如果设为1,则如你安装了一个i386的rpm,则yum不会用1686的包来升级。
retries=20
#retries,网络连接发生错误后的重试次数,如果设为0,则会无限重试。
obsoletes=1
gpgcheck=1
#gpgchkeck= 有1和0两个选择,分别代表是否是否进行gpg校验,如果没有这一项,默认是检查的。
reposdir=/etc/yy.rm #默认是 /etc/yum.repos.d/ 低下的 xx.repo后缀文件
#默认都会被include 进来 也就是说 /etc/yum.repos.d/xx.repo 无论配置文件有多少个 每个里面有多少个[name] 最后其实都被整合到 一个里面看就是了 重复的[name]后面的覆盖前面的
exclude=xxx
#exclude 排除某些软件在升级名单之外,可以用通配符,列表中各个项目要用空格隔开,这个对于安装了诸如美化包,中文补丁的朋友特别有用。
keepcache=[1 or 0]
#  设置 keepcache=1,yum 在成功安装软件包之后保留缓存的头文件 (headers) 和软件包。默认值为 keepcache=0 不保存

reposdir=[包含 .repo 文件的目录的绝对路径]
#  该选项用户指定 .repo 文件的绝对路径。.repo 文件包含软件仓库的信息 (作用与 /etc/yum.conf 文件中的 [repository] 片段相同)。

 

repo

        repo文件是Fedora中yum源(软件仓库)的配置文件,通常一个repo文件定义了一个或者多个软件仓库的细节内容,例如我们将从哪里下载需要安装或者升级的软件包,repo文件中的设置内容将被yum读取和应用!

 

repo的配置文件:vi /etc/yum.repo.d/xx.repo
这个字段其实也可以在yum.conf里面直接配置
[serverid]
#其中serverid是用于区别各个不同的repository(仓库;贮藏室;博物馆;亲信),必须有一个独一无二的名称。 重复了 前面覆盖后面--还是反过来呢???用enabled 测试是后面覆盖前面

name=Some name for this server
#name,是对repository的描述,支持像$releasever $basearch这样的变量; name=Fedora Core $releasever - $basearch - Released Updates

baseurl=url://path/to/repository/
#baseurl是服务器设置中最重要的部分,只有设置正确,才能从上面获取软件。它的格式是:
baseurl=url://server1/path/to/repository/
url://server2/path/to/repository/
url://server3/path/to/repository/
#其中url支持的协议有 http:// ftp:// file://三种。baseurl后可以跟多个url,你可以自己改为速度比较快的镜像站,但baseurl只能有一个,也就是说不能像如下格式:
baseurl=url://server1/path/to/repository/
baseurl=url://server2/path/to/repository/
baseurl=url://server3/path/to/repository/
其中url指向的目录必须是这个repository header目录的上一级,它也支持$releasever $basearch这样的变量。

#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
#上面的这一行是指定一个镜像服务器的地址列表,通常是开启的,本例中加了注释符号禁用了,我们可以试试,将$releasever和$basearch替换成自己对应的版本和架构,例如10和i386,在浏览器中打开,我们就能看到一长串镜可用的镜像服务器地址列表。

url之后可以加上多个选项,如gpgcheck、exclude、failovermethod等,比如:
gpgcheck=1
exclude=gaim
#其中gpgcheck,exclude的含义和[main]部分相同,但只对此服务器起作用,
failovermethod=priority
#failovermethode 有两个选项roundrobin和priority,意思分别是有多个url可供选择时,yum选择的次序,roundrobin是随机选择,如果连接失 败则使用下一个,依次循环,priority则根据url的次序从第一个开始。如果不指明,默认是roundrobin。

enabled=[1 or 0]
#当某个软件仓库被配置成 enabled=0 时,yum 在安装或升级软件包时不会将该仓库做为软件包提供源。使用这个选项,可以启用或禁用软件仓库。
#通过 yum 的 --enablerepo=[repo_name] 和 --disablerepo=[repo_name] 选项,或者通过 PackageKit 的"添加/删除软件"工具,也能够方便地启用和禁用指定的软件仓库

 

几个变量:
$releasever,发行版的版本,从[main]部分的distroverpkg获取,如果没有,则根据redhat-release包进行判断。
$arch,cpu体系,如i686,athlon等
$basearch,cpu的基本体系组,如i686和athlon同属i386,alpha和alphaev6同属alpha。
对yum.conf设定完成,我们就可以好好体验yum带来的方便了。

还有一件事没有做。那就是导入每个reposity的GPG key,前面说过,yum可以使用gpg对包进行校验,确保下载包的完整性,所以我们先要到各个repository站点找到gpg key,一般都会放在首页的醒目位置,一些名字诸如 RPM-GPG-KEY.txt之类的纯文本文件,把它们下载,然后用rpm --import xxx.txt命令将它们导入,最好把发行版自带GPG-KEY也导入,rpm --import /usr/share/doc/redhat-release-*/RPM-GPG-KEY 官方软件升级用的上。

 

epel

什么是epel
如果既想获得 RHEL 的高质量、高性能、高可靠性,又需要方便易用(关键是免费)的软件包更新功能,那么 Fedora Project 推出的 EPEL(Extra Packages for Enterprise Linux)正好适合你。EPEL(http://fedoraproject.org/wiki/EPEL) 是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。

 

repo和epel的关系

repo是配置源的,即配置从哪里下载包(以及依赖关系)的。

epel是作为桥的,centos等企业linux不具有repo,yum的功能,所以需要安装epel,使得其具有yum功能。

 

centos需要epel和repo

centos是redhat的开源版本,是企业linux系列的,没有yum功能。

所以需要配置epel。

配置了epel,又需要配置repo,以使得软件源有软件,且软件是较新的较全的。

 

参考:

https://www.cnblogs.com/nineep/p/6795692.html yum的repo文件详解、以及epel简介、yum源的更换

http://www.jb51.net/article/86809.htm linux下的yum命令原理和详解

=

=

=

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326171048&siteId=291194637