很多时候为了加速自己内部的rpm包安装速度,都会搭建自己的yum源仓库,而使用系统光盘自带的源,由于软件版本比较落后,所以不太适用,而大家都在用的阿里仓库比较好用,所以就想到了把阿里仓库的rpm全部拉到本地,并做yum仓库的定时更新。这样既能保证软件包是最新的,也能保证软件的安装速度。那么下面来具体实施,搭建自己的yum本地仓库,并定时从阿里仓库同步过来。

第一步:下载阿里镜像的repo安装包,centos6就下载6的,7的就下载7的地址:https://mirrors.aliyun.com/repo/

我们以centos7的镜像为例

  1. cd /etc/yum.repos.d/
  2. mkdir bak
  3. mv Centos* bak #将系统自带的源备份到bak目录下
  4. wget https://mirrors.aliyun.com/repo/Centos-7.repo
  5. cat Centos-7.repo
  6. # CentOS-Base.repo
  7. #
  8. # The mirror system uses the connecting IP address of the client and the
  9. # update status of each mirror to pick mirrors that are updated to and
  10. # geographically close to the client. You should use this for CentOS updates
  11. # unless you are manually picking other mirrors.
  12. #
  13. # If the mirrorlist= does not work for you, as a fall back you can try the
  14. # remarked out baseurl= line instead.
  15. #
  16. #
  17. [base]
  18. name=CentOS-$releasever - Base - mirrors.aliyun.com
  19. failovermethod=priority
  20. baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
  21. http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
  22. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  23. gpgcheck=1
  24. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  25. #released updates
  26. [updates]
  27. name=CentOS-$releasever - Updates - mirrors.aliyun.com
  28. failovermethod=priority
  29. baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
  30. http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
  31. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  32. gpgcheck=1
  33. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  34. #additional packages that may be useful
  35. [extras]
  36. name=CentOS-$releasever - Extras - mirrors.aliyun.com
  37. failovermethod=priority
  38. baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
  39. http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
  40. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  41. gpgcheck=1
  42. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  43. #additional packages that extend functionality of existing packages
  44. [centosplus]
  45. name=CentOS-$releasever - Plus - mirrors.aliyun.com
  46. failovermethod=priority
  47. baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
  48. http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
  49. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  50. gpgcheck=1
  51. enabled=0
  52. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  53. #contrib - packages by Centos Users
  54. [contrib]
  55. name=CentOS-$releasever - Contrib - mirrors.aliyun.com
  56. failovermethod=priority
  57. baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
  58. http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
  59. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
  60. gpgcheck=1
  61. enabled=0
  62. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

已经配置好的阿里仓库

  1. yum repolist #查看阿里的可用仓库,有启用的表示已经成功了
  2. 从阿里服务器将rpm同步到本地需要两个rpm软件createrepo 和 yum-utils
  3. yum install createrepo yum-utils -y #yum安装这两个包
  4. mkdir -p /mirrors/Packege #创建rpm包的存放目录
  5. reposync -r base -p /mirrors/Packege #将已经配置好的阿里仓库镜像内的rpm包拉到本地,b ase为本地已经配置好的仓库名,可以用yum repolist查看到
  6. createrepo -pdo /mirrors/ /mirrors/Packege #创建repo数据库
 
###############################同步rpm包,需要相当长一段时间################################
 
同步完成之后,本地的yum仓库已经基本完成了,只剩下定时更新了
 
  1. vim /cron/repository.sh #编写同步脚本
  2. reposync -r base -p /mirrors/Packege -d #来删除本地老旧
  3. reposync -r base -p /mirrors/Packege
  4. crontab -e #添加定时任务
  5. 0 0 1 * * sh /cron/repository.sh #每月1日0时更新yum仓库

