分类: LINUX
2011-04-03 11:08:45
yum的配置文件:/etc/yum.conf
下载文件保存路径:/var/cache/yum/extras/packages(yum默认是不保存rpm包的,需要把配置文件里keepcache设为“1”)
重启yum:# service yum-updatesd restart
更换163源
1.备份系统先前的配置文件CentOS-Base.repo
# cp CentOS-Base.repo CentOS-Base.repo.bak
2.编辑配置文件
#vi /etc/yum.repos.d/CentOS-Base.repo
CentOS-Base.repo内容如下
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# 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
#mirrorlist=$releasever&arch=$basearch&repo=os
#baseurl=$releasever/os/$basearch/
baseurl=$releasever/os/$basearch/
gpgcheck=1
gpgkey=#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=$releasever&arch=$basearch&repo=updates
#baseurl=$releasever/updates/$basearch/
baseurl=$releasever/updates/$basearch/
gpgcheck=1
gpgkey=#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#mirrorlist=$releasever&arch=$basearch&repo=addons
#baseurl=$releasever/addons/$basearch/
baseurl=$releasever/addons/$basearch/
gpgcheck=1
gpgkey=#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=$releasever&arch=$basearch&repo=extras
#baseurl=$releasever/extras/$basearch/
baseurl=$releasever/extras/$basearch/
gpgcheck=1
gpgkey=#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=$releasever&arch=$basearch&repo=centosplus
#baseurl=$releasever/centosplus/$basearch/
baseurl=$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=
相关参数:
repositoryid:用于指定一个仓库
name:用于指定易读的仓库名称
baseurl:用于指定本仓库的URL,可以是以下的3种类型,如http,ftp,file
mirrorlist:用于指定仓库的镜像站点
enable:用于指定是否使用本仓库,默认值为1,即可用。
gpgcheck:用于指定是否检查软件包的GPG签名。
gpgkey:用于指定GPG签名文件的URL。
-----------------------------------------------------
RHEL5换centos源
一、删除RHEL5自带的yum
rpm -qa|grep yum 应该能够找到5个包
rpm -e –nodeps 用这条命令逐一删除
二、安装yum
安装yum软件包:
rpm -ivh
rpm -ivh
python-iniparse is needed by yum-3.2.19-18.el5.centos.noarch
yum-fastestmirror is needed by yum-3.2.19-18.el5.centos.noarchrpm -ivh
rpm -ivh --nodeps三、下载配置文件
cd /etc/yum.repos.d/
wget
mv CentOS-Base.repo.5 CentOS-Base.repo
因为默认的配置文件中服务器地址用的版本号是变量$releasever,所以需要将其替换为实际的版本号,否则是无法连接到服务器的,当前CentOS最新版是5.3,所以我们修改CentOS-Base.repo
在vi编辑CentOS-Base.repo中进行全文件替换
:1,$s/$releasever/5.3/g
最后保存退出即可。然后执行
-------------------------------------------------------
搭建本地源
先说下原理:随便在机器上建立一个http或是ftp的站点,然后去修改yum的配置文件,关掉它默认搜索的源的地址,改成我们自己建立的。
一、http站点形式的(测试成功过,也比较方便)
1)把rpm文件拷到本机的随便一个目录下(我在根目录下建立了一个/data目录)
2)安装apache(我用的rpm的):1.装完后用/etc/init.d/httpd start
命令启动,然后测试下是否起来了。2.起来就去改配置文件/etc/httpd/conf/httpd.conf:把DocumentRoot改成拷rpm包的目录,DocumentRoot
"/data"
3)改yum的配置文件。1。先到/etc/yum.repos.d下看看是否有个rhel-debuginfo.repo文件,有给他改名字,只要结尾不是repo就行。2. 拷贝rhel-debuginfo.repo 为update.repo,主要是怕手写写错了。3. 默认的里头是这些:
[rhel-debuginfo] name=Red Hat Enterprise Linux $releasever - $basearch - Debug baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release |
[rhel-debuginfo]:头部标题,随便写
name=:名字,也随便写了
baseurl=:这个要写你的http的地址
enabled=0 :是否开启,1是开启。0是关闭
gpgcheck=:是否校验key。肯定不了,选0
gpgkey=:这个是你key的地址,都不了,就不用写这个了。
改好后的是:
[base] name=base RPM Repository for RHEL5 baseurl= enabled=1 gpgcheck=0 |
以后就可以yum装软件了,如果不行,就把目录变成可浏览列表的那样。
二、ftp站点的
----------------------------------------------------------------------------------------------
1. 安装yum
2. 修改。repo文件
ccd /etc/yum.repos.d/
#vi CentOS-Base.repo
写入一下内容:
name=CentOS-5 - Base
#mirrorlist=
repo=os
#baseurl=
baseurl=
gpgcheck=1
gpgkey=
#released updates
name=CentOS-5 - Updates
#mirrorlist=
baseurl=
gpgcheck=1
gpgkey=
#packages used/produced in the build but not released
name=CentOS-5 - Addons
#mirrorlist=
baseurl=
gpgcheck=1
gpgkey=
#additional packages that may be useful
name=CentOS-5 - Extras
#mirrorlist=
baseurl=
gpgcheck=1
gpgkey=
#additional packages that extend functionality of existing
packages
name=CentOS-5 - Plus
#mirrorlist=
baseurl=
gpgcheck=1
enabled=0
gpgkey=
#contrib - packages by Centos Users
name=CentOS-5 - Contrib
#mirrorlist=
baseurl=
gpgcheck=1
enabled=0
gpgkey=
# vi dag.repo
name=Dag RPM Repository for RHEL5
baseurl=
enabled=1
gpgcheck=1
gpgkey=
3. 导入key
#rpm ——import
4. 运行,测试
#yum update