CentOS Maven私服搭建-Nexus 3.0

40 篇文章 0 订阅
9 篇文章 0 订阅

一、前期准备

1.1 JDK安装

参考链接:https://blog.csdn.net/weixin_41668084/article/details/111147667

1.2 文件下载

1.2.1 官网下载(下载速度贼慢)

下载地址:https://www.sonatype.com/thanks/repo-oss

image-20210217183723775
1.2.1 百度网盘

下载链接:https://pan.baidu.com/s/1m-8tfihdLDxkmidpxZ3rDA 提取码:jdnn

二、安装教程

2.1 上传并解压文件

image-20210218164426181
#创建文件并解压文件到指定文件
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

2.4 修改数据以及相关日志的存储位置

vim /usr/local/nexus/nexus-3.29.0-02/bin/nexus.vmoptions
image-20210218170120969

2.5 启动nexus

#切换目录
cd /usr/local/nexus/nexus-3.29.0-02/bin
#启动访问web页面
./nexus run &
#启动nexus
./nexus start
#查看nexus运行状态
./nexus status
image-20210218170644157

2.6 页面登录验证

登录账号:admin,密码:admin

image-20210218170952694

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)

218 17:29:06 localhost.localdomain systemd[1]: Starting SYSV: nexus...
218 17:29:06 localhost.localdomain su[28290]: (to root) root on none
218 17:29:06 localhost.localdomain nexus[28289]: WARNING: ************************************************************
218 17:29:06 localhost.localdomain nexus[28289]: WARNING: Detected execution as "root" user.  This is NOT recommended!
218 17:29:06 localhost.localdomain nexus[28289]: WARNING: ************************************************************
218 17:29:06 localhost.localdomain nexus[28289]: Starting nexus
218 17:29:06 localhost.localdomain systemd[1]: Started SYSV: nexus.
[root@localhost nexus]#

三、nexus仓库配置

3.1 添加代理仓库

image-20210218174228561

3.2 选择maven代理仓库

image-20210218174340674

3.3 仓库配置

image-20210218174523848

3.4 Maven公共仓库配置

image-20210218174701174

3.5 添加阿里云代理仓库

image-20210218175011603

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

4.2 问题解决

4.2.1 修改配置

添加代码: @root - nofile 65536

vim /etc/security/limits.conf
image-20210218194143340
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

以上,请参考!


参考链接

  1. CentOS7配置nexus开机自启动
  2. Centos7 安装Nexus3
  3. 文件描述警告修复
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值