一、准备安装包:nexus-3.3.2-02-unix.tar.gz (版本3.x 必须配合jdk1.8)和 apache-maven-3.5.0-bin.zip
nexus:下载地址:https://www.sonatype.com/download-oss-sonatype
maven:下载地址:http://maven.apache.org/download.cgi
nexus如图:
二、准备环境
1、我是使用SecureCRT 来链接Linux服务器。
进入local下,命令:cd /usr/local这个目录随便,我只是习惯在这个目录下面操作,命令pwd是查看当前路径
2、 用一些ssh 等工具进行上传
上传apache-maven-3.5.0-bin.zip。解压命令:unzip apache-maven-3.5.0-bin.zip
上传nexus-3.3.2-02-unix.tar.gz ,然后创建nexus文件夹,命令 mkdir nexus,然后把下载的nexus-3.3.2-02-unix.tar.gz 上传到此目录下。解压 命令:tar -xzvf nexus-3.3.2-02-unix.tar.gz ,可以看到有两个文件夹nexus-3.3.2-02和sonatype-work
3.然后配置环境变量:
export JAVA_HOME=/opt/jdk1.8
export MAVEN_HOME=/usr/local/apache-maven-3.5.0
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
让配置生效
source /etc/profile
java -version
mvn --help
开启监听:
启动nexus(默认端口是8081)
[root@master-node src]# /usr/local/nexus/nexus-3.3.2-02/bin/nexus
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
Usage: /usr/local/nexus/bin/nexus {start|stop|run|run-redirect|status|restart|force-reload}
[root@master-node src]# /usr/local/nexus/nexus-3.3.2-02/bin/nexus start
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
Starting nexus
上面在启动过程中出现告警:不推荐使用root用户启动。这个告警不影响nexus的正常访问和使用。
去掉上面WARNING的办法:
[root@master-node src]# vim /etc/profile
......
export RUN_AS_USER=root
[root@master-node src]# source /etc/profile
[root@master-node src]# lsof -i:8081 //nexus服务启动成功后,需要稍等一段时间,8081端口才起来
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 1486 root 859u IPv4 23504303 0t0 TCP *:tproxy (LISTEN)
在部署机上的iptables里打开8081端口
[root@master-node src]# vim /etc/sysconfig/iptables
....
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8081 -j ACCEPT
[root@master-node src]# /etc/init.d/iptables restart
访问nexus,即http://localhost:8081 初始账户和密码:admin/admin123