在CentOS 7.3中創建本地yum源

1.掛載系統光盤

1.1創建掛載文件

[root@centos7?~]#?mkdir?/mnt/cdrom??????????????????????????#創建文件

1.2掛載光驅

[root@centos7?~]#?mount?/dev/cdrom?/mnt/cdrom/??????????????#掛載光驅?
mount:?/dev/sr0?is?write-protected,?mounting?read-only??????#掛載成功
[root@centos7?~]#?ll?/mnt/cdrom/????????????????????????????#查看掛載的文件夾total?1550
-rw-r--r--.?1?root?root??????14?Dec??5?21:02?CentOS_BuildTag
drwxr-xr-x.?3?root?root????2048?Dec??5?21:20?EFI
-rw-r--r--.?1?root?root?????215?Dec?10??2015?EULA
-rw-r--r--.?1?root?root???18009?Dec?10??2015?GPL
drwxr-xr-x.?3?root?root????2048?Dec??5?21:47?images
drwxr-xr-x.?2?root?root????2048?Dec??5?21:20?isolinux
drwxr-xr-x.?2?root?root????2048?Dec??5?21:20?LiveOS
drwxrwxr-x.?2?root?root?1548288?Dec??5?20:59?Packages
drwxrwxr-x.?2?root?root????4096?Dec??5?21:42?repodata
-rw-r--r--.?1?root?root????1690?Dec?10??2015?RPM-GPG-KEY-CentOS-7
-rw-r--r--.?1?root?root????1690?Dec?10??2015?RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--.?1?root?root????2883?Dec??5?21:52?TRANS.TBL

2.修改yum文件

2.1 查看yum目錄

[root@centos7?~]#?ll?/etc/yum.repos.d/??????
total?28
-rw-r--r--.?1?root?root?1664?Nov?30?02:12?CentOS-Base.repo???????#網絡yum源文件
-rw-r--r--.?1?root?root?1309?Nov?30?02:12?CentOS-CR.repo
-rw-r--r--.?1?root?root??649?Nov?30?02:12?CentOS-Debuginfo.repo
-rw-r--r--.?1?root?root??314?Nov?30?02:12?CentOS-fasttrack.repo
-rw-r--r--.?1?root?root??656?May?18?10:05?CentOS-Media.repo??????#本地yum源文件
-rw-r--r--.?1?root?root?1331?Nov?30?02:12?CentOS-Sources.repo
-rw-r--r--.?1?root?root?2893?Nov?30?02:12?CentOS-Vault.repo

2.2 修改yum源文件

[root@centos7?~]#?nano?/etc/yum.repos.d/CentOS-Media.repo????#修改本地yum源文件?
#?CentOS-Media.repo
#
#??This?repo?can?be?used?with?mounted?DVD?media,?verify?the?mount?point?for
#??CentOS-7.??You?can?use?this?repo?and?yum?to?install?items?directly?off?the
#??DVD?ISO?that?we?release.
#
#?To?use?this?repo,?put?in?your?DVD?and?use?it?with?the?other?repos?too:
#??yum?--enablerepo=c7-media?[command]
#
#?or?for?ONLY?the?media?repo,?do?this:
#
#??yum?--disablerepo=\*?--enablerepo=c7-media?[command]

[c7-media]???????????????????????????????????????????#庫名稱
name=CentOS-$releasever?-?Media??????????????????????#名稱描述
baseurl=file:///media/CentOS/????????????????????????#yum源目錄,源地址
????????file:///media/cdrom/?????????????????????????#這三個是系統的默認本地yum源的地址
????????file:///media/cdrecorder/
gpgcheck=1???????????????????????????????????????????#檢查GPG-KEY,0為不檢查,1為檢查
#enabled=0???????????????????????????????????????????#是否用該yum源,0為禁用,1為使用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7??#GPG-KEY秘鑰,gpgcheck的值為0時不需要配置

修改后

[c7-media]???????????????????????????????
baseurl=file:///mnt/cdrom/??????????????????????????#把掛載光盤文件的路徑加到這里???????????
????????file:///media/CentOS/?
????????file:///mdia/cdrom/????????????????
????????file:///media/cdrecorder/???????????
gpgcheck=1?????????????????????????????????
enabled=1???????????????????????????????????????????#把enabled的值改為1,啟用這個yum源

2.2 修改網絡yum源文件

[root@centos7?~]#?mv?/etc/yum.repos.d/CentOS-Base.repo{,.bak}???#把這個文件后面加上.bak繞過網絡yum源

