微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

构建企业YUM仓库

1、服务端

1)安装ftp服务

[root@VM_0_3_centos ~]# systemctl stop firwalld
Failed to stop firwalld.service: Unit firwalld.service not loaded.
[root@VM_0_3_centos ~]# setenforce 0
setenforce: SELinux is disabled
[root@VM_0_3_centos ~]# yum -y install vsftpd
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-25.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================
 Package                  Arch                     Version                           Repository            Size
================================================================================================================
Installing:
 vsftpd                   x86_64                   3.0.2-25.el7                      os                   171 k

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

Total download size: 171 k
Installed size: 353 k
Downloading packages:
vsftpd-3.0.2-25.el7.x86_64.rpm                                                           | 171 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : vsftpd-3.0.2-25.el7.x86_64                                                                   1/1 
  Verifying  : vsftpd-3.0.2-25.el7.x86_64                                                                   1/1 

Installed:
  vsftpd.x86_64 0:3.0.2-25.el7                                                                                  

Complete!
[root@VM_0_3_centos ~]# systemctl start vsftpd
[root@VM_0_3_centos ~]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

在客户端打开网页验证ftp运行正常:

image.png

找到ftp资源目录,新建文件夹:

[root@VM_0_3_centos ~]# rpm -ql vsftpd |grep pub
/var/ftp/pub
[root@VM_0_3_centos ~]# mkdir /var/ftp/centos7

在客户端刷新再次验证:

image.png

2)下载rpm资源包:

[root@VM_0_3_centos ~]# cd /var/ftp/centos7/
[root@VM_0_3_centos centos7]# curl http://mirrors.163.com/centos/7/updates/x86_64/Packages/ | awk -F '[">]+' '{print "wget http://mirrors.163.com/centos/7/updates/x86_64/Packages/"$2}'|bash

下载完成后,再次在客户端刷新可以看到centos7目录内已经有rpm资源了。

image.png

3)构建repodata仓库

[root@VM_0_3_centos centos7]# yum -y install createrepo
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package createrepo.noarch 0:0.9.9-28.el7 will be installed
--> Processing Dependency: python-deltarpm for package: createrepo-0.9.9-28.el7.noarch
--> Processing Dependency: deltarpm for package: createrepo-0.9.9-28.el7.noarch
--> Running transaction check
---> Package deltarpm.x86_64 0:3.6-3.el7 will be installed
---> Package python-deltarpm.x86_64 0:3.6-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================
 Package                         Arch                   Version                        Repository          Size
================================================================================================================
Installing:
 createrepo                      noarch                 0.9.9-28.el7                   os                  94 k
Installing for dependencies:
 deltarpm                        x86_64                 3.6-3.el7                      os                  82 k
 python-deltarpm                 x86_64                 3.6-3.el7                      os                  31 k

Transaction Summary
================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 207 k
Installed size: 558 k
Downloading packages:
(1/3): deltarpm-3.6-3.el7.x86_64.rpm                                                     |  82 kB  00:00:00     
(2/3): createrepo-0.9.9-28.el7.noarch.rpm                                                |  94 kB  00:00:00     
(3/3): python-deltarpm-3.6-3.el7.x86_64.rpm                                              |  31 kB  00:00:00     
----------------------------------------------------------------------------------------------------------------
Total                                                                           499 kB/s | 207 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : deltarpm-3.6-3.el7.x86_64                                                                    1/3 
  Installing : python-deltarpm-3.6-3.el7.x86_64                                                             2/3 
  Installing : createrepo-0.9.9-28.el7.noarch                                                               3/3 
  Verifying  : createrepo-0.9.9-28.el7.noarch                                                               1/3 
  Verifying  : deltarpm-3.6-3.el7.x86_64                                                                    2/3 
  Verifying  : python-deltarpm-3.6-3.el7.x86_64                                                             3/3 

Installed:
  createrepo.noarch 0:0.9.9-28.el7                                                                              

Dependency Installed:
  deltarpm.x86_64 0:3.6-3.el7                         python-deltarpm.x86_64 0:3.6-3.el7                        

Complete!
[root@VM_0_3_centos centos7]# createrepo /var/ftp/centos7/    ##生成仓库信息,每次新增软件要重新生成一次
Spawning worker 0 with 359 pkgs
Workers Finished
Saving Primary Metadata
Saving file lists Metadata
Saving other Metadata
Generating sqlite DBs
sqlite DBs complete

在客户端重新刷新,可以看到生成了repodata目录。

image.png


2、客户端

1)配置yum源

[root@VM_0_4_centos centos7]# ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Epel.repo
[root@VM_0_4_centos centos7]# gzip /etc/yum.repos.d/*
[root@VM_0_4_centos centos7]# ls /etc/yum.repos.d/
CentOS-Base.repo.gz  CentOS-Epel.repo.gz
[root@VM_0_4_centos centos7]# vim /etc/yum.repos.d/centos7.repo
[ftp]
name=centos7.ftp
baseurl=ftp://129.*.*.*/centos7
gpgcheck=0
enabled=1

2)测试验证

[root@VM_0_4_centos centos7]# yum install -y vim-enhanced   ##可以看到安装来源于FTP
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.160-6.el7_6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================
 Package                                 Arch                              Version                                        Repository                      Size
===============================================================================================================================================================
Installing:
 vim-enhanced                            x86_64                            2:7.4.160-6.el7_6                              ftp                            1.0 M

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

Total download size: 1.0 M
Installed size: 2.2 M
Downloading packages:
vim-enhanced-7.4.160-6.el7_6.x86_64.rpm                                                                                                 | 1.0 MB  00:00:08     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:vim-enhanced-7.4.160-6.el7_6.x86_64                                                                                                       1/1 
  Verifying  : 2:vim-enhanced-7.4.160-6.el7_6.x86_64                                                                                                       1/1 

Installed:
  vim-enhanced.x86_64 2:7.4.160-6.el7_6                                                                                                                        

Complete!


版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。