自制YUM仓库

简单写一写,用作仓库的虚拟机IP为192.168.149.129。我计划将/usr/local/src这个目录下的软件当做YUM源。首先确保http服务正常。

第一部分 搭建局域网yum源

1、我用的是apache,默认根目录是/var/www/html,所以在这个目录下做了一个软链接:

[root@bogon html]# ln -s /usr/local/src .
[root@bogon html]# ll
total 3
lrwxrwxrwx 1 root root 14 Nov  2 11:13 src -> /usr/local/src

2、使用createrepo命令格式化仓库:

[root@bogon src]# createrepo .
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@bogon src]# ls
repodata
[root@bogon src]# cd repodata/
[root@bogon repodata]# ls
01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2  6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz      repomd.xml
401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz      7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2
5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2    dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz

3、将rpm包放在src目录下,更新一下,在客户端应该就能看到这个包了:

[root@bogon src]# createrepo --update .
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 0 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

4、验证,在客户端/etc/yum.repos.d下创建一个以.repo结尾的文件:

[root@localhost yum.repos.d]# cat test.repo 
[TestYum]
name=TestYum
baseurl=http://192.168.149.129/src
gpgcheck=0
enabled=1

5、运行yum clean all && yum repolist,嗯,确实有1个包,完成。

第二部分 同步外网yum源中的软件包

6、在内网环境下,只有1个软件包是不行的,需要同步外网的yum源。首先,查询可以同步的外网yum源。mysql-tools-community源只有95个软件包,就同步它的软件包了。

# yum repolist
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
 * base: mirror.jdcloud.com
 * epel: hkg.mirror.rackspace.com
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
repo id                                                                             repo name                                                                                            status
base/7/x86_64                                                                       CentOS-7 - Base                                                                                      10,019
epel/x86_64                                                                         Extra Packages for Enterprise Linux 7 - x86_64                                                       13,373
extras/7/x86_64                                                                     CentOS-7 - Extras                                                                                       435
mysql-connectors-community/x86_64                                                   MySQL Connectors Community                                                                              118
mysql-tools-community/x86_64                                                        MySQL Tools Community                                                                                    95
mysql57-community/x86_64                                                            MySQL 5.7 Community Server                                                                              364
salt-latest/x86_64                                                                  SaltStack Latest Release Channel for RHEL/Centos 7                                                      108
updates/7/x86_64                                                                    CentOS-7 - Updates                                                                                    2,500
repolist: 27,012

使用reposync命令下载该源的软件包:

# reposync -r mysql-tools-community -p /var/www/html/src

7、使用createrepo更新本地yum仓库。为了测试需要,下载了21个包,之后中止了其余软件包的下载。

# createrepo /var/www/html/src
Spawning worker 0 with 11 pkgs
Spawning worker 1 with 10 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

在客户端进行验证,正常:

# yum repolist
Loaded plugins: auto-update-debuginfo, fastestmirror, refresh-packagekit, security
Determining fastest mirrors
TestYum                                                                                                                                                                 | 2.9 kB     00:00     
TestYum/primary_db                                                                                                                                                      |  16 kB     00:00     
repo id                                                                                     repo name                                                                                    status
TestYum                                                                                     TestYum                                                                                      21
repolist: 21

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值