ソフトウェアインストールのYUM


YumフルネームはYellowdogupdatermodifiedで、ソフトウェアをインストールする際に最も多く使用するのが最も便利で、最大のメリットは、ソフトウェアパッケージの依存関係を自動的に解決できることです.
1.yumサーバ
yumを使用してパッケージのインストールを行う場合は、yumサーバを作成する必要があります.
これは
[base] #       ,       ,         
name=CentOS-$releasever - Base - 163.com #         
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #             ,       
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ #        ,        
enable=1 #      ,      0
gpgcheck=1 #      rpm       
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #              
$releasever:         ,            
$basearch:  CPU   , x86_64,  i386  
yum       :
1.  baseurl=              :
file:///  #yum    ,            
http://   #    ,
ftp://   #ftp  
      ,           repodata  ,     ,          。yum                           

2.repodataディレクトリの情報
comps.xml                                          filelists.sqlite.bz2
filelists.xml.gz  #  rpm                                           other.sqlite.bz2
other.xml.gz #       ,  rpm        
primary.sqlite.bz2
primary.xml.gz  #  yum      rpm            ,     rpm        
repomd.xml  #     ,  rpm      

3.yumのプロファイル
[root@zhu1 ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum #yum     
keepcache=0 #        
debuglevel=2 #    
logfile=/var/log/yum.log #    
distroverpkg=redhat-release #    
tolerant=1 #        ,        ,      ,            
exactarch=1 #      ,        
obsoletes=1 #          
gpgcheck=1 #      
plugins=1 #      
bugtracker_url=http://bugs.centos.org/yum5bug
# Note: yum-RHN-plugin doesn't honor this.
metadata_expire=1h #     
installonly_limit = 5
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d #  yum      
~

4.yum共通コマンド
1.インストール可能なパッケージの表示
yum list #            
[root@zhu1 ~]# yum list | grep vsftpd
vsftpd.i386                              2.0.5-28.el5                  base

2.インストールされているパッケージの表示
[root@zhu1 ~]# yum list installed

3.yumウェアハウスにインストールされていないすべてのパッケージを表示
[root@zhu1 ~]# yum list extras

4.アップグレード可能なパッケージを表示
[root@zhu1 ~]# yum list updates

5.パッケージの名前を検索し、一部のキーワードに基づいて
[root@zhu1 ~]# yum search vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.grandcloud.cn
* base: mirrors.grandcloud.cn
* extras: mirrors.grandcloud.cn
* updates: mirrors.grandcloud.cn
=========================================== Matched: vsftpd ===========================================
vsftpd.i386 : vsftpd -      Ftp     

6.クエリーパッケージの詳細はrpm-qiに相当する
[root@zhu1 ~]# yum info vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.grandcloud.cn
* base: mirrors.grandcloud.cn
* extras: mirrors.grandcloud.cn
* updates: mirrors.grandcloud.cn
Installed Packages
Name       : vsftpd
Arch       : i386
Version    : 2.0.5
Release    : 28.el5
Size       : 289 k
Repo       : installed
Summary    : vsftpd -      Ftp     
URL        : http://vsftpd.beasts.org/
License    : GPL
Description: vsftpd         FTP     。        
:    。

7.ファイルに基づいて所属ソフトウェアを調べる
[root@zhu1 ~]# yum provides /etc/vsftpd/vsftpd.conf
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.grandcloud.cn
* base: mirrors.grandcloud.cn
* extras: mirrors.grandcloud.cn
* updates: mirrors.grandcloud.cn
vsftpd-2.0.5-28.el5.i386 : vsftpd -      Ftp     
Repo        : base
Matched from:
Filename    : /etc/vsftpd/vsftpd.conf
vsftpd-2.0.5-28.el5.i386 : vsftpd -      Ftp     
Repo        : installed
Matched from:
Other       : Provides-match: /etc/vsftpd/vsftpd.conf

8.インストール
[root@zhu1 ~]# yum -y install vsftpd

9.アンインストール
[root@zhu1 ~]# yum -y remove vsftpd

10.更新
[root@zhu1 ~]# yum update httpd

11.更新可能なパッケージのリスト
[root@zhu1 ~]# yum check-update

12.コンテナ数のリスト
[root@zhu1 ~]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.grandcloud.cn
* base: mirrors.grandcloud.cn
* extras: mirrors.grandcloud.cn
* updates: mirrors.grandcloud.cn
repo id                            repo name                                             status
addons                             CentOS-5 - Addons - 163.com                           enabled:     0
base                               CentOS-5 - Base - 163.com                             enabled: 2,770
centosplus                         CentOS-5 - Plus - 163.com                             disabled
contrib                            CentOS-5 - Contrib - 163.com                          disabled
extras                             CentOS-5 - Extras - 163.com                           enabled:   276
updates                            CentOS-5 - Updates - 163.com                          enabled:   508
repolist: 3,554

13.yumキャッシュ情報のクリア
[root@zhu1 ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning up Everything
Cleaning up list of fastest mirrors

15.yumインストール開発グループ
 yum     
(RHEL6.x)
yum  -y groupinstall        "DesktopPlatform Development"     "Development  tools"  "Server Platform Development"
(RHEL5.x)
yum  -y  groupinstall       "Development  tools " "Development  Libraries"

16.
[root@zhu1 ~]# yum --help
Loaded plugins: fastestmirror
usage: yum [options] COMMAND
List of Commands:
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
downgrade      downgrade a package
erase          Remove a package or packages from your system
groupinfo      Display details about a package group
groupinstall   Install the packages in a group on your system
grouplist      List available package groups
groupremove    Remove the packages in a group from your system
help           Display a helpful usage message
info           Display details about a package or group of packages
install        Install a package or packages on your system
list           List a package or groups of packages
localinstall   Install a local RPM
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package
repolist       Display the configured software repositories
resolvedep     Determine which package provides the given dependency
search         Search package details for the given string
shell          Run an interactive yum shell
update         Update a package or packages on your system
upgrade        Update packages taking obsoletes into account
options:
-h, --help            show this help message and exit
-t, --tolerant        be tolerant of errors
-C                    run entirely from cache, don't update cache
-c  [config file]     config file location
-R  [minutes]         maximum command wait time
-d  [debug level]     debugging output level
--showduplicates      show duplicates, in repos, in list/search commands
-e  [error level]     error output level
-q, --quiet           quiet operation
-v, --verbose         verbose operation
-y                    answer yes for all questions
--version             show Yum version and exit
--installroot=[path]  set install root
--enablerepo=[repo]   enable one or more repositories (wildcards allowed)
--disablerepo=[repo]  disable one or more repositories (wildcards allowed)
-x [package], --exclude=[package]
exclude package(s) by name or glob
--disableexcludes=[repo]
disable exclude from main, for a repo or for
everything
--obsoletes           enable obsoletes processing during updates
--noplugins           disable Yum plugins
--nogpgcheck          disable gpg signature checking
--disableplugin=[plugin]
disable plugins by name
--enableplugin=[plugin]
enable plugins by name
--skip-broken         skip packages with depsolving problems
--color=COLOR         control whether color is used
Plugin Options:

5.よく使うyumソース
1.
[root@zhu1 yum.repos.d]# yum repolist all
Loaded plugins: fastestmirror
Determining fastest mirrors
repolist: 0
[root@zhu1 yum.repos.d]# ll
   4
-rw-r--r-- 1 root root 87 09-28 03:27 zhu
[root@zhu1 yum.repos.d]# mv zhu zhu.repo
[root@zhu1 yum.repos.d]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
zhu                                                                             | 1.1 kB     00:00
zhu/primary                                                                     | 983 kB     00:04
zhu                                                                                          2770/2770
repo id                                       repo name                                  status
zhu                                           zhu                                        enabled: 2,770
repolist: 2,770
[root@zhu1 yum.repos.d]# nl zhu.repo
1  [zhu]
2  name=zhu
3  baseurl=http://debian.ustc.edu.cn/centos/5/os/i386/
4  enable=1
5  gpgcheck=0

2.マクロ変数の利用
[root@zhu1 yum.repos.d]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
zhu                                                                             | 1.1 kB     00:00
zhu/primary                                                                     | 983 kB     00:04
zhu                                                                                          2770/2770
repo id                                       repo name                                  status
zhu                                           zhu                                        enabled: 2,770
repolist: 2,770
[root@zhu1 yum.repos.d]# nl zhu.repo
1  [zhu]
2  name=zhu
3  baseurl=http://debian.ustc.edu.cn/centos/$releasever/os/$basearch/
4  enable=1
5  gpgcheck=0

yumソースまとめ
#           
#          
        (debian.ustc.edu.cn)
      (ftp.stju.edu.cn)
      (mirror.dlut.edu.cn)
      (mirror.bjtu.edu.cn)
      (mirror.bit.edu.cn)
    (mirror.neu.edu.cn)
    (mirrors.xmu.edu.cn)
    (mirror.lzu.edu.cn)
        (linux.xidian.edu.cn)
       (run.hit.edu.cn)
    (mirror.tju.edu.cn)
      (mirrors.neusoft.edu.cn)
      (mirrors.stuhome.net)
#         
       CMU(http://www.club.cc.cmu.edu/pub)
      MIT(http://mirrors.mit.edu/)
      (http://mirror.cc.columbia.edu/)
       (http://ftp.osuosl.org/pub)
         -    (http://cosmos.cites.illinois.edu/)
    (http://archive.linux.duke.edu/)
  ・       (http://mirrors.acm.jhu.edu/)
#    
       :http://mirrors.sohu.com/
       :http://mirrors.163.com/

捜狐:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - sohu.com
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.sohu.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates - sohu.com
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.sohu.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons - sohu.com
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
baseurl=http://mirrors.sohu.com/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - sohu.com
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.sohu.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - sohu.com
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://mirrors.sohu.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - sohu.com
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://mirrors.sohu.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

163
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5