Centos Yum configuration file REPO file details

What is a repo file?
The repo file is the configuration file of the yum source (software repository) in Fedora. Usually a repo file defines the details of one or more software repositories, such as where we will download the software packages that need to be installed or upgraded, and the settings in the repo file The content will be read and applied by yum!
The working principle of YUM is not complicated. The header of each RPM software will record the dependencies of the software. If the content of the header can be recorded and analyzed, you can know that each software needs additional before installation. What basic software to install. That is to say, first analyze all RPM files with analysis tools on the server, and then record the analysis. As long as you first query the recorded files during installation or upgrade, you can know all the associated software. So the basic workflow of YUM is as follows:
Server side: Store all RPM software packages on the server, and then use related functions to analyze the dependency relationship of each RPM file, and record these data into files and store them in a specific server Directory.
Client: If you need to install a certain software, first download the dependency file recorded on the server (through WWW or FTP), analyze the recorded data downloaded from the server, and then obtain all related software, all at once Download it and install it.

vi / etc/yum.conf
[main]
cachedir =/var/cache/yum/$basearch/$releasever

#cachedir: yum cache directory, yum stores downloaded rpm packages and databases here, generally /var/cache/yum/$basearch/$releasever.

keepcache=1

#keepcache: whether to keep the cache content, 0: to delete the package after installation, 1 to keep the package after installation

debuglevel=2
#debuglevel: debug level, 0──10, the default is 2 looks like it only records installation and deletion records
logfile=/var/log/yum.log < br style="color: #696969; line-height: 28px; font-family: "Hiragino Sans GB W3", "Hiragino Sans GB", Arial, Helvetica, simsun, u5b8bu4f53; font-size: 14px"> pkgpolicy=newest
#pkgpolicy : Package strategy. There are two options, newest and last. This function is if you set up multiple repositories, and the same software exists in different repositories at the same time, which one should be installed by yum, if it is newest, yum will install the latest version . If it is last, yum will sort the server id in alphabetical order and select the last software installation on the server. Generally choose newest.
distroverpkg=centos-release
#Specify a software package, yum will determine your release version based on this package, the default is redhat-release, or any rpm package installed for your own release.
tolerant=1
#tolerent, there are also two options 1 and 0, indicating whether yum tolerates errors related to software packages on the command line. For example, you want to install three packages 1, 2, 3, and 3 of them have been installed before If you set it to 1, yum will not display an error message. The default is 0.
exactarch=1
#exactarch, there are two options 1 and 0, which represent whether to upgrade only the packages that are consistent with the cpu system of your installation package. If set to 1, if you install an i386 rpm, yum will not use 1686 Package to upgrade.
retries=20
#retries, the number of retries after a network connection error occurs, if set to 0, it will retry indefinitely.
obsoletes=1
gpgcheck=1
#gpgchkeck= There are two choices, 1 and 0, which respectively represent whether to perform gpg verification. If there is no such item, the default is to check.
reposdir=/etc/yy.rm #The default is /etc/yum.repos.d/ low xx.repo suffix file
#By default, it will be included, which means /etc/yum.repos.d/xx.repo regardless of configuration How many files are there and how many [name]s are in each file. Finally, all of them are actually integrated into one. It is the duplicated [name] and overwrites the previous
exclude=xxx
#exclude Excluding some software from the upgrade list, you can use wildcards, and each item in the list should be separated by spaces. This is especially useful for friends who have installed such as beautification packs and Chinese patches.
keepcache=[1 or 0]
#   set keepcache=1, yum retains cached headers and packages after the package is successfully installed. The default value is keepcache=0 Do not save

reposdir=[absolute path of the directory containing the .repo file]
#   This option specifies the absolute path of the .repo file. The .repo file contains information about the software repository (same function as the [repository] section in the /etc/yum.conf file).

Second Part:
vi /etc/yum.repo.d/xx.repo
This field can also be configured directly in yum.conf

