在麒麟V10服务器上部署maven私有仓库nexus

一、下载 nexus

https://help.sonatype.com/repomanager3/download

选择对应操作系统版本

系统要求:

  • 安装 jdk 1.8 版本
  • linux 系统需要修改 nexus 用户最大文件打开数:
  • 修改 /etc/security/limits.conf,增加一行:nexus - nofile 65536 ,其中 nexus 为要运行 nexus 服务的用户。如果是使用 Ubuntu,它是忽略 /etc/security/limits.conf 配置的,如果进程是由 init.d 启动,可以编辑 /etc/pam.d/common-session ,去掉这一行的注释:# session    required   pam_limits.so
  • 如果是用 systemd 则需要在服务配置中添加一个 LimitNOFILE 配置:
[Unit]
Description=nexus service
After=network.target

[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus # 这个用户请保持和实际要运行 nexus 的用户一致
Restart=on-abort

[Install]
WantedBy=multi-user.target

二、部署

1、解压缩 nexus 软件包:

tar -zxvfnexus-3.26.1-02-unix.tar.gz

2、添加一个普通用户组和用户:

groupadd nexus

useradd -g nexus -s /sbin/nologin nexus

注意不要禁止设置用户 home 目录(-M参数),否则服务启动时会报错。

3、给与用户软件目录权限

chown -R nexus:nexus nexus-3.26.0-04

chown -Rnexus:nexussonatype-work/

4、编辑启动服务的用户 bin/nexus.rc,加入以下行:

run_as_user="nexus"

5、编辑添加系统服务 /etc/systemd/system/nexus.service

[Unit]
Description=nexus service
After=network.target

[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus # 这个用户请保持和实际要运行 nexus 的用户一致
Restart=on-abort

[Install]
WantedBy=multi-user.target

6、运行服务:

sudo systemctl daemon-reload

sudo systemctl enable nexus.service

sudo systemctl start nexus.service

三、验证

作者:李凌

猜你喜欢

转载自blog.csdn.net/m0_46573967/article/details/112761594
今日推荐