devops
devops基础01--gitlab - omgasw - 博客园 (cnblogs.com)
devops基础02--jenkins - omgasw - 博客园 (cnblogs.com)
devops基础03--sonarqube - omgasw - 博客园 (cnblogs.com)
devops基础04--maven - omgasw - 博客园 (cnblogs.com)
devops基础06--maven pom.xml - omgasw - 博客园 (cnblogs.com)
devops基础05--nexus - omgasw - 博客园 (cnblogs.com)
$
$
$
nexus
Nexus是Maven的仓库管理器,用来搭建一个本地仓库服务器,这样做的好处便于管理,节约网络资源, 速度快
nexus的3个仓库和1个仓库组:
maven-central:maven中央仓库
maven-releases:maven的release项目部署到私服时存放的仓库
maven-snapshots:maven的snapshot项目部署到私服时存放的仓库
maven-public:仓库组包含以上3个
nexus的仓库类型:
proxy:代理仓库,最常用的就是maven的中央仓库
hosted:本地仓库
3rd party:第三方仓库
1.nexus install
1.安装包下载(下载OSS版本为免费版)
Download Repository OSS (sonatype.com)
nexus 3.x下载 3.18.1(maven 私服) - 陌陌卡上 - 博客园 (cnblogs.com)
2.安装jdk1.8,安装提示必须使用1.8版本,1.8以上版本会报错
[root@jenkins01 bin]# ./nexus --help
No suitable Java Virtual Machine could be found on your system.
The version of the JVM must be 1.8.
Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.
yum -y install java-1.8.0-openjdk.x86_64
3.nexus软件包为解压即用
[root@gitlab01 apps]# tar zxvf nexus-3.18.1-01-unix.tar.gz [root@gitlab01 apps]# pwd /apps [root@gitlab01 apps]# ls nexus-3.18.1-01 sonatype-work [root@gitlab01 apps]# cd nexus-3.18.1-01/bin/ [root@gitlab01 bin]# ls contrib nexus nexus.rc nexus.vmoptions [root@gitlab01 bin]# ./nexus --help WARNING: ************************************************************ WARNING: Detected execution as "root" user. This is NOT recommended! WARNING: ************************************************************ Usage: ./nexus {start|stop|run|run-redirect|status|restart|force-reload}
4.启动nexus
nexus run:实时启动,可以看到打印日志
nexus start:后台启动,日志可以到以下路径查看
[root@gitlab01 log]# pwd /apps/sonatype-work/nexus3/log [root@gitlab01 log]# ls audit jvm.log karaf.log nexus_cluster.log nexus.log request.log [root@gitlab01 log]# tail nexus.log -f
## 启动nexus
[root@gitlab01 bin]# ./nexus start
## 验证端口
[root@gitlab01 bin]# netstat -lntup|grep 8081 tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 131019/java
5.web端登录
访问web页面 http://IP:8081
## 登录
首次登录密码在以下路径,登录后修改密码即可
[root@gitlab01 bin]# cat /apps/sonatype-work/nexus3/admin.password 20ead757-5729-459a-8bf7-3cdf958903d8
2.修改中央仓库
http://maven.aliyun.com/nexus/content/groups/public
nexus使用
##
1.配置使用私服依赖
在maven的settings.xml进行以下配置:
<mirrors> ... <mirror> <id>nexus01</id> <mirrorOf>*</mirrorOf> <name>Nexus01</name> <url>http://10.1.10.71:8081/repository/maven-public/</url> </mirror> </mirrors>
2.将项目部署到私服
1.在nexus中将maven-releases和maven-snapshots的hosted设置为allow redeploy
2.在maven的settings.xml进行以下配置:
<servers> ... <server> <id>nexus01</id> <username>admin</username> <password>admin123</password> </server> ... </servers>
3.在要部署到nexus中的项目的pom.xml中,使用<distributionManagement>设置项目要存放的nexus仓库
<distributionManagement> <!--对应nexus中的maven-releases库--> <repository> <id>nexus01</id> <name>nexus-releases</name> <url>http://10.1.10.71:8081/repository/maven-releases/</url> </repository> <!--对应nexus中的maven-snapshots库--> <snapshotRepository> <id>nexus01</id> <name>nexus-releases</name> <url>http://10.1.10.71:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
##
<distributionManagement>的<repository>的id值必须与maven的settings.xml中的<server>的id值相同