软件包管理器yum

Catalogue
  1. 1. 异常一
  2. 2. 异常二
  3. 3. 异常三
  4. 4. 用yum安装本地rpm包

yum的搜索功能
yum whatprovides tshark

异常一

CentOS7 yum安装软件提示:
another app is currently holding the yum lock;waiting for it to exit

yum在锁定状态中。
可以通过强制关掉yum进程:

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

异常二

错误:无法从 /var/lib/rpm 打开软件包数据库

1
2
3
cd /var/lib/rpm
rm -rf __db.*
rpm --rebuilddb

无法从/var/lib/rpm打开软件包数据库

异常三

Cannot find a valid baseurl for repo: base/7/x86_64

重新编写/etc/yum.repos.d/CentOS-Base.repo文件

进一台正常的机器,把/etc/yum.repos.d/CentOS-Base.repo文件内容复制过来就行

yum源配置文件/etc/yum.repos.d/CentOS-Base.repo,内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
cat /etc/yum.repos.d/CentOS-Base.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-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

1
2
3
4
5
6
7
8
9
清除缓存

yum clean all

rm -rf /var/cache/yum/

生成缓存

yum makecache

用yum安装本地rpm包

无法使用网络的环境下,可以使用yum安装本地rpm包

1
yum localinstall XXX.rpm

这样可能会出现依赖错误,那么根据报错提示安装相应的包即可