非凡居

Centos7更新源方法,与遇到的问题

Centos7更新源方法,与遇到的问题

先进入到yum源文件cd /etc/yum.repo.d/

1、创建一个repo_bak目录,用于保存系统中原来yum的repo文件。

sudo mkdir repo_bak

2、备份yum源文件至repo_bak

sudo mv *.repo repo_bak/

3、到网易和阿里开源镜像站点下载系统对应版本的repo文件

wget http://mirrors.aliyun.com/repo/Centos-7.repo

4、清除系统yum缓存并生成新的yum缓存

yum clean all 清除系统yum 缓存

yum makecache 生成yum缓存

5、安装epel源

yum list | grep epel-release 

yum install -y epel-release

6、使用阿里开源镜像提供的epel源

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

7、再次清除系统yum缓存,并重新生成新的yum缓存

yum clean all 清除yum缓存

yum makecache 生成yum缓存

8、查看系统可用的yum源和所有的yum源

yum repolist enabled

遇到的问题:

yum提示Another app is currently holding the yum lock; waiting for it to exit…
可以通过强制关掉yum进程:

#rm -f /var/run/yum.pid

然后就可以使用yum了。