linux-nexus

nexus

一、概述

背景:

  • maven编译的时候,npm/cnpm编译,需要下载大量的依赖包。
  • 这些依赖包在每一次构建的时候都需要使用。
  • 每次都从公网(maven 阿里云) npm(国内)。

可以搭建内部软件仓库:存放着依赖包

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

二、极速部署指南

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

[root@nexus ~]# ll
total 234836
-rw-------. 1 root root 1340 Jan 9 09:09 anaconda-ks.cfg
-rw-r--r-- 1 root root 117557932 Feb 21 20:59 jdk-8u351-linux-x64.rpm
-rw-r--r-- 1 root root 122904706 Mar 29 08:24 nexus-3.13.0-01-unix.tar.gz
[root@nexus ~]# rpm -ivh jdk-8u351-linux-x64.rpm
[root@nexus ~]# mkdir -p /app/tools/
[root@nexus ~]# tar xf nexus-3.13.0-01-unix.tar.gz -C /app/tools/
[root@nexus ~]# ln -s /app/tools/nexus-3.13.0-01/ /app/tools/nexus
[root@nexus ~]# ln -s /app/tools/nexus/bin/nexus /bin/
[root@nexus ~]# nexus --version
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
Usage: /usr/bin/nexus {start|stop|run|run-redirect|status|restart|force-reload}
[root@nexus ~]# nexus start
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
Starting nexus
启动的警告: 不推荐使用root运行。

登录后屏幕提示:

System Requirement: max file descriptors [4096] likely too low, increase to at least [65536].

翻译nexus要求: 文件描述符过低,请增加到65536(每个进程可以打开的文件数量)

[root@nexus ~]# ulimit -n 65536 #临时修改
[root@nexus ~]# tail -2 /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536

三、登录配置

http://nexus.cn:8081/

用户名: admin 密码:admin123

image-20230330214714295

1.配置连接阿里云maven源

image-20230330214750457

image-20230330214810311

http://maven.aliyun.com/nexus/content/groups/public/

2.连接使用nexus

连接nexus方式 说明 方法
全局 所有java项目都连接nexus仓库 maven conf/settings.xml
某个项目 某个项目连接nexus仓库 java项目下面 pom.xml
#配置maven,直接改用户名和密码还有域名就行
[root@jenkins ~]# cat /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.cn:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://nexus.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.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>
[root@jenkins ~]# cd /var/lib/jenkins/workspace/hello_word_maven_job
[root@jenkins /var/lib/jenkins/workspace/hello_word_maven_job]# ll
total 8
drwxr-xr-x 2 root root 29 Mar 28 21:01 dist
-rw-r--r-- 1 root root 930 Mar 28 21:02 pom.xml
-rw-r--r-- 1 root root 213 Mar 28 21:01 README.md
drwxr-xr-x 3 root root 18 Mar 28 21:01 src
drwxr-xr-x 5 root root 103 Mar 29 20:58 target
[root@jenkins /var/lib/jenkins/workspace/hello_word_maven_job]# cat /etc/hosts
172.16.1.74 nexus.cn
[root@jenkins /var/lib/jenkins/workspace/hello_word_maven_job]# mvn clean package
[INFO] Packaging webapp
[INFO] Assembling webapp [hello-world-war] in [/var/lib/jenkins/workspace/hello_word_maven_job/target/hello-world-war-1.0.0]
[INFO] Processing war project
[INFO] Copying webapp resources [/var/lib/jenkins/workspace/hello_word_maven_job/src/main/webapp]
[INFO] Webapp assembled in [72 msecs]
[INFO] Building war: /var/lib/jenkins/workspace/hello_word_maven_job/target/hello-world-war-1.0.0.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:00 min
[INFO] Finished at: 2023-03-30T21:55:58+08:00
[INFO] ------------------------------------------------------------------------

image-20230330215638983

本文作者:wh459086748

本文链接:https://www.cnblogs.com/world-of-yuan/p/17331532.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   wh459086748  阅读(184)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起