创建yum本地仓库,将阿里仓库同步到本地,并定时更新的更多相关文章

  1. maven多仓库配置 公司仓库和阿里仓库

    针对公司内网私服仓库,私服仓库不能访问外网,此时无法在私服仓库代理阿里的maven仓库.我们的maven就需要配置多个仓库: maven目录下的conf/settings.xml配置文件: 一.在pr ...

  2. CentOS7搭建本地YUM仓库,并定期同步阿里云源

    CentOS7同步阿里云镜像rpm包并自建本地yum仓库 系统环境 # cat /etc/centos-release CentOS Linux release 7.6.1810 (Core) # u ...

  3. 同步阿里云镜像到本地,在本地搭建YUM仓库

    1.下载阿里云镜像repo文件 项目使用CentOS6系统,因此我下载的文件是: # CentOS-Base.repo # # The mirror system uses the connectin ...

  4. CentOS 7 搭建本地YUM仓库,并定期同步阿里云源

    目录导航: 1. 系统环境 2. 修改yum 源为阿里云源 3. 安装yum相关的软件 4. 根据源标识同步源到本地目录 5. 安装nginx开启目录权限保证本地机器可以直接本地yum源 6. 客户端 ...

  5. CentOS7搭建yum源仓库(阿里源)

    文章目录 注意:环境要求 1.配置服务器端yum 1.1.安装yum源工具 1.2.配置nginx 1.2.1.配置nginx页面目录 1.3.替换yum源文件 1.4.建立yum源仓库 2.配置客户 ...

  6. Git本地仓库与远程github同步的时候提示fatal: remote origin already exists 错误解决办法

    Git本地仓库与远程github同步的时候提示fatal: remote origin already exists 错误解决办法 1.git在本地的电脑创建了仓库,要远程同步github的仓库.使用 ...

  7. Maven settings.xml配置(指定本地仓库、阿里云镜像设置)

    转: 详解Maven settings.xml配置(指定本地仓库.阿里云镜像设置) 更新时间:2018年12月18日 11:14:45   作者:AmaniZ   我要评论   一.settings. ...

  8. Maven本地仓库/中央仓库(阿里镜像)/JDK配置

    第一步打开你已经下载好的Maven,进入:根磁盘:\......\apache-maven-3.6.2\conf文件夹找到settings.xml文件(没有的可以自行创建一个同名的文件即可) 使用文本 ...

  9. github 创建网络仓库 ,使用git工具将本地文件上传/删除 --- 心得

    1.前言 使用  git做项目控制版本工具,当然,使用SVN也可以,但是,git让人感觉更先进一些,与GitHub结合,用起来很方便,服务端由官网控制. 而SVN分客户端和服务端,都是个人控制,因此, ...

随机推荐

  1. NDK学习笔记-JNI的异常处理与缓存策略

    在使用JNI的时候,可能会产生异常,此时就需要对异常进行处理 异常处理 JNI抛出Throwable异常,在Java层可以用Throwable捕捉 而在C只有清空异常这种处理 但如果在JNI中通过Th ...

  2. Django模板渲染之自定义inclusion_tag详细使用

    inclusion_tag在使用的时候可以帮我们减少很多前端和后端重复的代码 逻辑图: inclusion_tag的作用是主页面以一定的语法给一个参数,调用某个函数,这个函数可以通过主页面给的参数做一 ...

  3. 六扇门团队作业 ——《DorMi宿舍管理系统需求分析》

    团队作业 --<需求分析> 一.格式描述 这个作业属于哪个课程 <课程的链接> 这个作业要求在哪里 <作业要求的链接> 团队名称 六扇门 这个作业的目标 通过对用户 ...

  4. 初识 docker

    一.安装Docker 我使用的是腾讯云上的centos 7. docker -v 查看是否已经安装有docker 如果有 systemctl stop docker 停止docker服务 查看当前版本 ...

  5. 常用的API

    API (application programming Interface)应用程序编程接口 java 是字典 Scanner类的功能可以实现从键盘输入到程序当中. 引用类型的一般使用步骤 ·1导包 ...

  6. 怎么才能记住java线程的start()和run()谁是启动方法

    start()和run()开始的时候总是记不住那个是线程的启动方法,现在是记得很真切了! 如果用run()启动线程就跟不用线程效果是一样的,因为是run是顺序执行的.start()才是线程的启动方法. ...

  7. 恩佐夫博弈+JAVA大数

    题意:http://acm.hdu.edu.cn/showproblem.php?pid=5973 根号5复制后200位就行了,因为BigDecimal不支持开根号,除法二分开根. import ja ...

  8. fiddler笔记:主菜单栏

    主菜单可以启动几乎所有的fiddler功能.菜单系统通过FiddlerScript或Extensions进行扩展和增强. 1.File菜单 File菜单主要是用来启动和停止web流量的捕获,也可以加载 ...

  9. 牛客 216D 消消乐 (二分图最小点覆盖)

    大意: 给定棋盘, 每次消除一行或一列, 求最小次数使得消除完所有'*'. 裸的二分图最小点覆盖. 二分图的最小点覆盖等于最大匹配, 输出方案时从所有左部未盖点开始标记交替路上的点, 最后左部所有未标 ...

  10. 复习最短路 spfa+dijstra堆优化

    题目很简单,, 但是wa了三次,, 用<vector>之前一定要记得clear()...简单说下 spfa的问题 和bell_forman有点类似 每次取出一个点 然后更新 并把更新了的节 ...