码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-04-11 18:07:21      阅读:402      评论:0      收藏:0      [点我收藏+]

标签:yum   镜像站   阿里云   CentOS源   自建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
#
# 此脚本用于同步"# 
# 如果还需要其它系统那么直接往后面加上去及要
#
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


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

标签:yum   镜像站   阿里云   CentOS源   自建yum   

原文地址:http://blog.51cto.com/270142877/2097066

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!