`
gaoke
  • 浏览: 83460 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

6步搞定linux系统上搭建maven nexus服务

 
阅读更多

1.下载安装nexus

1.1下载安装nexus集成版

到这个地方http://www.sonatype.org/nexus/go 下载压缩包,根据linux的jdk版本选择不同版本的nexus安装包,jdk6只能下载2.5.1及以下版本,jdk7可支持到当前最新版本,nexus-2.9.X。

下载完成后将tar.gz包传到在linux指定目录新创建的文件夹,例如 mkdir /usr/nexus/n2.5.1下。

1.2.在线安装nexus集成版

如果linux可用wget命令,也可以直接在创建的目录下执行以下命令:

#wget http://download.sonatype.com/nexus/oss/nexus-2.5.1-bundle.tar.gz

2.创建用户并在相应目录下解压

#useradd maven

给用户授权 chown maven /usr/nexus

#su maven

#cd /usr/nexus/n2.5.1

#tar zxvf nexus-2.5.1-bundle.tar.gz

3.设置为系统服务(需root用户)

#su root

#cd  /etc/init.d

#cp /usr/nexus/n2.5.1/nexus-2.5.1-01/bin/jsw/linux-x86-64/nexus ./nexus

# chmod 755 nexus

# chkconfig --add nexus

# chkconfig --levels 345 nexus on

4. 编辑/etc/init.d/nexus的文本

4.1添加以下变量

RUN_AS_USER=maven ## 这个主要为了后面使用,不需要使用root用户启动服务

NEXUS_HOME=/usr/nexus/n2.5.1/nexus-2.5.1-01/

PLATFORM=linux-x86-64

PLATFORM_DIR="${NEXUS_HOME}/bin/jsw/${PLATFORM}"

4.2. 修改以下变量

WRAPPER_CMD="${PLATFORM_DIR}/wrapper"

WRAPPER_CONF="${PLATFORM_DIR}/../conf/wrapper.conf"

4.3将被#注释的PIDDIR放开,修改为对于maven用户具有读写权限的文件夹,例如:mkdir /home/maven/piddir。

PIDDIR="/home/maven/piddir"

5.启动nexus服务 

#service nexus start

显示如下信息即表示启动成功:

Starting Nexus OSS...

 

Started Nexus OSS.

 

如果不成功可通过service nexus console查看日志(也可在${NEXUS_HOME}/logs/wrapper.log中查看文本),根据报错内容寻找解决办法。

常见错误列举:

问题:Unable to start JVM: No such file or directory

解决办法:[NEXUS_HOME]/bin/jsw/conf/wrapper.conf中wrapper.java.command=/usr/java/jdk1.6.0_37/bin/java

[/usr/java/jdk1.6.0_37]为系统中的echo $JAVA_HOME出的绝对路径(尝试用变量未成功)

6启动之后,可以登录首页查看nexus的界面

http://192.168.1.26:8081/nexus/index.html

 

默认管理员用户名/密码: admin/admin123

 

maven客户端全局配置使用上面创建的私有仓库:

1.在mirrors标签下添加:

<mirror>

      <id>central</id>

      <mirrorOf>*</mirrorOf>

      <name>test-tools-server.</name>

      <url>http://10.105.76.236:8081/nexus/content/groups/public/</url>

    </mirror>

2.在frofiles标签下添加:

<profile>

 <id>central-repos</id>

      <repositories>

        <repository>

          <id>central</id>

          <name>Central</name>

          <url>http://central</url>

 <releases>

<enable>true</enable>

 </releases>

 <snapshots>

<enabled>true</enabled>

</snapshots>

        </repository>

      </repositories>

 <pluginRepositories>

     <pluginRepository>

       <id>central</id>

       <url>http://central</url>

       <releases><enabled>true</enabled></releases>

       <snapshots><enabled>true</enabled></snapshots>

     </pluginRepository>

   </pluginRepositories>

 

    </profile>

3.在settings标签底部,frofiles外添加:

<activeProfiles>

    <activeProfile>central-repos</activeProfile>

 

  </activeProfiles>

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics