码迷,mamicode.com
首页 > 其他好文 > 详细

rsync+nginx实现公网yum源

时间:2019-05-14 12:54:21      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:iso   txt   gid   直接   processes   read   scl   nec   track   

整个过程分3步:

1:nginx提供目录浏览功能

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

[root@oldboyedu ~]# 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

[root@oldboyedu ~]# cat /usr/share/nginx/html/rsync_exclude.txt

centosplus/

cloud/

contrib/

cr/

fasttrack/

isos/

sclo/

storage/

virt/

i386/

debug/

drpms/

centos7

[root@oldboyedu ~]# 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模式


[root@oldboyedu ~]# 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该有的功能都有了!

rsync+nginx实现公网yum源

标签:iso   txt   gid   直接   processes   read   scl   nec   track   

原文地址:https://www.cnblogs.com/Forever-x/p/10861297.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!