1、服務端
python
1)安裝ftp服務sql
[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運行正常:vim
找到ftp資源目錄,新建文件夾:centos
[root@VM_0_3_centos ~]# rpm -ql vsftpd |grep pub /var/ftp/pub [root@VM_0_3_centos ~]# mkdir /var/ftp/centos7
在客戶端刷新再次驗證:
bash
2)下載rpm資源包:curl
[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資源了。
ide
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目錄。url
二、客戶端centos7
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!