Nexus 安装部署
依赖
- jdk8
- 上传安装包到服务器(使用工具ftp|ssh)
- 解压安装包
tar -zxvf nexus-3.31.1-01-unix.tar.gz -C 指定路径
目录结构
- nexus-3.31.1-01:功能实现
- sonatype-work:存储数据
- 修改端口
# 配置文件路径 /nexus-3.31.1-01/etc/nexus-default.properties
# 66上端口 8089
- 基本命令
./nexus-3.31.1-01/bin/nexus start # 后台启动
./nexus-3.31.1-01/bin/nexus run # 前台启动
./nexus-3.31.1-01/bin/nexus stop # 停止
./nexus-3.31.1-01/bin/nexus restart # 重启
./nexus-3.31.1-01/bin/nexus status # 查看服务状态
- 开放端口
#ubuntu ubuntu
# Ubuntu
ufw allow tcp/端口号
ufw enable
- 访问服务
netstat -tunlp | grep 端口号 # 查看服务状态
浏览器输入服务器地址加nexus监听端口
输入用户名密码(根据提示到服务器指定路径)
修改密码
本地 maven 迁移至 Nexus
上传脚本
脚本放在本地仓库根目录下
#!/bin/bash
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
while getopts ":r:u:p:" opt; do
case $opt in
r) REPO_URL="$OPTARG"
;;
u) USERNAME="$OPTARG"
;;
p) PASSWORD="$OPTARG"
;;
esac
done
find . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;
执行脚本
./mavenimport.sh -u admin -p 123456 -r http://192.168.0.66:8089/repository/xunyi/