[serverid]
#The serverid is used to distinguish different repositories and must have a unique name. Repeated. The front covers the back–or the other way around? ? ? The enabled test is the back cover the front
name=Some name for this server
#name, is the description of the repository, supports variables like $releasever $basearch; name=Fedora Core $releasever-$basearch-Released Updates < br style="color: #696969; line-height: 28px; font-family: "Hiragino Sans GB W3", "Hiragino Sans GB", Arial, Helvetica, simsun, u5b8bu4f53; font-size: 14px"> baseurl=url://path/ to/repository/
#baseurl is the most important part of the server settings. Only when the settings are correct can you get the software from it. Its format is:
baseurl=url://server1/path/to/repository/
url://server2/path/to/repository/
url://server3/path/to/repository/
#The protocols supported by url are http:// ftp:// file://three kind. Baseurl can be followed by multiple urls. You can change to a faster mirror site by yourself, but there can only be one baseurl, which means it cannot be in the following format:
baseurl=url://server1/path/to/repository/< /span>
baseurl =url://server2/path/to/repository/
baseurl=url://server3/path/to/repository/
The directory pointed to by the url must be one level above the repository header directory, and it also supports variables such as $releasever $basearch.

#mirrorlist =http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
#The above line specifies the address list of a mirror server, which is usually enabled. In this example, a comment symbol is added to disable , We can try, replace $releasever and $basearch with their corresponding version and architecture, such as 10 and i3 86. Open it in the browser, and we can see a long list of mirror server addresses available for mirroring.

after the url You can add multiple options, such as gpgcheck, exclude, failovermethod, etc., such as:

gpgcheck=1
exclude=gaim
#The meaning of gpgcheck and exclude is the same as the [main] part, but only works on this server,
failovermethod=priority
#failovermethode has two options roundrobin and priority, which means the order of yum selection when there are multiple URLs to choose from. Roundrobin is randomly selected. If the connection fails, the next one will be used, and the priority will start from the first according to the order of the url. If not specified, the default is roundrobin.

enabled= [1 or 0]
#When a certain software warehouse is configured as enabled=0, yum will not use this warehouse as the source of the software package when installing or upgrading the software package. Using this option, you can enable or disable the software warehouse.
# Through yum’s –enablerepo=[repo_name] and –disablerepo=[repo_name] options, or through PackageKit’s “Add/Remove Software” tool, you can also easily enable and disable the specified software repository

A few variables < br style="color: #696969; line-height: 28px; font-family: "H iragino Sans GB W3", "Hiragino Sans GB", Arial, Helvetica, simsun, u5b8bu4f53; font-size: 14px"> $releasever, the release version, obtained from distroverpkg in the [main] section, if not, according to redhat-release Package to judge.
$arch, cpu system, such as i686, athlon, etc.
$basearch, the basic system group of cpu, such as i686 and athlon belong to i386, and alpha and alphaev6 belong to alpha.
After setting yum.conf, we can experience the convenience brought by yum.

There is one more Things are not done. That is to import the GPG key of each repository. As mentioned earlier, yum can use gpg to verify the package to ensure the integrity of the downloaded package, so we must first go to each repository site to find the gpg key, which is usually placed on the homepage. Location, some plain text files with names such as RPM-GPG-KEY.txt, download them, and then use the rpm –import xxx.txt command to import them. It is best to import the GPG-KEY that comes with the distribution, rpm –import /usr/share/doc/redhat-release-*/RPM-GPG-KEY 官方软件升级用的上。

再分享一下我老师大神的人工智能教程吧。 Zero-based! Easy to understand! Funny and humorous! Also bring yellow jokes! Hope you join our artificial intelligence team too! https://blog.csdn.net/jiangjunshow

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

vi /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever

#cachedir:yum缓存的目录,yum在此存储下载的rpm包和数据库,一般是/var/cache/yum/$basearch/$releasever。

keepcache=1

#keepcache:是否保留缓存内容,0:表示安装后删除软件包,1表示安装后保留软件包

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
#gpg chkeck= 有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] 片段相同)。

第二部分:
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 官方软件升级用的上。

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4854 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.