资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

CentOS6.9自建开源镜像站

1、  演示环境:

10年积累的网站设计制作、网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先建设网站后付款的网站建设流程,更有揭东免费网站建设让你可以放心的选择与我们合作。

创新互联是一家集网站建设,华亭企业网站建设,华亭品牌网站建设,网站定制,华亭网站建设报价,网络营销,网络优化,华亭网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

IP

OS

Nginx 版本

Rsync 版本

清华大学开源软件镜像站

192.168.1.146

CentOS   6.9 x86_64

1.10.2

3.0.6

https://mirrors.tuna.tsinghua.edu.cn/

备注:同步的上游 yum 源必须要支持 rsync 协议,否则不能使用 rsync 进行同步。国内的很多开源镜像站都不支持 rsync ,这里以清华大学开源软件镜像站为例。

2、  安装前准备:

(1) 服务器时间校对

(2) 配置 epel 源

3、  安装配置 Nginx :

(1) 安装 Nginx : # yum -y install nginx

(2) 创建软件包存放目录: # mkdir -pv /mirror/{centosplus,extras,os,updates,epel}

(3) 配置 Nginx :

# cd /etc/nginx/conf.d

# cp default.conf default.conf.bak

# vim default.conf

server {

listen  80;

server_name  localhost;

root /mirror/;

location / {

autoindex on;

autoindex_exact_size off;

autoindex_localtime on;

}

}

(4) 检查 Nginx 配置文件语法,并启动 Nginx : # nginx -t  # service nginx start

(5) 检查 Nginx 监听的 80 端口: # ss -tnlp | grep :80  # pidof nginx

(6) 浏览器中访问站点: 192.168.1.146

CentOS 6.9自建开源镜像站

4、  同步清华大学开源软件镜像站:

(1) 安装相关软件包: # yum -y install rsync createrepo

(2) 查看每个源下的软件包:

# rsync --list-only rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/centosplus/x86_64/Packages/

# rsync --list-only rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/extras/x86_64/Packages/

# rsync --list-only rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/os/x86_64/Packages/

# rsync --list-only rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/updates/x86_64/Packages/

# rsync -r --list-only rsync://mirrors.tuna.tsinghua.edu.cn/epel/6Server/x86_64/Packages/

(3) 编写同步脚本:

# mkdir -pv /scripts

# vim /scripts/yum_rsync.sh

#!/bin/bash

/usr/bin/rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/centosplus/x86_64/Packages/ /mirror/centosplus && /usr/bin/createrepo /mirror/centosplus

/usr/bin/rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/extras/x86_64/Packages/ /mirror/extras && /usr/bin/createrepo /mirror/extras

/usr/bin/rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/os/x86_64/Packages/ /mirror/os && /usr/bin/createrepo /mirror/os

/usr/bin/rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/updates/x86_64/Packages/ /mirror/updates && /usr/bin/createrepo /mirror/updates

/usr/bin/rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/epel/6Server/x86_64/Packages/ /mirror/epel && /usr/bin/createrepo /mirror/epel

# chmod +x /scripts/yum_rsync.sh

(4) 编写定时任务:每天凌晨 12 点开始执行同步脚本

# crontab -e  -->  0 0 * * * /scripts/yum_rsync.sh

备注:同步耗时较长,且保证磁盘有足够大的容量

同步时可以通过 # top 命令查看 rsync 进程:

CentOS 6.9自建开源镜像站

同步前目录结构及磁盘容量:

CentOS 6.9自建开源镜像站

同步后目录结构及磁盘容量:

CentOS 6.9自建开源镜像站

CentOS 6.9自建开源镜像站

CentOS 6.9自建开源镜像站

CentOS 6.9自建开源镜像站

CentOS 6.9自建开源镜像站

CentOS 6.9自建开源镜像站

CentOS 6.9自建开源镜像站

5、  其它服务器(例如: 192.168.1.145 )配置自建的 yum 源进行软件包下载安装测试:

(1) 创建 yum 源的 repo 配置文件:

# cd /etc/yum.repos.d

# mv CentOS-Base.repo CentOS-Base.repo.bak

# vim CentOS-Base.repo

[base]

name=Marion - CentOS-$releasever - Base

baseurl=http://192.168.1.146/os

enabled=1

gpgcheck=0

[centosplus]

name=Marion - CentOS-$releasever - Centosplus

baseurl=http://192.168.1.146/centosplus

enabled=1

gpgcheck=0

[extras]

name=Marion - CentOS-$releasever - Extras

baseurl=http://192.168.1.146/extras

enabled=1

gpgcheck=0

[updates]

name=Marion - CentOS-$releasever - Updates

baseurl=http://192.168.1.146/updates

enabled=1

gpgcheck=0

# vim epel.repo

[epel]

name=Marion - CentOS-$releasever - EPEL

baseurl=http://192.168.1.146/epel

enabled=1

gpgcheck=0

(2) 清除当前 yum 缓存: # yum clean all

(3) 重新生成 yum 缓存: # yum makecache

(4) 显示可用的 yum 源: # yum repolist

CentOS 6.9自建开源镜像站

(5) 测试 base 源: # yum -y install httpd  # yum info httpd

CentOS 6.9自建开源镜像站

(6) 测试 epel 源: # yum -y install nginx  # yum info nginx

CentOS 6.9自建开源镜像站

      本文转自Marion0728  51CTO博客,原文链接:http://blog.51cto.com/qiuyue/2052813 ,如需转载请自行联系原作者


网页标题:CentOS6.9自建开源镜像站
转载来于:http://cdkjz.cn/article/iijpco.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220