CentOS 1905 配置 Nexus 3.17.0-01(Maven 私库)

Nexus 下载:Nexus Repository OSS - Software Component Management | Sonatype

文档:Repository Manager 3

运行环境(需要 Java 8):https://help.sonatype.com/repomanager3/installation/java-runtime-environment

CentOS 1905 配置 Nexus 3.17.0-01(Yum 私库)


  1. 查看 CentOS Java 运行环境:
    [root@localhost ~]# java -version
    openjdk version "1.8.0_222-ea"
    OpenJDK Runtime Environment (build 1.8.0_222-ea-b03)
    OpenJDK 64-Bit Server VM (build 25.222-b03, mixed mode)
    [root@localhost ~]# 
    
    自定义 Java 运行环境请修改 nexus-3.17.0-01/bin/nexus 中的 INSTALL4J_JAVA_HOME_OVERRIDE 指向您的 JDK/JRE。
     
  2. 解压 Nexus:
    [root@192 ~]# cd /nexus/
    [root@192 nexus]# ls
    nexus-3.17.0-01-unix.tar.gz
    [root@192 nexus]# tar -zxvf nexus-3.17.0-01-unix.tar.gz 
    
  3. 进入 bin 文件夹:
    [root@192 nexus]# ls
    nexus-3.17.0-01  nexus-3.17.0-01-unix.tar.gz  sonatype-work
    [root@192 nexus]# cd nexus-3.17.0-01/
    [root@192 nexus-3.17.0-01]# ls
    bin  deploy  etc  lib  NOTICE.txt  OSS-LICENSE.txt  PRO-LICENSE.txt  public  system
    [root@192 nexus-3.17.0-01]# cd bin/
    [root@192 bin]# ls
    contrib  nexus  nexus.rc  nexus.vmoptions
    [root@192 bin]# 
    
  4. 查看 Nexus 相关命令:
    [root@192 bin]# ./nexus 
    WARNING: ************************************************************
    WARNING: Detected execution as "root" user.  This is NOT recommended!
    WARNING: ************************************************************
    Usage: ./nexus {start|stop|run|run-redirect|status|restart|force-reload}
    [root@192 bin]# 
    
    警告:检测到以“root”用户身份执行。这是不推荐的!
     
  5. 启动 Nexus:
    [root@192 bin]# ./nexus start
    WARNING: ************************************************************
    WARNING: Detected execution as "root" user.  This is NOT recommended!
    WARNING: ************************************************************
    Starting nexus
    [root@192 bin]# 
    
    可将 Nexus 设置为 CentOS 服务:
    ln -s /nexus/nexus-3.17.0-01/bin/nexus /etc/init.d/nexus
    查看相关命令:
    [root@192 bin]# service nexus
    WARNING: ************************************************************
    WARNING: Detected execution as "root" user.  This is NOT recommended!
    WARNING: ************************************************************
    Usage: /etc/init.d/nexus {start|stop|run|run-redirect|status|restart|force-reload}
    [root@192 bin]# 
    
    设置开机自启:
    /sbin/chkconfig nexus on
    查看开机自启:
    /sbin/chkconfig --list
    显示:
    [root@192 ~]# /sbin/chkconfig --list
    
    Note: This output shows SysV services only and does not include native
          systemd services. SysV configuration data might be overridden by native
          systemd configuration.
    
          If you want to list systemd services use 'systemctl list-unit-files'.
          To see services enabled on particular target use
          'systemctl list-dependencies [target]'.
    
    netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
    network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
    nexus          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
    [root@192 ~]# 
    
  6. 查看 Nexus 状态:
    [root@192 bin]# ./nexus status
    WARNING: ************************************************************
    WARNING: Detected execution as "root" user.  This is NOT recommended!
    WARNING: ************************************************************
    nexus is running.
    [root@192 bin]# 
    
  7. 查看 Nexus 默认端口:
    [root@192 bin]# cd ..
    [root@192 nexus-3.17.0-01]# cd etc/
    [root@192 etc]# ls
    fabric  jetty  karaf  logback  nexus-default.properties  ssl
    [root@192 etc]# cat nexus-default.properties 
    ## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
    ##
    # Jetty section
    application-port=8081
    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
    
    nexus.hazelcast.discovery.isEnabled=true
    [root@192 etc]# 
    
  8. 访问 Nexus:
    需要开通8081端口:
    firewall-cmd --zone=public --add-port=8081/tcp --permanent
    firewall-cmd --reload
    firewall-cmd --list-all


     
  9. 登录:
    默认管理员账户:admin
    默认所在文件如图所示:

     
  10. 查看默认密码:
    [root@192 etc]# cd ..
    [root@192 nexus-3.17.0-01]# cd ..
    [root@192 nexus]# ls
    nexus-3.17.0-01  nexus-3.17.0-01-unix.tar.gz  sonatype-work
    [root@192 nexus]# cd sonatype-work/
    [root@192 sonatype-work]# ls
    nexus3
    [root@192 sonatype-work]# cd nexus3/
    [root@192 nexus3]# ls
    admin.password  blobs  cache  db  elasticsearch  etc  generated-bundles  instances  kar  keystores  lock  log  orient  port  restore-from-backup  tmp
    [root@192 nexus3]# cat admin.password 
    b78060ee-1edd-46ba-82de-e3c7371ff525
    [root@192 nexus3]# 
    
  11. 此向导将帮助您完成所需的安装任务。
    点 Next:

     
  12. 修改密码:

     
  13. 配置匿名访问:
    默认情况下,启用匿名访问将允许未经身份验证的下载、浏览和搜索存储库内容。可以通过编辑分配给匿名用户的角色来更改未经身份验证用户的权限。
    直接点击 Next,不开启匿名访问:

     
  14. 点击 Finish:

     
  15. 创建代理仓库:
    由于中央仓库网速较慢,使用 阿里云 Maven 作为首选代理仓库:
    按照如图所示点击:

     
  16. 选择 maven2 (proxy):

     
  17. 填写仓库唯一标识符与远程代理存储的位置,其他默认即可:


    点 Create repository 创建仓库:

     
  18. 创建完成如图所示:

     
  19. 点击 aliyun-maven 的 Copy,即可复制其仓库地址:

     
  20. 按照如图所示点击:

     
  21. 查看 aliyun-maven 中的依赖:
    显示为空:

     
  22. 新建一个角色:
    如图所示进行点击:

     
  23. 新建角色如图所示:

     
  24. 有关角色的权限请查看:

     
  25. 新建用户:
    如图所示,进行点击:

     
  26. 设置用户相关的权限:

     
  27. 测试用户权限:
    使用 谷歌匿名浏览器 访问公共仓库:


    登录后显示:
    说明新建用户授权成功:

     
  28. 修改 公共仓库(maven-public,属于仓库组) 增加 阿里云 Maven 代理仓库为首选仓库:
    按照如图方式点击:

     
  29. 增加 阿里云 Maven 代理仓库,并设置为首选:
  30. 新建一个 Maven 项目:

     
  31. 在 Maven 项目中设置仓库:

     
  32. 可在 Maven 中的 setting.xml 中统一设置,如图:

     
  33. 增加用户名与密码:
    Maven 中的 setting.xml 文件:
    id 需要与 pom.xml 中设置的一样:

     
  34. 增加依赖:
    确保此依赖是你本地 Maven 仓库中不存在的:
    在此增加了两个较老版本的 Fastjson:

     
  35. 使用管理员登录,并按照如下操作点击:

     
  36. 可查看到已下载的 Jar 包:

     
  37. 如果想下载源码与文档,请按照如图点击:
    请注意,如果引用了相同 jar 包的不同版本,下载 jar 包时,旧版本的 jar 包的 源码与文档可能不会下载,需要将 新版 jar 包注释后,才能下载旧版的 源码与依赖:

     
  38. 再次查看:

     


  39.  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐晓伟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值