自建linux镜像站,自建Yum源并与科大开源镜像站进行同步

安装Nginx

yum -y install nginx

新增yum.conf配置文件

server {

listen       80;

server_name  yum.gogen.cn;

location / {

root   /usr/share/nginx/yum;

autoindex on;

autoindex_exact_size off;

autoindex_localtime on;

}

}

启动nginx

systemctl start nginx

systemctl enable nginx

创建目录

mkdir -p /usr/share/nginx/yum/epel/6/x86_64

mkdir -p /usr/share/nginx/yum/centos/6/updates/x86_64

mkdir -p /usr/share/nginx/yum/centos/6/extras/x86_64

mkdir -p /usr/share/nginx/yum/centos/6/os/x86_64

mkdir -p /usr/share/nginx/yum/epel/7/x86_64

mkdir -p /usr/share/nginx/yum/centos/7/updates/x86_64

mkdir -p /usr/share/nginx/yum/centos/7/extras/x86_64

mkdir -p /usr/share/nginx/yum/centos/7/os/x86_64

注:如果需要其它系统还需要创建对应的其它目录

同步镜像

#!/bin/bash

#

# 此脚本用于同步"http://mirrors.ustc.edu.cn"的镜像到本地

# 如果还需要其它系统那么直接往后面加上去

#

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64/  /usr/share/nginx/yum/epel/7/x86_64 && \

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/extras/x86_64/  /usr/share/nginx/yum/centos/7/extras/x86_64 && \

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/updates/x86_64/  /usr/share/nginx/yum/centos/7/updates/x86_64 && \

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/os/x86_64/  /usr/share/nginx/yum/centos/7/os/x86_64 && \

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/  /usr/share/nginx/yum/epel/6/x86_64 && \

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/extras/x86_64/  /usr/share/nginx/yum/centos/6/extras/x86_64 && \

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/updates/x86_64/  /usr/share/nginx/yum/centos/6/updates/x86_64 && \

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/  /usr/share/nginx/yum/centos/6/os/x86_64

加入计划任务

0 1 * * * sh /usr/local/sbin/sync.sh &> /tmp/yum.log

CentOS7的repo文件

CentOS-Base.repo

# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-$releasever - Base

baseurl=http://yum.gogen.cn/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates

[updates]

name=CentOS-$releasever - Updates

baseurl=http://yum.gogen.cn/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

baseurl=http://yum.gogen.cn/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

baseurl=http://yum.gogen.cn/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

epel.repo

[epel]

name=Extra Packages for Enterprise Linux 7 - $basearch

baseurl=http://yum.gogen.cn/epel/7/$basearch

failovermethod=priority

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]

name=Extra Packages for Enterprise Linux 7 - $basearch - Debug

baseurl=http://yum.gogen.cn/epel/7/$basearch/debug

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

gpgcheck=1

[epel-source]

name=Extra Packages for Enterprise Linux 7 - $basearch - Source

baseurl=http://yum.gogen.cn/epel/7/SRPMS

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

gpgcheck=1

CentOS6的repo文件

CentOS-Base.repo

# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-$releasever - Base - yum.gogen.cn

baseurl=http://yum.gogen.cn/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=http://yum.gogen.cn/centos/RPM-GPG-KEY-CentOS-6

#released updates

[updates]

name=CentOS-$releasever - Updates - yum.gogen.cn

baseurl=http://yum.gogen.cn/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=http://yum.gogen.cn/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras - yum.gogen.cn

baseurl=http://yum.gogen.cn/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=http://yum.gogen.cn/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus - yum.gogen.cn

baseurl=http://yum.gogen.cn/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://yum.gogen.cn/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib - yum.gogen.cn

baseurl=http://yum.gogen.cn/centos/$releasever/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://yum.gogen.cn/centos/RPM-GPG-KEY-CentOS-6

epel.repo

[epel]

name=Extra Packages for Enterprise Linux 6 - $basearch

baseurl=http://yum.gogen.cn/epel/6/$basearch

failovermethod=priority

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-debuginfo]

name=Extra Packages for Enterprise Linux 6 - $basearch - Debug

baseurl=http://yum.gogen.cn/epel/6/$basearch/debug

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

gpgcheck=1

[epel-source]

name=Extra Packages for Enterprise Linux 6 - $basearch - Source

baseurl=http://yum.gogen.cn/epel/6/SRPMS

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

gpgcheck=1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值