1.1 什么是 yum 源
Yellowdog Updater, Modified
一个基于 RPM 包管理的字符前端软件包管理器.
能够从指定的服务器自动下载 RPM 包并且安装, 可以处理依赖性关系, 并且一次安装所有依赖的软件包, 无须繁琐地一次次下载, 安装.
简单来说就是软件仓库 --yum 源 / 仓库, 类似于应用宝之类.
1.2 修改 yum 源
1.2.1 yum 源分类
按系统选择 yum 源
阿里云的 yum 源
- 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
首选以上阿里云的 yum 源 如果阿里云的 yum 源不能用
可以选择清华大学的 yum 源 https://mirrors.tuna.tsinghua.edu.cn/
1.2.2 修改过程
操作前备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
系统是 CentOS 6.9 所以选择 6 的 yum 源
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
修改完后 生成本地缓存 (缓存无处不在)
yum makecache
1.3 增加 epel 源
增加一个 epel 源
epel 源是什么
epel 源 --- 增加和扩展 yum 仓库 里面包含了许多基本源里没有的软件.
1.3.1 epel 源分类
首选以上阿里云的 epel 源 如果阿里云的 epel 源不能用
可以选择清华大学的 epel 源 地址: https://mirrors.tuna.tsinghua.edu.cn/
- 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
1.3.2 修改过程
按系统选择 epel 增加就可以 直接执行
- epel(RHEL 6)
- wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
1.4 yum 相关参数
1.4.1 清除本地的 yum 缓存.
yum clean all 清空 yum 缓存 (缓存的是软件的列表)
1.4.2 查看系统当前的 yum 源
yum repolist
系统的 yum 源默认是从世界各地下载软件, 优先选择自己离得最近的源下载, 不稳定.
- [root@oldboyedu-50 ~]# yum repolist
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.aliyun.com
- * extras: mirrors.aliyun.com
- * updates: mirrors.aliyun.com
- base | 3.7 kB 00:00
- epel | 3.2 kB 00:00
- epel/primary | 3.2 MB 00:09
- epel 12518/12518
- extras | 3.4 kB 00:00
- updates | 3.4 kB 00:00
- updates/primary_db | 1.2 MB 00:03
- repo id repo name status
- base CentOS-6 - Base - mirrors.aliyun.com 6,713
- epel Extra Packages for Enterprise Linux 6 - x86_64 12,518
- extras CentOS-6 - Extras - mirrors.aliyun.com 31
- updates CentOS-6 - Updates - mirrors.aliyun.com 113
repolist: 19,375 此位置相当于软件包的数量 系统默认的 yum 源 软件包大概 6000 多 这里是已经修改后的
1.5 yum 常见的错误
1.5.1 查看系统 yum 源出现的错误
查看系统 yum 源可能出现的错误
- [root@oldboy-50 ~]# yum repolist
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- repolist: 0
- [root@oldboy-50~]# ls -l /etc/yum.repos.d
- total 40
- -rw-r--r-- 1 root root 2572 Jul 2 2014 CentOS-Base.repo
/etc/yum.repos.d 目录下的 .repo 文件的内容没有 或 被删除都可以导致找不到 yum 源.
会出现以上的错误.
1.5.2 yum 正在运行
- [root@znix ~]# yum install tree
- Loaded plugins: fastestmirror, security
- Existing lock /var/run/yum.pid: another copy is running as pid 5219.
- Another app is currently holding the yum lock; waiting for it to exit...
- The other application is: yum
- Memory : 23 M RSS (859 MB VSZ)
- Started: Fri Sep 15 08:46:52 2017 - 00:12 ago
- State : Sleeping, pid: 5219
状态 :pid 5219
正在运行的 yum 的 pid
1.5.2.1 解决办法
1) 可以等待该 yum 程序执行完毕, 就可以进行安装
2) 可以 使用 kill 命令 将这个 pid 进程结束进程
- [root@znix ~]# ps -ef |grep 5219
- root 5219 5095 44 08:52 pts/1 00:00:21 /usr/bin/python /usr/bin/yum makecache
- root 5232 5146 0 08:53 pts/2 00:00:00 grep --color=auto 5219
来源: https://www.cnblogs.com/wenrulaogou/p/9488317.html