zoukankan      html  css  js  c++  java
  • 关闭安装包更新使用YUM在Linux中(RHEL / CentOS / Fedora)

    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
    plugins=1
    installonly_limit=5
    bugtracker_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.in
    base | 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 Process
    No Packages marked for Update

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

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

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

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

    [epel]
    name=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 python

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

    # yum --enablerepo=epel update perl php python

    输出如下:

    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: mirrors.hns.net.in
    * epel: ftp.kddilabs.jp
    * extras: mirrors.hns.net.in
    * updates: mirrors.hns.net.in
    Setting up Update Process
    No Packages marked for Update

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

    # yum --exclude=httpd update

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

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

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

  • 相关阅读:
    面向对象的思维
    343. 整数拆分
    413. 等差数列划分
    303. 区域和检索
    62. 不同路径
    char类型与int类型相加
    mybatis里面resultmap的问题
    easyui的datagrid如何获取一个对象里面的成员对象里面的属性?
    ==和equls的区别
    泛型的使用思想
  • 原文地址:https://www.cnblogs.com/Hackerman/p/10920613.html
Copyright © 2011-2022 走看看