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/