zoukankan      html  css  js  c++  java
  • [代码上线]-Nexus私有仓库

    第1章 安装Nexus私服

    以下操作在Nexus服务器进行:

    1.安装JDK和Nexus

    Nexus下载地址:

    https://www.sonatype.com/download-oss-sonatype
    

    安装命令:

    yum install java -y
    tar zxf nexus-3.23.0-03-unix.tar.gz -C /opt/
    cd /opt/
    ln -s nexus-3.23.0-03 nexus
    

    2.创建普通用户并更改权限

    useradd nexus -s /sbin/nologin
    chown -R nexus:nexus /opt/
    

    3.创建systemd启动服务

    cat >/usr/lib/systemd/system/nexus.service<<EOF
    [Unit]
    Description=nexus
    
    [Service]
    ExecStart=/opt/nexus/bin/nexus start
    ExecStop=/opt/nexus/bin/nexus stop
    Type=forking
    User=nexus
    Group=nexus
    
    [Install]
    WantedBy=multi-user.target
    EOF
    

    4.修改jvm内存使用大小

    默认2G内存,我们修改为1G

    vim /opt/nexus/bin/nexus.vmoptions
    -Xms1024m
    -Xmx1024m
    -XX:MaxDirectMemorySize=1024m
    

    5.启动并检查

    systemctl daemon-reload 
    systemctl start nexus
    netstat -lntup|grep 8081
    ps -ef|grep java
    

    6.配置账户密码

    打开浏览器并登陆

    http://10.0.0.202:8081/
    

    默认账号为admin,初始密码保存在文件里:

    cat /opt/sonatype-work/nexus3/admin.password
    

    7.初始化操作

    登录后需要我们修改密码:

    然后禁用匿名用户访问:

    8.启动排错

    报错1:提示找不到配置

    解决方法:

    删除 /opt/sonatype-work/nexus3目录即可,重新启动就会重新生成,这个目录是压缩包里自带的

    rm -rf /opt/sonatype-work/nexus3/
    

    报错2:提示无法锁定

    解决方法:

    使用普通用户登录后会在启动用户的家目录下创建.java的隐藏文件,如果普通用户没有家目录就会报错

    解决方法是创建启动用户的家目录,但是禁止登陆

    mkdir /home/nexus
    chown -R nexus:nexus /home/nexus
    

    错误3: 提示超时

    解决方法:

    系统设置里disable服务

    第2章 配置Nexus仓库代理地址为国内源

    1.默认仓库说明

    maven-central:maven中央库,默认从https://repo1.maven.org/maven2/拉取jar
    maven-releases:私库发行版jar,初次安装请将Deployment policy设置为Allow redeploy
    maven-snapshots:私库快照(调试版本)jar
    maven-public:仓库分组,把上面三个仓库组合在一起对外提供服务,在本地maven基础配置settings.xml或项目pom.xml中使用
    

    2.仓库类型

    Group:这是一个仓库聚合的概念,用户仓库地址选择Group的地址,即可访问Group中配置的,用于方便开发人员自己设定的仓库。maven-public就是一个Group类型的仓库,内部设置了多个仓库,访问顺序取决于配置顺序,3.x默认Releases,Snapshots,Central,当然你也可以自己设置。	
    Hosted:私有仓库,内部项目的发布仓库,专门用来存储我们自己生成的jar文件
    3rd party:未发布到公网的第三方jar (3.x去除了)
    Snapshots:本地项目的快照仓库
    Releases: 本地项目发布的正式版本
    Proxy:代理类型,从远程中央仓库中寻找数据的仓库(可以点击对应的仓库的Configuration页签下Remote Storage属性的值即被代理的远程仓库的路径),如可配置阿里云maven仓库
    Central:中央仓库
    Apache Snapshots:Apache专用快照仓库(3.x去除了)
    

    3.修改maven仓库地址

    将代理地址修改为阿里源:

    https://maven.aliyun.com/nexus/content/groups/public
    

    4.复制maven-public地址

    第3章 配置Maven使用Nexus仓库

    1.修改Maven配置文件

    <?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">
      <pluginGroups>
      </pluginGroups>
    
      <proxies>
      </proxies>
    
      <servers>
        <server>   
          <id>snapshots</id>   
          <username>admin</username>   
          <password>123456</password>   
        </server>   
        <server>   
          <id>releases</id>   
          <username>admin</username>   
          <password>123456</password>   
        </server>   
        <server>   
          <id>public</id>   
          <username>admin</username>   
          <password>123456</password>   
        </server>   
      </servers>
    
      <mirrors>
        <mirror>
          <id>public</id>
          <mirrorOf>*</mirrorOf>
          <url>http://10.0.0.202:8081/repository/maven-public/</url>
        </mirror>
      </mirrors>
    
      <profiles>
        <profile>
          <id>public</id>
          <repositories>
            <repository>
              <id>public</id>
              <url>http://10.0.0.202:8081/repository/maven-public/</url>
              <releases><enabled>true</enabled></releases>
              <snapshots><enabled>true</enabled></snapshots>
            </repository>
          </repositories>
          <pluginRepositories>
            <pluginRepository>
              <id>public</id>
              <url>http://10.0.0.202:8081/repository/maven-public/</url>
              <releases><enabled>true</enabled></releases>
              <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
          </pluginRepositories>
        </profile>
      </profiles>
    
      <activeProfiles>
        <activeProfile>public</activeProfile>
      </activeProfiles>
    
    </settings>
    

    2.测试重新构建

    3.检查结果

  • 相关阅读:
    指针
    初级程序员面试不靠谱指南(七)
    初级程序员面试不靠谱指南(六)
    Hadoop 中利用 mapreduce 读写 mysql 数据
    Mapreduce的文件和hbase共同输入
    mapreduce多文件输出的两方法
    mapreduce中一个map多个输入路径
    GDB介绍
    超强的指针学习笔记
    iOS开发之Appstore篇——版本更新
  • 原文地址:https://www.cnblogs.com/alaska/p/14911040.html
Copyright © 2011-2022 走看看