当前位置首页 > Fedora知识

关闭安装包更新使用YUM在Linux中(RHEL/CentOS/Fedora)

阅读次数:253 次  来源:admin  发布时间:

YUM (Yellowdog Updater Modified) 是一个开源的命令行工具,以及基于图形的软件包管理工具, 用于基于 RPM (RedHat Package Manager) 的 Linux 系统。它允许用户和系统管理员容易的安装,升级,卸载或者查找软件安装包在Linux系统中,它被开发以及发布通过 Seth Vidal 开源在GPL(General Public License) 下。这样的话任何人都可以下载和访问代码进行开发以及修复Bugs。YUM使用大量的第三方仓库通过依赖来自动安装包。

但是有些时候我们不想要更新一些安装包例如Apache,Mysql,PHP等其它主要的应用程序,因为更新的话将会对正在运行的web程序。要么就是你停止web应用程序等更新完成之后在启动。

在这篇文章我们主要展示如何关闭安装包的更新使用YUM工具,我们能够关闭安装包的更新从第三方仓库,那个关闭命令如下:

exclude=package package1 packages*

以上语法将排除“package“, “package1” 以及“package“更新或者安装的列表。每个关键字将被使用空格分离开。

如何关闭安装包更新使用YUM

关闭指定的安装包更新,需要修改/etc/yum.conf 文件。

# vi /etc/yum.conf

增加以下exclude的行在文件的底部,展示如下。

[main]

cachedir=/var/cache/yum/$basearch/$releasever

keepcache=0

debuglevel=2

logfile=/var/log/yum.log

exactarch=1

obsoletes=1

gpgcheck=1

lugins=1

installonly_limit=5

ugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release

# This is the default, if you make this bigger yum won't see if the metadata

# is newer on the remote and so you'll "gain" the bandwidth of not having to

# download the new metadata and "pay" for it by yum not having correct

# information.

# It is esp. important, to have correct metadata, for distributions like

# Fedora which don't keep old packages around. If you don't like this checking

# interupting your command line usage, it's much better to have something

# manually check the metadata once an hour (yum-updatesd will do this).

# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo

# in /etc/yum.repos.d

## Exclude following Packages Updates ##

exclude=httpd php mysql

在以上例子中,红色标记的行将关闭“httpd” “php” 和“MySQL”安装包的更新,接下来让我们试着安装和更新它们其中的一个试一下。

# yum update httpd

输出如下:

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: centos.01link.hk

* extras: centos.01link.hk

* updates: mirrors.hns.net.i

ase | 3.7 kB 00:00

extras | 3.0 kB 00:00

updates | 3.5 kB 00:00

updates/primary_db | 2.7 MB 00:16

Setting up Update Proce

No Packages marked for Update

如何关闭安装包更新从EPEL Repo

关闭指定的安装包更新从EPEL仓库,需要修改/etc/yum.repos.d/epel.repo文件。

# vi /etc/yum.repos.d/epel.repo

增加以下exclude的行在文件的底部,展示如下。

[epel]

ame=Extra Packages for Enterprise Linux 6 - $basearch

#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

failovermethod=priority

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

## Exclude following Packages Updates ##

exclude=perl php pytho

在以上例子中,红色标记的行将关闭“httpd” “php” 和“MySQL”安装包的更新,接下来我们试一下在EPEL仓库中更新一下安装包试一下。

# yum --enablerepo=epel update perl php pytho

输出如下:

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirrors.hns.net.i

* epel: ftp.kddilabs.j

* extras: mirrors.hns.net.i

* updates: mirrors.hns.net.i

Setting up Update Proce

No Packages marked for Update

你也可以不用配置以上两种方式,直接在命令行中新增排除参数来进行软件安装包更新的排除。例子如下:

# yum --exclude=httpd update

排除安装包的列表使用以下命令。

# yum --exclude=mysql\* --exclude=httpd\* update

以上是关闭安装包更新的一些方法,希望能帮助需要的朋友们,文章内容写得简单,望大家理解,有什么建议可以留言哦。

上一篇:Ubuntu虚拟机安装几点细节整理
下一篇:《centos系列》配置vim编辑器