CentOs7安装nexus3私服
获取解压nexus-3.9.0-01-unix.tar.gz
[root@localhost www]# wget https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.9.0-01-unix.tar.gz
[root@localhost www]# tar -xvf nexus-3.9.0-01-unix.tar.gz
[root@localhost www]# mv nexus-3.9.0-01 /opt/soft/
[root@localhost www]# ln -s /opt/soft/nexus-3.9.0-01 /opt/shortcut/nexus
创建nexu用户
[root@localhost www]# useradd -d "/home/nexus" -m -s "/sbin/nologin" nexus
[root@localhost www]# chown -R nexus:nexus /opt/shortcut/nexus
[root@localhost www]# chown -R nexus:nexus /opt/soft/sonatype-work (nexus的日志记录文件,不然启动不了)
//如果没有chown -R nexus:nexus /opt/soft/sonatype-work给sonatype-work目录授权,
//这个目录在`/opt/shortcut/nexus/bin/nexus.vmoptions`文件中指定,其中`/opt/shortcut/nexus/`是nexus的安装目录
Last login: Fri Mar 2 21:31:24 EST 2018 on pts/0
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to Permission denied
Warning: Cannot open log file: ../sonatype-work/nexus3/log/jvm.log
Warning: Forcing option -XX:LogFile=/tmp/jvm.log
Unable to delete file: /opt/soft/sonatype-work/nexus3/cache/bundle262/version0.0/revision.location
Unable to update instance pid: /opt/soft/sonatype-work/nexus3/instances/instance.properties (Permission denied)
修改配置
进入/opt/shortcut/nexus/bin
目录,查看文件
[root@localhost bin]# ll
total 32
drwxr-xr-x. 2 nexus nexus 4096 Mar 2 20:42 contrib
-rwxr-xr-x. 1 nexus nexus 17269 Feb 21 17:24 nexus
-rw-r--r--. 1 nexus nexus 36 Mar 2 21:12 nexus.rc
-rw-r--r--. 1 nexus nexus 465 Feb 21 17:24 nexus.vmoptions
修改nexus.rc
中的run_as_user
为nexus
# run_as_user=""
run_as_user="nexus"
查看nexus.vmoptions
文件
[root@localhost bin]# vi 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=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
进入/opt/shortcut/nexus/etc
目录
[root@localhost etc]# ll
total 8
drwxr-xr-x. 2 nexus nexus 171 Mar 2 20:42 fabric
drwxr-xr-x. 2 nexus nexus 157 Mar 2 20:42 jetty
drwxr-xr-x. 2 nexus nexus 4096 Mar 2 20:42 karaf
drwxr-xr-x. 2 nexus nexus 51 Mar 2 20:42 logback
-rw-r--r--. 1 nexus nexus 349 Mar 2 21:36 nexus-default.properties
drwxr-xr-x. 2 nexus nexus 26 Mar 2 20:42 ssl
修改nexus-default.properties
中的port和host属性,其中host属性不能写127.0.0.1
和localhost
[这个我访问不了],最后写的是DHCP(动态获取ip地址)时的ip地址
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8081
application-host=192.168.1*9.1*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 etc]# firewall-cmd --zone=public --add-port=8081/tcp --permanent
[root@localhost etc]# firewall-cmd --reload
启动和访问
启动命令
[root@localhost bin]# ./nexus start //后台启动,不显示日志
[root@localhost bin]# ./nexus run & //后台启动,显示日志
//启动成功
-------------------------------------------------
Started Sonatype Nexus OSS 3.9.0-01
-------------------------------------------------
访问http://192.168.1*9.1*0:8081