我们在更新yum源或者出现配置yum源之后,通常都会使用yum makecache 生成索引缓存索引提供搜索安装速度,索引缓存存储位置; /var/cache/yum/
yum makecache fast
yum makecache fast命令是将软件包信息提前在本地索引缓存,用来提高搜索安装软件的速度,建议执行这个命令可以提升yum安装的速度。
yum clean all
yum 会把下载的软件包和header存储在cache中而不自动删除。如果觉得占用磁盘空间,可以使用yum clean指令清除索引缓存和下载包的缓存。
验证:
1、查看当前索引缓存目录大小
[root@localhost 7]# cd /var/cache/yum/
[root@localhost 7]# du -sh *
112M base
8.0K CentOS-Base
8.0K docker-ce-stable
163M epel
4.2M extras
12K gitlab_gitlab-ce
12K gitlab_gitlab-ce-source
8.0K mysql56-community
8.0K mysql-connectors-community
8.0K mysql-tools-community
8.0K nginx
0 onlyoffice
4.0K timedhosts
0 timedhosts.22657
0 timedhosts.txt
114M updates
0 zabbix
0 zabbix-non-supported
2、清掉所有索引缓存,并查看索引缓存目录大小,查看结果已经清掉了
[root@localhost 7]#yum clean all
[root@localhost 7]# du -sh *
0 base
8.0K CentOS-Base
8.0K docker-ce-stable
0 epel
0 extras
12K gitlab_gitlab-ce
12K gitlab_gitlab-ce-source
8.0K mysql56-community
8.0K mysql-connectors-community
8.0K mysql-tools-community
8.0K nginx
0 onlyoffice
4.0K timedhosts
0 timedhosts.22657
0 updates
0 zabbix
0 zabbix-non-supported
3、生成yum索引缓存,并查看目录大小,查看结果目录大小恢复了
[root@localhost 7]# yum makecache
已加载插件:fastestmirror, langpacks
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/16): base/7/x86_64/group_gz | 153 kB 00:00:01
(2/16): base/7/x86_64/filelists_db | 7.2 MB 00:00:11
(3/16): epel/x86_64/group_gz | 96 kB 00:00:00
(4/16): epel/x86_64/updateinfo | 1.0 MB 00:00:02
(5/16): epel/x86_64/prestodelta | 520 B 00:00:00
(6/16): base/7/x86_64/other_db | 2.6 MB 00:00:15
(7/16): base/7/x86_64/primary_db | 6.1 MB 00:00:30
(8/16): epel/x86_64/primary_db | 6.9 MB 00:00:17
(9/16): extras/7/x86_64/filelists_db | 235 kB 00:00:00
(10/16): extras/7/x86_64/other_db | 143 kB 00:00:00
(11/16): extras/7/x86_64/primary_db | 242 kB 00:00:05
(12/16): epel/x86_64/other_db | 3.4 MB 00:00:12
(13/16): epel/x86_64/filelists_db | 12 MB 00:00:36
(14/16): updates/7/x86_64/primary_db | 8.8 MB 00:00:21
(15/16): updates/7/x86_64/other_db | 680 kB 00:00:00
(16/16): updates/7/x86_64/filelists_db | 5.1 MB 00:00:28
Determining fastest mirrors
元数据索引缓存已建立
[root@localhost 7]# du -sh *
112M base
8.0K CentOS-Base
8.0K docker-ce-stable
163M epel
4.2M extras
12K gitlab_gitlab-ce
12K gitlab_gitlab-ce-source
8.0K mysql56-community
8.0K mysql-connectors-community
8.0K mysql-tools-community
8.0K nginx
0 onlyoffice
4.0K timedhosts
0 timedhosts.22657
0 timedhosts.txt
114M updates
0 zabbix
0 zabbix-non-supported