yum命令及yum倉庫構建

yum命令

yum [options] [command] [package ...]

    yum命令行選項
        --nogpgcheck 禁止進行gpg check
        -y 自動回答yes
        -q 靜默模式
        --disablerepo=repoidglob 臨時禁用此處的repo
        --enablerepo=repoidglob 臨時啟用此處的repo
        --noplugins 禁用所有插件

    顯示倉庫列表
        yum repolist [all|enabled|disabled] 

    顯示程序包列表
        yum list [all | glob_exp1] [glob_exp2 
        yum list installed [glob_exp1] [...]
        yum list updates [glob_exp1] [...]  
        yum list available [glob_exp1] [...] 

    安裝程序包:        
        yum install package1 [package2] [...]

    升級程序包
        yum update [package1] [package2] [...]

    降級程序包    
        yum downgrade package1 [package2] [...]

    檢查可用升級
        yum check-update

    卸載指定程序包
        remove | erase package1 [package2] [...]

    查看程序包的信息
        yum info package1 [package2] [...]

    查看指定的特性(可以是某文件)是由那個程序包提供
        yum provides | whatprovides feature1 [feature2] [...]

    清理本地緩存
        yum clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]

    構建緩存
        yum makecache

    搜索程序包相關信息
        yum search string1 [string2] [...] 

    重新安裝(覆蓋重新安裝)
        yum reinstall package1 [package2] [...]

    查看指定包的依賴關系
        yum deplist package1 [package2] [...]

    查看yum事物歷史
        yum history [info|list|packages-list|packages-info|summary|addon-info|redo|undo|rollback|new|sync|stats]  

    包組管理的相關命令
        yum groupinstall group1 [group2][...]
        yum groupupdate group1 [group2][...]
        yum grouplist group1 [group2][...]
        yum groupremove group1 [group2][...]
        yum groupinfo group1 [group2][...]

yum命令示例

列出倉庫信息

[root@localhost ~]# yum repolsit
Loaded plugins: fastestmirror, langpacks
No such command: repolsit. Please use /usr/bin/yum --help
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                                          repo name                                                                      status
base/7/x86_64                                    CentOS-7 - Base - mirrors.aliyun.com                                            9,911
epel/x86_64                                      Extra Packages for Enterprise Linux 7 - x86_64                                 12,581
extras/7/x86_64                                  CentOS-7 - Extras - mirrors.aliyun.com                                            305
updates/7/x86_64                                 CentOS-7 - Updates - mirrors.aliyun.com                                           654
repolist: 23,451

安裝程序

[root@localhost ~]# yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-67.el7.centos.6 will be updated
--> Processing Dependency: httpd = 2.4.6-67.el7.centos.6 for package: 1:mod_ssl-2.4.6-67.el7.centos.6.x86_64
---> Package httpd.x86_64 0:2.4.6-80.el7.centos will be an update
--> Processing Dependency: httpd-tools = 2.4.6-80.el7.centos for package: httpd-2.4.6-80.el7.centos.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 will be updated
---> Package httpd-tools.x86_64 0:2.4.6-80.el7.centos will be an update
---> Package mod_ssl.x86_64 1:2.4.6-67.el7.centos.6 will be updated
---> Package mod_ssl.x86_64 1:2.4.6-80.el7.centos will be an update
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                         Arch                       Version                                    Repository                Size
======================================================================================================================================
Updating:
 httpd                           x86_64                     2.4.6-80.el7.centos                        base                     2.7 M
Updating for dependencies:
 httpd-tools                     x86_64                     2.4.6-80.el7.centos                        base                      89 k
 mod_ssl                         x86_64                     1:2.4.6-80.el7.centos                      base                     111 k

Transaction Summary
======================================================================================================================================
Upgrade  1 Package (+2 Dependent packages)

Total size: 2.9 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : httpd-tools-2.4.6-80.el7.centos.x86_64                                                                             1/6 
  Updating   : httpd-2.4.6-80.el7.centos.x86_64                                                                                   2/6 
  Updating   : 1:mod_ssl-2.4.6-80.el7.centos.x86_64                                                                               3/6 
  Cleanup    : 1:mod_ssl-2.4.6-67.el7.centos.6.x86_64                                                                             4/6 
  Cleanup    : httpd-2.4.6-67.el7.centos.6.x86_64                                                                                 5/6 
  Cleanup    : httpd-tools-2.4.6-67.el7.centos.6.x86_64                                                                           6/6 
  Verifying  : 1:mod_ssl-2.4.6-80.el7.centos.x86_64                                                                               1/6 
  Verifying  : httpd-2.4.6-80.el7.centos.x86_64                                                                                   2/6 
  Verifying  : httpd-tools-2.4.6-80.el7.centos.x86_64                                                                             3/6 
  Verifying  : httpd-2.4.6-67.el7.centos.6.x86_64                                                                                 4/6 
  Verifying  : 1:mod_ssl-2.4.6-67.el7.centos.6.x86_64                                                                             5/6 
  Verifying  : httpd-tools-2.4.6-67.el7.centos.6.x86_64                                                                           6/6 

