更改centos 5 yum源

简介:
根据需要选择设置源:
一、如何设置CentOS 5的yum源为上海交通大学网站
二、设置yum源为国内的服务器
三、CentOS 下使用本地镜像源
一。如何设置CentOS 5的yum源为上海交通大学网站
1.修改/etc/yum.repos.d/CentOS-Base.repo为:
CentOS-Base.repo
[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://ftp.sjtu.edu.cn/centos/5.0/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://ftp.sjtu.edu.cn/centos/5.0/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://ftp.sjtu.edu.cn/centos/5.0/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://ftp.sjtu.edu.cn/centos/5.0/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://ftp.sjtu.edu.cn/centos/5.0/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://ftp.sjtu.edu.cn/centos/5.0/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
2.执行
64位:
32位:
3.执行
yum update
Ok了,搞定。
二、设置yum源为国内的服务器:
1.相关需更改配置文件位置同上。
# 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-5 - Base
baseurl=http://mirror.be10.com/centos/5/os/i386/
gpgcheck=1
#released updates
[update]
name=CentOS-5 - Updates
baseurl=http://mirror.be10.com/centos/5/updates/i386/
gpgcheck=1
#packages used/produced in the build but not released
[addons]
name=CentOS-5 - Addons
baseurl=http://mirror.be10.com/centos/5/addons/i386/
gpgcheck=1
#additional packages that may be useful
[extras]
name=CentOS-5 - Extras
baseurl=http://mirror.be10.com/centos/5/extras/i386/
gpgcheck=1
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 - Plus
baseurl=http://mirror.be10.com/centos/5/centosplus/i386/
gpgcheck=1
enabled=0
#contrib - packages by Centos Users
[contrib]
name=CentOS-5 - Contrib
baseurl=http://mirror.be10.com/centos/5/contrib/i386/
gpgcheck=1
enabled=0
#packages in testing
[testing]
name=CentOS-5 - Testing
baseurl=http://mirror.be10.com/centos/5/testing/i386/
gpgcheck=1
enabled=0
三、CentOS 下使用本地镜像源
不知道大家有没有和我一样尝试使用rsync 同步mirrors.kernel.org/CentOS,总计超过6G的数据在只有30-50KB/s的速度下传输,也许需要3-5天才可以完成。怎么办?使用国内的服务器吧,但是他们只提供yum源更新,也就是只能使用http访问,而不提供rsync server。
这是我找到的一个速度不错的CentOS 4/5 yum源:218.201.144.68
使用wget将centos 5镜像到本地磁盘上
mkdir -pv /opt/CentOS
cd /opt/CentOS
以上命令会从网络上抓取2.6G左右的数据,会运行很长时间,你完全可以去做其它的工作。完成后,使用ls命令看看我们获取到的数据,我们只需要保留i386目录下面的数据,将其移动到opt,并将下载时产生的index.html?之类文件一并删除
cd /opt/CentOS/218.201.144.68/centos/5/os/
mv i386 /opt/CentOS5
cd /opt
rm -rf CentOS
find CentOS5 -name index.htm?\* -exec rm -f{}\;
下一步配置yum更新源。CentOS已经在/etc/yum.repos.d下面创建了CentOS-Media.repo,对该文件做适应修改就可以使用。以下是修改结果
[root@localhost etc]# cat yum.repos.d/CentOS-Media.repo
# CentOS-Media.repo
#
# This repo is used to mount the default locations for a CDROM / DVD on
# CentOS-5. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c4-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c4-media [command]
[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///opt/CentOS
# file:///media/cdrom/
# file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-beta
现在就可以使用yum check-update来测验一下本地源了。如果在没有连接网络情况,最好把yum.repos.d目录下面的其它repo文件适当更名,这样yum就只使用本地源,速度得以提升。

本文转自king_819 51CTO博客,原文链接:http://blog.51cto.com/kerry/102807,如需转载请自行联系原作者
相关文章
|
2月前
|
缓存
详解CentOS8更换yum源后出现同步仓库缓存失败的问题
详解CentOS8更换yum源后出现同步仓库缓存失败的问题
100 0
|
2月前
|
Linux 应用服务中间件 网络安全
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
293 0
|
2月前
|
缓存 Linux
Centos7中搭建本地yum源
Centos7中搭建本地yum源
133 0
|
10天前
|
缓存 Linux
linux centos7 挂载本地iso yum源
linux centos7 挂载本地iso yum源
51 0
|
10天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
47 0
|
1月前
|
Linux
centOS8不在维护,yum源问题解决
解决执行 yum makecache 出现appstream下载源数据失败问题
64 0
centOS8不在维护,yum源问题解决
|
1月前
|
Linux
linux centos6.8系统配置网络yum源
linux centos6.8系统配置网络yum源
78 0
|
2月前
|
Linux Shell
Linux:centos yum安装指令指南
Linux:centos yum安装指令指南
171 0
Linux:centos yum安装指令指南
|
2月前
|
SQL Linux Shell
centos yum 升级 glibc
在 CentOS 上使用 YUM 升级 GLIBC 库需要谨慎操作,因为 GLIBC 库是系统的基础组件,错误的升级可能导致系统不稳定或与现有应用程序不兼容。 以下是升级 GLIBC 库的步骤: 1. 备份重要数据:在执行任何系统级更改之前,请确保备份重要的数据和配置文件,以防止数据丢失或配置错误。 2. 更新系统:使用 YUM 更新系统软件包,确保系统是最新的稳定版本。可以使用以下命令进行更新: ```sql sudo yum update ``` 3. 备份 GLIBC 库:在升级之前,建议备份当前的 GLIBC 库。可以使用以下命令进行备份: ```bash sudo cp
608 0
|
4月前
|
缓存 Linux
centos7更换yum源 一条命令搞定
centos7更换yum源 一条命令搞定
318 0