yum repo文件详解

yum使用仓库保存管理rpm的软件包、仓库的配置文件保存在/etc/yum.repos.d/目录下格式如下:

[root@linuxprobe ~]# vim /etc/yum.repos.d/rhel7.repo
[rhel7]
name=rhel7 #描述仓库的基本信息,也可以就当个名称用
baseurl=file:///media/cdrom #仓库的地址,本地源或者网络源
enabled=1 #是否启用,1表示启用,0表示不启用
gpgcheck=0 #是否校验 1表示校验,0表示不校验

yum配置文件必须以.repo结尾,一个配置文件中可以保存多个yum仓库的配置信息,/etc/yum.repos.d/目录下可以存在多个配置文件.

使用yum操作软件的相关命令:
yum install software-name #安装指定的软件
yum remove software-name #卸载指定的软件
yum update software-name #更新指定的软件

使用yum进行查询操作:
yum search keyword #搜索
yum list (all|installed|recent|updates) #列出全部、安装的、最近的、软件更新
yum info packagename #显示指定软件信息
yum whatprovides packagename #查询哪个rpm包含软件包

repo文件常用变量

(1)$releasever:发行版的版本,从[main]部分的distroverpkg获取,如果没有,则根据redhat-release包进行判断。

(2)$arch,cpu体系,如i386、x86_64等。

(3)$basearch,cpu的基本体系组,如i686和athlon同属i386,alpha和alphaev6同属alpha。


阿里云的Centos-7.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-$releasever – Base – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

released updates

[updates]

name=CentOS-$releasever – Updates – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

additional packages that may be useful

[extras]

name=CentOS-$releasever – Extras – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$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-$releasever – Plus – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

contrib – packages by Centos Users

[contrib]

name=CentOS-$releasever – Contrib – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

发表评论

电子邮件地址不会被公开。 必填项已用*标注