3.驗證本地yum源

3.1清除本地緩存

[root@centos7?~]#?yum?clean?all

3.2查看本機yum源

[root@centos7?~]#?yum?repolist?
Loaded?plugins:?fastestmirror,?langpacks
c7-media?????????????????????????????????????????????????????????|?3.6?kB??00:00:00?????
(1/2):?c7-media/group_gz?????????????????????????????????????????|?155?kB??00:00:00?????
(2/2):?c7-media/primary_db???????????????????????????????????????|?5.6?MB??00:00:00?????
Determining?fastest?mirrors
*?c7-media:?
repo?id?????????????????????repo?name????????????????????????status
c7-media????????????????????CentOS-7?-?Media?????????????????9,363???????#創建的本地yum源
repolist:?9,363

3.3查看yum源里的安裝包

[root@centos7?~]#?yum?list?
telnet.x86_64????????????????????????1:0.17-60.el7???????????????????????c7-media??#這些文件的庫名都是本地yum源
telnet-server.x86_64?????????????????1:0.17-60.el7???????????????????????c7-media?
testng.noarch????????????????????????6.8.7-3.el7?????????????????????????c7-media?
testng-javadoc.noarch????????????????6.8.7-3.el7?????????????????????????c7-media?
tex-fonts-hebrew.noarch??????????????0.1-21.el7??????????????????????????c7-media?
tex-preview.noarch???????????????????11.87-4.el7?????????????????????????c7-media?
texi2html.noarch?????????????????????1.82-10.el7?????????????????????????c7-media?
texinfo.x86_64???????????????????????5.1-4.el7???????????????????????????c7-media?
texinfo-tex.x86_64???????????????????5.1-4.el7???????????????????????????c7-media?
texlive.x86_64???????????????????????2:2012-38.20130427_r30134.el7???????c7-media?
texlive-adjustbox.noarch?????????????2:svn26555.0-38.el7?????????????????c7-media?
texlive-adjustbox-doc.noarch?????????2:svn26555.0-38.el7?????????????????c7-media?
texlive-ae.noarch????????????????????2:svn15878.1.4-38.el7???????????????c7-media?
texlive-ae-doc.noarch????????????????2:svn15878.1.4-38.el7???????????????c7-media?
texlive-algorithms.noarch????????????2:svn15878.0.1-38.el7???????????????c7-media

本地yum源創建好了,現在就可以使用本地yum源來安裝軟件了

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

(0)
晴天晴天
上一篇 2017-05-18
下一篇 2017-05-18

相關推薦

  • TCP/IP協議

    無線網絡標準 IEEE 802.3 802.11a/b/g/n/ac 物理層,數據鏈路層data link layer   以太網是工作在物理層和數據鏈路層上 單工,雙工(物理層概念) 單工:單向傳輸數據??? (廣播,收音機) 雙工:雙向傳輸數據 全雙工:同時雙向?????? (手機) 半雙工:輪流雙向???? (對講機)   Hub集…

    Linux筆記 2018-06-24
  • Linux系統網絡管理

    本機索引: 一、基本網絡配置 二、主機、網卡名稱管理 三、網卡別名 四、Bonding技術 五、實現網絡組 六、Linux網絡管理常用命令   一、基本網絡配置: 將Linux主機接入網絡,需要配置網絡相關設置 一般包括以下內容: 主機名 IP/netmask 路由:默認網關 DNS服務器: 主DNS服務器 次DNS服務器   網絡配置文…

    2018-05-03
  • Linux基本指令

    hostname??完整主機名cat?+文件路徑??可查看文件信息cat /etc/shells??顯示所有shelluname -r????查看內核版本ls?cpu???查看cpu信息free命令??查看內存?后面加-k是顯示的內存以kb為單位,-m(MB),-g(GB),-h顯示易讀單位lsblk??查看硬盤dmesg??查看計算機啟動的一些相關信息dm…

    2018-07-22
  • Work One

    1、描述計算機的組成及其功能。 計算機系統 硬件(Hardware)系統 軟件(Software)系統 Hardware:據馮·諾伊曼體系可分為運算器、控制器、存儲器、輸入設備、輸出設備五大部分組成。 運算器:負責對數據進行各種算術運算和邏輯運算,即對數據進行加工處理。 控制器:CPU的組成部分之一,對程序規定的控制信息進行解釋,根據其要求進行控制,調度程序…

    2018-06-26
欧美性久久久久