二丫讲梵 二丫讲梵
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)

二丫讲梵

行者常至,为者常成
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)
  • Nexus系列文章

    • 前言
    • nexus的安装
    • 使用nexus3配置docker私有仓库
    • 使用nexus3配置maven私有仓库
    • 使用nexus3配置npm私有仓库
    • 使用nexus3配置yum私有仓库
      • 1,创建 blob 存储。
      • 2,创建 hosted 类型的 yum 库。
      • 3,创建一个 proxy 类型的 yum 仓库。
      • 4,创建一个 group 类型的 yum 仓库。
      • 5,构建缓存。
        • 1,将原有的移走。
        • 2,创建一个新的源。
        • 3,构建缓存。
      • 6,验证一下效果。
        • 1,将原有的移走。
        • 2,创建一个新的源。
    • 使用nexus3配置Python私有仓库
    • 使用nexus3配置golang私有仓库
    • maven私服nexus2-14-5迁移到nexus3-7-1
    • maven上传jar包以及SNAPSHOT的一个坑
    • Gradel上传本地包的一些坑及注意点
    • go1-12与1-14之私服使用的差异与变化
    • 通过命令行往python私仓传包
    • 关于yum仓库往nexus私服传包等实践
    • 将maven本地包上传到nexus私服的实践
    • 将npm本地包上传到nexus私服的实践
    • nexus2.x升级到3.x之后仓库地址改变的问题探索
    • 关于gradle中plugins依赖未走私服导致编译失败的原因探析
  • Jenkins系列文章

  • ELK笔记

  • Kubernetes笔记

  • LLM专题

  • 系列专题
  • Nexus系列文章
二丫讲梵
2018-11-08
目录

使用nexus3配置yum私有仓库

文章发布较早,内容可能过时,阅读注意甄别。

yum 相较于 rpm,能够更好地解决安装软件时的依赖包问题,使用 yum 安装更简单更方便。搭建本地 YUM 源服务器,可以避免升级安装软件时占用公网带宽;有了本地 YUM 源服务器,可以解决无法连接 Internet 的其他 YUM 客户端的软件升级和安装。

提示

搭建 yum 私服,我们依旧使用 nexus3,这个强大的让人忍不住想保住它亲一亲的优秀开源工具,再增添多少的赞美也不为过。

与其他私服一样的,yum 私服同样有三种类型:

  • hosted : 本地存储,即同 yum 官方仓库一样提供本地私服功能
  • proxy : 提供代理其他仓库的类型,如我们常用的 163 仓库
  • group : 组类型,实质作用是组合多个仓库为一个地址,相当于一个透明代理。

那么就来一个一个创建。

# 1,创建 blob 存储。

为其创建一个单独的存储空间,命名为yum-hub。

image

# 2,创建 hosted 类型的 yum 库。

后来才发现,其实每次创建的这个 hosted 类型的,并没有什么用。不过照例创建一波吧。

  • Name::定义一个名称 local-yum
  • Storage:Blob store,我们下拉选择前面创建好的专用 blob:yum-hub。
  • Hosted:开发环境,我们运行重复发布,因此 Delpoyment policy 我们选择 Allow redeploy。这个很重要!

整体配置截图如下:

image

# 3,创建一个 proxy 类型的 yum 仓库。

  • Name: proxy-163-yum
  • Proxy:Remote Storage: 远程仓库地址,这里填写: http://mirrors.163.com/centos/
  • Storage: yum-hub

其他的均是默认。

这里就先创建一个代理 163 的仓库,其实还可以多创建几个,诸如阿里云的,搜狐的,等等,这个根据个人需求来定义。

整体配置截图如下:

image

# 4,创建一个 group 类型的 yum 仓库。

  • Name:group-yum
  • Storage:选择专用的 blob 存储 yum-hub。
  • group : 将左边可选的 2 个仓库,添加到右边的 members 下。

整体配置截图如下:

image

这些配置完成之后,就可以使用了。

申明

原创文章eryajf,未经授权,严禁转载,侵权必究!此乃文中随机水印,敬请读者谅解。

Copyright 二丫讲梵 (opens new window) 版权所有

# 5,构建缓存。

新建一台环境干净的主机,此时需要保证这台主机能够上网,因为私服当中还没有进行初始化。

先简单配置一下,将 yum 源指向到私服中来。

# 1,将原有的移走。

[root@7-3 ~]$cd /etc/yum.repos.d/
[root@7-3 yum.repos.d]$ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@7-3 yum.repos.d]$mkdir bak
[root@7-3 yum.repos.d]$mv * bak
mv: cannot move ‘bak’ to a subdirectory of itself, ‘bak/bak’
[root@7-3 yum.repos.d]$ls
bak
1
2
3
4
5
6
7
8

