关闭

CentOS/Ubuntu安装nexus(Maven仓库管理器)

12987人阅读 评论(1) 收藏 举报
分类:
Nexus是一个强大的Maven仓库管理器,
它极大地简化了自己内部仓库的维护和外部仓库的访问。
利用Nexus你可以只在一个地方就能够完全控制访问和部署在你所维护仓库中的每个Artifact。
Nexus是一套“开箱即用”的系统不需要数据库,它使用文件系统加Lucene来组织数据。
Nexus使用ExtJS来开发界面,利用Restlet来提供完整的REST APIs,通过m2eclipse与Eclipse集成使用。
Nexus支持WebDAV与LDAP安全身份认证。

官网下载:

http://www.sonatype.org/nexus/archived/

http://www.sonatype.com/download-oss-sonatype


建议:

1.下载"nexus-latest-bundle"比较稳定!

2.使用jdk1.7

3.使用nexus用户运行

JDK安装:jdk安装  https://github.com/loveshareme/docs/blob/master/Jdk1.8.0_121.md

我的准备:

 CentOS Linux release 7.1.1503 (Core) / Ubuntu-14.04.5 LTS trusty
 nexus-latest-bundle.tar.gz
 jdk-7u80-linux-x64.tar.gz

注:最终启动,如果远程访问关闭,或者是stoped的nexus的jre版本和本地jre的version不符合(一般1.7就ok)!

1:解压:

root@server:/home/temp# ll
-rw-rw-r-- 1 server server 153530841 Mar 14  2017 jdk-7u80-linux-x64.tar.gz
-rw-rw-r-- 1 server server  45585753 Mar 14  2017 nexus-latest-bundle.tar.gz
root@server:/home/temp# mkdir nexus
root@server:/home/temp# tar zxvf nexus-latest-bundle.tar.gz -C /home/temp/nexus
root@server:/home/temp# cd nexus
root@server:/home/temp/nexus# ll
drwxr-xr-x 8 root   root   4096 May 28  2014 nexus-2.8.1-01/
drwxr-xr-x 3 root   root   4096 May 28  2014 sonatype-work/
root@server:/usr/local/nexus# cd ..

注:安装nexus,本地仓库默认的jar包存储位置是:/sonatype-work/nexus/storage/central。由于Central仓库占用存储较大,所以要注意存储位置。

2:移动位置合适位置:

root@server:/usr/local/nexus# cd ..
root@server:/usr/local# mv nexus/ /usr/local/

3:修改配置文件1:vim /usr/local/nexus/nexus-2.8.1-01/conf/nexus.properties 
# 配置端口信息
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
# 配置IP端口访问
# http://192.168.10.56:8081/nexus/
# 自定义:/nexus修改为: /
nexus-webapp-context-path=/

# Nexus section
#配置work目录地址,Maven仓库JAR缓存地址,可修改其他地址eg:${bundleBasedir}/nexus-work/nexus 
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF
4:修改配置文件2:vim /usr/local/nexus/nexus-2.8.1-01/bin/nexus
………………
#NEXUS_HOME=".."
#如果目录改变配置,如果修改了运行路径
NEXUS_HOME="/usr/local/nexus/nexus-2.8.1-01"
……………………
#RUN_AS_USER=
#nexus启动用户,root会有提示,推荐使用自定义用户
RUN_AS_USER=nexus
注:nexus很依赖于jdk,编写,所以必须安装好jdk并设置环境变量/etc/profile并生效!备注附件!

4.1 修改配置文件3:vim /usr/local/nexus/nexus-2.8.1-01/bin/jsw/conf/wrapper.conf
# Set the JVM executable
# (modify this to absolute path if you need a Java that is not on the OS path)
#wrapper.java.command=java
修改为jdk路径:
wrapper.java.command=/usr/local/jdk1.7.0_80/bin/java
注:此处jdk配置:vim /etc/profile   source /etc/profile
#JDK
export JAVA_HOME=/usr/local/jdk1.7.0_80
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib:.
[root@CentOS-Slave1 metrics]# pwd
/home/nexus/nexus-2.11.1-01/nexus/WEB-INF/classes/org/sonatype/nexus/webapp/metrics
[root@CentOS-Slave1 metrics]# ls
DeadlockHealthCheckProvider.class  HealthCheckMediator.class  MetricsModule$1.class  MetricsModule$2.class  MetricsModule.class
4.2 添加用户和组:
groupadd nexus
useradd nexus -g nexus -d /usr/local/nexus -s /bin/sh

4.3归属:
chown -R nexus: /usr/local/nexus/

