安装
一般远程调用下载软件,一般文件路径类型是http,下载https文件需要一个认证指令,即wget 后面加上--no-check-certificate
wget --no-check-certificate https://download.sonatype.com/nexus/3/latest-unix.tar.gz
#解压文件
tar -zxvf nexus-3.19.1-01-unix.tar.gz -C ../software/
[maven@bogon software]$ ls
nexus-3.19.1-01 sonatype-work
#修改配置文件
cd /home/maven/software/nexus-3.19.1-01/etc
vi nexus-default.properties
修改host为对用服务器的ip
application-host=192.168.1.10
#启动nexus
cd /home/maven/software/nexus-3.19.1-01/bin
./nexus start
#查看启动日志
cd /home/maven/software/sonatype-work/nexus3/log
tail -f nexus.log
#查看链接日志
tail -f nexus-request.log
#登录nexus manager
http://192.168.1.10/nexus
用户名 admin 密码存在/home/maven/software/sonatype-work/nexus3/ 下的admin.password中
b046cac7-e7ec-4514-9f59-4c15373a1178
创建maven(proxy)代理
Aliyun https://maven.aliyun.com/nexus/content/groups/public/
在maven-public仓库中添加Aliyun成员
添加maven仓库角色
添加maven用户
配置本地maven的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>E:\mavenRepository</localRepository>
<servers>
<server>
<id>maven-public</id>
<!--创建的maven用户名和密码-->
<username>kathryn</username>
<password>kathryn</password>
</server>
</servers>
<mirrors>
<mirror>
<id>maven-public</id>
<!--*:表示访问maven-public中所有成员-->
<mirrorOf>*</mirrorOf>
<name>maven-public</name>
<!--nexus中maven-public的url-->
<url>http://192.168.1.10/nexus/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>maven-public</id>
<url>http://maven-public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven-public</id>
<url>http://maven-public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
设置nexus开机自启动
新建nexus启动脚本
进入/etc/init.d目录,新建脚本文件nexus.sh
脚本内容:
#!/bin/bash
#chkconfig:0001 20 90
#description:nexus
#processname:nexus
source /etc/profile
#export JAVA_HOME=/root/app/jdk1.8
export NEXUS_HOME=/home/maven/app/nexus-3.21.1-01
case $1 in
start) sh $NEXUS_HOME/bin/nexus start;;
stop) sh $NEXUS_HOME/bin/nexus stop;;
status) sh $NEXUS_HOME/bin/nexus status;;
restart) sh $NEXUS_HOME/bin/nexus restart;;
dump) sh $NEXUS_HOME/bin/nexus dump;;
console) sh $NEXUS_HOME/bin/nexus console;;
*) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
设置脚本权限
[root@linux_maven init.d]#
chmod 755 /etc/init.d/nexus.sh
使用service命令查看nexus状态:
systemctl status nexus
添加到开机启动
chkconfig nexus.sh on
查看nexus开机启动
chkconfig --list nexus.sh
结果:
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