从零开始搭建系统2.1——Nexus安装及配置

 

在安装配置Nexus时,请先确定您已经配置好jdk

1.创建目录

2.下载安装包

[root@localhost usr]# cd nexus

下载地址:https://www.sonatype.com/download-oss-sonatype

wget https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.9.0-01-unix.tar.gz

3.解压安装包

tar -zxvf nexus-3.9.0-01-unix.tar.gz

解压之后生成两个文件夹,分别为nexus-2.3.1-01、sonatype-work

 

4.启动

进入到bin目录下,执行./nexus start

解决上面的提示:

创建nexus用户

groupadd nexus#创建组

useradd nexus -g nexus#创建用户并将用户添加到组

 #修改文件所有者

chown -R nexus  /usr/nexus/

修改 nexus 脚本,指定启动用户

 

5.开启8081端口

添加

firewall-cmd --zone=public --add-port=8081/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=8081/tcp
查看所有打开的端口
firewall-cmd --zone=public --list-ports

 5.验证是否启动成功

http://192.168.0.200:8081

 

出现上述页面,说明配置nexus成功!

点击右上角“Log in”, 输入用户名和密码(默认用户名:admin      密码: admin123)登录。

6.开机启动

sudo ln -s /usr/nexus/nexus-3.9.0-01/bin/nexus /etc/init.d/nexus

使用
service nexus status/start/stop
查看nexus服务状态、启动服务、停止服务等

使用
chkconfig nexus on/off

设置nexus服务开机自启动或者开机不启动

 

如果启动不起来的话可以用下面方式启动,通过启动日志查找问题

service nexus start-launchd

7.配置nexus

新建store

 

8.proxy私仓,使用的外部私仓是阿里的仓库http://maven.aliyun.com/nexus/content/groups/public:

 

 9.release私仓

 

10.snapshot私仓

11.group私仓组

12.如何在项目中使用

settings.xml 配置

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<localRepository>D:\.m2\repository</localRepository>

<pluginGroups>
<pluginGroup>org.sonatype.plugins</pluginGroup>
</pluginGroups>

<proxies>
</proxies>

<servers>
<server>
<id>Releases</id>
<username>admin</username>
<password>admin123</password>
</server>

<server>
<id>Snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>

<mirrors>

<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.0.200:8081/repository/nexus-public/</url>
</mirror>
</mirrors>

<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></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>

</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

项目pom配置

<distributionManagement>
<repository>
<id>Releases</id>
<name>Releases</name>
<url>http://192.168.0.200:8081/repository/nexus-releases</url>
</repository>
<snapshotRepository>
<id>Snapshots</id>
<name>Snapshots</name>
<url>http://192.168.0.200:8081/repository/nexus-snapshots</url>
</snapshotRepository>
</distributionManagement>

 

 

13.直接deploy即可

 

 14.设置可重复deploy

如果需要可重复deploy同一个版本的jar包,可进行如下配置

 

 

 

posted @ 2018-03-24 13:24  C位出道  阅读(474)  评论(0编辑  收藏  举报