Updated:
  httpd.x86_64 0:2.4.6-80.el7.centos                                                                                                  

Dependency Updated:
  httpd-tools.x86_64 0:2.4.6-80.el7.centos                            mod_ssl.x86_64 1:2.4.6-80.el7.centos                           

Complete!

查看程序包信息

[root@localhost ~]# yum info httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Installed Packages
Name        : httpd
Arch        : x86_64
Version     : 2.4.6
Release     : 80.el7.centos
Size        : 9.4 M
Repo        : installed
From repo   : base
Summary     : Apache HTTP Server
URL         : http://httpd.apache.org/
License     : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
            : web server.

查看程序包依賴關系

[root@localhost yum.repos.d]# yum deplist zsh
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
package: zsh.x86_64 5.0.2-28.el7
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-30.el7
  dependency: /sbin/install-info
   provider: info.x86_64 5.1-5.el7
  dependency: coreutils
   provider: coreutils.x86_64 8.22-21.el7
  dependency: grep
   provider: grep.x86_64 2.20-3.el7
  dependency: libc.so.6(GLIBC_2.15)(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libdl.so.2()(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libdl.so.2(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libm.so.6()(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libm.so.6(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libncursesw.so.5()(64bit)
   provider: ncurses-libs.x86_64 5.9-14.20130511.el7_4
  dependency: librt.so.1()(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: librt.so.1(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libtinfo.so.5()(64bit)
   provider: ncurses-libs.x86_64 5.9-14.20130511.el7_4
  dependency: rtld(GNU_HASH)
   provider: glibc.x86_64 2.17-222.el7
   provider: glibc.i686 2.17-222.el7

查看yum事物歷史

[root@localhost yum.repos.d]# yum history info
Loaded plugins: fastestmirror, langpacks
Transaction ID : 5
Begin time     : Fri May 11 20:41:41 2018
Begin rpmdb    : 1408:2c966990202e5fca6613cab588b093ca3fe2d932
End time       :            20:41:43 2018 (2 seconds)
End rpmdb      : 1409:1ef029b64fc79bfd40c9f33a48e1a7357c15adbb
User           : root <root>
Return-Code    : Success
Command Line   : install tree
Transaction performed with:
    Installed     rpm-4.11.3-17.el7.x86_64                      @anaconda
    Installed     yum-3.4.3-132.el7.centos.0.1.noarch           @anaconda
    Installed     yum-plugin-fastestmirror-1.1.31-34.el7.noarch @anaconda
Packages Altered:
    Install tree-1.6.0-10.el7.x86_64 @base
history info


[root@localhost yum.repos.d]# yum history
Loaded plugins: fastestmirror, langpacks
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     5 | root <root>              | 2018-05-11 20:41 | Install        |    1   
     4 | root <root>              | 2018-05-03 20:14 | Update         |    1   
     3 | root <root>              | 2018-05-03 20:04 | I, U           |   25   
     2 | root <root>              | 2018-05-03 20:02 | Install        |    1   
     1 | System <unset>           | 2018-04-30 23:41 | Install        | 1387   
history list

卸載程序

[root@localhost ~]# yum remove httpd
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-80.el7.centos will be erased
--> Processing Dependency: httpd-mmn = 20120211x8664 for package: mod_wsgi-3.4-12.el7_0.x86_64
--> Processing Dependency: httpd-mmn = 20120211x8664 for package: 1:mod_ssl-2.4.6-80.el7.centos.x86_64
--> Processing Dependency: httpd for package: cobbler-2.8.2-1.el7.x86_64
--> Processing Dependency: httpd for package: 1:mod_ssl-2.4.6-80.el7.centos.x86_64
--> Processing Dependency: httpd = 2.4.6-80.el7.centos for package: 1:mod_ssl-2.4.6-80.el7.centos.x86_64
--> Running transaction check
---> Package cobbler.x86_64 0:2.8.2-1.el7 will be erased
--> Processing Dependency: cobbler for package: cobbler-web-2.8.2-1.el7.noarch
---> Package mod_ssl.x86_64 1:2.4.6-80.el7.centos will be erased
---> Package mod_wsgi.x86_64 0:3.4-12.el7_0 will be erased
--> Running transaction check
---> Package cobbler-web.noarch 0:2.8.2-1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                         Arch                       Version                                   Repository                 Size
======================================================================================================================================
Removing:
 httpd                           x86_64                     2.4.6-80.el7.centos                       @base                     9.4 M
Removing for dependencies:
 cobbler                         x86_64                     2.8.2-1.el7                               @epel                     2.0 M
 cobbler-web                     noarch                     2.8.2-1.el7                               @epel                     1.5 M
 mod_ssl                         x86_64                     1:2.4.6-80.el7.centos                     @base                     224 k
 mod_wsgi                        x86_64                     3.4-12.el7_0                              @base                     197 k

Transaction Summary
======================================================================================================================================
Remove  1 Package (+4 Dependent packages)

Installed size: 13 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : cobbler-web-2.8.2-1.el7.noarch                                                                                     1/5 
  Erasing    : cobbler-2.8.2-1.el7.x86_64                                                                                         2/5 
warning: /etc/cobbler/settings saved as /etc/cobbler/settings.rpmsave
  Erasing    : mod_wsgi-3.4-12.el7_0.x86_64                                                                                       3/5 
  Erasing    : 1:mod_ssl-2.4.6-80.el7.centos.x86_64                                                                               4/5 
  Erasing    : httpd-2.4.6-80.el7.centos.x86_64                                                                                   5/5 
  Verifying  : cobbler-2.8.2-1.el7.x86_64                                                                                         1/5 
  Verifying  : mod_wsgi-3.4-12.el7_0.x86_64                                                                                       2/5 
  Verifying  : cobbler-web-2.8.2-1.el7.noarch                                                                                     3/5 
  Verifying  : 1:mod_ssl-2.4.6-80.el7.centos.x86_64                                                                               4/5 
  Verifying  : httpd-2.4.6-80.el7.centos.x86_64                                                                                   5/5 

Removed:
  httpd.x86_64 0:2.4.6-80.el7.centos

構建yum倉庫

本地倉庫

1.使用系統自帶的光盤作為本地yum源,首先掛載光盤

[root@localhost dev]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only

2.創建/etc/yum.repos.d/local.repo

[basename]
name=local repo
baseurl=file:///mnt
enabled=1
gpgcheck=0

3.清除并構建緩存

yum clean all
yum makecache

網絡倉庫

1.創建/etc/yum.repos.d/aliyum.repo

[basealiyun]
name=aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=0

3.清除并構建緩存

yum clean all
yum makecache

[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: basealiyun bassename
Cleaning up everything
Cleaning up list of fastest mirrors


[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
basealiyun                                                                                                     | 3.6 kB  00:00:00     
bassename                                                                                                      | 3.6 kB  00:00:00     
(1/8): basealiyun/7/x86_64/group_gz                                                                            | 166 kB  00:00:00     
(2/8): basealiyun/7/x86_64/primary_db                                                                          | 5.9 MB  00:00:02     
(3/8): basealiyun/7/x86_64/filelists_db                                                                        | 6.9 MB  00:00:02     
(4/8): bassename/group_gz                                                                                      | 155 kB  00:00:00     
(5/8): bassename/primary_db                                                                                    | 5.3 MB  00:00:00     
(6/8): bassename/filelists_db                                                                                  | 6.2 MB  00:00:00     
(7/8): basealiyun/7/x86_64/other_db                                                                            | 2.5 MB  00:00:00     
(8/8): bassename/other_db                                                                                      | 2.3 MB  00:00:00     
Determining fastest mirrors
Metadata Cache Created
[root@localhost yum.repos.d]# yum repolsit
Loaded plugins: fastestmirror, langpacks
No such command: repolsit. Please use /usr/bin/yum --help
[root@localhost yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id                                                             repo name                                                   status
basealiyun/7/x86_64                                                 aliyun                                                      9,911
bassename                                                           local repo                                                  9,007
repolist: 18,918

本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/100818

(0)
dyzhoudyzhou
上一篇 2018-06-10 21:49
下一篇 2018-06-11 00:58

相關推薦

  • mysq數據庫五

    主從級聯復制;主主服務器的搭建;半同步和過濾;主從復制加密;mah高可用性;5實現galeracluster

    2018-06-15
  • 馬哥教育 — 第三周作業

    1.列出當前系統上所有已經登錄的用戶的用戶名,注意:同一個用戶登錄多次,則只顯示一次即可 2. 取出最后登錄到當前系統的用戶的相關信息 3. 取出當前系統上被用戶當作其默認shell的最多的那個shell 4.將/etc/passwd中的第三個字段數字最大的后10個用戶的信息全部改為大寫后保存至/tmp/maxusers.txt文件中 5. 取出當前主機的i…

    2018-05-29
  • 第七周

    1、簡述linux操作系統啟動流程 inux系統啟動流程大致是這樣的: post ->BIOS(Boot Sequence) –> MBR(GRUB) –> Kernel(ramdisk) –> rootfs –> /sbin/init(/etc/inittab) BIOS 主板在接通電源后,BIOS會第一個獲得系統的控制權。B…

    Linux筆記 2018-07-15
  • 硬鏈接

    軟連接:

    Linux筆記 2018-04-01
  • LVS介紹及工作原理

    LVS是Linux Virtual Server的簡寫,意即Linux虛擬服務器,是一個虛擬的服務器集群系統。本項目在1998年5月由章文嵩博士成立,是中國國內最早出現的自由軟件項目之一。

    2018-07-03
  • 初學Linux之標準I/O和管道

    標準輸入和輸出 程序是由指令+數據組成程序的數據流有三種: 輸入數據流:<–標準輸入(stdin),一般默認是鍵盤輸出數據流:–>標準輸出(stdout),一般默認到終端窗口錯誤輸出流:–>標準錯誤(stderr),一般默認到終端窗口 標準輸入:0標準輸出:1錯誤輸出:2 I/O重定向:改變默認位置 輸出…

    Linux筆記 2018-04-03
欧美性久久久久