CentOS更改yum源

刺骨的言语ヽ痛彻心扉 2022-07-12 05:41 297阅读 0赞

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

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

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

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

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

  1. [root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

[4] 运行yum makecache生成缓存

  1. [root@localhost yum.repos.d]# yum makecache

[5] 更新系统

  1. [root@localhost yum.repos.d]# yum -y update

[6] 安装vim编辑器

  1. [root@localhost ~]# yum -y install vim*

**​cat CentOS-Base-aliyun.repo
# CentOS-Base.repo
#
# 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-6 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/os/$basearch/
http://mirrors.aliyuncs.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/updates/$basearch/
http://mirrors.aliyuncs.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/extras/$basearch/
http://mirrors.aliyuncs.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

163的yum

cat CentOS-Base-163.repo

# CentOS-Base.repo
#
# 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-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6**

一、配置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

发表评论

表情:
评论列表 (有 0 条评论,297人围观)

还没有评论,来说两句吧...

相关阅读

    相关 更改redhat yum

    步骤总结 1. 卸载原有的yum的rpm包 2. 去阿里镜像站下载centos必要的yum包 3. rpm -ivh yum- 安装相对应的rpm 4. 去阿里镜

    相关 更改Centos6的yum

    1、阿里云Linux安装软件镜像源 阿里云是最近新出的一个镜像源。得益与阿里云的高速发展,这么大的需求,肯定会推出自己的镜像源。阿里云Linux安装镜像源地址:http://