1. 安装
- 下载直接解压就可以 https://www.sonatype.com/download-oss-sonatype
- nexus-3 nexus服务的主目录
- sonatype-work 工作目录,包含nexus生成的配置文件,日志文件、仓库文件、索引文件、插件文件、缓存文件等等。
- 配置
#1
[cdh@r123m ~]$ cat /usr/local/soft/nexus-3.12/nexus-3.12.1/etc/nexus-default.properties
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8002 # 端口
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/
# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
nexus-pro-feature
#2
[cdh@r123m ~]$ cat /usr/local/soft/nexus-3.12/nexus-3.12.1/bin/nexus.vmoptions
-Xms1200M
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
# 默认存储目录
-Dkaraf.data=/data/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
2. 启动
[cdh@r123m ~]$ nexus start
Starting nexus
3.仓库类型
- proxy 代理类型 主要是用于去远程仓库拉取jar包
- hosted 宿主,主机 主要用于存放公司内部的jar包 ;Releases、Snapshots,版本中带SNAPSHOT传到snapshots中,带RELEASES的传到Releases中
- group 组类型
不是单独的类型,而是多个type的集合。主要作用对外暴露访问。
此类型描述的仓库,把其他的仓库使用同一个地址暴露出去,组仓库用来方便开发人员进行设置的仓库,不具有实际的功能,只是一个概念,简单说就是访问这个group设置的一个地址,其他仓库的jar都能获取到。
- virtual 虚拟类型 ,nexus2有。主要是解决1.x的兼容问题
- nexus3中出现的nuget不用管,非java的. 是.net的类型
4.私服场景
nexus可以做多个组件的私服,或是本地仓库,比如: maven、python、nodejs、docker、yum等。