linux开源6.9 安装教程,CentOS 6.9自建开源镜像站

1、演示环境:IPOSNginx版本Rsync版本清华大学开源软件镜像站

192.168.1.146CentOS   6.9 x86_641.10.23.0.6https://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

8ad2c09039de3f4d78b428ea7be3849f.png

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进程:

d71a6ccaa30faeb50d99ae92ae2bd380.png

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

f4fa56a602d46c5ddf2f8c0b3b23650b.png

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

984a7ded26ee0da1278d1ba634ea3e08.png

abb4b7cbda65daf9000bff5b3927b9db.png

8fb0a2ac9290ed8319b5744905b89b73.png

e482d012a0cf36eda23a9f53ba03cc82.png

e5bb53f8271eaaf001effc4349421f5e.png

4378501770e26699f1e0efe4fab70854.png

6eb3a1481bb5fb9d574a419088a5ab3e.png

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

33cf4c38e71b507882d47a0bec9cd6ed.png

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

c6932bb5409a49377ca464d1a073ecbb.png

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

f70d620a553dfd3e74bf1555a4aa0d15.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值