自建yum源


我们通常使用的是阿里源,搜狐源等,看着这么高大上,有没有想试一试怎么搭建。。。

获得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!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值