-
Notifications
You must be signed in to change notification settings - Fork 0
create mvn repository
yangyp8110 edited this page Jan 17, 2018
·
1 revision
- nexus很依赖于jdk, 所以必须安装好jdk并设置环境变量/etc/profile并生效!
- Nexus 2.11 下载地址: http://www.sonatype.org/nexus/archived/#step2top
- maven 3.5 下载地址:http://maven.apache.org/download.cgi
- jdk 1.8
解压
apache-maven-3.5.0-bin.tar.gz
与nexus-2.11.4-01-bundle.tar.gz
[root@yyp softpackages]# tar xzf apache-maven-3.5.0-bin.tar.gz
# 解压缩
drwxr-xr-x. 6 root root 92 Apr 16 06:10 apache-maven-3.5.0
[root@yyp softpackages]# tar xzf nexus-2.11.4-01-bundle.tar.gz
# 得到两个解压包
drwxr-xr-x. 8 root root 4096 Jul 10 2015 nexus-2.11.4-01
drwxr-xr-x. 3 root root 35 Jul 9 2015 sonatype-work
将解压包移动到
/usr/local/install
[root@yyp ~]# vi /etc/profile
# maven 3.5
MAVEN_HOME=/usr/local/install/apache-maven-3.5.0
export MAVEN_HOME
export PATH=${PATH}:${MAVEN_HOME}/bin
#
- 配置立即生效
[root@yyp ~]# source /etc/profile
[root@yyp ~]# mvn -v
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T15:39:06-04:00)
Maven home: /usr/local/install/apache-maven-3.5.0
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /usr/local/install/jdk1.8.0_111/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-123.el7.x86_64", arch: "amd64", family: "unix"
- nexus解压有两个文件夹,mv到
/usr/local/install/nexus
下- 默认jar存放位置是sonatype-work里
- 配置
/usr/local/install/nexus/nexus-2.11.4-01/conf/nexus.properties
# Jetty section
# 配置端口信息
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
#配置IP端口访问
nexus-webapp-context-path=/nexus
# Nexus section
#配置work目录地址,Maven仓库JAR缓存地址,可修改其他地址eg:${bundleBasedir}/nexus-work/nexus
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF
- 配置
/usr/local/install/nexus/nexus-2.11.4-01/bin/nexus
,修改nexus路径与root用户启动:
#NEXUS_HOME=".."
#如果目录改变配置,如果修改了运行路径
NEXUS_HOME="/usr/local/install/nexus/nexus-2.11.4-01"
……………………
#RUN_AS_USER=
#nexus启动用户
RUN_AS_USER=root
- 修改jdk配置
/usr/local/install/nexus/nexus-2.11.4-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
wrapper.java.command=/usr/local/install/jdk1.8.0_111/bin/java
/nexus-2.11.4-01/nexus/WEB-INF/classes/org/sonatype/nexus/webapp/metrics/
[root@yyp install]# cd nexus/nexus-2.11.4-01/nexus/WEB-INF/classes/org/sonatype/nexus/webapp/metrics/
[root@yyp metrics]# pwd
/usr/local/install/nexus/nexus-2.11.4-01/nexus/WEB-INF/classes/org/sonatype/nexus/webapp/metrics
[root@yyp metrics]# ls
DeadlockHealthCheckProvider.class HealthCheckMediator.class MetricsModule$1.class MetricsModule$2.class MetricsModule.class
[root@yyp metrics]#
- 用户和组:
groupadd nexus
useradd nexus -g nexus -d /usr/local/nexus -s /bin/sh
- 归属:
chown -R nexus: /usr/local/nexus/
- 启动nexus服务:(警告:不推荐作为root用户运行.)
[root@yyp install]# nexus/nexus-2.11.4-01/bin/nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.
[root@yyp install]#
- 查看启动日志,启动成功
[root@yyp install]# tail -f nexus/nexus-2.11.4-01/logs/wrapper.log
……
……
ledjvm 1 | 2017-04-16 09:48:55,853-0400 INFO [jetty-main-1] *SYSTEM org.eclipse.jetty.server.AbstractConnector - Started InstrumentedSelectChannelConnec
tor@0.0.0.0:8081jvm 1 | 2017-04-16 09:48:55,854-0400 INFO [jetty-main-1] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Running
jvm 1 | 2017-04-16 09:48:55,854-0400 INFO [WrapperListener_start_runner] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Started
- 日志
*SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Started
表示启动成功。
访问 http://192.168.74.129:8081/nexus ,如下图所示,默认的用户名和密码:admin/admin123:
- 设置 nexus 开机启动:
[root@yyp install]# cd nexus/nexus-2.11.4-01/bin/
[root@yyp bin]# ls
jsw nexus nexus.bat
[root@yyp bin]# cp nexus /etc/rc
rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ rc.d/ rc.local
[root@yyp bin]# cp nexus /etc/rc.d/init.d/
[root@yyp bin]# cd /etc/rc.d/init.d/
[root@yyp init.d]# ls
functions iprdump iprinit iprupdate netconsole network nexus README
[root@yyp init.d]# chkconfig --add ne
netconsole network nexus
[root@yyp init.d]# chkconfig --add nexus
[root@yyp 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
[root@yyp init.d]# chkconfig nexus on
[root@yyp 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
[root@yyp init.d]#
maven可以通过http, ftp, ssh等deploy到远程服务器,也可以deploy到本地文件系统里。
<groupId>com.yangyp.common</groupId>
<artifactId>yangyp.common</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
- file 到本地路径
I:\private-maven-repository\
maven 里配置distributionManagement depoly到本地:
<distributionManagement>
<repository>
<id>yangyp-mvn-repo</id>
<url>file:I:\private-maven-repository\</url>
</repository>
</distributionManagement>
命令deploy到本地:
mvn deploy -DaltDeploymentRepository=yangyp-mvn-repo::default::file:I:\private-maven-repository
在路径I:\private-maven-repository\com\yangyp\common\yangyp.common\
可以看到deploy文件列表
1.0-SNAPSHOT
maven-metadata.xml
maven-metadata.xml.md5
maven-metadata.xml.sha1