在windows上成功地安装了nexus(可能参看在windows XP下搭建nexus本地仓库一文),也在网上看过很多在linux下安装nexus的示例(这里包括官网),今天自己尝试在安装的时候却出现了各种问题,这再次说明了实践才是最重要的。
现在简述一下在ubuntu下面安装nexus的步骤(这里默认已经安装好了JDK,JDK的安装可以参考的我另一篇文章ubuntu10.0.4安装和卸载jdk):
1. 下载nexus 下载最新版nexus(到目前为止最新版为nexus-2.7.0-05,下载地址http://www.sonatype.org/nexus/go,得到nexus-latest-bundle.tar.gz
2. 下载完成后将nexus-latest-bundle.tar.gz拷贝到/usr/local/目录下,并进入/usr/local目录
#:sudo cp nexus-latest-bundle.tar.gz /usr/local/
#:cd /usr/local
3. 解压nexus-latest-bundle.tar.gz,得到nexus-2.7.0-05和sonatype-work,并做一个软链接
tar -zxvf nexus-latest-bundle.tar.gz
ln -s nexus-2.7.0-04 nexus2
4.运行nexus
cd nexus2
./bin/nexus start
如果运气好会运行成功,这里之所以说运气,是因为各种原因会造成运行失败,如果成功会看到如下显示信息:
Starting Nexus OSS....
Started Nexus OSS
如果失败会看到:
Starting Nexus OSS...
Failed to start Nexus OSS.
引起失败的原因可能是权限问题:nexus所在的安装目录属于私有权限,它的拥有者是root用户,这时需要将nexus所在的目录分配给当前用户(Nexus不建议用root权限启动运行nexus),这里的授权就自己去看chown命令的用法了;
如果安装成功但在浏览器中访问不了(访问默认地址:http://localhost:8081/nexus),通过查看wrapper.log日志可能会看到“Unable to start java JVM:No such file or directory",此时需要将wrapper.conf文件里面的wapper.java.command=java修改成wapper.java.command=%JAVA_HOME%/bin/java(就是安装jdk所在的文件路径);
此外还有各种异常出现,这里就不再罗列,大家遇到就自己上网google吧。
下面说下我在安装后启动时遇到的问题:
1. Unable to start java JVM:No such file or directory,解决方法,修改wapper.conf配置文件里面的wapper.java.command。我开始修改成wapper.java.command={JAVA_HOME}/bin/java,但根本不起作用,看网上很我资料也说是改成那样,最后无意中看到一篇文章(具体是哪篇忘记了)说是改wapper.java.command=%JAVA_HOME%/bin/java,要用%%而不是用{}。
2.还有一个问题就是启动时报如下异常
2.还有一个问题就是启动时报如下异常
/usr/local/nexus$ ./bin/nexus console
Running Nexus OSS...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | 2013-12-31 20:07:56 INFO [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - Starting with arguments: [./conf/jetty.xml]
jvm 1 | 2013-12-31 20:07:56 INFO [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - JVM ID: 1, JVM PID: 2594, Wrapper PID: 2592, User: linming
jvm 1 | 2013-12-31 20:07:56 INFO [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - Current directory: /usr/local/nexus-2.7.0-05
jvm 1 | 2013-12-31 20:07:57 INFO [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - Temp directory: /usr/local/sonatype-work/nexus/tmp
jvm 1 | 2013-12-31 20:07:57 ERROR [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - Failed to start
jvm 1 | java.nio.file.AccessDeniedException: /usr/local/sonatype-work/nexus/tmp
jvm 1 | at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[na:1.7.0_07]
jvm 1 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[na:1.7.0_07]
jvm 1 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[na:1.7.0_07]
jvm 1 | at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:382) ~[na:1.7.0_07]
jvm 1 | at java.nio.file.Files.createDirectory(Files.java:628) ~[na:1.7.0_07]
jvm 1 | at java.nio.file.Files.createAndCheckIsDirectory(Files.java:732) ~[na:1.7.0_07]
jvm 1 | at java.nio.file.Files.createDirectories(Files.java:718) ~[na:1.7.0_07]
jvm 1 | at org.sonatype.nexus.bootstrap.Launcher.ensureTmpDirSanity(Launcher.java:247) ~[nexus-bootstrap-2.7.0-05.jar:2.7.0-05]
jvm 1 | at org.sonatype.nexus.bootstrap.Launcher.start(Launcher.java:95) ~[nexus-bootstrap-2.7.0-05.jar:2.7.0-05]
解决方法:
sudo chmod -R 777 sonatype-work/nexus