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

发布时间:2021-11-04 16:36:34 作者:柒染
来源:亿速云 阅读:209

如何搭建私有YUM仓库与内网镜像站,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

搭建私有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/siyou
cd /home/mirros/siyou
lrzsz
#或则进入到该目录,将软件下载到此目录,但是不安装
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=$infra
baseurl=http://192.168.1.47/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=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=$infra
baseurl=http://192.168.1.47/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=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=$infra
baseurl=http://192.168.1.47/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=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 Enterprise Linux 7 - $basearch
baseurl=http://192.168.1.47/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://192.168.1.47/epel/7/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://192.168.1.47/epel/7/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

客户端使用

第二:清除缓存,并重建makecache
yum clean all && yum makecache
第三:安装软件
yum install tree -y

关于如何搭建私有YUM仓库与内网镜像站问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

推荐阅读:
  1. 搭建yum仓库
  2. 用registry搭建私有镜像仓库

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

yum

上一篇:Vue框架的面试题有哪些

下一篇:怎么推送Web浏览器的通知

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》