Centos7 安装Nexus3私服

Centos7 安装Nexus3私服


注:如无特殊说明 $install-dir即为nexus的安装目录

  • 1. 下载nexus

    下载地址: https://help.sonatype.com/repomanager3/download/download-archives—repository-manager-3
    选择版本进行下载,笔者选择的是 nexus-3.17.0-01
    [root@localhost software]# wget http://download.sonatype.com/nexus/3/nexus-3.17.0-01-unix.tar.gz
    如果在服务器上使用wget下载比较慢的话,可以选择先下载到本地,然后上传到服务器

  • 2. 安装nexus

    • 解压安装包

      • [root@localhost software]# tar -zxvf nexus-3.17.0-01-unix.tar.gz
      • 安装目录说明:
        bin: 此目录包含nexus启动脚本本身以及与启动相关的配置文件,例如通过bin/nexus.vmoptions文件,你可以配置一些JVM参数和日志存放位置等配置
        etc: 该目录包含配置文件
        lib: 该目录包含与Apache Karaf相关的二进制库
        public: 该目录包含应用程序的公共资源
        system: 该目录包含构成应用程序的所有组件和插件
        LICENSE.txt 和 NOTICE.txt: 这些文件包含有关许可和版权声明的法律详细信息
        
        
    • 进入bin目录下,启动nexus

       [root@localhost bin]# ./nexus start
       WARNING: ************************************************************
       WARNING: Detected execution as "root" user.  This is NOT recommended!
       WARNING: ************************************************************
       Starting nexus
    
    
    • 查看nexus状态
      [root@localhost bin]# ./nexus status
      WARNING: ************************************************************
      WARNING: Detected execution as "root" user.  This is NOT recommended!
      WARNING: ************************************************************
      nexus is running.
      
      
    • 其他命令详解
      • 重启: nexus restart
      • 强制重新刷新仓库: nexus force-reload
      • 非守护线程方式启动: nexus run

  • 3. 配置 nexus 以服务的形式启动,并且开机自启动

    • 配置环境变量,添加NEXUS_HOME
      [root@localhost bin]# vim /etc/profile
      添加以下参数到profile

      export NEXUS_HOME=/usr/local/nexus-3.17.0-01
      export PATH=$PATH:$NEXUS_HOME/bin
      

      修改完执行以下命令
      [root@localhost bin]# source /etc/profile

    • 修改 nexus.rc和 nexus

      [root@localhost bin]# vim /usr/local/nexus-3.17.0-01/bin/nexus.rc
      修改为 
      run_as_user="root"
      
      [root@localhost bin]# vim /usr/local/nexus-3.17.0-01/bin/nexus
      添加或修改为
      INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/jdk1.8.0_221
      
    • 添加nexus到/etc/init.d/nexus的软连接
      [root@localhost bin]# sudo ln -s /usr/local/nexus-3.17.0-01/bin/nexus /etc/init.d/nexus

    • 使用systemd添加服务和开机自启(CentOS-7推荐使用)

      • 在/etc/systemd/system/下新建文件nexus.service
        [root@localhost bin]# touch /etc/systemd/system/nexus.service

      • 编辑该文件,内容如下(根据自身nexus安装目录修改)

      [Unit]
      Description=nexus service
      After=network.target
      
      [Service]
      Type=forking
      LimitNOFILE=65536
      ExecStart=/usr/local/nexus-3.17.0-01/bin/nexus start
      ExecStop=/usr/local/nexus-3.17.0-01/bin/nexus stop
      User=root
      Restart=on-abort
      
      [Install]
      WantedBy=multi-user.target
      
      
      • 使用以下命令重启服务
      
      [root@localhost bin]# sudo systemctl daemon-reload
      [root@localhost bin]# sudo systemctl enable nexus.service
      Created symlink from /etc/systemd/system/multi-user.target.wants/nexus.service to /etc/systemd/system/nexus.service.
      [root@localhost bin]# sudo systemctl start nexus.service
      
      

  • 4. 访问用户界面

    • 启动存储库管理器后,应用程序将侦听配置的IP地址范围和端口。默认情况下,使用任何IP地址和端口8081。要访问Web应用程序用户界面,请启动Web浏览器并输入URL, http://<server_host>:<port> 例如 http://localhost:8081/。访问界面如图:
      UI
      存储库管理器安装包括具有完全访问权限的管理用户。它的用户名是 admin ,初始密码可以admin.password在$data-dir 目录中的文件中找到。您可以使用用户界面右上角的按钮登录。

  • 5. 配置运行时环境

    • 配置内存
      1. 找到$install-dir/bin/nexus.vmoptions,在文本编辑器中打开
      2. 找到配置内存的行,修改后重启服务即可:
         -Xms2703M
         -Xmx2703M
         -XX:MaxDirectMemorySize=2703M
        
        
    • 配置http端口
      1. 找到$install-dir/etc/nexus-default.properties,在编辑器中打开
      2. 找到配置端口的行,修改后重启nexus
        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=/
        
        
    • 配置数据目录
      1. 修改$install-dir/bin/nexus.vmoptions来为要保留的数据定义新位置.
      2. 修改 -Dkaraf.data, -Djava.io.tmpdir 和 -XX:LogFile,更改数据目录,谨记所变更的目录必须为绝对路径
        -Dkaraf.data=/opt/sonatype-work/nexus3
        -Djava.io.tmpdir=/opt/sonatype-work/nexus3/tmp
        -XX:LogFile=/opt/sonatype-work/nexus3/log/jvm.log
        

参考:

  • https://help.sonatype.com/repomanager3/installation
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值