关于nexus

Nexus也是一种远程仓库,那Nexus的作用是:为了节省带宽和时间,在局域网内架设一个私有的仓库服务器,用其代理所有外部的远程仓库。例如当本地Maven项目需要下载构件时,先去私服请求,如果私服没有,则再去远程仓库请求,从远程仓库下载构件后,把构件缓存在私服上。这样,即使暂时没有Internet链接,由于私服已经缓存了大量构件,整个项目还是可以正常使用的。

基础环境

服务器:
test12:192.168.37.13
系统版本:CentOS Linux release 7.6.1810 (Core)

Maven安装

因为nexus经常用到用maven去下载java项目需要的构件,下面就先介绍一下maven的安装
1、到官网上下载安装包:http://maven.apache.org/download.cgi
2、解压到指定目录下:tar -zxvf apache-maven-3.6.1-bin.tar.gz -C /usr/local
3、添加环境变量

[root@test13 ~]# cat /etc/profile.d/maven.sh 
#MAVEN
MAVEN_HOME=/usr/local/apache-maven-3.6.1
export MAVEN_HOME
PATH=$PATH:$MAVEN_HOME/bin
export PATH
[root@test13 ~]# source /etc/profile.d/maven.sh 
[root@test13 ~]# mvn -version
安装:

1、下载安装包:https://www.sonatype.com/download-oss-sonatype
2、安装java环境,下载jdk的rpm包直接安装即可
3、把下载下来的nexus的tar包解压到指定目录,会在解压的目录下生成nexus和sonatype-work两个目录
tar zxvf nexus-3.16.2-01-unix.tar.gz -C /usr/local/
4、创建nexus用户:useradd nexus -M -s /sbin/nologin
5、把解压后的那个目录所有者更改为nexus:
chown nexus.nexus /usr/local/nexus-3.16.2-01 -R
chown nexus.nexus /usr/local/sonatype-work -R
6、把/usr/local/nexus-3.16.2-01/bin/nexus.rc注释去掉并设置为nexus用户
run_as_user=”nexus”
7、添加为服务

[root@test13 ~]# cat /etc/systemd/system/nexus.service 
[Unit]
Description=nexus service
After=network.target

[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/usr/local/nexus-3.16.2-01/bin/nexus start
ExecStop=/usr/local/nexus-3.16.2-01/bin/nexus stop
User=nexus
Restart=on-abort

[Install]
WantedBy=multi-user.target

8、刷新、启动服务并添加到开机启动
systemctl daemon-reload
systemctl start nexus.service
systemctl enable nexus.service
9、访问地址:http:ip:8081,默认帐号:admin 密码:admin123

升级迁移
文档更新时间: 2019-06-11 17:46   作者:子木