搭建Nexus仓库
搭建Nexus仓库

搭建Nexus仓库

官方下载页面:https://help.sonatype.com/repomanager3/download/download-archives---repository-<br>manager-3
官方安装文档链接:https://help.sonatype.com/repomanager3/installation
安装要求:https://help.sonatype.com/repomanager3/installation/system-requirements(#官方要求内存8G以上,太小比如4G以下会导致无法启动)
#脚本二进制安装
[root@ubuntu2004 ~]#ls
install_jdk_tomcat_nexus.sh  jdk-8u341-linux-x64.tar.gz  nexus-3.41.1-01-unix.tar.gz

[root@ubuntu2004 ~]#bash install_jdk_tomcat_nexus.sh 
1) 离线安装Oracle-JDK
2) 离线安装Tomcat
3) 退出
请按要求输入操作选项:1
离线安装Oracle-JDK
请输入JDK文件名称(例如:jdk-8u333-linux-x64.tar.gz):jdk-8u341-linux-x64.tar.gz
...
JDK 安装完成                                               [  OK  ]
[root@ubuntu2004 ~]#bash install_nexus.sh
1) 在线线安装Nexus
2) 离线安装Nexus
3) 退出
请按要求输入操作选项:2
离线安装Nexus
请输入文件名称(例如:nexus-3.41.1-01-unix.tar):nexus-3.41.1-01-unix.tar.gz
nexus 安装成功                                             [  OK  ]
-------------------------------------------------------------------
访问链接: http://10.0.0.207:8081/
用户和密码: admin/bcf69074-875d-4897-bf0b-57d249728825
[root@ubuntu2004 ~]#ss -tnlp
State                  Recv-Q                 Send-Q                                 Local Address:Port                                  Peer Address:Port                 Process                                                    
LISTEN                 0                      1                                          127.0.0.1:36217                                      0.0.0.0:*                     users:(("java",pid=3727,fd=116))                          
LISTEN                 0                      50                                           0.0.0.0:8081                                       0.0.0.0:*                     users:(("java",pid=3727,fd=786))                          
LISTEN                 0                      4096                                   127.0.0.53%lo:53                                         0.0.0.0:*                     users:(("systemd-resolve",pid=754,fd=13))                 
LISTEN                 0                      128                                          0.0.0.0:22                                         0.0.0.0:*                     users:(("sshd",pid=814,fd=3))                             
LISTEN                 0                      128                                             [::]:22                                            [::]:*                     users:(("sshd",pid=814,fd=4))                             

Hosted:本地仓库,通常我们会部署自己的构件到这一类型的仓库,比如公司的第三方库
Proxy:代理仓库,它们被用来代理远程的公共仓库,如maven 中央仓库(官方仓库)
Group:仓库组,用来合并多个 hosted/proxy 仓库,当你的项目希望在多个repository 使用资源时就不需要多次引用了,只需要引用一个 group 即可

优化默认maven仓库

阿里云参考地址修改: https://developer.aliyun.com/mvn/guide

配置邮件

使用 Nexus 构建私有Yum仓库

阿里云镜像地址: https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/8/x86_64/
[root@ubuntu2004 ~]#mkdir -p /data/blobs/
#测试验证
[root@localhost ~]#vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=zabbix
baseurl=http://10.0.0.207:8081/repository/zabbix-5.9-yum-centos8/
enabled=1
gpgcheck=0

[root@localhost yum.repos.d]#yum -y install zabbix-agent2
zabbix                                                                                                                                                       346 kB/s | 1.5 kB     00:00    
Dependencies resolved.
=============================================================================================================================================================================================
 Package                                          Architecture                              Version                                          Repository                                 Size
=============================================================================================================================================================================================
Installing:
 zabbix-agent2                                    x86_64                                    5.0.28-1.el8                                     zabbix                                    5.3 M

Transaction Summary
=============================================================================================================================================================================================
Install  1 Package

Total size: 5.3 M
Installed size: 19 M
Downloading Packages:
[SKIPPED] zabbix-agent2-5.0.28-1.el8.x86_64.rpm: Already downloaded                                                                                                                         
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                     1/1 
  Running scriptlet: zabbix-agent2-5.0.28-1.el8.x86_64                                                                                                                                   1/1 
  Installing       : zabbix-agent2-5.0.28-1.el8.x86_64                                                                                                                                   1/1 
  Running scriptlet: zabbix-agent2-5.0.28-1.el8.x86_64                                                                                                                                   1/1 
  Verifying        : zabbix-agent2-5.0.28-1.el8.x86_64                                                                                                                                   1/1 

Installed:
  zabbix-agent2-5.0.28-1.el8.x86_64                                                                                                                                                          

Complete!

使用 Nexus 构建私有 Apt 仓库

