rsync linux yum,使用rsync搭建centos的镜像站

本文详细记录了一位爱好者从零开始搭建个人开源镜像站的过程,包括安装Nginx、配置Nginx、同步Linux发行版软件源以及使用rsync进行数据同步。在过程中遇到了配置问题,最终成功并实现了对EPEL软件源的同步。同时,还提到了监控网速和防火墙设置等维护要点。
摘要由CSDN通过智能技术生成

简介

自己一直以来相搭建一个开源镜像站,一方面可以了解搭建镜像站的知识,一方面可以同步那些国内没有的linux发行版软件源,但是最主要的原因只是为了好玩

注意点

我这个教程不是专业教程,但是要注意的是镜像站是一个对I/O要求很高,网络带宽要求很高,磁盘占用量的站点,不然没人用

步骤

安装需要的软件(nginx,rsync)

配置nginx

编写同步脚本

编译安装nginx

安装PCRE库

下载解压

wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz

tar -zxvf pcre-8.41.tar.gz

cd pcre-8.41

编译安装

./configure --prefix=/usr/local/pcre

make

make install

安装zlib

下载解压

wget http://zlib.net/zlib-1.2.11.tar.gz

tar -zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11

编译安装

./configure --prefix=/usr/local/zlib

make

make install

安装openssl库

wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz

tar -zxvf openssl-1.0.2l.tar.gz

cd openssl-1.0.2l

编译安装

./config --prefix=/usr/local/openssl

make

make install

安装nginx

下载解压

wget http://mirrors.sohu.com/nginx/nginx-1.12.1.tar.gz

tar -zxvf nginx-1.12.1.tar.gz

cd nginx-1.12.1

编译安装

./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre/ --with-zlib=/usr/local/zlib/ --with-openssl=/usr/local/openssl/

make

报错

[root@bboysoul nginx-1.12.1]# make

make -f objs/Makefile

make[1]: Entering directory `/root/nginx-1.12.1'

cd /usr/local/pcre/ \

&& if [ -f Makefile ]; then make distclean; fi \

&& \

./configure --disable-shared

/bin/sh: line 2: ./configure: No such file or directory

make[1]: *** [/usr/local/pcre//Makefile] Error 127

make[1]: Leaving directory `/root/nginx-1.12.1'

make: *** [build] Error 2

百度了一下,原来–with-pcre要指定的不是安装目录而是源码目录

./configure --prefix=/usr/local/nginx --with-pcre=/root/pcre-8.41 --with-zlib=/usr/local/zlib/ --with-openssl=/usr/local/openssl/

make

又报错

src/http/modules/ngx_http_log_module.c:13:18: fatal error: zlib.h: No such file or directory

#include

^

compilation terminated.

make[1]: *** [objs/src/http/modules/ngx_http_log_module.o] Error 1

make[1]: Leaving directory `/root/nginx-1.12.1'

make: *** [build] Error 2

直接指定zlib的源码目录好了

./configure --prefix=/usr/local/nginx --with-pcre=/root/pcre-8.41 --with-zlib=/root/zlib-1.2.11 --with-openssl=/usr/local/openssl/

make

make install

成功

测试一下

如果你这个时候还是访问不了你的nginx,出现ERR_ADDRESS_UNREACHABLE这个错误,你要检查一下你的防火墙,可以配置也可以选择关闭

systemctl stop firewalld.service

其实到这一步的时候我已经忘记我在干什么了,看了一下标题,哦!原来我在做一个镜像站,,,,,

安装rsync

yum install rsync

配置

之后,配置一下站点

在home文件夹下创建一个站点文件来存放同步过来的资源

mkdir /home/mirror

之后修改nginx.conf的server段为

server {

listen 80;

server_name localhost;

root /home/mirror;

location / {

autoindex on;

autoindex_exact_size off;

autoindex_localtime on;

}

}

重启一下服务器

[root@bboysoul sbin]# pidof nginx

31632 31631

[root@bboysoul sbin]# kill 31632 31631

[root@bboysoul sbin]# pidof nginx

[root@bboysoul sbin]# ./nginx

[root@bboysoul sbin]#

接着你去访问站点,看到的就会是下面这样,因为打开了nginx的目录浏览功能autoindex

Index of /

../

安装createrepo

yum install createrepo

因为centos的软件包目录有点多,而且大,所以为了方便我就只同步epel软件源了

mkdir epel

cd epel

mkdir 7

之后编写一个同步脚本

rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS/ /home/mirror/epel/7/SRPMS/

createrepo /home/mirror/epel/7/SRPMS/

rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/epel/7/aarch64/ /home/mirror/epel/7/aarch64/

createrepo /home/mirror/epel/7/aarch64/

rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/epel/7/ppc64/ /home/mirror/epel/7/ppc64/

createrepo /home/mirror/epel/7/ppc64/

rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/epel/7/ppc64le/ /home/mirror/epel/7/ppc64le/

createrepo /home/mirror/epel/7/ppc64le/

rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/ /home/mirror/epel/7/x86_64/

createrepo /home/mirror/epel/7/x86_64/

echo "bboysoul done"

赋予执行权限

sudo chmod +x rsync.sh

安装screen

yum install screen

建立一个新的会话

screen -S rsync

执行脚本

./rsync.sh

ctrl+a+d退出

你可以安装bwm-ng来监控网速,我这边的状态是这样的

同步时间很久的,注意磁盘有没有被占满

同步时间肯定很久。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值