自建centos5/6/7 64位yum源(官网rsync同步)

简介: 自建centos yum源,5、6、7 64位yum源,官网rsync同步
centos 5.11  (172.16.4.158)
rsync -avzP --exclude=debug --exclude=i386 rsync://archive.kernel.org/centos-vault/5.11/ /opt/data/centos-vault/5.11/
初始化repodata索引文件
createrepo -pdo /opt/data/ /opt/data/
# 每加入一个rpm包就要更新一下
createrepo --update /opt/data/

-------/etc/yum.repos.d/CentOS-Base.repo---------
[base]
name=CentOS-5.11 - Base
failovermethod=priority
baseurl=http://172.16.4.158/centos-vault/5.11/os/$basearch/
gpgcheck=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
 
#released updates
[updates]
name=CentOS-5.11 - Updates
failovermethod=priority
baseurl=http://172.16.4.158/centos-vault/5.11/updates/$basearch/
gpgcheck=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
 
#additional packages that may be useful
[extras]
name=CentOS-5.11 - Extras
failovermethod=priority
baseurl=http://172.16.4.158/centos-vault/5.11/extras/$basearch/
gpgcheck=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5.11 - Plus
failovermethod=priority
baseurl=http://172.16.4.158/centos-vault/5.11/centosplus/$basearch/
gpgcheck=0
enabled=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-5.11 - Contrib
failovermethod=priority
baseurl=http://172.16.4.158/centos-vault/5.11/contrib/$basearch/
gpgcheck=0
enabled=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5


---------/opt/cron/rsyum5.11.sh-------
#!/bin/bash
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://archive.kernel.org/centos-vault/5.11/ /opt/data/centos-vault/5.11/
/usr/bin/createrepo --update /opt/data/
chown -R nginx.nginx /opt/data

--------crontab--------

0 2 * * * /opt/cron/rsyum5.11.sh > /dev/null 2>&1 &

----------------

centos 6   (10.10.34.201)
mkdir -p /opt/data/centos/6/os/x86_64/
mkdir -p /opt/data/centos/6/extras/x86_64/
mkdir -p /opt/data/centos/6/updates/x86_64/
mkdir -p /opt/data/epel/6/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/ /opt/data/centos/6/os/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /opt/data/centos/6/extras/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /opt/data/centos/6/updates/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 --exclude=debug rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/ /opt/data/epel/6/x86_64/

初始化repodata索引文件
createrepo -pdo /opt/data/ /opt/data/
# 每加入一个rpm包就要更新一下
/usr/bin/createrepo --update /opt/data/

------/etc/yum.repos.d/CentOS-Base.repo----------
[base]
name=CentOS - base
baseurl=http://10.10.34.201/centos/6/os/$basearch/
enable=1
gpgcheck=0

 
[updates]
name=CentOS - updates
baseurl=http://10.10.34.201/centos/6/updates/$basearch/
enable=1
gpgcheck=0

 
[extras]
name=CentOS - extras
baseurl=http://10.10.34.201/centos/6/extras/$basearch/
enable=1
gpgcheck=0


[epel]
name=CentOS - epel
baseurl=http://10.10.34.201/epel/6/x86_64/
enable=1
gpgcheck=0

----------/opt/cron/rsyum6.sh------
#!/bin/bash
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/ /opt/data/centos/6/os/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /opt/data/centos/6/extras/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /opt/data/centos/6/updates/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 --exclude=debug rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/ /opt/data/epel/6/x86_64/
/usr/bin/createrepo --update /opt/data/
chown -R nobody.nobody /opt/data

---------crontab-------
0 2 * * * /opt/cron/rsyum6.sh > /dev/null 2>&1 &

----------------

centos 7   (10.10.34.101)
mkdir -p /opt/data/centos/7
rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/7/    /opt/data/centos/7/


mkdir -p /opt/data/centos/7/os/x86_64/
mkdir -p /opt/data/centos/7/extras/x86_64/
mkdir -p /opt/data/centos/7/updates/x86_64/
mkdir -p /opt/data/epel/7/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/7/os/x86_64/ /opt/data/centos/7/os/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/7/extras/x86_64/ /opt/data/centos/7/extras/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/7/updates/x86_64/ /opt/data/centos/7/updates/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 --exclude=debug rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64/ /opt/data/epel/7/x86_64/

yum -y install createrepo
yum -y install rsync

1).创建镜像文件存放目录
#创建四个目录,用于同步公网yum源
mkdir -p /opt/data/centos/6/os/x86_64/
mkdir -p /opt/data/centos/6/extras/x86_64/
mkdir -p /opt/data/centos/6/updates/x86_64/
mkdir -p /opt/data/epel/6/x86_64/
2)同步源
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/ /opt/data/centos/6/os/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /opt/data/centos/6/extras/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 rsync://rsync.mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /opt/data/centos/6/updates/x86_64/
/usr/bin/rsync -avzP --exclude=debug --exclude=i386 --exclude=debug rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/ /opt/data/epel/6/x86_64/
3)nginx
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        root /opt/data/;
        location / {
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
            #root   html;
            #index  index.html index.htm;
        }



