自建yum源

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

獲得rpm包

可以在網(wǎng)上找到一些rpm包,放到文件夾里面。這里使用光盤里的rpm包。為了速度快,就復(fù)制少量的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/
#查看這個(gè)文件夾是否存在

配置yum源

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

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

驗(yàn)證

[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

發(fā)現(xiàn) CentOS-custom 已經(jīng)存在。下面我安裝一下軟件

yum install tree --disablerepo=CentOS7-base此處是使用禁用某個(gè)默認(rèn)源
發(fā)現(xiàn)可以使用自制的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_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!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1. 概述 日常的工作中,經(jīng)常要安裝和卸載軟件,在linux centos的版本里提供了rpm這個(gè)命令進(jìn)行安裝,但...
    ghbsunny閱讀 4,056評(píng)論 0 3
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,554評(píng)論 19 139
  • 【Linux軟件安裝管理系列】— — 傳送門: — —《Linux軟件安裝管理之——源碼安裝詳解》 — —《Lin...
    四月不見閱讀 10,877評(píng)論 0 53
  • 獲取yum的安裝包 不管是安裝openstack還是相關(guān)的組件,都常用yum命令來下載,而默認(rèn)的yum源經(jīng)常是指向...
    邵勝奧閱讀 3,483評(píng)論 2 10
  • 歡迎搜索關(guān)注公眾號(hào),更多精彩,每周更新 公號(hào)所有提及影片,可留言回復(fù)獲取 2017/04/20 THU 006期...
    戲言TaleOFTales閱讀 430評(píng)論 0 0

友情鏈接更多精彩內(nèi)容