# 2,创建一个新的源。

[root@7-3 yum.repos.d]$vim nexus.repo
1

添加如下内容:

其中的 url 就是私服当中创建的 group 的对外地址,后面的$releasever/os/$basearch/不要漏掉了。

[nexus]
name=Nexus Repository
baseurl=http://192.168.106.65:8081/repository/group-yum/$releasever/os/$basearch/
enabled=1
gpgcheck=0
1
2
3
4
5

注意这还不是完整内容,我第一次构建的时候只写了这些内容,以求私服自己能够通过刚刚配置的 proxy 将远程的包拉下来,最后发现这种方式,死活都是无法成功的。

注意

如下内容的实现方式有些不够优雅,想要更好的实践,可参考文章关于 yum 仓库往私服传包等实践 (opens new window)

因此,这里还应该将 163 的源配置添加进来。

完整内容应该如下:

[root@7-3 yum.repos.d]$cat nexus.repo
[nexus]
name=Nexus Repository
baseurl=http://192.168.106.65:8081/repository/group-yum/$releasever/os/$basearch/
enabled=1
gpgcheck=0

#released updates
[updates]
name=CentOS-$releasever-Updates-163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever-Extras-163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever-Plus-163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

# 3,构建缓存。

现在,就可以通过 makecache 将远程的包拉到内部私服当中了。

操作之前,就像古代变戏法一般的,依旧先去私服看一眼group-yum当中是否有包存在,这是一个固定流程哈。

image

可以看到空空如也,那么通过如下三步操作创建缓存。

[root@7-3 yum.repos.d]$yum clean all
Loaded plugins: fastestmirror
Cleaning repos: extras nexus updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@7-3 yum.repos.d]$yum makecache
Loaded plugins: fastestmirror
extras                                                                                                                                                             | 3.4 kB  00:00:00
nexus                                                                                                                                                              | 1.8 kB  00:00:00
updates                                                                                                                                                            | 3.4 kB  00:00:00
(1/12): extras/7/x86_64/prestodelta                                                                                                                                | 100 kB  00:00:00
(2/12): extras/7/x86_64/primary_db                                                                                                                                 | 204 kB  00:00:00
(3/12): extras/7/x86_64/other_db                                                                                                                                   | 126 kB  00:00:00
(4/12): extras/7/x86_64/filelists_db                                                                                                                               | 604 kB  00:00:00
(5/12): nexus/7/x86_64/group_gz                                                                                                                                    | 167 kB  00:00:00
(6/12): nexus/7/x86_64/primary                                                                                                                                     | 2.9 MB  00:00:00
(7/12): nexus/7/x86_64/other                                                                                                                                       | 1.6 MB  00:00:00
(8/12): nexus/7/x86_64/filelists                                                                                                                                   | 7.1 MB  00:00:00
(9/12): updates/7/x86_64/prestodelta                                                                                                                               | 679 kB  00:00:00
(10/12): updates/7/x86_64/filelists_db                                                                                                                             | 3.4 MB  00:00:00
(11/12): updates/7/x86_64/other_db                                                                                                                                 | 578 kB  00:00:00
(12/12): updates/7/x86_64/primary_db                                                                                                                               | 6.0 MB  00:00:01
Determining fastest mirrors
nexus                                                                                                                                                                           9911/9911
nexus                                                                                                                                                                           9911/9911
nexus                                                                                                                                                                           9911/9911
Metadata Cache Created

[root@7-3 yum.repos.d]$yum update -y #这个过程比较长,内容比较多,不完全复制了。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

当上边的第三步执行完成之后,此时我们可以回到刚刚那个空白的页面,看看内容是否上来了。

image

就是这么神奇。

# 6,验证一下效果。

验证的方式其实也很简单,找一台不能上网但是可以与刚刚私服通信的主机,将其 yum 源指向的配置好的私服,看看安装软件什么的是否可以 so easy。

或者是将其他的源都切断,然后 yum 源仅仅指向私服,看看安装是否顺利。

这里采用第二种方式简单试验一下。

# 1,将原有的移走。

[root@7-2 ~]$cd /etc/yum.repos.d/
[root@7-2 yum.repos.d]$ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@7-2 yum.repos.d]$mkdir bak
[root@7-2 yum.repos.d]$mv * bak
mv: cannot move ‘bak’ to a subdirectory of itself, ‘bak/bak’
[root@7-2 yum.repos.d]$ls
bak
1
2
3
4
5
6
7
8

此时尝试一下安装。

[root@7-2 yum.repos.d]$yum -y install httpd

