1. Nginx提供目录浏览功能
1)安装Nginx,直接yum安装。
[root@qiudao ~]
2)配置文件
[root@qiudao ~]
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;
}
}
}
3)启动Nginx
[root@qiudao ~]
[root@qiudao ~]
[root@qiudao ~]
2. 同步公网Yum源
同步了centos7基础源和epel源,有的同学担心,这样会特别占用空间!是的,如果不启用过滤,全部同步,确实很占用空间!
1)创建本地Yum源路径
[root@qiudao ~]
[root@qiudao ~]
2)下面编写Rsync里面的--exclude-from文件
[root@qiudao ~]
EFI/
LiveOS/
images/
isolinux/
CentOS_BuildTag
EULA
GPL
RPM-GPG-KEY-CentOS-7
RPM-GPG-KEY-CentOS-Testing-7
[root@qiudao ~]
drpms/
3)开始同步
[root@qiudao ~]
[root@qiudao ~]
[root@qiudao ~]
[root@qiudao ~]
最终2个源全部同步完成,到这里已经能提供yum服务了,但是无法为下游提供同步服务,于是有了第三步。
3. 部署Rsync
1)开启Rsync --daemon模式
[root@qiudao ~]
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
2)启动Rsync
[root@qiudao ~]
[root@qiudao ~]
到这里,一个公网yum该有的功能都有了!
3) 配置客户端,将其yum下载的源指向本地
①.将原来的源移动到别处
[root@qiudao ~]
[root@qiudao ~]
②.清本地Yum缓存:
[root@qiudao ~]
③.创建新的Repo源
[root@qiudao ~]
[centos]
name=CentOS-$releasever - Base
baseurl=http://192.168.15.84/centos/7/$basearch
enable=1
gpgcheck=0
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://192.168.15.84/epel/7/$basearch
enabled=1
gpgcheck=0
④.或者在站点目录下面编写个Repo源文件
[root@qiudao ~]
[centos]
name=CentOS-$releasever - Base
baseurl=http://192.168.15.84/centos/7/$basearch
enable=1
gpgcheck=0
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://192.168.15.84/epel/7/$basearch
enabled=1
gpgcheck=0
⑤.下载到本地
[root@qiudao ~]
⑥.显示Yum仓库源
[root@qiudao ~]
4.书写定时任务
[root@qiudao ~]
00 22 * * * /usr/bin/rsync -az --exclude={EFI/,LiveOS/,images/,isolinux/,CentOS_BuildTag,EULA,GPL,RPM-GPG-KEY-CentOS-7,RPM-GPG-KEY-CentOS-Testing-7} rsync://rsync.mirrors.ustc.edu.cn/centos/7/os/x86_64/ /usr/share/nginx/html/centos/7/x86_64/ &>/dev/null
00 23 * * * /usr/bin/rsync -az --exclude={debug/,drpms/} rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64/ /usr/share/nginx/html/epel/7/x86_64/ &>/dev/null