本地yum倉庫配置以及創建yum倉庫

如何使用光盤當做本地yum倉庫?

    1.掛載光盤至某目錄,例如/media/cdrom

    

[root@CentOS7 ~]# mount /dev/cdrom /media/cdrom/
mount: /dev/sr0 is write-protected, mounting read-only
[root@CentOS7 ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda2       52403200 3793592  48609608   8% /
devtmpfs          486144       0    486144   0% /dev
tmpfs             500664     144    500520   1% /dev/shm
tmpfs             500664    7244    493420   2% /run
tmpfs             500664       0    500664   0% /sys/fs/cgroup
/dev/sda5       20961280 6858720  14102560  33% /testdir
/dev/sda1         201388  141668     59720  71% /boot
tmpfs             100136      20    100116   1% /run/user/0
/dev/sr0         7587292 7587292         0 100% /media/cdrom
[root@CentOS7 ~]#

    2.創建配置文件

[root@CentOS7 ~]# cat /etc/yum.repos.d/base.repo 
[base]
name=CentOS 7 (local)
baseurl=file:///media/cdrom
gpgcheck=0
enabled=1
[root@CentOS7 ~]#

    3.查看所配置的倉庫是否生效

[root@CentOS7 ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id                                              repo name                                                     status
base                                                 CentOS 7 (local)                                              9,007
repolist: 9,007
[root@CentOS7 ~]#

    4.配置成功即可從倉庫中安裝程序包

[root@CentOS7 ~]# yum -y install tree
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package                              Arch                                   Version                                        Repository                            Size
=======================================================================================================================================================================
Installing:
 tree                                 x86_64                                 1.6.0-10.el7                                   base                                  46 k
Transaction Summary
=======================================================================================================================================================================
Install  1 Package
Total download size: 46 k
Installed size: 87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : tree-1.6.0-10.el7.x86_64                                                                                                                            1/1 
  Verifying  : tree-1.6.0-10.el7.x86_64                                                                                                                            1/1 
Installed:
  tree.x86_64 0:1.6.0-10.el7                                                                                                                                           
Complete!
[root@CentOS7 ~]#

如何創建yum倉庫?

    1.在指定的程序包路徑當中運行createrepo命令創建yum倉庫

[root@CentOS7 repodb]# pwd
/testdir/repodb
[root@CentOS7 repodb]# createrepo .
Spawning worker 0 with 9007 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@CentOS7 repodb]#

    2.配置所指向的yum倉庫

[root@CentOS7 ~]# cat /etc/yum.repos.d/base.repo 
[base]
name=CentOS 7 (local)
baseurl=file:///testdir/repodb
gpgcheck=0
enabled=1
[root@CentOS7 ~]#

    3.yum倉庫即可使用

[root@CentOS7 ~]# yum -y install tree
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package                              Arch                                   Version                                        Repository                            Size
=======================================================================================================================================================================
Installing:
 tree                                 x86_64                                 1.6.0-10.el7                                   base                                  46 k
Transaction Summary
=======================================================================================================================================================================
Install  1 Package
Total download size: 46 k
Installed size: 87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : tree-1.6.0-10.el7.x86_64                                                                                                                            1/1 
  Verifying  : tree-1.6.0-10.el7.x86_64                                                                                                                            1/1 
Installed:
  tree.x86_64 0:1.6.0-10.el7                                                                                                                                           
Complete!
[root@CentOS7 ~]#

原創文章,作者:zhai796898,如若轉載,請注明出處:http://www.www58058.com/39403

(0)
zhai796898zhai796898
上一篇 2016-08-23 21:46
下一篇 2016-08-23 22:41

相關推薦

  • http

    http http:hyper text transfer protocol, 應用層協議, 80/tcp, 文本協議 html:hyper text mark language, 是一種編程語言,超文本標記語言; html格式示例: <html> <head> <title>TITLE</title> &lt…

    Linux干貨 2017-06-04
  • FHS-文件系統層級結構標準

    文件系統層級結構標準(FHS:Filesystem Hierarchy Standard) 文件系統層次結構標準(英語:Filesystem Hierarchy Standard,FHS)定義了Linux操作系統中的主要目錄及目錄內容。當前的版本是2.3,在2004年1月29日公布。多數Linux發行版遵從FHS標準并且聲明其自身政策以維護FHS的要求。然而…

    Linux干貨 2016-10-16
  • 邏輯卷管理器LVM使用簡介

    邏輯卷管理器(LVM) 原理圖如下: 先準備一個分區/dev/sdb1,注意也存在ID問題,選擇8e。 1.先把磁盤變成物理卷 在做這步前可以先看下系統中存在的物理卷,沒有就什么都不會顯示。 把我們準備好的兩個磁盤變成物理卷,注意我那使用舊的格式化的分區磁盤,可能會出現上面有文件系統或者卷標類型的問題,所以盡量使用新磁盤做實驗。如果出現這種情況,可以使用dd…

    2017-05-02
  • 全面解析文件文件系統

    前言: 文件系統作為linux總最基礎的但愿。理解并深入了解文件系統對linux的學習有重要意義。我們從文件系統創建,構成以及工作流程幾個方面全方位的介紹文件系統的相關概念。 簡述: 一塊完整的磁盤經過分區后我們就可以通過格式化,根據我們的需求構建文件系統能使用的文件系統格式。傳統的文檔系統中,一個分區就只能夠被格式化為一個文件系統。所以我們可以說一個文件系…

    Linux干貨 2016-11-14
  • LA LN MP

    L A/N MP 安裝 添加epel源 yum install epel* 安裝所需環境 yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zl…

    Linux干貨 2016-05-28
  • N26-第九周

    1、寫一個腳本,判斷當前系統上所有用戶的shell是否為可登錄shell(即用戶的shell不是/sbin/nologin);分別這兩類用戶的個數;通過字符串比較來實現; #!/bin/bash # # # NUM1=0 NUM2=0 for i in `cut -d: -f7 /etc/passwd` ;do if [[ “$i” = ‘/bin/bash…

    Linux干貨 2017-03-15
欧美性久久久久