CentOS7 安装 Nexus

目录

1. 安装启动Nexus

1.1 安装

1.2 启动 nexus

1.3 其他命令

2. 配置Nexus

1. 使用admin账户登录 , 然后点击齿轮(Configuration) > Repositories(仓库)

2. 配置ali的maven镜像,提高速度 (代理库)

3. 在group中加入ali镜像

4. 私有仓库(hosted)不用创建 , 使用原有的 maven-releases 和 maven-snapshots即可

3. 配置Maven客户端和pom.xml实现发布

1. 配置setting.xml

2. pom.xml配置


资源下载:评论区留下联系邮箱,阿里网盘暂不支持分享。
注意:安装nexus前,需要安装JDK

1. 安装启动Nexus

1.1 安装

1) 在usr/local目录下创建mysql安装目录:

cd /usr/local
mkdir soft/nexus

2) 将资源放在nexus文件下

3) 解压nexus文件

tar zxvf nexus-3.9.0-01-unix.tar.gz

4) 配置 nexus 环境变量

打开 etc/ 目录下的 profile 文件,命令如下

vim /etc/profile

把 nuxus 环境添加到 profile 尾部,环境代码如下

# nexus
export MAVEN_HOME=/usr/local/soft/nexus/nexus-3.9.0-01
export PATH=$PATH:$MAVEN_HOME/bin

注:/usr/local/nexus/nexus-3.9.0-01 为nexus的安装路径

5) 重新加载配置文件,让配置生效

# 重新加载profile文件,让配置生效
source profile

# 或者,这个命令在任何目录都可以操作 
source /etc/profile

1.2 启动 nexus

1) 进入 nexus 根目录下的 bin 目录,启动 nexus 服务

nexus start

2) 更改端口

  1. nexus 默认端口是 8081 , 如果我们的端口被占用了,则需要重新为 nexus 指定端口,端口的配置文件在安装目录下的 etc 目录
  2. 进入 etc 目录,找到 nexus-default.properties 文件
  3. 用 vim 打开 nexus-default.properties 文件

# Jetty section
application-port=8081
application-host=0.0.0.0

改为

# Jetty section
application-port=8084
application-host=0.0.0.0

这样我们就把 nexus 的端口从 8081 改为 8084 , 还需要重启 nexus服务

# 重启服务
nexus restart

3) 开启端口

# 开启8084端口
firewall-cmd --zone=public --add-port=8084/tcp --permanent

# 重启
firewall-cmd --reload

默认用户名/密码为 : admin/admin123

1.3 其他命令

# 启动
nexus start

# 停止
nexus stop

# 重启
nexus restart

# 查看状态
nexus status

2. 配置Nexus

1. 使用admin账户登录 , 然后点击齿轮(Configuration) > Repositories(仓库)

仓库有3类 , proxy(代理仓库-也就是别人的仓库) hosted(私有仓库 - 也就是自己的仓库) group(聚合仓库 - 一般引用都是使用这个库)

2. 配置ali的maven镜像,提高速度 (代理库)

阿里rep地址 : https://maven.aliyun.com/repository/public

1) 点击 Create repository

2) 选择maven2(proxy)

3) 点击 Create repository即可

3. 在group中加入ali镜像

找到maven-public的group仓库 , 点右边的>进入修改

在最下面 Group处 , 把ali的镜像加入

4. 私有仓库(hosted)不用创建 , 使用原有的 maven-releases 和 maven-snapshots即可

3. 配置Maven客户端和pom.xml实现发布

