[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