yum緩存

[root@localhost ~]# ls /var/ftp/
pub  rhel5  rhel6
[root@localhost ~]#
YUM倉庫有兩個rhel5、rhel6

 YUM客戶端的配置如下:

[root@s2 ~]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum
keepcache=0

debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
metadata_expire=1800

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

[root@s2 ~]# cat /etc/yum.repos.d/rhel.repo
[rhel]
name=Red Hat
baseurl=ftp://192.168.1.29/rhel5
enabled=1
gpgcheck=0

1.使用 yum 緩存

 默認情況下,yum客戶端在成功下載和安裝軟包後會把下載的文件刪掉而不進行緩存。這樣可以減少磁盤空間的佔用。需要時可以啓用緩存功能,這樣yum可以將rpm數據緩存到YUM的緩存目錄中。

緩存的好處:提高YUM的性能;可以離線運行YUM操作,只使用緩存;也可以複製緩存中的軟件包以備用。

 

存放下載的軟件包、倉庫信息等數據

§位於/var/cache/yum/$basearch/$releasever

 

 

2. 啓用 yum 緩存 客戶端的/etc/yum.conf中的keepcache=1

打​開​緩​存​後​,每​個​ yum 操​作​都​可​​從​倉​庫​下​載​軟​件​包​數​據​。​要​保​證​緩​存​包​含​了​軟​件​包​數​據​,在​啓​用​緩​存​後需要​運​行​一​個​操​作​,例​如​ list 或​ search 來​下​載​軟​件​包​數​據​而​不​影​響​系​統​。​
修改keepcache=1後:
[root@s2 ~]# ls /var/cache/yum/
[root@s2 ~]#
[root@s2 ~]# yum -y install httpd
……
[root@s2 ~]# ls /var/cache/yum/
rhel
[root@s2 ~]# ls /var/cache/yum/rhel/
cachecookie  headers  packages  primary.xml.gz  primary.xml.gz.sqlite  repomd.xml
[root@s2 ~]# ls /var/cache/yum/rhel/packages/
httpd-2.2.3-6.el5.i386.rpm
[root@s2 ~]#
[root@s2 ~]# ls /var/cache/yum/rhel/headers/
httpd-2.2.3-6.el5.i386.hdr[root@s2 ~]# du -sh /var/cache/yum/rhel/packages/httpd-2.2.3-6.el5.i386.rpm
1.1M    /var/cache/yum/rhel/packages/httpd-2.2.3-6.el5.i386.rpm

 

3.在​只​使​用​緩​存​的​模​式​下​使​用​ yum

要​在​沒​有​網​絡​的​情​況​下​執​行​ yum,只​要​啓​用​了​緩​存​,就​可​以​用​ -C 選​項​。​這​樣​ yum 就​不​會​檢​查​網​絡​上​的​倉​庫​,只​使​用​緩​存​。​在​這​個​模​式​中​,yum 只​能​安​裝​已​下​載​並​緩​存​的​軟​件​包​。​[root@localhost ~]# service vsftpd stop
Shutting down vsftpd:                                      [  OK  ]
[root@localhost ~]# 

因爲客戶端緩存的有httpd的rpm包,所以[root@s2 ~]# yum -y remove httpd可以執行成功。緩存中沒有dhcp的rpm包,所以[root@s2 ~]# yum -y install dhcp這條命令不能正確執行。

 

4.清空yum緩存
[root@s2 ~]# ls /var/cache/yum/rhel/headers/
dhcp-3.0.5-3.el5.i386.hdr  httpd-2.2.3-6.el5.i386.hdr
[root@s2 ~]# yum clean headers
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
2 headers removed
[root@s2 ~]# ls /var/cache/yum/rhel/headers/
[root@s2 ~]#
[root@s2 ~]# ls /var/cache/yum/rhel/packages/
dhcp-3.0.5-3.el5.i386.rpm  httpd-2.2.3-6.el5.i386.rpm
[root@s2 ~]# yum clean packages
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
2 packages removed
[root@s2 ~]# ls /var/cache/yum/rhel/packages/
[root@s2 ~]#
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章