ubuntu仓库
https://mirrors.aliyun.com/ubuntu/
[root@ubuntu2004 ~]#cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
[root@ubuntu2004 ~]#cat /etc/apt/sources.list
deb http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal main restricted universe multiverse
deb-src http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal main restricted universe multiverse

deb http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal-security main restricted universe multiverse
deb-src http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal-security main restricted universe multiverse

deb http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal-updates main restricted universe multiverse
deb-src http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal-updates main restricted universe multiverse

deb http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal-proposed main restricted universe multiverse
deb-src http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal-proposed main restricted universe multiverse

deb http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal-backports main restricted universe multiverse
deb-src http://10.0.0.207:8081/repository/ubuntu2004dddddd/ focal-backports main restricted universe multiverse

[root@ubuntu2004 ~]#apt update 
命中:1 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-proposed InRelease
命中:2 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-backports InRelease
获取:3 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal InRelease [265 kB]
获取:4 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security InRelease [114 kB]
获取:5 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates InRelease [114 kB]
获取:6 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/universe Sources [9,707 kB]
获取:7 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/restricted Sources [6,472 B]
获取:8 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/main Sources [847 kB]
获取:9 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/multiverse Sources [174 kB]
获取:10 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/main amd64 Packages [970 kB]
获取:11 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/main Translation-en [506 kB]
获取:12 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/main Translation-zh_CN [113 kB]
获取:13 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal amd64 Contents (deb) [40.9 MB]
获取:14 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/main amd64 c-n-f Metadata [29.5 kB]
获取:15 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/restricted amd64 Packages [22.0 kB]
获取:16 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/restricted Translation-en [6,212 B]
获取:17 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/restricted Translation-zh_CN [1,324 B]
获取:18 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/restricted amd64 c-n-f Metadata [392 B]
获取:19 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/universe amd64 Packages [8,628 kB]
获取:20 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/universe Translation-en [5,124 kB]
获取:21 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/universe Translation-zh_CN [388 kB]
获取:22 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/universe amd64 c-n-f Metadata [265 kB]
获取:23 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/multiverse amd64 Packages [144 kB]
获取:24 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/multiverse Translation-en [104 kB]
获取:25 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/multiverse Translation-zh_CN [4,612 B]
获取:26 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/multiverse amd64 c-n-f Metadata [9,136 B]
获取:27 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/universe Sources [106 kB]
获取:28 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/main Sources [249 kB]
获取:29 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/restricted Sources [44.7 kB]
获取:30 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/multiverse Sources [10.5 kB]
获取:31 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/main amd64 Packages [1,742 kB]
获取:32 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/main Translation-en [292 kB]
获取:33 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security amd64 Contents (deb) [131 MB]
获取:34 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/main amd64 c-n-f Metadata [11.1 kB]
获取:35 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/restricted amd64 Packages [1,204 kB]
获取:36 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/restricted Translation-en [171 kB]
获取:37 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/restricted amd64 c-n-f Metadata [588 B]
获取:38 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/universe amd64 Packages [727 kB]
获取:39 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/universe Translation-en [134 kB]
获取:40 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/universe amd64 c-n-f Metadata [15.1 kB]
获取:41 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/multiverse amd64 Packages [22.2 kB]
获取:42 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/multiverse Translation-en [5,376 B]
获取:43 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-security/multiverse amd64 c-n-f Metadata [508 B]
获取:44 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates/main Sources [524 kB]
获取:45 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates/multiverse Sources [20.4 kB]
获取:46 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates/universe Sources [257 kB]
获取:47 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates/restricted Sources [44.8 kB]
获取:48 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates/main amd64 Packages [2,116 kB]
获取:49 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates/main Translation-en [375 kB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]
获取:50 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal-updates amd64 Contents (deb) [143 MB]                                                                     
已下载 144 MB,耗时 1分 24秒 (1,701 kB/s)                                                                                                                                  
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
有 65 个软件包可以升级。请执行 ‘apt list --upgradable’ 来查看它们。

[root@ubuntu2004 ~]#apt install -y sl
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
下列【新】软件包将被安装:
  sl
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 65 个软件包未被升级。
需要下载 12.7 kB 的归档。
解压缩后会消耗 60.4 kB 的额外空间。
获取:1 http://10.0.0.207:8081/repository/ubuntu2004dddddd focal/universe amd64 sl amd64 5.02-1 [12.7 kB]
已下载 12.7 kB,耗时 0秒 (52.3 kB/s)
正在选中未选择的软件包 sl。
(正在读取数据库 ... 系统当前共安装有 109206 个文件和目录。)
准备解压 .../archives/sl_5.02-1_amd64.deb  ...
正在解压 sl (5.02-1) ...
正在设置 sl (5.02-1) ...
正在处理用于 man-db (2.9.1-1) 的触发器 ...