rsync+nginx实现公网yum源
发布时间:2020-12-14 01:11:55 所属栏目:Linux 来源:网络整理
导读:整个过程分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 ap
整个过程分3步: 1:nginx提供目录浏览功能nginx直接yum安装,不废话,直接贴配置文件 [[email?protected] ~]# cat /etc/nginx/nginx.conf worker_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 repos 30 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/centos 00 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/centos 00 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.txt centosplus/ cloud/ contrib/ cr/ fasttrack/ isos/ sclo/ storage/ virt/ i386/ debug/ drpms/ centos7 [[email?protected] ~]# cat /usr/share/nginx/html/rsync_exclude2.txt atomic/ 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 server 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 = /usr/share/nginx/html/centos [epel] path = /usr/share/nginx/html/epel 到这里,一个公网yum该有的功能都有了! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |