1,使用nginx 搭建一个web系统并显示文件目录并让这台机器可以上外网,虚拟机即可,系统centos7.9 ,硬盘容量需要至少1T以上
2,编写yum的同步脚本,我选择从科技大学源同步
3,创建centos6和7的目录和epel源同步基本的包,
4,客户端report文件以及替换系统默认源文件
一,搭建nginx 服务web显示linux目录
下载nginx http://nginx.org/en/download.html
安装依赖
#sudo yum -y install wget zlib zlib-devel openssl openssl-devel make pcre pcre-devel gcc gcc-c++ libtool
#wget http://nginx.org/download/nginx-1.18.0.tar.gz
#tar -zxvf nginx-1.18.0.tar.gz -C /opt
#cd /opt/
#./configure --prefix=/usr/local/nginx
可选##--prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-pcre
#make && make install
检查nginx版本/usr/local/nginx/sbin/nginx -V
设置环境变量
#export PATH=$PATH:/usr/local/nginx/sbin/
useradd -s /bin/nologin -M nginx
检查nginx配置 nginx -t
启动nginx nginx
关闭nginx nginx -s stop
查看nginx状态 ps auxfww|grep nginx netstat -tulnp|grep nginx
使用systemctl 管理nginx /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
[Install]
WantedBy=multi-user.target
这只nginx web,vim /usr/local/nginx/conf
####################################
[root@SVR-centos7 conf]# vim nginx.conf
worker_processes 4;
events {
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name yum;
location / {
root /data/yum;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
charset utf-8;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
###########################################################
二,同步脚本,用于同步centos6和centos7以及epel源
[root@SVR-yum2 backup]# cat rsync.sh
#!/bin/bash
# 此脚本用于同步"#
# 如果还需要其它系统那么直接往后面加上去及要
# add centos repo
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/8/Modular/ /backup/yum/epel/8/Modular &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/8/Everything/ /backup/yum/epel/8/Everything &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64/ /backup/yum/epel/7/x86_64 &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/extras/x86_64/ /backup/yum/centos/7/extras/x86_64 &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/updates/x86_64/ /backup/yum/centos/7/updates/x86_64 &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/os/x86_64/ /backup/yum/centos/7/os/x86_64 &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/centosplus/x86_64/ /backup/yum/centos/7/centosplus/x86_64 &&
rsync -avrt rsync://mirrors.ustc.edu.cn/centos/7/sclo/x86_64/ /backup/yum/centos/7/sclo/x86_64/ &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/ /backup/yum/epel/6/x86_64 &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /backup/yum/centos/6/extras/x86_64 &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /backup/yum/centos/6/updates/x86_64 &&
rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/ /backup/yum/centos/6/os/x86_64 &&
#rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/centosplus/x86_64/ /yum/centos/6/centosplus/x86_64
rsync -avrt rsync://mirrors.ustc.edu.cn/centos/6/sclo/x86_64/ /backup/yum/centos/6/sclo/x86_64/
rsync -avrt rsync://li.nux.ro/download/nux/dextop/el7/x86_64/ /backup/yum/centos/7/centosplus/x86_64
三,在系统下数据盘里面创建目录,目录最好使用lvm格式,可以动态扩容,根据
/backup/yum/centos/7
/backup/yum/centos/6
/backup/yum/epel/7/x86_64
/backup/yum/epel/6/x86_64
四,定时同步vim /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
* * * * 0 root /usr/bin/sh /backup/rsync.sh
五,替换客户端系统默认源文件以及更新
把系统里面/etc/yum.repo.d 里面的CentOS-Base.repo等文件删除创建一个文件名称为XXX.repo文件,然后 yum clean all
和 yum makecache
文件内容如下:
[base]
name=CentOS-$releasever - Base
baseurl=http://yum.srv/centos/$releasever/os/$basearch/
enable=1
gpgcheck=0
[updates]
name=CentOS-$releasever - Updates
baseurl=http://yum.srv/centos/$releasever/updates/$basearch/
gpgcheck=0
enable=1
[extras]
name=CentOS-$releasever - Extras
baseurl=http://yum.srv/centos/$releasever/extras/$basearch/
gpgcheck=0
enable=1
[epel]
name=epel-$releasever
baseurl=http://yum.srv/epel/$releasever/$basearch/
gpgcheck=0
enable=1