Last active
December 12, 2017 02:38
-
-
Save wmydz1/349a4b2fa2c2a7206cc879f1c2d9849f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CentOS 7 下安装和配置 Sonatype Nexus 3.3 | |
| http://qizhanming.com/blog/2017/05/16/install-sonatype-nexus-oss-33-on-centos-7 | |
| 2017-05-16 | 标签: centos, java, sonatype nexus | |
| 前言 | |
| CentOS 7 下安装 Sonatype Nexus OSS 3.3 ,因为 3.1 以后,相比 3.0 配置文件发生了一些变化,记录一下大致的安装和配置过程。 | |
| Sonatype Nexus 一直是 Maven 仓库管理工具,Nexus 3.1 之后新增了很多功能。 | |
| 安装参考 How To Install Latest Sonatype Nexus 3 On Linux | |
| 配置参考 Configuration and Data Directory Changes for Nexus Repository Manager 3.1.0 | |
| 本例操作系统为 CentOS 7,命令基本一致。 | |
| 环境说明 | |
| CentOS 7(Minimal Install) | |
| 安装和配置步骤 | |
| 1.更新系统 | |
| $ sudo yum update | |
| 版本如下 | |
| $ cat /etc/redhat-release | |
| CentOS Linux release 7.3.1611 (Core) | |
| 2.安装 OpenJDK 1.8 | |
| $ sudo yum install java-1.8.0-openjdk.x86_64 | |
| 检验一下 | |
| $ java -version | |
| openjdk version "1.8.0_131" | |
| OpenJDK Runtime Environment (build 1.8.0_131-b11) | |
| OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode) | |
| 3.创建目录,并且 cd 进入这个目录 | |
| $ cd /opt | |
| 4.下载 Sonatype Nexus OSS 3(请根据实际情况下载最新版本) | |
| $ sudo curl -O https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.3.1-01-unix.tar.gz | |
| 5.解压 | |
| $ sudo tar -xzvf nexus-3.3.1-01-unix.tar.gz | |
| 6.创建链接 | |
| $ sudo ln -s nexus-3.3.1-01 nexus | |
| 7.创建 nexus 用户 | |
| $ sudo useradd nexus | |
| 8.授权 | |
| $ sudo chown -R nexus:nexus /opt/nexus | |
| $ sudo chown -R nexus:nexus /opt/sonatype-work/ | |
| 9.打开 /opt/nexus/bin/nexus.rc 文件, 去掉 run_as_user 变量的注释 | |
| $ sudo vi /opt/nexus/bin/nexus.rc | |
| run_as_user="nexus" | |
| 10.安装服务(本例以 systemd 为例) | |
| 创建服务文件 | |
| $ sudo vi /etc/systemd/system/nexus.service | |
| 添加如下内容 | |
| [Unit] | |
| Description=nexus service | |
| After=network.target | |
| [Service] | |
| Type=forking | |
| ExecStart=/opt/nexus/bin/nexus start | |
| ExecStop=/opt/nexus/bin/nexus stop | |
| User=nexus | |
| Restart=on-abort | |
| [Install] | |
| WantedBy=multi-user.target | |
| 安装并启动服务 | |
| $ sudo systemctl daemon-reload | |
| $ sudo systemctl enable nexus | |
| $ sudo systemctl start nexus | |
| 11.查看服务 | |
| $ sudo systemctl status nexus | |
| 12.添加防火墙规则 | |
| $ sudo firewall-cmd --zone=public --permanent --add-port=8081/tcp | |
| $ sudo firewall-cmd --reload | |
| 13.访问测试 | |
| 访问地址: http://ip:8081/ | |
| 访问凭证(默认的用户名和密码): | |
| username: admin | |
| password: admin123 | |
| 14.更改 nexus 的 context path | |
| 如需修改路径,编辑 /opt/sonatype-work/nexus3/etc/nexus.properties 文件即可 | |
| $ sudo vi /opt/nexus/nexus/etc/nexus.properties | |
| nexus-context-path=/nexus | |
| 重启服务 | |
| $ sudo systemctl restart nexus | |
| 访问测试 | |
| 地址 http://ip:8081/nexus | |
| 结束语 | |
| 本例安装和配置 Sonatype Nexus 3.3,步骤比较简单。但是版本更新还是个问题,因为每次都手动安装就比较费时了,如果能 yum 安装就比较方便了。 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment