Yum 學習筆記

Yum 學習筆記

背景

Yumphp

學習教程

學習內容

Yellowdog Updater, Modifiedhtml

經常使用命令

  • 查看可用的更新linux

    yum check-update
  • 更新單個 rpmgit

    yum update package_name
  • 安裝全部的更新github

    yum update
    yum update-minimal --security
  • 定時更新包sql

    yum install yum-cron
    service yum-cron start
    service yum-cron status
  • 查找包數據庫

    yum search vim gvim emacs
    yum search all vim gvim emacs
  • 列出包vim

    yum list *rmc*
    yum list all
    yum list installed
    yum list available
    yum grouplist
    yum repolist
  • 查看包的詳情centos

    yum info package_name(rpm -q --info package_name)
  • 安裝包緩存

    yum install package_name
    yum install package_name package_name…
    yum groupinstall group_name
    yum groupinstall groupid
    • 查看特定文件屬於哪一個軟件包
    yum provides "*bin/named"
  • 卸載包

    yum remove package_name…
    yum groupremove group
  • 查看 yum 歷史

    yum history list
    yum history package-list *rmc*
    yum history addon-info last
    
    yum history new #新建歷史記錄
Action Abbreviation Description
Downgrade D At least one package has been downgraded to an older version.
Erase E At least one package has been removed.
Install I At least one new package has been installed.
Obsoleting O At least one package has been marked as obsolete.
Reinstall R At least one package has been reinstalled.
Update U At least one package has been updated to a newer version.
Symbol Description
< Before the transaction finished, the rpmdb database was changed outside Yum.
> After the transaction finished, the rpmdb database was changed outside Yum.
* The transaction failed to finish.
# The transaction finished successfully, but yum returned a non-zero exit code.
E The transaction finished successfully, but an error or a warning was displayed.
P The transaction finished successfully, but problems already existed in the rpmdb database.
s The transaction finished successfully, but the --skip-broken command-line option was used and certain packages were skipped.
  • 回滾操做

    yum history undo id
  • 重作

    yum history redo id
    yum -q history addon-info id saved_tx > file_name
    yum load-transaction file_nam
  • 掉電異常處理

    yum-complete-transaction
    yum-complete-transaction --cleanup-only

repo 配置項

  • 全局配置文件/etc/yum.conf

    cachedir=/var/cache/yum/$basearch/$releasever #緩存地址
    keepcache=0 #1:安裝成功後本地仍保留包 0:不保留
    debuglevel=2 #範圍1-10,級別越高,日誌越詳細,0:disable
    logfile=/var/log/yum.log #日誌文件
    exactarch=1 #是否檢查架構 0:不檢查 1:檢查(32位和64位不能互相兼容)
    obsoletes=1 # 1:更新時,執行老包廢棄邏輯
    gpgcheck=1 #是否進行gpg檢查 0:不檢查 1:檢查
    plugins=1 # 0:不可用全部插件 1:可用
    installonly_limit=5 #限制同時安裝的rpm個數
  • 子倉庫配置
  • 目錄:/etc/yum.repos.d/

    [xxx-base-12]
    name=xxx-base-12
    enabled=1
    gpgcheck=0
    baseurl=http://xxx.mmb.com/dev/os/centos6.7_64
  • 配置文件中的變量

    • $releasever 發行版,對應 conf 中的 distroverpkg.例如 6Client 或 6Server
    • $arch,CPU 架構, i686 或 x86_64
    • $basearch,系統基礎架構,i386 或 x86_64
    • $YUM0-9
  • 建立本身的$變量

    echo "Red Hat Enterprise Linux" > /etc/yum/vars/osname

yum 是怎麼工做的?

yum install jdk

  1. 獲取 庫中全部可用的 package 的列表
  2. 計算 yum 是否能夠獲取到你所須要 包的依賴
  3. 若是 2 知足,則在用戶確認後,下載相關的依賴包,並安裝

建立一個 yum 源倉庫 createRepo

  • 建立私有 repo

    yum install createrepo
    mkdir -p  /home/privateRepo
    createrepo --database /home/privateRepo #privateRepo中會生成yum的元數據repodata,sqlite數據庫會提升yum操做速度
    
    createrepo --unique-md-filenames /home/privateRepo #全部元數據的文件名必須惟一,這個選項一般用在鏡像庫
  • 一個庫中有大量的 包,只有 小部分增長或者 改變時,耗時太長。

    createrepo --update /srv/my/repo
  • 排除庫中的某些包

    createrepo -x filename -x filename2 -x filename* /srv/my/repo
  • 改變 checksum

    createrepo --checksum /srv/my/repo

詳解repodata

  • filelists.xml.gz

    • pkgid 包 id(惟一)
    • name 包名
    • arch 架構
    • version 版本號
    • file 將要被安裝的文件名
    <package pkgid="deee52b24486906ee52576ee471b57061ccd5544" name="php-mbstring" arch="i386">
      <version epoch="0" ver="5.1.6" rel="32.el5" />
      <file>
        /etc/php.d/mbstring.ini
      </file>
      <file>
        /usr/lib/php/modules/mbstring.so
      </file>
    </package>
  • primary.xml.gz

    • 基本信息
    • sha hash
    • 概述
    <package type="rpm">
      <name>
        php53-mbstring
      </name>
      <arch>
        i386
      </arch>
      <version epoch="0" ver="5.3.3" rel="5.el5" />
      <checksum type="sha" pkgid="YES">
        e4d153d1ac6f71fa50bb6587cf13b324ee44537c
      </checksum>
      <summary>
        A module for PHP applications which need multi-byte string handling
      </summary>
      <description>
        The php-mbstring package contains a dynamic shared object that will add
      </description>
    </package>
  • repomd.xml

    • 定位 primary.xml.gz,filelists.xml.gz,other.xml.gz
    • 修改的時間戳
    • checksum
    <?xml version="1.0" encoding="UTF-8"?>
    <repomd xmlns="http://linux.duke.edu/metadata/repo">
    <data type="other">
      <location href="repodata/other.xml.gz"/>
      <checksum type="sha">53349b063023303c5976135a7e485b0aa932ba6f</checksum>
      <timestamp>1360494599</timestamp>
      <open-checksum type="sha">2245d5a3cf0c3398a28b0c63948ecdf58668041e</open-checksum>
    </data>
    <data type="filelists">
      <location href="repodata/filelists.xml.gz"/>
      <checksum type="sha">35d6d80d5b115f0da3452534c1f5cf9c0efcef3f</checksum>
      <timestamp>1360494599</timestamp>
      <open-checksum type="sha">5d1f2791794e1cc20590099a962cf5260f942b7a</open-checksum>
    </data>
    <data type="primary">
      <location href="repodata/primary.xml.gz"/>
      <checksum type="sha">afe11b0976096135357e11e2ff1707d88ebef6fd</checksum>
      <timestamp>1360494599</timestamp>
      <open-checksum type="sha">976baa466007d496accfa24922f2f0722c56f1dd</open-checksum>
    </data>
    </repomd>
  • other.xml.gz

    • 做者
    • 版本信息
    • 修改記錄
    • 以前版本的 bugfix 信息等
相關文章
相關標籤/搜索