欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

linux下配置yum源方法详解

程序员文章站 2022-05-22 15:26:17
本人使用的方法一,成功配置,方法二没测过,可以作为参考 方法一: 1.确保rhel5中已经安装了yum [root@lvs-master ~]# r...

本人使用的方法一,成功配置,方法二没测过,可以作为参考

方法一:

1.确保rhel5中已经安装了yum

[root@lvs-master ~]# rpm -qa |grep yum 
yum-metadata-parser-2-el5 
yum-updatesd-9-el5 
yum-22-el5 
yum-security-16-el5 
yum-rhn-plugin-4-el5 

2.修改源配置文件 #vim /etc/yum.repos.d/centos-base.repo

(如果目录下没有.repo文件自己创建一个)

[base] 
name=centos-5-base 
#mirrorlist=http://mirrorlistcentosorg/?release=$releasever5&arch=$basearch&repo=os 
#baseurl=http://mirrorcentosorg/centos/$releasever/os/$basearch/ 
baseurl=http://ftpsjtueducn/centos/5/os/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos5 
#released updates 
[update] 
name=centos-5-updates 
#mirrorlist=http://mirrorlistcentosorg/?release=4&arch=$basearch&repo=updates 
baseurl=http://ftpsjtueducn/centos/5/updates/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos5 
#packages used/produced in the build but not released 
[addons] 
name=centos-5-addons 
#mirrorlist=http://mirrorlistcentosorg/?release=4&arch=$basearch&repo=addons 
baseurl=http://ftpsjtueducn/centos/5/addons/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos5 
#additional packages that may be useful 
[extras] 
name=centos-5-extras 
#mirrorlist=http://mirrorlistcentosorg/?release=4&arch=$basearch&repo=extras 
baseurl=http://ftpsjtueducn/centos/5/extras/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos5 
#additional packages that extend functionality of existing packages 
[centosplus] 
name=centos-5-plus 
#mirrorlist=http://mirrorlistcentosorg/?release=4&arch=$basearch&repo=centosplus 
baseurl=http://ftpsjtueducn/centos/5/centosplus/$basearch/ 
gpgcheck=1 
enabled=0 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos5 
#contrib - packages by centos users 
[contrib] 
name=centos-5-contrib 
#mirrorlist=http://mirrorlistcentosorg/?release=4&arch=$basearch&repo=contrib 
baseurl=http://ftpsjtueducn/centos/5/contrib/$basearch/ 
gpgcheck=1 
enabled=0 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos5 
# vi dagrepo 
[dag] 
name=dag rpm repository for rhel5 
baseurl=http://ftprikenjp/linux/dag/redhat/el5/en/$basearch/dag/ 
enabled=1 
gpgcheck=1 
gpgkey=http://ftprikenjp/linux/dag/packages/rpm-gpg-keydagtxt 

3. 导入key

#rpm --import http://ftp.sjtu.edu.cn/centos/5/os/i386/rpm-gpg-key-centos-5 

4. 运行,测试

#yum update 

5.clean操作

#yum clean all 

方法二:

# cd /etc/yum.repos.d/ 
#mv centos-baserepo centos-baserepobak 
#wget http://docslinuxtoneorg/soft/lemp/centos-baserepo 
该文件内容如下: 
[base] 
name=centos-5 - base 
baseurl=http://centosustceducn/centos/5/os/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos-5 
#released updates 
[update] 
name=centos-5 - updates 
baseurl=http://centosustceducn/centos/5/updates/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos-5 
#packages used/produced in the build but not released 
[addons] 
name=centos-5 - addons 
baseurl=http://centosustceducn/centos/5/addons/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos-5 
#additional packages that may be useful 
[extras] 
name=centos-5 - extras 
baseurl=http://centosustceducn/centos/5/extras/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos-5 
#additional packages that extend functionality of existing packages 
[centosplus] 
name=centos-5 - plus 
baseurl=http://centosustceducn/centos/5/centosplus/$basearch/ 
gpgcheck=1 
enabled=0 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos-5 
#contrib - packages by centos users 
[contrib] 
name=centos-5 - contrib 
baseurl=http://centosustceducn/centos/5/contrib/$basearch/ 
gpgcheck=1 
enabled=0 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos-5 
#packages in testing 
[testing] 
name=centos-5 - testing 
baseurl=http://centosustceducn/centos/5/testing/$basearch/ 
gpgcheck=1 
enabled=0 
gpgkey=http://mirrorcentosorg/centos/rpm-gpg-key-centos-5 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。