2).确定以上yum源上游源同步镜像地址
  参考官方源:
  CentOS官方标准源:
      http://mirror.centos.org/centos/6.7/
  中科大yum源:
      rsync://mirrors.ustc.edu.cn/centos/6.7/os/x86_64/Packages/
      rsync://mirrors.ustc.edu.cn/centos/6.7/updates/
      rsync://mirrors.ustc.edu.cn/centos/6.7/extras/x86_64/Packages/
  epel源:
      http://mirrors.fedoraproject.org/publiclist/EPEL/
      rsync://mirrors.kernel.org/fedora-epel
  中科大epel源:
      rsync://mirrors.ustc.edu.cn/epel/6/x86_64/
  备注:上游yum源必须要支持rsync协议,否则不能使用rsync进行同步(国内的源很多不支持,这里选用中科大yum源)。
列出各个源下面的软件包
# rsync --list-only rsync://rsync.mirrors.ustc.edu.cn/centos/6.7/os/x86_64/Packages/
# rsync --list-only rsync://rsync.mirrors.ustc.edu.cn/centos/6.7/updates/x86_64/Packages/
# rsync --list-only rsync://rsync.mirrors.ustc.edu.cn/centos/6.7/extras/x86_64/Packages/
# rsync --list-only rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/

#下面四条命令,同时复制执行,就会开始同步官网yum源到本地。

1 /usr/bin/rsync -av rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/ /opt/data/centos/6/os/x86_64/
2 /usr/bin/rsync -av rsync://rsync.mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /opt/data/centos/6/extras/x86_64/
3 /usr/bin/rsync -av rsync://rsync.mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /opt/data/centos/6/updates/x86_64/
4 /usr/bin/rsync -av --exclude=debug rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/ /opt/data/epel/6/x86_64/

rsync -avzP --exclude=debug --exclude=i386 

#创建四个目录,用于同步公网yum源
mkdir -p /data/yum_data/centos/6/os/x86_64/
mkdir -p /data/yum_data/centos/6/extras/x86_64/
mkdir -p /data/yum_data/centos/6/updates/x86_64/
mkdir -p /data/yum_data/epel/6/x86_64/

#下面四条命令,同时复制执行,就会开始同步官网yum源到本地。

1 /usr/bin/rsync -av rsync://mirrors.ustc.edu.cn/centos/6/os/x86_64/ /data/yum_data/centos/6/os/x86_64/
2 /usr/bin/rsync -av rsync://mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /data/yum_data/centos/6/extras/x86_64/
3 /usr/bin/rsync -av rsync://mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /data/yum_data/centos/6/updates/x86_64/
4 /usr/bin/rsync -av --exclude=debug rsync://mirrors.ustc.edu.cn/epel/6/x86_64/ /data/yum_data/epel/6/x86_64/

目录
相关文章
|
3天前
|
Linux
CentOS 7 配置yum阿里源 (三步即可)
CentOS 7 配置yum阿里源 (三步即可)
|
15天前
|
Linux
centos 6.5安装yum
centos 6.5安装yum
49 0
|
15天前
|
Linux
CentOS6使用第三方YUM源(EPEL、RPMForge和RPMFusion)
CentOS6使用第三方YUM源(EPEL、RPMForge和RPMFusion)
|
17天前
|
存储 Linux 网络安全
centos7使用yum网络安装
这些是使用Yum进行网络安装的基本步骤。根据你的需求,你可以重复步骤3和4来安装其他软件包。请注意,执行Yum操作需要root或具有sudo权限的用户。
44 1
|
27天前
|
缓存 Linux
修改CentOS默认yum源为阿里镜像源
修改CentOS默认yum源为阿里镜像源
205 0
|
29天前
|
缓存 Linux
linux centos7 挂载本地iso yum源
linux centos7 挂载本地iso yum源
84 0
|
29天前
|
关系型数据库 MySQL Linux
Centos7 yum安装lAMP 环境 php版本5.6.38 mysql版本5.7.22
Centos7 yum安装lAMP 环境 php版本5.6.38 mysql版本5.7.22
27 0
|
7月前
|
Web App开发 Linux 开发工具
Centos7 yum 安装chrome
Centos7 yum 安装chrome配置yum源vim /etc/yum.repos.d/google-chrome.repo写入以下内容[google-chrome]name=google-chromebaseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearchenabled=1gpgcheck=1gpgkey=http...
176 0
|
6月前
|
Linux
解决CentOS yum安装Mysql8提示“公钥尚未安装”或“密钥已安装,但是不适用于此软件包”的问题
解决CentOS yum安装Mysql8提示“公钥尚未安装”或“密钥已安装,但是不适用于此软件包”的问题
1645 0
|
29天前
|
关系型数据库 MySQL Linux
CentOS 7.4下使用yum安装MySQL5.6
CentOS 7.4下使用yum安装MySQL5.6
75 0

热门文章

最新文章