自建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/

目录
相关文章
|
2月前
|
安全 关系型数据库 MySQL
CentOS 7 yum 安装 MySQL教程
在CentOS 7上安装MySQL 8,其实流程很清晰。首先通过官方Yum仓库来安装服务,然后启动并设为开机自启。最重要的环节是首次安全设置:需要先从日志里找到临时密码来登录,再修改成你自己的密码,并为远程连接创建用户和授权。最后,也别忘了在服务器防火墙上放行3306端口,这样远程才能连上。
479 16
|
6月前
|
Linux
Centos6配置阿里云yum源报错
在CentOS 6配置阿里云Yum源时,可能出现EPEL仓库访问报错(404 Not Found)。解决方法:编辑`/etc/yum.repos.d/epel.repo`文件,将`enabled`和`gpgcheck`参数设为0 ``` 此设置可解决仓库无法访问的问题。
1545 29
|
9月前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
971 25
|
10月前
|
缓存 Linux
CentOS-6的iso下载地址镜像yum源
通过上述步骤,您可以成功下载CentOS 6的ISO镜像文件,并配置适用于CentOS 6的YUM源。尽管CentOS 6已经停止更新,但使用这些镜像和YUM源配置,可以继续在需要的环境中使用和维护CentOS 6系统。
4853 20
|
10月前
|
Linux
CentOs9 yum源出现404问题
CentOs9-stream yum源出现404问题
|
11月前
|
缓存 Linux
解决CentOS 7停止更新后yum源失效问题【图文教程】
以上步骤完成后,你的 CentOS 7 系统就会使用阿里云的 yum 源,更换yum以后就可以正常使用啦。
9784 2
|
3月前
|
存储 Ubuntu Linux
VMware-安装CentOS系统教程及安装包
虚拟机相当于是一个独立于你电脑的环境,在这个环境上面,你可以安装Linux、Windows、Ubuntu等各个类型各个版本的系统,在这个系统里面你不用担心有病读等,不用担心文件误删导致系统崩溃。 虚拟机也和正常的电脑系统是一样的,也可以开关机,不用的时候,你关机就可以了,也不会占用你的系统资源,使用起来还是比较方便 这里也有已经做好的CentOS 7系统,下载下来解压后直接用VMware打开就可以使用
736 69
|
2月前
|
存储 分布式计算 Linux
安装篇--CentOS 7 虚拟机安装
VMware 装 CentOS 7 不知道从哪下手?这篇超详细图文教程手把手教你在 VMware Workstation 中完成 CentOS 7 桌面系统的完整安装流程。从 ISO 镜像下载、虚拟机配置,到安装图形界面、设置用户密码,每一步都有截图讲解,适合零基础新手快速上手。装好之后无论你是要搭 Hadoop 集群,还是练 Linux ,这个环境都够你折腾一整天!
915 2
|
3月前
|
Ubuntu Linux 索引
Centos 7、Debian及Ubuntu系统中安装和验证tree命令的指南。
通过上述步骤,我们可以在CentOS 7、Debian和Ubuntu系统中安装并验证 `tree`命令。在命令行界面中执行安装命令,然后通过版本检查确认安装成功。这保证了在多个平台上 `tree`命令的一致性和可用性,使得用户无论在哪种Linux发行版上都能使用此工具浏览目录结构。
345 78
|
4月前
|
Linux 网络安全 Apache
针对在Centos/Linux安装Apache过程中出现的常见问题集锦
以上每个问题的解决方案应深入分析错误日志、系统消息和各种配置文件,以找到根本原因并加以解决。务必保持系统和Apache软件包更新到最新版本,以修复已知的bugs和安全漏洞。安装和管理Web服务器是一项需要细致关注和不断学习的任务。随着技术的发展,推荐定期查看官方文档和社区论坛,以保持知识的更新。
228 80