Loaded plugins: fastestmirror

Determining fastest mirrors
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 To enable Red Hat Subscription Management repositories:
     subscription-manager repos --enable <repo>
 To enable custom repositories:
     yum-config-manager --enable <repo>
1
2
3
4
5
6
7
8
9
10
11

# 2,创建一个新的源。

[root@7-2 yum.repos.d]$cat nexus.repo
[nexus]
name=Nexus Repository
baseurl=http://192.168.106.65:8081/repository/group-yum/$releasever/os/$basearch/
enabled=1
gpgcheck=0
1
2
3
4
5
6

再尝试安装:

[root@7-2 yum.repos.d]$yum -y install httpd
Loaded plugins: fastestmirror
nexus                                                                                                                                                              | 1.8 kB  00:00:00
(1/2): nexus/7/x86_64/group_gz                                                                                                                                     | 167 kB  00:00:00
(2/2): nexus/7/x86_64/primary                                                                                                                                      | 2.9 MB  00:00:00
Loading mirror speeds from cached hostfile
nexus                                                                                                                                                                           9911/9911
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-80.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-80.el7.centos for package: httpd-2.4.6-80.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-80.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-80.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-80.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-80.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================================
 Package                                      Arch                                    Version                                                Repository                              Size
==========================================================================================================================================================================================
Installing:
 httpd                                        x86_64                                  2.4.6-80.el7.centos                                    nexus                                  2.7 M
Installing for dependencies:
 apr                                          x86_64                                  1.4.8-3.el7_4.1                                        nexus                                  103 k
 apr-util                                     x86_64                                  1.5.2-6.el7                                            nexus                                   92 k
 httpd-tools                                  x86_64                                  2.4.6-80.el7.centos                                    nexus                                   89 k
 mailcap                                      noarch                                  2.1.41-2.el7                                           nexus                                   31 k

Transaction Summary
==========================================================================================================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Downloading packages:
(1/5): apr-1.4.8-3.el7_4.1.x86_64.rpm                                                                                                                              | 103 kB  00:00:00
(2/5): apr-util-1.5.2-6.el7.x86_64.rpm                                                                                                                             |  92 kB  00:00:00
(3/5): httpd-tools-2.4.6-80.el7.centos.x86_64.rpm                                                                                                                  |  89 kB  00:00:00
(4/5): mailcap-2.1.41-2.el7.noarch.rpm                                                                                                                             |  31 kB  00:00:00
(5/5): httpd-2.4.6-80.el7.centos.x86_64.rpm                                                                                                                        | 2.7 MB  00:00:03
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                     880 kB/s | 3.0 MB  00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7_4.1.x86_64                                                                                                                                             1/5
  Installing : apr-util-1.5.2-6.el7.x86_64                                                                                                                                            2/5
  Installing : httpd-tools-2.4.6-80.el7.centos.x86_64                                                                                                                                 3/5
  Installing : mailcap-2.1.41-2.el7.noarch                                                                                                                                            4/5
  Installing : httpd-2.4.6-80.el7.centos.x86_64                                                                                                                                       5/5
  Verifying  : httpd-tools-2.4.6-80.el7.centos.x86_64                                                                                                                                 1/5
  Verifying  : apr-1.4.8-3.el7_4.1.x86_64                                                                                                                                             2/5
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                                                                                            3/5
  Verifying  : httpd-2.4.6-80.el7.centos.x86_64                                                                                                                                       4/5
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                                                                                            5/5

Installed:
  httpd.x86_64 0:2.4.6-80.el7.centos

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1              apr-util.x86_64 0:1.5.2-6.el7              httpd-tools.x86_64 0:2.4.6-80.el7.centos              mailcap.noarch 0:2.1.41-2.el7

Complete!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

就是这个 feel,爽爽爽。

到此地,关于 nexus3 所支持的私服类型,基本上生产中常用的,都一一介绍过了,到目前为止,我也没有在网上看到过任何一个写,针对 nexus 写一个系列的教程并分享出来的,啥也不说了,乡亲们呐,我心情激动,我骄傲!!!

微信 支付宝
#nexus#yum
上次更新: 2024/07/04, 22:40:37
使用nexus3配置npm私有仓库
使用nexus3配置Python私有仓库

← 使用nexus3配置npm私有仓库 使用nexus3配置Python私有仓库→

最近更新
01
记录二五年五一之短暂回归家庭
05-09
02
学习周刊-总第210期-2025年第19周
05-09
03
学习周刊-总第209期-2025年第18周
05-03
更多文章>
Theme by Vdoing | Copyright © 2017-2025 | 点击查看十年之约 | 浙ICP备18057030号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式