自建yum源

1240

我們通常使用的是阿里源,搜狐源等,看着這麼高大上,有沒有想試一試怎麼搭建。。。

獲得rpm包

可以在網上找到一些rpm包,放到文件夾裏面。這裏使用光盤裏的rpm包。爲了速度快,就複製少量的rpm包到文件夾裏

[root@CentOS7 ~]# mkdir customrepo
[root@CentOS7 ~]# cp /misc/cd/Packages/tr* ./customrepo/
[root@CentOS7 ~]# ls customrepo/
trace-cmd-2.6.0-3.el7.x86_64.rpm      tracker-firefox-plugin-1.2.7-2.el7.x86_64.rpm  trousers-0.3.13-1.el7.x86_64.rpm
traceroute-2.0.22-2.el7.x86_64.rpm    tracker-needle-1.2.7-2.el7.x86_64.rpm          trousers-devel-0.3.13-1.el7.i686.rpm
tracker-1.2.7-2.el7.i686.rpm          tracker-preferences-1.2.7-2.el7.x86_64.rpm     trousers-devel-0.3.13-1.el7.x86_64.rpm
tracker-1.2.7-2.el7.x86_64.rpm        trang-20091111-14.el7.noarch.rpm               trousers-static-0.3.13-1.el7.i686.rpm
tracker-devel-1.2.7-2.el7.i686.rpm    transfig-3.2.5d-13.el7.x86_64.rpm              trousers-static-0.3.13-1.el7.x86_64.rpm
tracker-devel-1.2.7-2.el7.x86_64.rpm  tree-1.6.0-10.el7.x86_64.rpm
tracker-docs-1.2.7-2.el7.noarch.rpm   trousers-0.3.13-1.el7.i686.rpm

注意: 只要有repodata目錄,就可以爲yum源

生成yum源

[root@CentOS7 ~]# createrepo ./customrepo/
[root@CentOS7 ~]# ls -ld customrepo/repodata/ 
drwxr-xr-x. 2 root root 4096 Jun 10 17:40 customrepo/repodata/
#查看這個文件夾是否存在

配置yum源

要配置yum源,則需要在/etc/yum.repo.d/中新建以repo結尾的文件,或者在已存在的以repo結尾的文件中寫入。此處就在已存在的文件中寫入下列幾行:

[CentOS7-custom]
name=CentOS-custom
baseurl=file:///root/customrepo/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

驗證

[root@CentOS7 ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id                                                               repo name                                                               status
CentOS7-base                                                          CentOS-7-base                                                            9,363
CentOS7-custom                                                        CentOS-custom                                                               19
aliyun_epel/7                                                         ailiyun_yum_epel                                                        11,787
aliyun_yum                                                            ailiyun_yum                                                              9,363
repolist: 30,532

發現 CentOS-custom 已經存在。下面我安裝一下軟件

yum install tree --disablerepo=CentOS7-base此處是使用禁用某個默認源
發現可以使用自制的Centos-custom源安裝成功
[root@CentOS7 ~]# yum install tree --disablerepo=CentOS7-base
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                           CentOS7-custom                           46 k

Transaction Summary
====================================================================================================================================================
Install  1 Package

Total download size: 46 k
Installed size: 87 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : tree-1.6.0-10.el7.x86_641/1 
  Verifying  : tree-1.6.0-10.el7.x86_64                                                                                                         1/1 

Installed:
  tree.x86_64 0:1.6.0-10.el7                                                                                                                        

Complete!
發佈了43 篇原創文章 · 獲贊 41 · 訪問量 27萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章