多版本YUM仓库搭建

Posted vpandaxjl

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了多版本YUM仓库搭建相关的知识,希望对你有一定的参考价值。

服务器:CentOS7

YUM源:阿里云

空间要求:CentOS6+CentOS7  50G,考虑后期更新预留,LVS空间100G

1、在服务器配置CentOS7的yum源和CentOS6的yum源

#Centos7
[base7] name
=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 [updates7] name=CentOS-$releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 [extras7] name=CentOS-$releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 [epel7] name=CentOS-7-epel-cmiot.local baseurl=https://mirrors.aliyun.com/epel/7/x86_64/ gpgcheck=0
#Centos6
[base6] name
=CentOS-6 - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/6/os/x86_64/ http://mirrors.aliyuncs.com/centos/6/os/x86_64/ http://mirrors.cloud.aliyuncs.com/centos/6/os/x86_64/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 [updates6] name=CentOS-6 - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/6/updates/x86_64/ http://mirrors.aliyuncs.com/centos/6/updates/x86_64/ http://mirrors.cloud.aliyuncs.com/centos/6/updates/x86_64/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 [extras6] name=CentOS-6 - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/6/extras/x86_64/ http://mirrors.aliyuncs.com/centos/6/extras/x86_64/ http://mirrors.cloud.aliyuncs.com/centos/6/extras/x86_64/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 [epel6] name=CentOS-6-epel-cmiot.local baseurl=https://mirrors.aliyun.com/epel/6/x86_64/ gpgcheck=0

2、检查yum的可用性,并查看yum的repoid

技术图片

 3、安装repo同步工具和必要软件包

yum install -y wget make cmake gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel createrepo yum-utils

4、创建yum软件包目录并向阿里同步,时间较久。

mkdir -p /mirror/Aliyun/CentOS/6
reposync -n --repoid=extras6 --repoid=updates6 --repoid=base6 --repoid=epel6 -p /mirror/Aliyun/CentOS/6

mkdir -p /mirror/Aliyun/CentOS/7
reposync -n --repoid=extras7 --repoid=updates7 --repoid=base7 --repoid=epel7 -p /mirror/Aliyun/CentOS/7

5、创建索引

createrepo -po /mirror/Aliyun/CentOS/6/base6/ /mirror/Aliyun/CentOS/6/base6/
createrepo -po /mirror/Aliyun/CentOS/6/epel6/ /mirror/Aliyun/CentOS/6/epel6/
createrepo -po /mirror/Aliyun/CentOS/6/extras6/ /mirror/Aliyun/CentOS/6/extras6/
createrepo -po /mirror/Aliyun/CentOS/6/updates6/ /mirror/Aliyun/CentOS/6/updates6/
createrepo -po /mirror/Aliyun/CentOS/7/base7/ /mirror/Aliyun/CentOS/7/base7/
createrepo -po /mirror/Aliyun/CentOS/7/epel7/ /mirror/Aliyun/CentOS/7/epel7/
createrepo -po /data/website/centos/7/extras7 /data/website/centos/7/extras7
createrepo -po /mirror/Aliyun/CentOS/7/updates7/ /mirror/Aliyun/CentOS/7/updates7/

6、安装nginx并配置

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        root         /mirror ;   #这里是yum源存放目录      
        location / {
            autoindex on;        #打开目录浏览功能
            autoindex_exact_size off;  # off:以可读的方式显示文件大小
            autoindex_localtime on; # on、off:是否以服务器的文件时间作为显示的时间
            charset utf-8,gbk; #展示中文文件名
            index index.html;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

7、创建更新软件包的定时任务

0 1 * * * /mirror/update.sh
#!/bin/bash
reposync -n --repoid=extras6 --repoid=updates6 --repoid=base6 --repoid=epel6 -p /mirror/Aliyun/CentOS/6
reposync -n --repoid=extras7 --repoid=updates7 --repoid=base7 --repoid=epel7 -p /mirror/Aliyun/CentOS/7
createrepo --update /mirror/Aliyun/CentOS/6/base6/
createrepo --update /mirror/Aliyun/CentOS/6/epel6/
createrepo --update /mirror/Aliyun/CentOS/6/extras6/
createrepo --update /mirror/Aliyun/CentOS/6/updates6/
createrepo --update /mirror/Aliyun/CentOS/7/base7/
createrepo --update /mirror/Aliyun/CentOS/7/epel7/
createrepo --update /mirror/Aliyun/CentOS/7/extras7/
createrepo --update /mirror/Aliyun/CentOS/7/updates7/

8、配置客户端yum文件使用

[base]
name=CentOS-$releasever - Base
baseurl=http://10.150.203.8/Aliyun/CentOS/$releasever/base$releasever
gpgcheck=1
gpgkey=http://10.150.203.8/Aliyun/CentOS/RPM-GPG-KEY-CentOS-$releasever

[updates]
name=CentOS-$releasever - Updates
baseurl=http://10.150.203.8/Aliyun/CentOS/$releasever/updates$releasever
gpgcheck=1
gpgkey=http://10.150.203.8/Aliyun/CentOS/RPM-GPG-KEY-CentOS-$releasever

[extras]
name=CentOS-$releasever - Extras
baseurl=http://10.150.203.8/Aliyun/CentOS/$releasever/extras$releasever
gpgcheck=1
gpgkey=http://10.150.203.8/Aliyun/CentOS/RPM-GPG-KEY-CentOS-$releasever

[epel]
name=CentOS-$releasever - epel
baseurl=http://10.150.203.8/Aliyun/CentOS/$releasever/epel$releasever
gpgcheck=0

以上是关于多版本YUM仓库搭建的主要内容,如果未能解决你的问题,请参考以下文章

其他综合-内网下Yum仓库搭建配置

Centos7同步阿里yum仓库 搭建yum私有仓库

###Centos7同步阿里yum仓库 搭建yum私有仓库

shell脚本的基础常识及yum仓库的自动搭建

源码编译yum仓库搭建

yum仓库搭建