配置网络yum仓库和本地仓库

一、配置网络yum源

环境:centos 6.9

具体操作如下:

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

或者

curl -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

或者

curl -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

或者

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

3、清空缓存

yum clean all

4、加载新yum源缓存

yum makecache

5、验证是否配置成功

yum repolist

------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------

二、配置本地yum源

1、在虚拟机设置里加载光盘

2、挂载光盘

mount  /dev/cdrom  /mnt

挂载完后在/mnt目录下  有一个packages和repodate目录

packages 下是光盘中所有可以安装的rpm包

repodate  下是这些rpm包的元数据信息

3、编辑

vi /etc/yum.repos.d/CentOS-Base.repo 

用以下内容替换该文件内容:

[local]
name=CentOS-$releasever - Base --local
failovermethod=priority
baseurl=file:///mnt
gpgcheck=0

4、清空缓存

yum clean all

5、加载新yum源缓存

yum makecache

6、验证是否配置成功

yum repolist

猜你喜欢

转载自blog.csdn.net/pengzonglu7292/article/details/88951953