Centos7 安装Nexus

Nexus 介绍

Nexus 是一个强大的maven仓库管理器,它极大地简化了本地内部仓库的维护和外部仓库的访问。

不仅如此,他还可以用来创建yum、pypi、npm、docker、nuget、rubygems 等各种私有仓库。

 每次可重复且快速的构建:

轻松管理所有包裹
  • 存储和分发具有本机包管理器兼容性的组件
  • 支持 Java/Maven、npm、NuGet、PyPI、RubyGems、CocoaPods 等生态系统
  • 分发打包和容器化的应用程序,例如 Docker、Helm、Yum 和 APT
  • 与流行的 IDE 和 CI 兼容,例如 Eclipse、IntelliJ、Visual Studio、Jenkins

 

当前操作系统版本&JDK版本

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)

[root@localhost ~]# java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)

Nexus下载版本

下载地址:https://help.sonatype.com/repomanager3/product-information/download
官方网址:https://www.sonatype.com/

解压下载文件

[root@localhost ~]# tar xf nexus-3.39.0-01-unix.tar.gz

[root@localhost nexus]# ll
总用量 211156
drwxr-xr-x. 10 root root       181 6月  16 00:43 nexus-3.39.0-01
-rw-r--r--.  1 root root 216219704 6月  16 00:42 nexus-3.39.0-01-unix.tar.gz
drwxr-xr-x.  3 root root        20 6月  16 00:43 sonatype-work

# nexus-3.39.0-01	Nexus 运行所需要的文件,如运行脚本,依赖jar包等
# sonatype-work	该目录包含Nexus生成的配置文件、日志文件、仓库文件等

启动Nexus

[root@localhost nexus]# cd nexus-3.39.0-01/bin/
[root@localhost bin]# ll
总用量 32
drwxr-xr-x. 2 root root  4096 6月  16 00:43 contrib
-rwxr-xr-x. 1 root root 18620 5月  19 21:15 nexus
-rw-r--r--. 1 root root    15 5月  19 21:15 nexus.rc
-rw-r--r--. 1 root root  1635 5月  19 21:15 nexus.vmoptions

[root@localhost bin]# ./nexus run &


如果出现如下表示启动成功
-------------------------------------------------

Started Sonatype Nexus OSS 3.39.0-01

-------------------------------------------------

访问

远程访问:http://192.168.160.12:8081
或本地访问 :http://127.0.0.1:8081

远程访问防火墙可能会拦截,本地测试可以先把防火墙禁用。
[root@localhost ~]# systemctl status firewalld.service 
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 三 2022-06-15 21:52:53 CST; 2h 56min ago
     Docs: man:firewalld(1)
 Main PID: 731 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─731 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# systemctl disable firewalld.service

#当前版本是3.39.0-01(之前版本账号和密码自行查找)登录用户名是admin,密码位置在sonatype-work/nexus3/admin.password

[root@localhost nexus]# cd sonatype-work/nexus3/
[root@localhost nexus3]# ll
总用量 32
-rw-r--r--.   1 root root   36 6月  16 00:45 admin.password
drwxr-xr-x.   3 root root   21 6月  16 00:45 blobs
drwxr-xr-x. 333 root root 8192 6月  16 01:15 cache
drwxr-xr-x.   6 root root  113 6月  16 00:45 db
drwxr-xr-x.   3 root root   19 6月  16 00:45 elasticsearch
drwxr-xr-x.   3 root root   45 6月  16 00:44 etc
drwxr-xr-x.   2 root root    6 6月  16 00:44 generated-bundles
drwxr-xr-x.   2 root root   33 6月  16 00:44 instances
-rw-r--r--.   1 root root    4 6月  16 01:14 karaf.pid
drwxr-xr-x.   3 root root   18 6月  16 00:45 keystores
-rw-r--r--.   1 root root   14 6月  16 01:14 lock
drwxr-xr-x.   4 root root  145 6月  16 01:00 log
drwxr-xr-x.   3 root root   21 6月  16 00:43 orient
-rw-r--r--.   1 root root    5 6月  16 01:14 port
drwxr-xr-x.   2 root root    6 6月  16 00:45 restore-from-backup
drwxr-xr-x.   8 root root 4096 6月  16 01:15 tmp
[root@localhost nexus3]# cat admin.password 
3a2ae1b6-530b-4756-a248-f30a1971a005
登录之后修改密码为:admin

 优化配置

设置开机自启
[root@localhost bin]# ln -s /root/nexus/nexus-3.39.0-01/bin/nexus /etc/init.d/nexus3
[root@localhost bin]# chkconfig --add nexus3
[root@localhost bin]# chkconfig nexus3 on

配置运行用户

[root@localhost bin]# useradd nexus
[root@localhost bin]# pwd
//root/nexus/nexus-3.39.0-01/bin
[root@localhost bin]# vim nexus.rc

run_as_user="nexus"

配置之后记得更改目录权限,否则下次启动会没有权限。

[root@localhost nexus]# pwd
//root/nexus
[root@localhost nexus]# chown -R nexus.nexus nexus-3.39.0-01
[root@localhost nexus]# chown -R nexus.nexus sonatype-work/

配置jdk
[root@localhost bin]# pwd
//root/nexus/nexus-3.39.0-01/bin

[root@localhost bin]# cat nexus
#!/bin/sh
# chkconfig:         2345 75 15
# description:       nexus
### BEGIN INIT INFO
# Provides:          nexus
# Required-Start:    $local_fs $network $remote_fs $syslog $time
# Required-Stop:     $local_fs $network $remote_fs $syslog $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: nexus
### END INIT INFO

# Uncomment the following line to override the JVM search sequence
 INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/jdk1.8.0_144
# Uncomment the following line to add additional VM parameters
# INSTALL4J_ADD_VM_PARAMS=


修改端口

一般使用默认的,如果需要修改,则更改/root/nexus/nexus-3.39.0-01/etc/nexus-default.properties

参考网站:二丫讲梵https://wiki.eryajf.net/pages/1803.html官网网址https://www.sonatype.com/products/repository-pro/trial

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值