rsync+nginx配置本地yum源或公网yum源

文章目录

  • rsync+nginx配置本地yum源或公网yum源
  • 补充,配置rsync+apache发布镜像目录

rsync+nginx配置本地yum源或公网yum源

  1. 创建存放yum源目录
mkdir -p /data/mirror/{centos/7,epel}
  1. 配置nginx发布镜像目录,当然也可以用apache或者其他web服务器
# vim /etc/nginx/conf.d/mirror.conf
server {
        listen 80;
        server_name 192.168.1.17;

        location / {
                root /data/mirror;
                autoindex on;
        }
}

[外链图片转存失败(img-f96d4dX4-1562146728646)(7D5417BA90DF4E14A91584C0719C817A)]
[外链图片转存失败(img-RVwTzd1c-1562146728647)(409CD543CFD148AE99D0CA9F559ACA98)]

  1. 从公网的仓库同步软件包至本地,并过滤不需要的软件包
# 1.同步centos7的基础源到 /data/mirror/centos/7
rsync -zaP --exclude-from /data/mirror/exclude_7.txt rsync://rsync.mirrors.ustc.edu.cn/centos/7.6.1810/ /data/mirror/centos/7

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

# 3.centos7 --exclude-from=FILE 排除FILE中指定模式的文件(保留os和extras)
[root@localhost ~]vim /data/mirror/exclude_7.txt
atomic/
centosplus/
cloud/
configmanagement/
cr/
dotnet/
fasttrack/
isos/
nfv/
opstools/
paas/
rt/
sclo/
storage/
virt/
debug/
drpms/

# 4.centos7_epel排除的文件(保留x86_64)
[root@localhost ~]# vim /data/mirror/exclude_7_epel.txt
SRPMS/
aarch64/
ppc64/
ppc64le/
state

## 建议将同步任务加入定时任务

rsync+nginx配置本地yum源或公网yum源_第1张图片
3. 配置本地yum仓库

[root@localhost ~]# vim /etc/yum.repos.d/localBase.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://192.168.1.17/centos/7/os/$basearch/
enable=1
gpgcheck=0

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://192.168.1.17/centos/7/updates/$basearch/
enable=1
gpgcheck=0

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://192.168.1.17/centos/7/extras/$basearch/
enable=1
gpgcheck=0

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://192.168.1.17/centos/epel/7/$basearch
enabled=1
gpgcheck=0
  1. 本地公网yum源配置完毕
    rsync+nginx配置本地yum源或公网yum源_第2张图片

  2. 若想将本地yum源为下游提供同步服务,可以使用rsync协议将目录共享出去

[root@localhost ~]# vim /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 = /data/mirror/centos
[epel]
path = /data/mirror/epel

补充,配置rsync+apache发布镜像目录

# vim /etc/httpd/conf/httpd.conf

# 注释掉这一段
# 
   # AllowOverride none
   # Require all denied
# 

# 添加这一段
Alias /centos "/data/mirrors/centos/"

    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all


# /etc/init.d/httpd reload

你可能感兴趣的:(Nginx)