Day05-03-Nexus仓库

05-nexus-仓库

1. 概述

  • 背景:

    • maven编译的时候,npm/cnpm编译,需要下载大量的依赖包。
    • 这些依赖包在每一次构建的时候都需要使用。
    • 每次都从公网(maven 阿里云) npm(国内)。
  • 可以搭建内部软件仓库:存放着依赖包

  • 这个软件依赖仓库可以通过nexus实现

2. 极速部署指南

  • 下载
  • 部署
  • 配置
  • 启动
  • 配置代码项目的内容pom.xml

2.1 下载

https://www.sonatype.com/download-oss-sonatype

2.2 部署

tar xf nexus-3.13.0-01-unix.tar.gz -C /app/tools/
ln -s /app/tools/nexus-3.13.0-01/ /app/tools/nexus
ll /app/tools/nexus/bin/
ln -s /app/tools/nexus/bin/nexus /sbin/

安装jdk
安装rpm包版本的jdk.
rpm -ivh jdk-8u331-linux-x64.rpm

[root@oldboy-devops-nexus ~]# nexus start
Starting nexus
[root@oldboy-devops-nexus ~]# nexus status
nexus is running.

image-20240524093023215

启动的警告: 不推荐使用root运行。

[root@devops-nexus ~]# nexus --version
WARNING: ************************************************************
WARNING: Detected execution as "root" user.  This is NOT recommended!
WARNING: ************************************************************

2.3 配置

  • hosts 解析 10.0.0.74 nexus.oldboylinux.cn
  • 用户名:admin 密码:admin123

image-20240524093739904

登录后屏幕提示:
System Requirement: max file descriptors [4096] likely too low, increase to at least [65536].
翻译nexus要求: 文件描述符过低,请增加到65536(每个进程可以打开的文件数量)

配置后重启生效。
vim /etc/security/limits.conf
 新增
 * soft nofile 65536
 * hard nofile 65536
命令临时重启后失效 
 ulimit -n 65536
  • 私服使用全流程

image-20240524094327713

  • 配置连接阿里云maven源

image-20240524095512842

  • 修改proxy部分地址为阿里云地址 http://maven.aliyun.com/nexus/content/groups/public/

image-20240524095642894

image-20240524095733816

2.4 连接使用nexus

  • maven conf/settings.xml
  • java项目下面 pom.xml
连接nexus方式说明方法
方式01-全局所有java项目都连接nexus仓库maven conf/settings.xml
方式02-某个项目某个项目连接nexus仓库java项目下面 pom.xml
cp /app/tools/maven/conf/settings.xml{,.ori}
cp settings-by-lidao996.xml /app/tools/maven/conf/settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <pluginGroups>
  
  </pluginGroups>
  
  <proxies>
  </proxies>
  
  <servers>
     <server>
       <id>my-nexus-releases</id>
       <username>admin</username>
       <password>admin123</password>
       </server>
     <server>
       <id>my-nexus-snapshot</id>
       <username>admin</username>
       <password>admin123</password>
     </server>
  </servers>
  
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://nexus.oldboylinux.cn:8081/repository/maven-public/</url>
    </mirror>
  </mirrors>
  
  
  <profiles>
    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://nexus.oldboylinux.cn:8081/repository/maven-public/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://nexus.oldboylinux.cn:8081/repository/maven-public/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

2.4 编译与测试

http://nexus.oldboylinux.cn:8081/repository/maven-central/

image-20240524111732186

image-20240524111715991

image-20240524111656322

3. 总结

  • 仓库/私服。
  • maven(java)
  • npm仓库

image-20240524103929519

image-20240524105538581

  • 17
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值