nginx+rsync实现本地yum源以及公网yum源

nginx+rsync实现本地yum源以及公网yum源

1.配置nginx的autoindex模块,开启目录浏览功能
2.使用rsync同步公网源上的软件包,至本地目录中
3.配置客户端指向即可

1.nginx提供目录浏览功能

[root@xuliangwei ~]# cat /etc/nginx/conf.d/yum.conf
server {
    listen 80;
    listen [::]:80;
    server_name mirrors.bgx.com;
    location / {
        root /repo;
        autoindex on; #开启目录浏览功能
    }

2.从公网的仓库同步软件包至本地

但需要注意,如果全同步,会特别占用空间,所以我们可以将不需要的软件包进行过滤。rsync同步命令(建议将其加入定时任务)

#1.同步centos7的基础源
rsync -zaP --exclude-from /repo/exclude_7.txt rsync://rsync.mirrors.ustc.edu.cn/centos/7.6.1810/ /repo/centos

#2.同步centos7的epel源
rsync -zaP --exclude-from /repo/exclude_7_epel.txt rsync://rsync.mirrors.ustc.edu.cn/epel/7/ /repo/epel

#centos7排除的文件(保留os和extras)
[root@oldboyedu ~]# cat /repo/exclude_7.txt
atomic/
centosplus/
cloud/
configmanagement/
cr/
dotnet/
fasttrack/
isos/
nfv/
opstools/
paas/
rt/
sclo/
storage/
virt/
debug/
drpms/

#centos7_epel排除的文件(保留x86_64)
[root@xuliangwei ~]# cat /repo/exclude_7_epel.txt
SRPMS/
aarch64/
ppc64/
ppc64le/
state

3.客户端配置本地yum仓库

[centos]
name = Local Base Repository
baseurl = http://mirrors.bgx.com/centos
enable = 1
gpgcheck = 0

[epel]
name = Local Epel Repository
baseurl = http://mirrors.bgx.com/epel
enable = 1
gpgcheck = 0

4.扩展

如果想为下游提供同步服务,我们可以使用rsync协议将目录共享出去,让其他人也可以同步(一般玩不起,毕竟没钱)。

[root@xuliangwei ~]# cat /etc/rsyncd.conf
uid = nginx
gid = nginx
use chroot = no
max connections = 2000
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log

ignore errors
read only = true            #只提供同步,所以只读即可
list = true                 #允许查看列表,认证的什么的不需要配置
hosts allow = 0.0.0.0/0     #允许任何人同步

##########提供同步的模块
[centos]
path = /repo/centos
[epel]
path = /repo/epel

转载于:https://www.cnblogs.com/gongjingyun123--/p/11467105.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值