Centos5.0 yum的使用与详细配置

转自:http://blog.163.com/herod_xiao/

yum = Yellow dog Updater, Modified
主要功能是更方便的添加/删除/更新RPM包.
它能自动解决包的倚赖性问题.
它能便于管理大量系统的更新问题

yum 的配置文档在 /etc/yum中

相关文件有yum.conf

[root@test56 uc]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Media.repo
两红色配置文件就是用来yum安装、更新rpm包的

CentOS-Base.repo是外网更新站点

CentOS-Media.repo是本地媒介更新点

vi CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os ;镜像点
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

 

由于http://mirrorlist.centos.org/为国外站点,更新、安装速度慢,下面是国外镜像点

etc/yum.repos.d/CentOS-Base.repo
CentOS5 yum国内镜像服务器 配置文件:

[base]
name=CentOS-5 - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&
repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://mirror.be10.com/centos/$releasever/os/$basearch/
http://ftp.hostrino.com/pub/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#released updates
[update]
name=CentOS-5 - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://mirror.be10.com/centos/$releasever/updates/$basearch/
http://ftp.hostrino.com/pub/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#packages used/produced in the build but not released
[addons]
name=CentOS-5 - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
baseurl=http://mirror.be10.com/centos/$releasever/addons/$basearch/
http://ftp.hostrino.com/pub/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#additional packages that may be useful
[extras]
name=CentOS-5 - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras

baseurl=http://mirror.be10.com/centos/$releasever/extras/$basearch/
http://ftp.hostrino.com/pub/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://mirror.be10.com/centos/$releasever/centosplus/$basearch/
http://ftp.hostrino.com/pub/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#contrib - packages by Centos Users
[contrib]
name=CentOS-5 - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://mirror.be10.com/centos/$releasever/contrib/$basearch/
http://ftp.hostrino.com/pub/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

 

配置档案参数的说明:

gpgchkeck= 有1和0两个选择,分别代表是否是否进行gpg校验,如果没有这一项,默认好像也是检查的。

enabled=0 表示不启用此更新库

name,是对repository的描述,支持像 ;
baseurl是服务器设置中最重要的部分,只有设置正确,才能从上面获取软件。

yum可以使用gpg对包进行校验,确保下载包的完整性,所以我们先要到各个repository站 点找到gpg key

 

如果想让yum在光盘内更新RPM包,做如下设置

默认系统会直接找到CentOS-Base.repo(是外网更新站点)做更新、安装

我们可以修改其文件名让系统找不到此文件,然后找

CentOS-Media.repo是本地媒介更新点

做更新、安装,这样速度会快的多

mv CentOS-Base.repo CentOS-Base.repo.bak

启用CentOS-Media.repo ,做如下配置

# mkdir /dvd
# mount /dev/cdrom /dvd

vi CentOS-Media.repo

[c5-media] ;这个没有启用
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
file:///media/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-beta

[dvd]
name=dvd
baseurl=file:///dvd
gpgcheck=0 ;不检查gpgkey
 

这样就可以使用yum来更新了

yum使用方法

查看一软件包

yum list | grep mysql ;查看mysq软件包

yum update

yum install mysq ;安装mysql软件包

你可能感兴趣的:(linux,centos,职场,yum,休闲)