1. 配置setting.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <!-- 配置本地jar包存放路径 -->
    <localRepository>D:/repository</localRepository>
    <pluginGroups></pluginGroups>
    <proxies></proxies>
    <servers>
        <!-- 配置从nexus私服下载jar包所需要的账号密码 -->
        <server>
            <id>nexus</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
        <!-- 配置往nexus私服上传jar包所需要的账号密码 -->
        <server>
            <!--注意这个id  需要和pom.xml的对应-->
            <id>maven-releases</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
        <!-- 配置往nexus私服上传jar包所需要的账号密码 -->
        <server>
            <!--注意这个id  需要和pom.xml的对应-->
            <id>maven-snapshots</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
    </servers>
    <!-- 配置镜像代理 -->
    <mirrors>
        <mirror>
            <id>nexus</id>
            <mirrorOf>*</mirrorOf><!-- 配置为*的意思是将所有请求都转发到镜像仓库上 -->
            <url>http://172.16.150.132:8084/repository/maven-public/</url>
        </mirror>
        <!--这2个备用 以免在外网环境连不上私服-->
        <!--    <mirror>-->
        <!--        <id>alimaven</id>-->
        <!--        <mirrorOf>central</mirrorOf>-->
        <!--        <url>https://maven.aliyun.com/repository/public/</url>-->
        <!--    </mirror>-->
        <!--    <mirror>-->
        <!--        <id>alimaven_central</id>-->
        <!--        <mirrorOf>central</mirrorOf>-->
        <!--        <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>-->
        <!--    </mirror>-->
    </mirrors>
    <profiles>
        <profile>
            <id>nexus</id>
            <!--Override the repository (and pluginRepository) "central" from the Maven Super POM
                to activate snapshots for both! -->
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
        <profile>
            <id>jdk1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>nexus</activeProfile>
        <activeProfile>jdk1.8</activeProfile>
    </activeProfiles>
</settings>

2. pom.xml配置

在pom.xml中插入发布相关信息

<!-- 配置私服上传jar包地址 -->
<distributionManagement>
    <repository>
        <!-- release包上传地址 -->
        <id>maven-releases</id>
        <url>http://172.16.150.132:8084/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
        <!-- snapshots包上传地址 -->
        <id>maven-snapshots</id>
        <url>http://172.16.150.132:8084/repository/maven-snapshots/</url>
    </snapshotRepository>
</distributionManagement>

完成 , 可直接通过deploy发布到私服

查看私服是否有上传文件

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
您好!对于在CentOS 7下迁移Nexus,您可以按照以下步骤进行操作: 1. 在源服务器上备份Nexus数据:首先,您需要备份现有的Nexus数据。您可以通过将Nexus数据目录(默认情况下为/var/nexus)复制到另一个位置来实现。您可以使用如下命令进行备份: ``` cp -R /var/nexus /path/to/backup ``` 2. 安装新的Nexus服务器:在目标服务器上安装新的Nexus服务器。您可以从Nexus官方网站下载最新版本的二进制文件,并根据他们的安装说明进行安装。 3. 停止新的Nexus服务器:确保在迁移过程中停止新的Nexus服务器。您可以使用如下命令停止Nexus服务: ``` sudo systemctl stop nexus ``` 4. 迁移备份数据:将之前备份的Nexus数据复制到新的服务器上的相应位置。确保目录和文件权限正确,并且属于Nexus用户。 5. 更新新的Nexus服务器配置:打开新的Nexus服务器的配置文件(默认路径为/etc/nexus.properties)并更新以下配置项: - `nexus-work`:将其设置为新的Nexus数据目录路径。 - `application-host`:如果您想更改Nexus服务器的主机名或IP地址,可以在此处更新。 - 其他可能需要更改的配置项,如代理服务器设置等。 6. 启动新的Nexus服务器:启动新的Nexus服务器并确保它正常运行。您可以使用如下命令启动Nexus服务: ``` sudo systemctl start nexus ``` 7. 验证迁移:使用新的Nexus服务器的主机名或IP地址访问Nexus Web界面,并确保所有存储库和设置都已正确迁移。 请注意,此处提供的步骤仅供参考,实际操作可能因您的环境和需求而有所不同。在进行任何重要操作之前,请务必备份数据并谨慎操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值