一、前期准备
1.1 JDK安装
参考链接:https://blog.csdn.net/weixin_41668084/article/details/111147667
1.2 文件下载
1.2.1 官网下载(下载速度贼慢)
![image-20210217183723775](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210217183725.png)
1.2.1 百度网盘
下载链接:https://pan.baidu.com/s/1m-8tfihdLDxkmidpxZ3rDA 提取码:jdnn
二、安装教程
2.1 上传并解压文件
![image-20210218164426181](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218164427.png)
#创建文件并解压文件到指定文件
mkdir /usr/local/nexus && tar -zxvf nexus-3.29.0-02-unix.tar.gz -C /usr/local/nexus
2.2 修改默认用户
vim /usr/local/nexus/nexus-3.29.0-02/bin/nexus.rc
cat /usr/local/nexus/nexus-3.29.0-02/bin/nexus.rc
run_as_user="root"
2.3 修改默认端口
vim /usr/local/nexus/nexus-3.29.0-02/etc/nexus-default.properties
![image-20210218165823062](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218165824.png)
2.4 修改数据以及相关日志的存储位置
vim /usr/local/nexus/nexus-3.29.0-02/bin/nexus.vmoptions
![image-20210218170120969](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218170122.png)
2.5 启动nexus
#切换目录
cd /usr/local/nexus/nexus-3.29.0-02/bin
#启动访问web页面
./nexus run &
#启动nexus
./nexus start
#查看nexus运行状态
./nexus status
![image-20210218170644157](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218170645.png)
2.6 页面登录验证
登录账号:admin,密码:admin
![image-20210218170952694](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218170954.png)
2.7 配置nexus开机自启动
2.7.1 新建nexus启动脚本
# 新建nexus脚本
vim /etc/init.d/nexus
#赋予权限
chmod +x /etc/init.d/nexus
#查看内容
cat /etc/init.d/nexus
#!/bin/bash
#chkconfig:2345 20 90
#description:nexus
#processname:nexus
export JAVA_HOME=/usr/local/java/
case $1 in
start) su root /usr/local/nexus/nexus-3.29.0-02/bin/nexus start;;
stop) su root /usr/local/nexus/nexus-3.29.0-02/bin/nexus stop;;
status) su root /usr/local/nexus/nexus-3.29.0-02/bin/nexus status;;
restart) su root /usr/local/nexus/nexus-3.29.0-02/bin/nexus restart;;
dump) su root /usr/local/nexus/nexus-3.29.0-02/bin/nexus dump;;
console) su root /usr/local/nexus/nexus-3.29.0-02/bin/nexus console;;
*) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
esac
2.7.2 设置脚本权限
chmod +x /etc/init.d/nexus
2.7.3 添加到开机启动
#加入开机启动
chkconfig --add nexus
chkconfig nexus on
[root@localhost nexus]# systemctl enable nexus
nexus.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig nexus on
[root@localhost nexus]#
2.7.4 nexus启动及状态查看
[root@localhost nexus]# systemctl start nexus
[root@localhost nexus]# systemctl status nexus
● nexus.service - SYSV: nexus
Loaded: loaded (/etc/rc.d/init.d/nexus; bad; vendor preset: disabled)
Active: active (exited) since 四 2021-02-18 17:29:06 CST; 11s ago
Docs: man:systemd-sysv-generator(8)
Process: 28289 ExecStart=/etc/rc.d/init.d/nexus start (code=exited, status=0/SUCCESS)
2月 18 17:29:06 localhost.localdomain systemd[1]: Starting SYSV: nexus...
2月 18 17:29:06 localhost.localdomain su[28290]: (to root) root on none
2月 18 17:29:06 localhost.localdomain nexus[28289]: WARNING: ************************************************************
2月 18 17:29:06 localhost.localdomain nexus[28289]: WARNING: Detected execution as "root" user. This is NOT recommended!
2月 18 17:29:06 localhost.localdomain nexus[28289]: WARNING: ************************************************************
2月 18 17:29:06 localhost.localdomain nexus[28289]: Starting nexus
2月 18 17:29:06 localhost.localdomain systemd[1]: Started SYSV: nexus.
[root@localhost nexus]#
三、nexus仓库配置
3.1 添加代理仓库
![image-20210218174228561](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218174230.png)
3.2 选择maven代理仓库
![image-20210218174340674](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218174342.png)
3.3 仓库配置
![image-20210218174523848](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218174525.png)
3.4 Maven公共仓库配置
![image-20210218174701174](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218174702.png)
3.5 添加阿里云代理仓库
![image-20210218175011603](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218175012.png)
3.5 Maven私服使用
3.5.1 全局使用
配置maven插件中的settings.xml文件
<!--服务账号密码-->
<server>
<id>mirror-nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
<!--配置镜像地址-->
<mirrors>
<mirror>
<id>mirror-nexus</id>
<name>nexus-mirror</name>
<url>http://192.168.61.77/repository/maven-public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
3.5.2 项目使用
构建项目中在pom.xml里面增加配置文件
<repositories>
<repository>
<id>public</id>
<name>public</name>
<url>http://192.168.61.77/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
四、问题解决
4.1 问题现状
在 CentOS 或其他 Linux 系统上安装 Sonatype Nexus Repository Manager,配置完毕启动登录后,在 /support/status 状态页面的 File Descriptors 项目可能会显示 Recommended file descriptor limit is 65536 but count is 4096. 警告。
原因是 Nexus 3 将很有可能要消耗比 Linux 或 OSX 操作系统允许每个用户的默认文件句柄数(4096)更多的数量。
![image-20210218193526816](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218193528.png)
4.2 问题解决
4.2.1 修改配置
添加代码: @root - nofile 65536
vim /etc/security/limits.conf
![image-20210218194143340](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218194145.png)
4.2.2 修改nexus用户
vim /usr/local/nexus/nexus-3.29.0-02/bin/nexus.rc
cat /usr/local/nexus/nexus-3.29.0-02/bin/nexus.rc
run_as_user="root"
4.2.3 系统重启
#重启nexus
systemctl restart nexus
4.3页面验证
问题已经修复成功。
![image-20210218194803193](https://gitee.com/gbc_sxy/imagebed/raw/master/img/20210218194805.png)
以上,请参考!