CentOS 7 安装nexus

1、下载nexus ,使用版本nexus-3.13.0-01-unix.tar.gz,下载地址

https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.13.0-01-unix.tar.gz

2、解压后移动到安装目录(/opt/nexus)

创建安装目录

[root@ou Downloads]# mkdir /opt/nexus/

解压安装包到安装目录:

[root@ou Downloads]# tar -zxvf nexus-3.13.0-01-unix.tar.gz -C /opt/nexus/

切换到安装目录:

[root@ou Downloads]# cd /opt/nexus

查看目录详情:

[root@ou nexus]# lsnexus-3.13.0-01 sonatype-work

解压缩后可以看到有两个文件夹,第一个是nexus服务,第二个是它的私有仓库目录。 这时已经可以启动 nexus

进入位置:NEXUS_HOME/bin

本示例位置:

/opt/nexus/nexus-3.13.0-01/bin

进入bin目录:

[root@ou nexus]# cd nexus-3.13.0-01/bin[root@ou bin]# ./nexus start****************************************WARNING - NOT RECOMMENDED TO RUN AS ROOT****************************************If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.

当用root权限运行时会弹出提示,解决方式是

[root@ou bin]# vim nexus在配置文件上部找到#RUN_AS_USER=在下一行添加RUN_AS_USER=root具体示例:# the JVM and is not useful in situations where a privileged resource or# port needs to be allocated prior to the user being changed.#RUN_AS_USER=RUN_AS_USER=root

3、设置系统服务

3.1、添加 NEXUS_HOME 环境变量

vim /etc/profile

在后面添加

export NEXUS_HOME=/opt/nexus/nexus-3.13.0-01

使新加入的内容生效

source /etc/profile

3.2、添加本地jdk

vim /opt/nexus/nexus-3.13.0-01/bin/nexus

在文件中找到 INSTALL4J_JAVA_HOME_OVERRIDE 这一行(这一行默认被注释),添加上自己的JDK路径

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/java/jdk1.8.0_181-amd64

3.3、配置以 nexus 用户启动应用

nexus 官网建议不要使用 root 帐户启动应用,所以创建一个 nexus 用户

useradd nexus

修改 nexus 配置,使用 nexus 作为应用启动的帐户

gedit /opt/nexus/nexus-3.13.0-01/bin/nexus.rc

将内容修改为

run_as_user=”nexus”

修改 nexus 的目录权限

chown nexus nexus

3.4、设置系统服务(systemd)

vi /usr/lib/systemd/system/nexus.service[Unit]Description=nexusAfter=network.target[Service]Type=forkingExecStart=/opt/nexus/nexus-3.13.0-01/bin/nexus startExecReload=/opt/nexus/nexus-3.13.0-01/bin/nexus stopExecStop=/opt/nexus/nexus-3.13.0-01/bin/nexus stopPrivateTmp=true[Install]WantedBy=multi-user.target然后执行 systemctl daemon-reload,重新加载服务再执行 systemctl enable nexus,使该服务可以开机自启。启动服务 systemctl start nexus

4、登陆管理界面

默认管理地址为:http://localhost:8081/nexus/ 使用界面右上角log in进行默认用户的登陆,默认用户为:admin,密码为:admin123。

5、点击左侧的users查看当前系统的用户。

可以看到一共三个用户,admin,deployment和anonymous。admin:该用户拥有Nexus的全部权限,默认密码为admin123。deployment:该用户能够访问Nexus,浏览仓库内容、搜索、上传部署构件,但是不能对Nexus进行任何配置,默认密码为deployment123。anonymous:该用户对应了所有未登录的匿名用户,它们可以浏览仓库并进行搜索

6、集成Maven 打开本地 %M2_HOME%\conf\settings.xml 文件 6.1、设置本地仓库位置

<localRepository>/opt/apache-maven-3.5.4/repository</localRepository>

6.2、设置 Server

<server> <id>nexus-releases</id> <username>admin</username> <password>admin123</password></server><server> <id>nexus-snapshots</id> <username>admin</username> <password>admin123</password></server>

6.3、设置 Nexus 镜像(localhost 修改为安装 Nexus 的服务器地址)

<mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://localhost:8081/repository/maven-public/</url></mirror>

6.4、设置 Profile(localhost 修改为安装 Nexus 的服务器地址)

<profile> <id>nexus-resp</id> <repositories> <repository> <id>nexus-releases</id> <url>http://localhost:8081/repository/maven-releases/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> <repository> <id>nexus-snapshots</id> <url>http://localhost:8081/repository/maven-snapshots/</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus-plugin</id> <url>http://localhost:8081/repository/maven-public/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </pluginRepository> </pluginRepositories></profile>

6.5、设置默认激活的 profile

<activeProfiles> <activeProfile>nexus-resp</activeProfile></activeProfiles>

6.6、修改工程pom文件

<distributionManagement> <repository> <id>nexus-releases</id> <name>Team Nexus Release Repository</name> <url>http://localhost:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Team Nexus Snapshot Repository</name> <url>http://localhost:8081/repository/maven-snapshots/</url> </snapshotRepository></distributionManagement><repositories> <repository> <id>nexus-public</id> <name>Nexus public Repository</name> <url>http://localhost:8081/repository/maven-public</url> </repository></repositories> 
操作完成,执行 mvn deploy,应该就可以 Nexus 上查找到你当前项目了。 


【Nexus】--设置开机自启动

一枪尽骚丶魂 2018-12-17 12:00:48  2120  收藏 1
分类专栏: nexus Linux 文章标签: nexus nexus自启动

接上文《基于CentOS6.5安装Nexus》

1、新建nexus启动脚本

进入/etc/init.d目录,新建脚本文件nexus

​# vim /etc/init.d/nexus

脚本内容

  1.  
    #!/bin/bash
  2.  
     
  3.  
    #chkconfig:2345 20 90
  4.  
    #description:nexus
  5.  
    #processname:nexus
  6.  
     
  7.  
    export JAVA_HOME=/opt/server/jdk1.8.0_51
  8.  
     
  9.  
    case $1 in
  10.  
    start) su root /usr/local/nexus-3.14.0-04/bin/nexus start;;
  11.  
    stop) su root /usr/local/nexus-3.14.0-04/bin/nexus stop;;
  12.  
    status) su root /usr/local/nexus-3.14.0-04/bin/nexus status;;
  13.  
    restart) su root /usr/local/nexus-3.14.0-04/bin/nexus restart;;
  14.  
    dump) su root /usr/local/nexus-3.14.0-04/bin/nexus dump;;
  15.  
    console) su root /usr/local/nexus-3.14.0-04/bin/nexus console;;
  16.  
    *) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
  17.  
    esac

2、给脚本设置权限

# chmod +x /etc/init.d/nexus

3、使用service命令使用nexus

  1.  
    # service nexus status
  2.  
    WARNING: ************************************************************
  3.  
    WARNING: Detected execution as "root" user. This is NOT recommended!
  4.  
    WARNING: ************************************************************
  5.  
    nexus is running.

4、添加到开机启动

# chkconfig --add nexus

5、查看nexus开机启动

posted @   ianCloud  阅读(1865)  评论(0编辑  收藏  举报
编辑推荐:
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器
点击右上角即可分享
微信分享提示