ITPub博客

首页 > 应用开发 > > 搭建私有YUM仓库与内网镜像站

搭建私有YUM仓库与内网镜像站

作者:markriver 时间:2019-08-16 09:24:51 0 删除 编辑

搭建私有YUM仓库

私有yum仓库环境系统版本:centos7.4 IP:192.168.1.47#最好能上公网

私有yum仓库服务端配置

第一:创建使用yum仓库存放路径mkdir /home/mirros/siyou -p第二:安装必要软件(yumdownloader这个命令在yum-utils工具里,用来下载软件包,但不安装)yum install createrepo yum-utils -y第三:上传自己打包好的rpm包到/home/mirros/siyoucd /home/mirros/siyoulrzsz#或则进入到该目录,将软件下载到此目录,但是不安装yumdownloader openssl-*第四:初始化repodata索引文件(每新放入一个rpm都需要更新索引,不让识别不到新加的)createrepo -pdo /home/mirrors/siyou/ /home/mirrors/siyou/#下面是添加rpm包后的更新命令createrepo --update /home/mirrors/siyou/第五:提供http服务cd /home/mirros/python -m SimpleHTTPServer 80

客户端配置

在使用私有源时,软件包与base其他源一样时,建议先禁用其他源。

cd /etc/yum.repos.d

vim Centos-siyou.repo

[siyou]

name=siyou

baseurl=http://192.168.1.47/siyou

enable=1 #1表示启用,没有此参数也表示启用

gpgcheck=0

#重建缓存,并安装软件

yum clean all && yum makecache

yum install openssl-*

镜像站环境

系统版本:centos7.4 IP:192.168.1.47 #要能上公网

centos及epel官方源,中国站(中科大镜像站)http://mirrors.ustc.edu.cn

centos日常使用的软件源介绍(base,extras,updates)

注意:中科大的rsync,每个ip同时只能同步两条

内网镜像服务器配置

第一:安装软件

yum install rsync

第二:同步软件源

#同步centos7的base源

mkdir /home/mirrors/centos/7 -p

rsync -av rsync://mirrors.ustc.edu.cn/centos/7/os /home/mirrors/centos/7

#同步centos7的extras源

rsync -av rsync://mirrors.ustc.edu.cn/centos/7/extras /home/mirrors/centos/7

#同步centos7的updates源

rsync -av rsync://mirrors.ustc.edu.cn/centos/7/updates /home/mirrors/centos/7

+++++++++++++++++++++++++++++

或则省去前面三步,直接同步centos7的官方源

rsync -av rsync://mirrors.ustc.edu.cn/centos/7 /home/mirrors/centos

#简单同步一个分支的所有信息

rsync -av rsync://mirrors.ustc.edu.cn/centos/7.4.1708 /home/mirrors/centos/

第三:添加epel源同步(epel源是扩展的,不是centos官方维护的,但是包含很多软件)

mkdir /home/mirrors/epel/7 -p

rsync -av rsync://mirrors.ustc.edu.cn/epel/7/ /home/mirrors/epel/7

第四:要长期使用需要将上面同步命令,写入定期执行文件,定期同步更新

第五:启动http

cd /home/mirrors

python -m SimpleHTTPServer 80

客户端配置

第一:备份/etc/yum.repo/目录下的官方源,并创建一个自己的源,如下vim /etc/yum.repo/ccc.repo[base]name=CentOS-$releasever - Base#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infrabaseurl=http://192.168.1.47/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#released updates [updates]name=CentOS-$releasever - Updates#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infrabaseurl=http://192.168.1.47/centos/$releasever/updates/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#additional packages that may be useful[extras]name=CentOS-$releasever - Extras#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infrabaseurl=http://192.168.1.47/centos/$releasever/extras/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

第二:客户端怎么安装epel源#在安装extras源后,默认是自带并启用的yum install epel* -y#编辑/etc/yum.repo/epel.repo文件vim /etc/yum.repo/epel.repo[epel]name=Extra Packages for EnterpriseLinux7 - $basearchbaseurl=http://192.168.1.47/epel/7/$basearch#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearchfailovermethod=priorityenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7[epel-debuginfo]name=Extra Packages for Enterprise Linux 7 - $basearch - Debugbaseurl=http://192.168.1.47/epel/7/$basearch/debug#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck=1[epel-source]name=Extra Packages for Enterprise Linux 7 - $basearch - Sourcebaseurl=http://192.168.1.47/epel/7/SRPMS#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck=1

客户端使用

第二:清除缓存,并重建makecache

yum clean all && yum makecache

第三:安装软件

yum install tree -y


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/818/viewspace-3159562/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 聊聊微服务网关
请登录后发表评论 登录
全部评论

注册时间:2020-07-03

  • 博文量
    502
  • 访问量
    18497