http://blog.csdn.net/yougoule/article/details/78188329
1.下载nexus-3.11.0-01-unix.tar.gz
2.解压
[root@MiWiFi-R3-srv ~]# tar -zxvf nexus-3.11.0-01-unix.tar.gz -C /usr/local/
3.修改nexus3的运行用户为root
[root@MiWiFi-R3-srv bin]# vim nexus.rc
run_as_user="root"
4.修改nexus3启动时要使用的jdk版本
[root@MiWiFi-R3-srv bin]# vim nexus
第14行:
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/java/jdk1.8.0_144
5.修改nexus3默认端口(可选)
[root@MiWiFi-R3-srv etc]# cd /usr/local/nexus-3.11.0-01/etc/
[root@MiWiFi-R3-srv etc]# vim nexus-default.properties
默认端口:8081
application-port=8081
6.修改nexus3数据以及相关日志的存储位置(可选):
[root@MiWiFi-R3-srv bin]# cd /usr/local/nexus-3.11.0-01/bin/
[root@MiWiFi-R3-srv bin]# vim nexus.vmoptions
-XX:LogFile=./sonatype-work/nexus3/log/jvm.log
-Dkaraf.data=./sonatype-work/nexus3
-Djava.io.tmpdir=./sonatype-work/nexus3/tmp
7.启动nexus3
[root@MiWiFi-R3-srv ~]# cd /usr/local/nexus-3.11.0-01/bin
[root@MiWiFi-R3-srv ~]# ./nexus run &
稍等一会(首次启动会比较慢),当出现以下日志的时候表示启动成功!
-------------------------------------------------
Started Sonatype Nexus OSS 3.11.0-01
-------------------------------------------------
8.开启远程访问端口
[root@MiWiFi-R3-srv bin]# firewall-cmd --zone=public --add-port=8081/tcp --permanent
[root@MiWiFi-R3-srv bin]# firewall-cmd --reload
9.测试
nexus3默认端口是:8081
nexus3默认账号是:admin
nexus3默认密码是:admin123
10.设置开机自启动(systemctl方式)
创建一个服务
[root@MiWiFi-R3-srv ~]# vim /usr/lib/systemd/system/nexus.service
填入相关内容
[Unit]
Description=nexus service
[Service]
Type=forking
LimitNOFILE=65536 #警告处理
ExecStart=/usr/local/nexus/nexus-3.11.0-01/bin/nexus start
ExecReload=/usr/local/nexus/nexus-3.11.0-01/bin/nexus restart
ExecStop=/usr/local/nexus/nexus-3.11.0-01/bin/nexus stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
将服务加入开机启动
[root@MiWiFi-R3-srv ~]# systemctl enable nexus.service
重新加载配置文件
[root@MiWiFi-R3-srv ~]# systemctl daemon-reload
11.配置本地maven的setting.xml文件
F:\hzl_maven_repository
maven-releases
admin
admin123
maven-snapshots
admin
admin123
nexus
*
http://192.168.1.169:8081/repository/maven-public/
HzlNexus
HzlNexus
http://192.168.1.169:8081/repository/maven-public/
true always
true always
HzlNexus
http://192.168.1.169:8081/repository/maven-public/
true always
true always
HzlNexus
项目中的pom.xml文件设置
maven-releases
Nexus Release Repository
http://192.168.1.169:8081/repository/maven-releases/
maven-snapshots
Nexus Snapshot Repository
http://192.168.1.169:8081/repository/maven-snapshots/
12.添加阿里云或其他仓库
aliyun:http://maven.aliyun.com/nexus/content/groups/public/
13.出现警告“System Requirement: max file descriptors [4096] likely too low, increase to at least [65536].”
最后的解决方法是在/etc/security/limits.conf
中,注释掉原来的nexus - nofile 65536
这一行,并增加以下两行:
nexus soft nofile 65536
nexus hard nofile 65536
或设置任意用户的nofile为65536:
* soft nofile 65536
* hard nofile 65536
保存修改后重启Nexus,就没有上面的警告了。