CentOS更改yum源

简介:

[1] 首先备份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

[2] 进入yum源配置文件所在文件夹

[root@localhost yum.repos.d]# cd /etc/yum.repos.d/

[3] 下载163的yum源配置文件,放入/etc/yum.repos.d/(操作前请做好相应备份)

[root@localhost yum.repos.d]#

[4] 运行yum makecache生成缓存

[root@localhost yum.repos.d]#

[5] 更新系统

[root@localhost yum.repos.d]#

[6] 安装vim编辑器

[root@localhost ~]#



一、配置yum源

网易(163)yum源是国内最好的yum源之一 ,无论是速度还是软件版本,都非常的不错,将yum源设置为163yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。具体设置方法如下: 

1,进入yum源配置目录

1
#cd /etc/yum.repos.d

2,备份系统自带的yum源

1
#mv CentOS-Base.repo CentOS-Base.repo.bk

下载163网易的yum源:

1
#wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

3,更新玩yum源后,执行下边命令更新yum配置,使操作立即生效

1
#yum makecache

4,除了网易之外,国内还有其他不错的yum源,比如中科大和搜狐的,大家可以根据自己需求下载

中科大的yum源:

1
#wget http://centos.ustc.edu.cn/CentOS-Base.repo

sohu的yum源

1
#wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo

理论上讲,这些yum源redhat系统以及fedora也是可以用 的,但是没有经过测试,需要的可以自己测试一下。



二、安装yum-downloadonly,下载rpm软件包



方法1、安装yum-downloadonly插件,下载rpm包

 

1
2
3
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
#yum install yum-downloadonly
#yum install --downloadonly --downloaddir=/nginx.rpm pcre

如果下载不到yum-downloadonly这个软件包,请查看附件,下载之后解压缩,上传到linux上,进行安装。


方法2、修改配置文件/etc/yum.conf ,将 keepcache=0 修改为 keepcache=1


通过yum安装的软件将会在下面的cachedir中缓存。


cachedir=/var/cache/yum/$basearch/$releasever


例如:

1
2
3
# cd /var/cache/yum/x86_64/6/base/packages/
libpcap-1.4.0-4.20130826git2dbcaa1.el6.x86_64.rpm   
tcpdump-4.0.0-9.20090921gitdf3cb4.2.el6.x86_64.rpm

三、使用CentOS的iso搭建本地yum源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ls /etc/yum.repos.d/
#CentOS-Base.repo  CentOS-Media.repo
#cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
#vim /etc/yum.repos.d/CentOS-Base.repo
       1 [dvd]
       2 name= install  dvd
       3 baseurl= file : ///media/CentOS_6 .5_Final #iso的挂载路径
       enable =1
       5 gpgcheck=1 #是否对下载的rpm包进行安全检查
       6 gpgkey= file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#yum makecache 
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
dvd                                                                                  | 1.1 kB     00:00     
dvd /filelists                                                                         | 2.9 MB     00:00     
dvd /other                                                                             | 9.1 MB     00:00     
dvd /group                                                                             | 920 kB     00:00     
dvd /primary                                                                           | 920 kB     00:00     
dvd                                                                                               2599 /2599
dvd                                                                                               2599 /2599
dvd                                                                                               2599 /2599
Metadata Cache Created



cat rhel-debuginfo.repo



[Cluster]

name=Red Hat Enterprise Linux $releasever - $basearch - Cluster

baseurl=file:///mnt/cdrom/Cluster

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[ClusterStorage]

name=Red Hat Enterprise Linux $releasever - $basearch - ClusterStorage

baseurl=file:///mnt/cdrom/ClusterStorage

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[Server]

name=Red Hat Enterprise Linux $releasever - $basearch - Server

baseurl=file:///mnt/cdrom/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[VT]

name=Red Hat Enterprise Linux $releasever - $basearch - VT

baseurl=file:///mnt/cdrom/VT

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release











本文转自 chengxuyonghu 51CTO博客,原文链接:http://blog.51cto.com/6226001001/1897399,如需转载请自行联系原作者
目录
相关文章
|
2月前
|
缓存
详解CentOS8更换yum源后出现同步仓库缓存失败的问题
详解CentOS8更换yum源后出现同步仓库缓存失败的问题
107 0
|
2月前
|
Linux 应用服务中间件 网络安全
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
307 0
|
2月前
|
缓存 Linux
Centos7中搭建本地yum源
Centos7中搭建本地yum源
138 0
|
20小时前
|
Linux
centos 6.5安装yum
centos 6.5安装yum
6 0
|
2天前
|
存储 Linux 网络安全
centos7使用yum网络安装
这些是使用Yum进行网络安装的基本步骤。根据你的需求,你可以重复步骤3和4来安装其他软件包。请注意,执行Yum操作需要root或具有sudo权限的用户。
14 1
|
14天前
|
缓存 Linux
linux centos7 挂载本地iso yum源
linux centos7 挂载本地iso yum源
64 0
|
14天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
68 0
|
1月前
|
Linux
centOS8不在维护,yum源问题解决
解决执行 yum makecache 出现appstream下载源数据失败问题
66 0
centOS8不在维护,yum源问题解决
|
1月前
|
Linux
linux centos6.8系统配置网络yum源
linux centos6.8系统配置网络yum源
98 0
|
2月前
|
Linux Shell
Linux:centos yum安装指令指南
Linux:centos yum安装指令指南
173 0
Linux:centos yum安装指令指南