yum本身比较简陋,但是可以通过增加插件及yum安装源来增强,以方便使用。
【常用插件】
yum-fastestmirror #自动选择最快的yum源
yum-priorities #多yum源下优先级支持
yum-downloadonly
#只下载rpm包而不安装
【yum安装源】
RPMForge(http://pkgs.repoforge.org)拥有4000多种CentOS的软件包,被CentOS社区认为是最安全也是最稳定的一个软件仓库。
|
【使用yum-install.sh脚本自动安装插件及rpmforge源】
#!/bin/sh
#使用: ./yum-install.sh
#安装必要插件
yum install -y yum-fastestmirror
yum install -y yum-priorities
#vi /etc/yum/pluginconf.d/priorities.conf #确认 enabled = 1
#准备目录
cd /etc/yum.repos.d/
rm *.rpm
mkdir rpmforge_bak
yum install -y wget
#下载安装rpmforge
#从 http://rpmrepo.org/RPMforge/Using 可以得到rpmforge的最新版本
if [ "$HOSTTYPE" == "i686" ]
then
wget http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/apt-0.5.15lorg3.94a-5.el5.rf.x86_64.rpm
wget http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
elif [ "$HOSTTYPE" == "x86_64" ]
then
wget http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/apt-0.5.15lorg3.94a-5.el5.rf.i386.rpm
wget http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
fi
rpm -Uvh *.rpm
mv *.rpm rpmforge_bak
#安装其他插件
yum install -y yum-downloadonly
使用:./yum-install.sh
[root@instant_cacti ~]# yum --help #执行该命令,可以看到以下插件已经生效
Loaded plugins: downloadonly, fastestmirror, priorities
...
Loaded plugins: downloadonly, fastestmirror, priorities
...
【yum-downloadonly插件使用】
[root@instant_cacti ~]# yum --help|grep
download
Loaded plugins: aliases, changelog, downloadonly, fastestmirror, priorities
--downloadonly don't update, just download
--downloaddir=DLDIR specifies an alternate directory to store packages
Loaded plugins: aliases, changelog, downloadonly, fastestmirror, priorities
--downloadonly don't update, just download
--downloaddir=DLDIR specifies an alternate directory to store packages
[root@instant_cacti ~]# yum
install -y cacti --downloadonly --downloaddir=./ #下载rpm包到当前目录
...
...
Remove 0 Package(s)
Install 1 Package(s)
Downgrade 0 Package(s)
Total download size: 2.2 M
Downloading Packages:
cacti-0.8.7g-2.el5.rf.noarch.rpm 0% [ ] 0.0 B/s | 16 kB --:-- ETAcacti-0.8.7g-2.el5.rf.noarch.rpm | 2.2 MB 00:05
exiting because --downloadonly specified
Install 1 Package(s)
Downgrade 0 Package(s)
Total download size: 2.2 M
Downloading Packages:
cacti-0.8.7g-2.el5.rf.noarch.rpm 0% [ ] 0.0 B/s | 16 kB --:-- ETAcacti-0.8.7g-2.el5.rf.noarch.rpm | 2.2 MB 00:05
exiting because --downloadonly specified