5:启动nexus服务:
[root@CentOS-Slave1 bin]# /usr/local/nexus/nexus-2.8.1-01/bin/nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.
警告:不推荐作为root用户运行.
/usr/local/nexus/nexus-2.8.1-01/bin/nexus status
Nexus OSS is running (1095).
/usr/local/nexus/nexus-2.8.1-01/bin/nexus stop
6:nexus启动日志:
[root@CentOS-Slave1 logs]# pwd
/home/nexus/nexus-2.11.1-01/logs
[root@CentOS-Slave1 logs]# tail -f wrapper.log 
……………………
xceptionMapper
jvm 1    | 2015-10-18 16:38:29,492+0800 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.rest.NexusApplication_UriMatching - Strict URI matching: true
jvm 1    | 2015-10-18 16:38:29,816+0800 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.configuration.ModelUtils - Loading model /home/nexus/sonatype-work/nexus/conf/ldap.xml
jvm 1    | 2015-10-18 16:38:29,873+0800 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.configuration.ModelUtils - Loading model /home/nexus/sonatype-work/nexus/conf/lvo-plugin.xml
jvm 1    | 2015-10-18 16:38:30,994+0800 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.webresources.internal.WebResourceServiceImpl - Discovered 1973 resources
jvm 1    | 2015-10-18 16:38:30,996+0800 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.webresources.internal.WebResourceServlet - Max-age: 30 days (2592000 seconds)
jvm 1    | 2015-10-18 16:38:31,132+0800 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.bootstrap.jetty.InstrumentedSelectChannelConnector - Metrics enabled
jvm 1    | 2015-10-18 16:38:31,166+0800 INFO  [jetty-main-1] *SYSTEM org.eclipse.jetty.server.AbstractConnector - Started InstrumentedSelectChannelConnector@0.0.0.0:8081
jvm 1    | 2015-10-18 16:38:31,166+0800 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Running
jvm 1    | 2015-10-18 16:38:31,166+0800 INFO  [WrapperListener_start_runner] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Started

注:启动日志:*SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Started则,启动成功!
用浏览器访问:http://192.168.10.56:8081/

7:nexus开机启动:

[root@CentOS-Slave1 bin]# pwd
/home/nexus/nexus-2.11.1-01/bin
[root@CentOS-Slave1 bin]# ls
jsw  nexus  nexus.bat
[root@CentOS-Slave1 bin]# cp nexus /etc/rc.d/init.d/
[root@CentOS-Slave1 bin]# cd /etc/rc.d/init.d/
[root@CentOS-Slave1 init.d]# ls
functions  jexec  mysql  netconsole  network  nexus  README
[root@CentOS-Slave1 init.d]# chkconfig --add nexus
[root@CentOS-Slave1 init.d]# chkconfig --list | grep nexus 

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

nexus          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
[root@CentOS-Slave1 init.d]# chkconfig nexus on
[root@CentOS-Slave1 init.d]# chkconfig --list | grep nexus 

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

nexus          	0:off	1:off	2:on	3:on	4:on	5:on	6:off

问题1:

[root@CentOS-Slave1 bin]# ./nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.

解决1:上:4:修改配置文件2:/home/nexus/nexus-2.11.1-01/bin/nexus ---> RUN_AS_USER=root

备注附件:

安装jdk:

[root@CentOS-Slave1 install-files]# rpm -ivh jdk-8u60-linux-x64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8.0_60-2000:1.8.0_60-fcs    ################################# [100%]
Unpacking JAR files...
	tools.jar...
	plugin.jar...
	javaws.jar...
	deploy.jar...
	rt.jar...
	jsse.jar...
	charsets.jar...
	localedata.jar...
	jfxrt.jar...
[root@CentOS-Slave1 install-files]# vim /etc/profile
……………………
#jdk
export JAVA_HOME=/usr/java/jdk1.8.0_60
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib:.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
[root@CentOS-Slave1 install-files]# source /etc/profile

参数说明:

nexus的仓库类型分为以下四种:group: 仓库组,hosted:宿主 ,proxy:代理,virtual:虚拟
仓库组和多个仓库:
Public Repositories:  仓库组
3rd party: 无法从公共仓库获得的第三方发布版本的构件仓库
Apache Snapshots: 用了代理ApacheMaven仓库快照版本的构件仓库
Central: 用来代理maven中央仓库中发布版本构件的仓库
Central M1 shadow: 用于提供中央仓库中M1格式的发布版本的构件镜像仓库
Codehaus Snapshots: 用来代理CodehausMaven 仓库的快照版本构件的仓库
Releases: 用来部署管理内部的发布版本构件的宿主类型仓库
Snapshots:用来部署管理内部的快照版本构件的宿主类型仓库
maven的pom.xml设置1:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
	<localRepository>T:\developer\maven-repository</localRepository>
	<mirrors>
		<mirror>
			<!--This sends everything else to /public -->
			<id>nexus</id>
			<mirrorOf>*</mirrorOf>
			<url>http://nexus.loveshare.me/content/groups/public/</url>
		</mirror>
	</mirrors>
	<profiles>
		<profile>
			<id>nexus</id>
			<!--Enable snapshots for the built in central repo to direct -->
			<!--all requests to nexus via the mirror -->
			<repositories>
				<repository>
					<id>central</id>
					<url>http://nexus.loveshare.me/content/groups/public/</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</repository> 
			</repositories>
			<pluginRepositories>
				<pluginRepository>
					<id>central</id>
					<url>http://nexus.loveshare.me/content/groups/public/</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</pluginRepository>
			</pluginRepositories>
		</profile>
	</profiles>
	<activeProfiles>
		<!--make the profile active all the time -->
		<activeProfile>nexus</activeProfile>
	</activeProfiles>
	 
