凉城旧巷
Python从入门到自闭,Java从自闭到放弃,数据库从删库到跑路,Linux从rm -rf到完犊子!!!
posts - 315,comments - 20,views - 38万

局域网yum和Epel源搭建

一、内网yum服务器同步网上现有的镜像源

1、创建存储目录

mkdir -p /data/aliyun

 

2、 准备同步阿里云的源

baseupdatesextrasepel, 确保/etc/yum.repos.d/ 下只有下面这两个repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
	vim /etc/yum.repos.d/CentOS-Base.repo
		:%s/$releasever/7/g
	
wget -O /etc/yum.repos.d/CentOS-epel.repo http:/mirrors.aliyun.com/repo/epel-7.repo

 

3、 开始同步下载包

# 安装工具
yum -y install yum-utils
reposync -p /data/aliyun

 

4、 建仓

createrepo用以创建 yum 源(软件仓库),即为存放于本地特定位置的众多 rpm 包建立索引,描述各包所需依赖信息,并形成元数据。

#工具安装
yum -y install createrepo
createrepo -p /data/aliyun/base/Packages

createrepo -p /data/aliyun/extras/Packages

createrepo -p /data/aliyun/updates/Packages

createrepo -p /data/aliyun/epel/Packages

 

5、nginx搭建服务

yum install -y nginx

修改nginx配置文件,vim /etc/nginx/nginx.conf

 

6、crontab定时同步

编辑/etc/crontab文件,添加

1 2 * * * reposync -np /data/aliyun/   # -np:只同步更新的部分

 

二、yum仓库指向内网yum服务器

1、配置yum仓库

/etc/yum.repos.d/新建一个文件local.repo

  • baseurl所在的目录下必须报刊repodata/目录

  • baseurl中ip实则为ip:port,由于nginx默认为80端口,可省略

[base]
name = "local_repo"
baseurl = http://192.168.136.183/base/Packages/
gpgcheck = 0
enabled = 1

[updates]
name = "local_repo"
baseurl = http://192.168.136.183/updates/Packages/
gpgcheck = 0
enabled = 1

[extras]
name = "local_repo"
baseurl = http://192.168.136.183/extras/Packages/
gpgcheck = 0
enabled = 1

 

  • 本地源
[base]
name = "local_repo"
baseurl = file:///data/aliyun/base/Packages/
gpgcheck = 0
enabled = 1

[updates]
name = "local_repo"
baseurl = file:///data/aliyun/updates/Packages/
gpgcheck = 0
enabled = 1

[extras]
name = "local_repo"
baseurl = file:///data/aliyun/extras/Packages/
gpgcheck = 0
enabled = 1

 

2、配置epel仓库

/etc/yum.repos.d/新建一个文件local_epel.repo

[epel]
name = "local_epel_repo"
baseurl = http://192.168.136.183/epel/Packages/
gpgcheck = 0
enabled = 1

 

  • 本地epel源
[epel]
name = "local_epel_repo"
baseurl = file:///data/aliyun/epel/Packages/
gpgcheck = 0
enabled = 1

 

三、使用本地源

yum clean all
yum makecacke
posted on   凉城旧巷  阅读(1080)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示