nexus3-maven私服搭建-Centos7
一、下载
下载地址:
https://help.sonatype.com/repomanager3/download/download-archives—repository-manager-3
二、解压
[root@localhost ~]# cd /usr/local/
[root@localhost local]# mkdir nexus
[root@localhost local]# cd nexus/
[root@localhost nexus]# ls
nexus-3.41.1-01-unix.tar.gz
[root@localhost nexus]# tar -zxvf nexus-3.41.1-01-unix.tar.gz
三、配置环境变量
由于Nexus3默认不允许使用root用户启动,因此我们需要修改以下环境变量:
对于服务器的内存是有要求的,默认最低2G,所以最好将内存设置大一些:4G或者更大!
#编辑环境变量
vim /etc/profile
#文件内容的末尾,另起一行,添加如下内容:
export RUN_AS_USER=root
#刷新环境变量
source /etc/profile
四、手动启动
[root@localhost nexus]# cd /usr/local/nexus/nexus-3.41.1-01/bin
[root@localhost bin]# ./nexus start
如果服务器中没有安装jdk,那么将会启动失败,并报以下截图中的错误:
成功安装jdk后再次手动启动nexus:
查看nexus的状态:
./nexus status
停止nexus:
./nexus stop
重启nexus:
./nexus restart
五、设置开机自启动
1. 创建脚本
[root@localhost bin]# cd /etc/init.d/
[root@localhost init.d]# touch auto-nexus
[root@localhost init.d]# ls
auto-nexus functions netconsole network README
[root@localhost init.d]# vi auto-nexus
2. 添加脚本内容
#!/bin/bash
#chkconfig:2345 20 90
#description:auto-nexus
#processname:auto-nexus
export JAVA_HOME=/usr/local/jdk1.8/jdk1.8.0_333
export NEXUS_HOME=/usr/local/nexus/nexus-3.41.1-01
case $1 in
start) su root $NEXUS_HOME/bin/nexus start;;
stop) su root $NEXUS_HOME/bin/nexus stop;;
status) su root $NEXUS_HOME/bin/nexus status;;
restart) su root $NEXUS_HOME/bin/nexus restart;;
*) echo "require start | stop | restart | status " ;;
esac
3. 脚本授权
# 脚本文件授权
[root@localhost init.d]# chmod +x /etc/init.d/auto-nexus
4. 设置开机启动
# 设置开机启动
[root@localhost init.d]# chkconfig auto-nexus on
六、开启防火墙端口
开放主机的Nexus客户端访问端口(默认是8081)
#开放端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent
#重启防火墙程序
systemctl restart firewalld.service
七、远程登录验证:
默认登录用户:admin
密码:保存于服务器的“/usr/local/nexus/sonatype-work/nexus3/admin.password”中,初次登录系统会提示用户修改密码;