rsync+nginx实现公网yum源

rsync+nginx实现公网yum源,第1张

概述整个过程分3步: 1:nginx提供目录浏览功能 nginx直接yum安装,不废话,直接贴配置文件 [[email protected] ~]# cat /etc/nginx/nginx.confworker_processes auto;events {worker_connections 1024;}http {include mime.types;charset

整个过程分3步:

1:Nginx提供目录浏览功能

Nginx直接yum安装,不废话,直接贴配置文件

[[email protected] ~]# cat /etc/Nginx/Nginx.confworker_processes auto;events {worker_connections 1024;}http {include mime.types;charset utf-8;default_type application/octet-stream;sendfile on;autoindex on; #开启目录浏览功能keepalive_timeout 65;server {Listen 80;Listen [::]:80;server_name localhost;location / {root HTML;index index.HTML index.htm;}}}
2:从上游yum源同步yum源到本地

直接贴定时任务

# rsync centos6 repos30 21 * * * /usr/bin/rsync -zaP --exclude-from /usr/share/Nginx/HTML/rsync_exclude2.txt rsync://rsync.mirrors.ustc.edu.cn/centos/7.4.1708 /usr/share/Nginx/HTML/centos00 22 * * * /usr/bin/rsync -zaP --exclude-from /usr/share/Nginx/HTML/rsync_exclude.txt rsync://rsync.mirrors.ustc.edu.cn/centos/6.9 /usr/share/Nginx/HTML/centos00 21 * * * /usr/bin/rsync -zaP --exclude-from /usr/share/Nginx/HTML/rsync_exclude.txt rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64 /usr/share/Nginx/HTML/epel/7/30 20 * * * /usr/bin/rsync -zaP --exclude-from /usr/share/Nginx/HTML/rsync_exclude.txt rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64 /usr/share/Nginx/HTML/epel/6/

从定时任务的配置,可以看出,我同步了centos6、7基础源和epel源,有的同学担心,这样会特别占用空间!是的,如果不启用过滤,全部同步,确实很占用空间!

下面我把rsync里面的--exclude-from文件贴出来,centos6和7稍微不同

centos6

[[email protected] ~]# cat /usr/share/Nginx/HTML/rsync_exclude.txtcentosplus/cloud/contrib/cr/fasttrack/isos/sclo/storage/virt/i386/deBUG/drpms/

centos7

[[email protected] ~]# cat /usr/share/Nginx/HTML/rsync_exclude2.txtatomic/centosplus/cloud/configmanagement/cr/dotnet/fasttrack/isos/nfv/opstools/paas/rt/sclo/storage/virt/deBUG/drpms/

最终4个源全部同步完,并且可用只占了60G左右

到这里已经能提供yum服务了,但是无法为下游提供同步服务,于是有了第三步

3:开启rsync --daemon模式
[[email protected] ~]# cat /etc/rsyncd.conf#rsync serveruID = NginxgID = Nginxuse chroot = nomax connections = 2000timeout = 600pID file = /var/run/rsyncd.pIDlock file = /var/run/rsync.locklog file = /var/log/rsyncd.logignore errorsread only = true #只提供同步,只读足够List = true             #允许查看列表,认证的什么的不需要配置hosts allow = 0.0.0.0/0#####################################[centos]path = /usr/share/Nginx/HTML/centos[epel]path = /usr/share/Nginx/HTML/epel

到这里,一个公网yum该有的功能都有了!

总结

以上是内存溢出为你收集整理的rsync+nginx实现公网yum源全部内容,希望文章能够帮你解决rsync+nginx实现公网yum源所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1026594.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存