nexus install

java install

1
2
3
4
5
6
7
8
[root@localhost app]# tar xzf jdk-8u111-linux-x64.tar.gz
[root@localhost app]# mv jdk1.8.0_111 /mnt/app/java
[root@localhost app]# echo 'JAVA_HOME=/mnt/app/java' | tee /etc/profile.d/java.sh
[root@localhost app]# echo 'JRE_HOME=${JAVA_HOME}/jre' | tee -a /etc/profile.d/java.sh
[root@localhost app]# echo 'CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib' | tee -a /etc/profile.d/java.sh
[root@localhost app]# echo 'export PATH=${JAVA_HOME}/bin:$PATH' | tee -a /etc/profile.d/java.sh
[root@localhost app]# source /etc/profile
[root@localhost app]# java -version

maven install

1
2
3
4
5
[root@localhost app]# tar xzf apache-maven-3.3.9-bin.tar.gz
[root@localhost app]# mv apache-maven-3.3.9 /mnt/app/maven
[root@localhost app]# echo 'MAVEN_HOME=/mnt/app/maven' | tee -a /etc/profile.d/maven.sh
[root@localhost app]# echo 'export PATH=${PATH}:${MAVEN_HOME}/bin' | tee -a /etc/profile.d/maven.sh
[root@localhost app]# source /etc/profile

nexus install

  1. 创建用户

    1
    2
    [root@localhost ~]# useradd nexus
    [root@localhost ~]# echo 'cMaxj(^s7:do! | passwd --stdin nexus
  2. nexus 安装

    1
    2
    3
    4
    5
    6
    [root@localhost ~]# tar xzf nexus-3.1.0-04-unix.tar.gz
    [root@localhost ~]# mv nexus-3.1.0-04 /mnt/app/nexus
    [root@localhost ~]# echo 'export NEXUS_HOME=/mnt/app/nexus' | tee /etc/profile.d/nexus.sh
    [root@localhost ~]# echo 'export NEXUS_BIN=${NEXUS_HOME}/bin' | tee -a /etc/profile.d/nexus.sh
    [root@localhost ~]# echo 'export PATH=${NEXUS_BIN}:$PATH' | tee -a /etc/profile.d/nexus.sh
    [root@localhost ~]# source /etc/profile
  3. nexus 修改配置文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    [root@localhost ~]# vim /mnt/app/nexus/etc/nexus-default.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

    [root@localhost ~]# vim /mnt/app/nexus/bin/nexus.rc
    run_as_user="nexus"

    [root@localhost ~]# vim /mnt/app/nexus/bin/nexus.vmoptions
    -Xms1200M
    -Xmx1200M
    -XX:MaxDirectMemorySize=2G
    -XX:+HeapDumpOnOutOfMemoryError
    -XX:+UnlockDiagnosticVMOptions
    -XX:+UnsyncloadClass
    -XX:+LogVMOutput
    -XX:LogFile=/mnt/log/nexus/nexus.log
    -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=/mnt/data/nexus
    -Djava.io.tmpdir=/mnt/data/nexus/tmp
    -Dkaraf.startLocalConsole=false
  4. nexus 创建日志和数据目录,并修改文件属性

    1
    2
    3
    [root@localhost ~]# mkdir -p /mnt/{data,log}/nexus
    [root@localhost ~]# mkdir -p /mnt/data/nexus/tmp
    [root@localhost ~]# chown -R nexus.nexus /mnt/{app,data,log}/nexus
  5. nexus 启动

    1
    2
    3
    4
    [root@localhost ~]# su - nexus
    [nexus@localhost ~]$ /mnt/app/nexus/bin/nexus start
    [nexus@localhost ~]$ /mnt/app/nexus/bin/nexus stop
    [nexus@localhost ~]$ /mnt/app/nexus/bin/nexus status
  6. nexus 加入开机启动项

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    方式一:
    [root@localhost ~]# vim /etc/rc.local
    su nexus -c "/mnt/app/nexus/bin/nexus start"

    方式二:
    [root@localhost ~]# vim /usr/lib/systemd/system/nexus.service
    [Unit]
    Description=nexus service
    After=network.target

    [Service]
    Type=forking
    ExecStart=/mnt/app/nexus/bin/nexus start
    ExecStop=/mnt/app/nexus/bin/nexus stop
    User=nexus
    Restart=on-abort

    [Install]
    WantedBy=multi-user.target

    [root@localhost ~]# systemctl daemon-reload
    [root@localhost ~]# systemctl enable nexus
    [root@localhost ~]# systemctl start nexus
  7. 通过浏览器打开

    1
    2
    3
    http://192.168.10.75:8081

    默认密码: admin/admin123