本地Yum源

本地yum源个人认为有3种,本地光盘镜像源,ftp共享源,以及国内第三方源如阿里云、网易、搜狐等,还有一种第三方库源叫epel;如有不足之处还请各方看官多多指正,感激不尽。现在一一列出,如下:

1.本地镜像源:
[root@linux ~]# mkdir -p /media/cdrom
[root@linux ~]# mount /dev/cdrom /media/cdrom
mount: /dev/sr0 is write-protected, mounting read-only
[root@linux ~]# vim /etc/yum.repos.d/rhel7.repo
[rhel7]
name=rhel7
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0


2.ftp共享源:
这个源和上面的差不多,都是局域网共享一个主服务器搭建出来的源,就是上面的baseurl=file://xxx改成ftp路径即可;


3.国内第三方源,这类源一般较之光盘源可能更新,里面的软件版本高一些,貌似centos7.5都能自动选择国内源了,默认repo文件情况下,下面是步骤:
更改yum源为网易的

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

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)

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

http://mirrors.163.com/.help/CentOS7-Base-163.repo

运行以下命令生成缓存

yum clean all

yum makecache


更改阿里云的yum源、以及扩展源。

1、备份

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

2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、之后运行yum makecache生成缓存

二 、配置阿里云的epel源。

1、备份(如有配置其他epel源)

mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup

mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

2、下载新repo 到/etc/yum.repos.d/

epel(RHEL 7)

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

epel(RHEL 6)

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

epel(RHEL 5)

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo


或者这样也行:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

你可能感兴趣的:(本地Yum源)