栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

centos6&7&8搭建私有仓库

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

centos6&7&8搭建私有仓库

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

首先,制作私有仓库的目的就是为那些在内网的机器提供标准版本的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-7



2.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=BaseOS --repoid=extras >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 ./
 

到此就i完成了,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包

二、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-6



2.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的仓库,随用随插,直接搞~!

三、centos8
编写文件
[root@localhost 8_repo]# cat CentOS-AppStream.repo
[AppStream]

name=CentOS-8-AppStream

baseurl=http://mirrors.aliyun.com/centos/8-stream/AppStream/x86_64/os/

gpgcheck=1

enabled=1

gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

[root@localhost 8_repo]# cat CentOS-Base.repo
[BaseOS]

name=CentOS-8-Base

baseurl=http://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/

gpgcheck=1

enabled=1

gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

[root@localhost 8_repo]# cat CentOS-Extras.repo
[extras]

name=CentOS-8-Extras

baseurl=http://mirrors.aliyun.com/centos/8-stream/extras/x86_64/os/

gpgcheck=1

enabled=1

gpgkey=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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/842034.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号