</settings>
maven的pom.xml设置2:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>T:\developer\maven-repository</localRepository>
  <pluginGroups></pluginGroups>
  <proxies></proxies>
  <servers></servers>
  <mirrors>
	<mirror>
        <id>nexus-loveshare</id>
        <mirrorOf>*</mirrorOf>
        <name>Nexus loveshare</name>
        <url>http://nexus.loveshare.me/content/groups/public/</url>
    </mirror> 
  </mirrors>
  <profiles></profiles>
</settings>


9
0
查看评论
发表评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场

CentOS7安装配置Nexus

最近闲来没事,就自己在linux上试着安装配置了Nexus,原以为很难的样子,主要自己动了手才发现其实也就那么一回事。 下载          Nexus下载地址:http://www.sonatyp...
  • dandanzmc
  • dandanzmc
  • 2016-07-17 22:17
  • 2757

CentOS Nexus安装与使用

上一篇文章“CentOS Maven安装与使用”已经介绍了Maven的安装与使用,那么我们下面开始创建Nexus实现私服的功能。 1、Nexus下载 点击链接“nexus-2.3.1-bundle.t...
  • Jay_1989
  • Jay_1989
  • 2016-10-08 15:30
  • 1484

搭建nexus3版的maven私服(Centos7环境)

1.安装jdk1.8 关于jdk1.8的安装,请参考我的这篇博客在这里就不做赘述了: http://blog.csdn.net/yougoule/article/details/78188329 ...
  • yougoule
  • yougoule
  • 2017-02-24 16:10
  • 6404

CentOS 下搭建maven仓库及安装nexus

1、搜索下载nexus-2.11.4-01-bundle.tar.gz 2、上传文件到目标机器,解压后  tar zxvf nexus-2.11.1-01-bundle.tar.gz  mv nexu...
  • u011350541
  • u011350541
  • 2016-11-07 15:00
  • 698

centos7下搭建nexus

1:下载nexus 下载路径:http://www.sonatype.org/nexus/archived/ 我下载的是:Nexus2.12.0-01 2:通过ftp上传到centos服务器上。 解压...
  • lishuai1028
  • lishuai1028
  • 2016-05-29 11:44
  • 2525

centos7.3 安装nexus-3.6

本地安装了jdk1.7   很多应用都使用该版本,但是mvn需要jdkk1.8版本,需求冲突,故做如下操作 一环境准备 环境: nexus3.6.0  ,jdk8 1,下载路径:http:/...
  • quanwei132
  • quanwei132
  • 2017-10-18 13:28
  • 806

Linux:CentOS7安装maven私服Nexus

一、下载Nexus的下载地址:https://www.sonatype.com/download-oss-sonatype 二、安装创建文件夹Neuxs,将下载的文件上传tar -zxvf n...
  • plei_yue
  • plei_yue
  • 2017-11-23 17:09
  • 112

CentOS安装Nexus:(一)安装Maven私服

使用Nexus搭建私服的主要背景是:我们做的是内容管理平台EMC Documentum产品的二次开发有很多平台所特有的第三方jar包需要管理,同时需要用Nexus简化内部仓库的维护和外部仓库的访问。有...
  • zhoushuren01
  • zhoushuren01
  • 2016-10-17 17:30
  • 774

centos7环境基于jenkins、nuget、nexus的netcore持续集成

centos7环境基于jenkins、nuget、mono、nexus的netcore持续集成
  • xqj198404
  • xqj198404
  • 2017-12-16 18:09
  • 77

CentOS安装nexus(Maven仓库管理器)

[plain] view plain copy Nexus是一个强大的Maven仓库管理器,   它极大地简化了自己内部仓库的维护和外部仓库的访问。   利用Nexu...
  • u013322876
  • u013322876
  • 2017-02-06 00:17
  • 206
    个人资料
    • 访问:852928次
    • 积分:7630
    • 等级:
    • 排名:第3279名
    • 原创:140篇
    • 转载:1篇
    • 译文:2篇
    • 评论:81条
    文章分类
    最新评论