无论6跟7都要先准备两个文件,一个CentOS-Base.repo,另一个是epel.repo。8版本是三个文件

首先,制作私有仓库的目的就是为那些在内网的机器提供标准版本的yum源,所以我们可以先找一台可以访问外网的机器,将仓库制作下来,之后导入到内网机器,并设置从指定目录yum的repo即可使用。

一、centos7

准备两个文件:

1.base文件
[root@localhost 7_repo]# cat CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#[base]
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#released updates
[updates]
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#additional packages that may be useful
[extras]
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#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-72.epel文件
[root@localhost 7_repo]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.aliyun.com/epel/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://mirrors.aliyun.com/epel/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0

yum clean all

yum makecache

之后创建一个目录,或者直接拿家目录搞,比如/root

cd /yum

执行以下四个命令:

[root@xxx ~]# reposync -r base  #reposync将根据刚下载的repo下载rpm包到指定文件夹
[root@xxx ~]# reposync -r extras
[root@xxx ~]# reposync -r updates
[root@xxx ~]# reposync -r epel
包很多,要等待很久下载完成,可以放在后台上跑。命令如下:

nohup reposync  --repoid=base --repoid=extras --repoid=updates --repoid=epel >output 2>&1 &

[root@xxx ~]# cd /root/base
[root@xxx ~]# createrepo ./
[root@xxx ~]# cd /root/extras
[root@xxx ~]# createrepo ./
[root@xxx ~]# cd /root/updates
[root@xxx ~]# createrepo ./
[root@xxx ~]# cd /root/epel
[root@xxx ~]# createrepo ./

到此就完成了,7版本现在大概50G,可以将整个root目录拷贝到移动硬盘上,再导入到内网机器

并设置base.repo,如下:

[root@localhost 7_repo]# cat base.repo
[base]
name=CentOS-Base
baseurl=file:///root/base
path=/
enabled=1
gpgcheck=0[updates]
name=CentOS-Updates
baseurl=file:///root/updates
path=/
enabled=1
gpgcheck=0[extras]
name=CentOS-Extras
baseurl=file:///root/extras
path=/
enabled=1
gpgcheck=0[epel]
name=CentOS-Epel
baseurl=file:///root/epel
path=/
enabled=1
gpgcheck=0

之后机器即可本地使用Yum安装rpm包,或者将所有包的目录打包放到移动硬盘里,哪个机器需要就上传上去,写一个指定路径安装的repo文件即可使用。

二、centos6

还是准备两个文件,6版本现在跟7的网址已经不同,已经不维护了,所以准备的文件需要修改。如下:

1.centos-base.repo
[root@localhost yum.repos.d]# cat CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=https://vault.centos.org/6.10/os/x86_64/
gpgcheck=1
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-6#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=https://vault.centos.org/6.10/updates/x86_64/
gpgcheck=1
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-6#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://vault.centos.org/6.10/extras/x86_64/
gpgcheck=1
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://vault.centos.org/6.10/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=https://vault.centos.org/6.10/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-62.epel.repo(找了很久,记住这个地址)
[root@localhost yum.repos.d]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://archives.fedoraproject.org/pub/archive/epel/6/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
baseurl=http://archives.fedoraproject.org/pub/archive/epel/6/$basearch/debug
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=0[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
baseurl=http://archives.fedoraproject.org/pub/archive/epel/6/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=0

OK,准备完毕。

yum clean all

yum makecache

之后执行reposync等等操作,参考上面centos7的操作即可。制作完毕后,还是放到移动硬盘里,作为内网机器安装centos6版本rpm的仓库,随用随插,直接搞~!

注意:centos6系统机器如果使用其他机器用nginx展示的yum仓库时:

本机上的repo文件如下编写:

[root@centos6-test yum.repos.d]# cat local_yum.repo[base]
name=local base
baseurl=http://10.219.40.143/base/
gpgcheck=0
enabled=1[updates]
name=local updates
baseurl=http://10.219.40.143/updates/
gpgcheck=0
enabled=1[extras]
name=local extras
baseurl=http://10.219.40.143/extras/
gpgcheck=0
enabled=1[epel]
name=local epel
baseurl=http://10.219.40.143/epel/
gpgcheck=0
enabled=1

6版本有个报错需要注意,那就是设置好repo文件,执行yum时,会报repomd.xml找不到的问题,

解决方法:依照报错提示的路径,将repodata目录新建到Packages下面,将所有原repodata目录下文件全部拷贝到新路径下。

三、centos8
编写文件

[root@localhost 8_repo]# cat CentOS-AppStream.repo
[AppStream]name=CentOS-8-AppStreambaseurl=http://mirrors.aliyun.com/centos/8-stream/AppStream/x86_64/os/gpgcheck=1enabled=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official[root@localhost 8_repo]# cat CentOS-Base.repo
[BaseOS]name=CentOS-8-Basebaseurl=http://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/gpgcheck=1enabled=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official[root@localhost 8_repo]# cat CentOS-Extras.repo
[extras]name=CentOS-8-Extrasbaseurl=http://mirrors.aliyun.com/centos/8-stream/extras/x86_64/os/gpgcheck=1enabled=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

yum clean all

yum makecache

reposync --repoid=AppStream --repoid=BaseOS --repoid=extras

createrepo -p AppStream/

createrepo -p BaseOS

createrepo -p extras

番外:

cento8下载ceph源和epel源(所有包)

wget -e robots=off  -r -p -np -k  -c --no-check-certificate  -P `pwd` https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-15.2.17/el8/

wget -e robots=off  -r -p -np -k  -c --no-check-certificate  -P `pwd` https://mirrors.tuna.tsinghua.edu.cn/epel/8/

阿里云有检测,大批量下载会block卡住

centos678搭建私有仓库相关推荐

  1. docker搭建私有仓库

    紧接上一篇镜像发布到官方之后,我们来搭建我们自己的私有仓库,比较,如果真的要在生产环境使用的话,这是必须的. 首先,我们来准备一下搭建私有仓库所需要的信息. #先吧私有仓库down下来,这需要一点时间 ...

  2. Docker入门之四搭建私有仓库

    前面学习了下镜像和容器,今天来学习下仓库,来搭建本地私有仓库.当然可以使用远程的共有的仓库,但在企业中有的还是放在本地,所以需要搭建私有仓库. 一.搭建仓库 可以在容器中run一个仓库镜像. dock ...

  3. 【Docker】Registry搭建私有仓库、证书认证、用户登录认证

    一.Docker Registry工作原理 02_Docker Registry角色 Docker Registry有三个角色,分别是index.registry和registry client. i ...

  4. Docker 容器仓库之搭建私有仓库、hub仓库

    一.什么是仓库 Docker 仓库是用来包含镜像的位置,Docker提供一个注册服务器(Register)来保存多个仓库,每个仓库又可以包含多个具备不同tag的镜像. Docker运行中使用的默认仓库 ...

  5. 玩转NPM,搭建私有仓库-姜威-专题视频课程

    玩转NPM,搭建私有仓库-152人已学习 课程介绍         NPM是前端工程师必用的工具之一,本课程从 install 项目管理开始,逐步介绍NPM的相关命令,如何上传第一个自己的npm包,如 ...

  6. Harbor搭建私有仓库

    Harbor搭建私有仓库 Harbor简介     Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,可以用来构建企业内部的Docker镜像仓库.详细介绍可参考 [干货] ...

  7. Windows系统用Docker搭建私有仓库

    Windows系统用Docker搭建私有仓库 一.安装Docker Desktop 二.创建私有仓库 三.验证私有仓库是否创建成功 一.安装Docker Desktop 1.1.可以在软件管家安装这个 ...

  8. Git 搭建私有仓库

    简介: 如果你不想把自己的代码公开让别人阅读.使用,也不想花钱购买 GitHub 私有仓库,那么你就需要自己动手做一个了. 当然你也可以使用 Coding.net ,上面可以创建免费的私有仓库.( 今 ...

  9. docker搭建私有仓库笔记

    为什么80%的码农都做不了架构师?>>>    安装之前需要docker环境,安装docker环境参考:http://www.runoob.com/docker/centos-doc ...

最新文章

  1. 【体验】感谢朋友雪中送炭寄来的便携示波器,便携示波器开箱体验
  2. python实操题_Python100道练习题,光看不练假把式,Python实操资源
  3. java指导手册,Java 注解指导手册 – 终极向导
  4. java 修饰符 访问控制符_Java访问修饰符(访问控制符)
  5. Codeforces Round #561 (Div. 2)ABC
  6. ElastciSearch简单总结(笔记)
  7. 【机器视觉学习笔记】Hough变换直线检测(C++)
  8. 3、Django下载与简介
  9. Lucene应用开发揭秘 上线啦!((更新程度:完毕))
  10. 【leetcode】Minimum Path Sum
  11. 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---31
  12. js bom dom
  13. 从openjdk.java.net获取OpenJDK8源码并编译(amd64/aarch64/arm64)
  14. 计算机桌面空白图标如何删除,桌面上有两个i空白文件的图标删不掉怎么办急急急...
  15. Unity 中的基础光照
  16. @Around环绕增强
  17. LINUX kernel内核各版本下载
  18. 计算机高配置表格,数据大的excel表格对显卡有要求-求excel大量数据处理的电脑配置...
  19. 给自己立一个flag吧
  20. easyUI 分页中引入了lang-zh_CN.js却仍然显示英文,不显示中文

热门文章

  1. WordPress多站点发布文章同步,API实现一篇文章发布多个平台(同栏目)
  2. 运维服务体系总结(思维导图)
  3. HTTP流量神器Goreplay核心源码详解
  4. 小米解锁BL锁(普通解锁)
  5. Maple与Mathematica的对比分析
  6. 学术不端网查重靠谱吗_学术不端网安全吗?查重过程是怎样的?
  7. JCE无限制权限策略文件
  8. 工厂车间看板的使用规则,类别和作用
  9. 什么是泛型以及泛型的作用?
  10. android 下载进度条代码实现,Android文件下载进度条的实现代码