Linux下Nexus私服搭建

来源:互联网 发布:淘宝分享代码下载 编辑:程序博客网 时间:2024/05/21 17:00
1.下载
Nexus 官方下载:http://www.sonatype.org/nexus/go, 
Nexus 最新版下载:http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
Nexus war下载:http://www.sonatype.org/downloads/nexus-latest.war
当前最新版地址:https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.5-02-bundle.tar.gz
nexus有两种安装实现方式,一种是war包的方式,将它直接放在例如tomcat下就可以启用的,还有一种源码的方式。
现在我们还是说说源码方式的。开始吧。。。
2.解压tar.gz文件
#cd /home/
#tar zxvf nexus-2.14.5-02-bundle.tar.gz
3.Nexus启动
nexus启动是在bin目录下,首先看一下启动/关闭/重启等命令, 输入命令:
#cd nexus-2.14.5-02/bin/
#./nexus
出现如下选项:
[root@HTDVPT111 bin]# ./nexus
Usage: ./nexus { console | start | stop | restart | status | dump }
启动nexus:
[root@HTDVPT111 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.
大概意思就是要在环境配置export RUN_AS_USER=root,临时配置
在命令行下输入:
export RUN_AS_USER=root
也可以在系统里面永久配置
#vi /etc/profile
加入export RUN_AS_USER=root
使配置生效
[root@HTDVPT111 bin]# source /etc/profile
然后执行,就不会再提示了
#./nexus start
关闭nexus: 
#./nexus stop
4.Nexus验证
启动nexus后,在浏览器输入地址: http://ip:8081/nexus
如果正常打开界面,说明配置nexus成功!
点击右上角“Log in”,输入用户名和密码(默认用户名:admin 密码:admin123)登录
5.设置
1.点击左侧菜单栏Views/Repositories下的Repositories选择Central仓库点击下边的Configuration把
Download Remote Indexes属性设为True保存即可
2.然后在Central仓库上右键然后点击Repair Index 即可下载中心仓库的索引文件,稍等几分钟点击下
边的Browse Index即可看见下载的索引文件。
如果这种在线更新索引的方法不行,nexus repair或update index没反应,那么可以手动下载索引导入,往下看。
6.手动配置nexus index
http://repo.maven.apache.org/maven2/.index/ 下载中心仓库最新版本的索引文件,
我们需要下载如下两个文件(一般在列表的末尾位置)  
nexus-maven-repository-index.gz 
nexus-maven-repository-index.properties 
下面就是解压这个索引文件,虽然后缀名为gz,但解压方式却比较特别,
我们需要下载一个jar包indexer-cli-5.1.1.jar,我们需要通过这个特殊的jar来解压这个索引文件 
将上面三个文件(.gz & .properties & .jar)放置到同一目录下,运行如下命令:
java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d indexer
等待程序运行完成之后可以发现indexer文件夹下出现了很多文件
然后关闭nexus: 
#./nexus stop
删除目录{nexus-home}/sonatype-work/nexus/indexer/central-ctx下的所有文件,否则每次重启nexus后他都会把手动下载的索引清理掉
最后将indexer文件下下的这些文件移动到{nexus-home}/sonatype-work/nexus/indexer/central-ctx目录下
例:mv /home/indexer/* /home/sonatype-work/nexus/indexer/central-ctx
重新启动nexus
#./nexus start
进入管理界面,选择central->Browse Index,就看到更新的索引了。
注1:中央仓库的jar都在这里面:{nexus-home}/sonatype-work/nexus/storage/central/
注2:默认的中央仓库https://repo1.maven.org/maven2/可能比较慢,
可以换成国内的阿里云http://maven.aliyun.com/nexus/content/groups/public/
ok,私服搭建成功!
原创粉丝点击