yum軟件倉庫的搭建方式有三種,分別是本地yum源,網絡yum源,第三方軟件倉庫。網絡
如下示例演示了搭建本地yum倉庫的方法:工具
1. 刪除 /etc/yum.repos.d/dvd.repo 這個倉庫文件url
[root@desktop1 ~]# ll /etc/yum.repos.d/ total 8 -rw-r--r--. 1 root root 84 Sep 27 20:20 dvd.repo -r--r--r--. 1 root root 114 Oct 30 2015 packagekit-media.repo [root@desktop1 ~]# rm -f /etc/yum.repos.d/dvd.repo
2.運行yum repolist,確保當前的電腦中沒有yum倉庫 spa
[root@desktop1 ~]# yum repolist Loaded plugins: langpacks repolist: 0
3. 使用 yum-config-manager 工具,建立一個倉庫文件,軟件包的目錄爲本地主機文件系統 中的:/rhel7/dvdcode
[root@desktop1 ~]# yum-config-manager --add-repo=file:///rhel7/dvd Loaded plugins: langpacks adding repo from: file:///rhel7/dvd [rhel7_dvd] name=added from: file:///rhel7/dvd baseurl=file:///rhel7/dvd enabled=1
4. 再次查看/etc/repos.d/中已經有了新的軟件倉庫blog
[root@desktop1 ~]# ll /etc/yum.repos.d/ total 8 -r--r--r--. 1 root root 114 Oct 30 2015 packagekit-media.repo -rw-r--r--. 1 root root 85 Nov 2 16:41 rhel7_dvd.repo
5. 編輯倉庫文件rhel7_dvd.repo,確保 repo id 爲「LOCAL_RHEL7」,repo name 爲「LOCAL_REPO」 ci
原始文件:it
[rhel7_dvd] name=added from: file:///rhel7/dvd baseurl=file:///rhel7/dvd enabled=1
更改後:io
[root@desktop1 ~]# cat /etc/yum.repos.d/rhel7_dvd.repo [LOCAL_RHEL7] name=LOCAL_REPO gpgcheck=1 gpgkey=file:///rhel7/dvd/RPM-GPG-KEY-redhat-release
6. 使用 yum repolist 確保上一步驟的更改已生效 class
[root@desktop1 ~]# yum repolist Loaded plugins: langpacks LOCAL_RHEL7 | 4.1 kB 00:00:00 (1/2): LOCAL_RHEL7/group_gz | 134 kB 00:00:00 (2/2): LOCAL_RHEL7/primary_db | 3.4 MB 00:00:00 repo id repo name status LOCAL_RHEL7 LOCAL_REPO 4,305 repolist: 4,305
7. 嘗試安裝 bind 這個軟件包,確認你的 YUM 倉庫可使用
[root@desktop1 ~]# yum -y install bind Loaded plugins: langpacks Resolving Dependencies --> Running transaction check ---> Package bind.x86_64 32:9.9.4-14.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================== Package Arch Version Repository Size ================================================================================================================== Installing: bind x86_64 32:9.9.4-14.el7 LOCAL_RHEL7 1.8 M Transaction Summary ================================================================================================================== Install 1 Package Total download size: 1.8 M Installed size: 4.3 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 32:bind-9.9.4-14.el7.x86_64 1/1 Verifying : 32:bind-9.9.4-14.el7.x86_64 1/1 Installed: bind.x86_64 32:9.9.4-14.el7 Complete! [root@desktop1 ~]#