CentOS7 Nexus2 私服搭建

简单说明:

办公环境下需要Nexus私服为开发提供缓存服务,本博文简单记录办公环境下的Nexus2.X私服搭建步骤
Nexus官网:https://www.sonatype.com
需要下载OSS2.X的软件包:https://download.sonatype.com/nexus/oss/nexus-2.14.8-01-bundle.tar.gz
依据《CentOS7实验机模板搭建部署》克隆实验机

部署搭建:

# 主机名和hosts配置
HOSTNAME=nexus
hostnamectl set-hostname "$HOSTNAME"
echo "$HOSTNAME">/etc/hostname
echo "$(grep -E '127|::1' /etc/hosts)">/etc/hosts
echo "$(ip a|grep "inet "|grep -v 127|awk -F'[ /]' '{print $6}') $HOSTNAME">>/etc/hosts

# 配置安装jdk1.8
cd /usr/local/
tar -xf /tmp/jdk-8u172-linux-x64.tar.gz
echo 'export JAVA_HOME=/usr/local/jdk1.8.0_172'>>/etc/profile
echo 'export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib'>>/etc/profile
echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH'>>/etc/profile
source /etc/profile
java -version

# 配置安装Maven(非必需)
cd /usr/local/
unzip /tmp/apache-maven-3.5.2-bin.zip
echo 'export MAVEN_HOME=/usr/local/apache-maven-3.5.2'>>/etc/profile
echo 'export PATH=$PATH:$MAVEN_HOME/bin'>>/etc/profile
source /etc/profile
mvn --version

# 解压安装Nexus
cd /usr/local/
tar -xf /tmp/nexus-2.14.8-01-bundle.tar.gz

# 配置Nexus
cd /usr/local/nexus-2.14.8-01/bin
sed -i 's|^NEXUS_HOME=".*$|NEXUS_HOME="/usr/local/nexus-2.14.8-01"|g' nexus
sed -i 's/^#RUN_AS_USER.*/&\nRUN_AS_USER=root/g' nexus
sed -i 's|^#! /bin/sh$|#!/bin/bash|g' nexus
sed -i 's|^#!/bin/bash$|&\nJAVA_HOME=/usr/local/jdk1.8.0_172\nPLATFORM=linux-x86-64|g' nexus
cd /usr/local/nexus-2.14.8-01/bin/jsw/conf
sed -i 's|^wrapper.java.command=java$|wrapper.java.command=/usr/local/jdk1.8.0_172/bin/java|' wrapper.conf

# 配置开机启动
cat >/usr/lib/systemd/system/nexus.service<

网页配置:

Nexus2默认端口是:8081
Nexus2默认账号是:admin
Nexus2默认密码是:admin123
浏览器访问Nexus2主机的8081端口进行登录配置:
http://192.168.77.10:8081/nexus
配置过程略,涉及到国内网络访问较慢的问题,有些国外仓库需要寻找国内镜像源

迁移恢复:

将已经存在的Nexus私服缓存数据直接迁移到新搭建私服中:

# 新搭Nexus服务关闭
systemctl stop nexus.service
# 原Nexus服务关闭
systemctl stop nexus.service
# 数据同步迁移
cd /usr/local/sonatype-work/nexus
rm -rf *
scp -r 192.168.21.10:/usr/local/sonatype-work/nexus/* .
# 启动恢复
systemctl start nexus.service

[TOC]

你可能感兴趣的:(DevOps和生产中间件)