文章目录
1 安装jdk1.11
1.1 下载JDK
1.2 解压JDK
[root@localhost ~]# cd /usr/local/jdk
[root@localhost jdk]# tar -zxvf jdk-11.0.17.tar.gz
1.3 配置环境变量(非必须,nexus可指定)
编辑/etc/profile文件,在文件末尾添加以下内容:
[root@localhost ~]# vi /etc/profile
export JAVA_HOME=/usr/local/jdk/jdk-11.0.17
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
1.4 应用环境变量(非必须)
执行以下命令使配置生效:
[root@localhost ~]# source /etc/profile
1.5 验证安装(非必须)
执行以下命令检查JDK版本:
[root@localhost ~]# java -version
2 安装nexus3.7
2.1 下载Nexus
2.2 添加用户和用户组,授权目录
[root@localhost ~]# groupadd nexus
[root@localhost ~]# useradd -g nexus nexus
[root@localhost ~]# chown -R nexus:nexus /opt/nexus
2.3 解压Nexus
[root@localhost ~]# cd /opt/nexus
[root@localhost nexus]# tar -zxvf nexus-3.72.0-04-unix.tar.gz
2.4 指定 JDK 路径
[root@localhost ~]# vi /opt/nexus/nexus-3.72.0-04/bin/nexus
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/jdk/jdk-11.0.17
2.5 Nexus进程以普通用户身份运行
[root@localhost ~]# vi /opt/nexus/nexus-3.72.0-04/bin/nexus.rc
run_as_user="nexus"
2.6 创建软连接
[root@localhost ~]# ln -s /opt/nexus/nexus-3.72.0-04/bin/nexus /etc/init.d/nexus
2.7 启动脚本
[root@localhost ~]# vi /etc/systemd/system/nexus.service
[Unit]
Description=nexus service
After=network.target
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/nexus-3.72.0-04/bin/nexus start
ExecStop=/opt/nexus/nexus-3.72.0-04/bin/nexus stop
User=nexus
Restart=on-abort
TimeoutSec=600
[Install]
WantedBy=multi-user.target
2.8 设置开机自启
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl enable nexus.service
[root@localhost ~]# systemctl start nexus.service
2.9 检查服务
默认端口8081
[root@localhost ~]# ps ef|grep 8081
初始密码:
/opt/nexus/sonatype-work/nexus3
admin.password
3 迁移nexus
3.1 打包sonatype-work目录
[root@localhost ~]# cd /opt/nexus
[root@localhost nexus]# tar -czvf sonatyp-work.tar.gz ./sonatype-work
3.2 传送到新服务器
[root@localhost nexus]# scp sonatyp-work.tar.gz [email protected]:/opt/nexus
3.3 新服务器解压覆盖
[root@localhost nexus]# tar -xzvf sonatyp-work.tar.gz
3.4 授权目录
[root@localhost nexus]# chown nexus:nexus sonatyp-work
附录
遇到问题,启动怎么查看日志
./nexus run >> …/my-nexus.log