美文网首页向日葵武士Maven
【nexus】CentOS 7.x 上搭建nexus maven

【nexus】CentOS 7.x 上搭建nexus maven

作者: Bogon | 来源:发表于2018-12-02 23:17 被阅读10次

    一、安装环境

    操作系统:CentOS7.1 Minimal

    IP:192168.1.101

    java:jdk-8u131

    nexus: nexus-3.5.0-02

    相关软件包:

    https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

    http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html

    关闭防火墙

    # systemctl stop firewalld

    # systemctl  disable firewalld

    # iptables  -F

    二、安装nexus

    # rpm -e --nodeps $(rpm -qa | grep -i openjdk)

    #  wget  https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.5.0-02-unix.tar.gz

    #  tar  zxvf nexus-3.5.0-02-unix.tar.gz      -C     /opt

    # tar   zxvf  jdk-8u131-linux-x64.tar.gz     -C     /opt

    # ll   /opt/

    # groupadd -g 2018  nexus

    # useradd  -u 2018 -g  2018 nexus

    # echo "123456" | passwd  --stdin  nexus

    # echo "JAVA_HOME=/opt/jdk1.8.0_131"   >> /etc/profile.d/jdk.sh

    #  source  /etc/profile.d/jdk.sh

    # echo "export PATH=$JAVA_HOME/bin:$PATH" >>  /etc/profile.d/jdk.sh

    # source  /etc/profile.d/jdk.sh

    # java -version

    # vim /opt/nexus-3.5.0-02/bin/nexus.rc

    run_as_user="nexus"

    # vim /opt/nexus-3.5.0-02/bin/nexus 

    INSTALL4J_JAVA_HOME="/opt/jdk1.8.0_131"

    # vim /etc/systemd/system/nexus.service 

    ########################

    [Unit]

    Description=nexus service

    After=network.target

    [Service]

    Type=forking

    LimitNOFILE=65536 

    ExecStart=/opt/nexus-3.5.0-02/bin/nexus start

    ExecStop=/opt/nexus-3.5.0-02/bin/nexus stop

    User=nexus

    Restart=on-abort

    [Install]

    WantedBy=multi-user.target

    #################################

    # chown  -R  nexus:nexus  /opt/nexus-3.5.0-02 

    # chown  -R  nexus:nexus  /opt/sonatype-work 

    #  systemctl  daemon-reload

    #  systemctl  start nexus.service

    #  ss  -tan  | grep 8081

    生成keystore文件:

    # keytool  \

    -genkeypair \

    -keystore /opt/nexus-3.5.0-02/etc/ssl/keystore.jks \

    -alias nexus \

    -keypass nexus@123 \

    -storepass nexus@123 \

    -keyalg RSA \

    -keysize 2048 \

    -validity 5000 \

    -dname "CN=*.test.com,OU=TEST,O=TEST,L=Shenzhen,ST=Guangdong,C=CN" \

    -ext "SAN=IP:192.168.1.101"  \

    -ext "BC=ca:true"

    # chown  -R   nexus:nexus  /opt/nexus-3.5.0-02 

    # chown  -R   nexus:nexus  /opt/sonatype-work 

    #  vim /opt/sonatype-work/nexus3/etc/nexus.properties

    nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml,${jetty.etc}/jetty-https.xml

    application-port-ssl=8443

    # vim /opt/nexus-3.5.0-02/etc/jetty/jetty-https.xml

    # systemctl  restart  nexus

    # systemctl  status  nexus

    # systemctl  enable  nexus

    # ss  -tan | grep 8081

    # ss  -tan | grep 8443

    三、测试

    浏览器访问http://192.168.1.101:8081

    浏览器访问https://192.168.1.101:8443

    默认登录用户密码:admin/admin123


    四、更新 nexus  maven索引

    需要下载如下三个文件:

    indexer-cli-6.0.0.jar

    nexus-maven-repository-index.gz

    nexus-maven-repository-index.properties

    # wget  http://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz

    # wget http://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.properties

    # wegt http://central.maven.org/maven2/org/apache/maven/indexer/indexer-cli/6.0.0/indexer-cli-6.0.0.jar

    相关下载链接:

    http://repo.maven.apache.org/maven2/.index

    http://central.maven.org/maven2/org/apache/maven/indexer/indexer-cli

    #  mkdir  -p  /opt/maven

    # cp indexer-cli-6.0.0.jar nexus-maven-repository-index.gz nexus-maven-repository-index.properties   /opt/maven

    # cd  /opt/maven

    # java -jar indexer-cli-6.0.0.jar -u nexus-maven-repository-index.gz  -d  indexer

    等待程序运行完成之后可以发现/opt/maven/indexer文件夹下出现了很多文件

    将/opt/maven/indexer下的文件放置到 /opt/sonatype-work/nexus3/indexer/central-ctx 目录下

    # mkdir  -p  /opt/sonatype-work/nexus3/indexer/central-ctx

    # cp  -r  /opt/maven/indexer/*   /opt/sonatype-work/nexus3/indexer/central-ctx

    # chown -R nexus:nexus  /opt/sonatype-work

    # systemctl restart nexus 

    # systemctl status nexus 

    五、参考

    https://www.sonatype.org

    https://help.sonatype.com/repomanager3/installation

    http://www.eclipse.org/jetty/documentation/9.3.x/configuring-ssl.html

    https://docs.docker.com/engine/reference/commandline/login

    https://docs.docker.com/engine/reference/commandline/login/#parent-command

    https://github.com/codeclou/docker-sonatype-nexus-repository-oss

    http://blog.codecp.org/2016/05/23/Nexus%20oss%203.0%20%E6%9E%84%E5%BB%BAdocker%E4%BB%93%E5%BA%93

    https://docs.docker.com/registry/insecure/#docker-still-complains-about-the-certificate-when-using-authentication

    https://help.sonatype.com/repomanager3/download

    https://help.sonatype.com/repomanager3/system-requirements#SystemRequirements-Linux

    相关文章

      网友评论

        本文标题:【nexus】CentOS 7.x 上搭建nexus maven

        本文链接:https://www.haomeiwen.com/subject/dsvscqtx.html