企业必备——Linux Centos7远程YUM仓库部署

企业必备——Linux Centos7远程YUM仓库部署

本章目的:客户端Centos7-1能享用远程服务器Centos7 的YUM仓库

本章环境:一台服务器Centos7,一台客户端

Centos7-1,VM虚拟机

1.安装vsftpd服务

[[email protected] ~]# yum install vsftpd -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: centos.ustc.edu.cn
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 vsftpd.x86_64.0.3.0.2-25.el7 将被 安装
--> 解决依赖关系完成

2.挂载镜像

企业必备——Linux Centos7远程YUM仓库部署

[[email protected] ~]# mount /dev/sr0 /mnt/ //挂载到mnt目录
mount: /dev/sr0 写保护,将以只读方式挂载
[[email protected] ~]# df -hT   
文件系统       类型      容量  已用  可用 已用% 挂载点
/dev/sda2      xfs        10G  3.9G  6.2G   39% /
devtmpfs       devtmpfs  898M     0  898M    0% /dev
tmpfs          tmpfs     912M     0  912M    0% /dev/shm
tmpfs          tmpfs     912M  9.0M  903M    1% /run
tmpfs          tmpfs     912M     0  912M    0% /sys/fs/cgroup
/dev/sda5      xfs        10G   37M   10G    1% /home
/dev/sda1      xfs       6.0G  174M  5.9G    3% /boot
tmpfs          tmpfs     183M   20K  183M    1% /run/user/0
/dev/sr0       iso9660   4.3G  4.3G     0  100% /mnt
[[email protected] ~]# cd /var/
[[email protected] var]# ls     //在var目录下面看到我们的ftb文件了
account  crash  ftp     kerberos  lock  nis       run     tmp
adm      db     games   lib       log   opt       spool   yp
cache    empty  gopher  local     mail  preserve  target

3.在ftp站点目录下,创建目录centos7,把我们的YUM源放在下面

[[email protected] var]# cd ftp/
[[email protected] ftp]# ls
pub
[[email protected] ftp]# mkdir centos7 //创建一个目录
[[email protected] ftp]# ls
centos7  pub
[[email protected] ftp]# cp -rf /mnt/* centos7/ &  //我们把挂载点里面的所有文件放在我们刚才创建的目录底下
[1] 2705
[[email protected] ftp]# jobs   //查看后台运行的进程
[1]+  运行中               cp -i -rf /mnt/* centos7/ &

4.创建目录other,把我们的扩展源放在目录底下

[[email protected] ftp]# mkdir other  //创建一个扩展目录
[[email protected] ftp]# ls
centos7  other  pub
[[email protected] ftp]# createrepo -g /mnt/repodata/repomd.xml other/   //扩展目录下放非官方的软件包,第三方组织
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[1]+  完成                  cp -i -rf /mnt/* centos7/

5.查看我们的进程,YUM源和扩展源

[[email protected] ftp]# jobs //查看进程状态,我们刚才的镜像已经复制好了
[[email protected] ftp]# cd centos7/
[[email protected] centos7]# ls
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL
[[email protected] centos7]# cd ../other/
[[email protected] other]# ls
repodata
[[email protected] other]# cd repodata/  //我们的非官方软件包就放在这个配置文件里
[[email protected] repodata]# ls
01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2
401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz
5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2
5f62201963ee83e178738d9f88078560377cc06f972a4c0094ab3be00cae515f-repomd.xml
6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz
7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2
c48538ac0f65ece36eb71d41b76f1eb1f98c58cc26777348490feaed8f38ab56-repomd.xml.gz
dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz
repomd.xml

6.开启服务关闭防火墙

[[email protected] repodata]# cd ~
[[email protected] ~]# systemctl start vsftpd  //开启vsftpd服务
[[email protected] ~]# netstat -ntap | grep 21  查看21端口,负责连接
tcp6       0      0 :::21                   :::*                    LISTEN      3244/vsftpd         
[[email protected] ~]# netstat -ntap | grep 20
[[email protected] ~]# systemctl stop firewalld.service  //关闭防火墙
[[email protected] ~]# setenforce 0   //关闭增强功能
[[email protected] ~]# 

7.在客户端Centos7中安装ftp服务

[[email protected] ~]# yum -install ftp -y   安装ftp服务
已加载插件:fastestmirror, langpacks
Usage: yum [options] COMMAND

List of Commands:

8.连接ftp服务器

[[email protected] ~]# ftp 192.168.17.128      //我们连接ftp输入服务器的地址
Connected to 192.168.17.128 (192.168.17.128).
220 (vsFTPd 3.0.2)
Name (192.168.17.128:root): ftp   //匿名登录
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 
ftp> 

9.把我们原来yum仓库的文件放到我们创建的目录中

[email protected] ~]# cd /etc/yum.repos.d/  //查看我们客户端的YUM仓库配置文件
[[email protected] yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[[email protected] yum.repos.d]# vim centos-Base.repo
[[email protected] yum.repos.d]# mkdir bak   //创建一个目录
[[email protected] yum.repos.d]# mv *.repo bak/   //把所有的配置文件全放在我们刚才的目录底下
[[email protected] yum.repos.d]# ls
bak
[[email protected] yum.repos.d]# ls bak/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.rep

10.清除Yum缓存

[[email protected] yum.repos.d]# yum clean all   //清除yum缓存
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile

11.我们给客户端Centos7配一个路径

[[email protected] yum.repos.d]# vim centos7.repo
[base]  
name=centos7.Packages  //软件包
baseurl=ftp://192.168.17.128/centos7 //输入服务器地址和目录
enabled=1  //开启服务
gpgcheck=1  //密钥验证,因为我们是远程使用YUM仓库
gpgkey=ftp://192.168.17.128/centos7/RPM-GPG-KEY-CentOS-7
//RPM-GPG-KEY-CentOS-7  //这端密钥是服务器端的
[other]
name=other.Packages
baseurl=ftp://192.168.17.128/other
enabled=1
gpgcheck=0

~                                                                                      
~                                     
wq

[[email protected] ftp]# cd centos7/    //把我们服务器的的密钥辅助到我们客户端的路径配置文件里
[[email protected] centos7]# ls
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL

12.验证一下YUM源是否能使用

[[email protected] yum.repos.d]# yum list
yum-plugin-remove-with-leaves.noarch         1.1.31-50.el7                    base     
yum-plugin-rpm-warm-cache.noarch             1.1.31-50.el7                    base     
yum-plugin-show-leaves.noarch                1.1.31-50.el7                    base     
yum-plugin-tmprepo.noarch                    1.1.31-50.el7                    base     
yum-plugin-tsflags.noarch                    1.1.31-50.el7                    base     
yum-plugin-upgrade-helper.noarch             1.1.31-50.el7                    base     
yum-plugin-verify.noarch                     1.1.31-50.el7                    base     
yum-plugin-versionlock.noarch                1.1.31-50.el7                    base     
yum-rhn-plugin.noarch                        2.0.1-10.el7                     base     
yum-updateonboot.noarch              

以上就是我们的所有内容了

谢谢大家观看

猜你喜欢

转载自blog.51cto.com/14449524/2437438