• CentOS系统中安装Nexus并导入已有的构件库


    Nexus是Maven仓库管理器,用于搭建一个本地仓库服务器,这样做的主要的好处就是节约网络资源,速度快,开发团队中所有的Maven可以共享这个本地仓库,下载一遍共享使用。另外一个优点就是他为你的组织提供一个搭建构件的地方。本文将介绍如何在CentOS系统中安装配置Nexus,并介绍如何导入已有的构件仓库。

    1、 软件

    a) 下载Nexus 地址:http://www.sonatype.org/downloads/nexus-2.1.2-bundle.tar.gz
    b) 如无特殊说明,本文档操作用户为nexus
    c) nexus默认的管理员用户名密码是:admin/admin123

    2、 安装

    a) 解压

    1 $ tar zxvf nexus-2.1.2-bundle.tar.gz

    b) 移动到其他目录

    1 $ mv nexus-2.1.2 /home/nexus/nexus

    c) 设置为系统自启动服务(使用root用户)

    1 # cd /etc/init.d/
    2 # cp /home/nexus/nexus/bin/jsw/linux-x86-64/nexus nexus

    编辑/etc/init.d/nexus文件,添加以下变量定义:

    1 NEXUS_HOME=/home/nexus/nexus
    2 PLATFORM=linux-x86-64
    3 PLATFORM_DIR="${NEXUS_HOME}/bin/jsw/${PLATFORM}"


    修改以下变量:

    1 WRAPPER_CMD="${PLATFORM_DIR}/wrapper"
    2 WRAPPER_CONF="${PLATFORM_DIR}/../conf/wrapper.conf"
    3 PIDDIR="${NEXUS_HOME}"

    修改如下变量,设置启动用户为nexus:

    1 RUN_AS_USER=nexus

    执行命令添加nexus自启动服务

    1 # chkconfig –add nexus
    2 # chkconfig –levels 345 nexus on

    执行如下命令启动、停止nexus服务

    1 # service nexus start
    2 # service nexus stop

    d) 检查是否启动成功

    在本机浏览器中访问URL: http://localhost:8081/nexus
    会出现Nexus的欢迎页面
    注:如果想远程通过浏览器访问,则在远程浏览器中输入http://<ip>:8081/nexus
    <ip> 可通过在本地机器上输入命令 ifconfig 查看
    如果未能访问到nexus的欢迎页面,需要查看本机的防火墙设置,是否打开了端口8081

    e) 修改配置

    配置文件位置nexus/conf/nexus.properties,配置示例如下:

     1 # Sonatype Nexus
     2 # ==============
     3 # This is the most basic configuration of Nexus.
     4 
     5 # Jetty section
     6 application-port=8081
     7 application-host=0.0.0.0
     8 nexus-webapp=${bundleBasedir}/nexus
     9 nexus-webapp-context-path=/nexus
    10 
    11 # Nexus section
    12 nexus-work=${bundleBasedir}/../sonatype-work/nexus
    13 runtime=${bundleBasedir}/nexus/WEB-INF
    14 pr.encryptor.publicKeyPath=/apr/public-key.txt

    主要配置参数:

    application-port:nexus启动端口
    nexus-work:指定构件库的存储位置

    3、 导入已有的构件库

    nexus的构件仓库都保存在sonatype-work目录中,该目录的位置由nexus/conf/nexus.properties配置文件指定。
    将已有的sonatype-work目录替换安装后的nexus的sonatype-work目录。
    修改sonatype-work/nexus/conf目录下的nexus.xml文件,修改<localStorage>节点下面的<url>子节点为真实路径即可,如central库的配置:

     1 <repository>
     2       <id>central</id>
     3       <name>Central</name>
     4       <providerRole>org.sonatype.nexus.proxy.repository.Repository</providerRole>
     5       <providerHint>maven2</providerHint>
     6       <localStatus>IN_SERVICE</localStatus>
     7       <notFoundCacheActive>true</notFoundCacheActive>
     8       <notFoundCacheTTL>1440</notFoundCacheTTL>
     9       <userManaged>true</userManaged>
    10       <exposed>true</exposed>
    11       <browseable>true</browseable>
    12       <writePolicy>READ_ONLY</writePolicy>
    13       <indexable>true</indexable>
    14       <searchable>true</searchable>
    15       <localStorage>
    16         <provider>file</provider>
    17         <url>file:/home/nexus/sonatype-work/nexus/storage/central</url>
    18       </localStorage>
    19       <remoteStorage>
    20         <provider>apacheHttpClient3x</provider>
    21         <url>http://repo1.maven.org/maven2/</url>
    22         <mirrors>
    23           <mirror>
    24             <id>http://repo.springsource.org/repo/</id>
    25             <url>http://repo.springsource.org/repo/</url>
    26           </mirror>
    27           <mirror>
    28             <id>http://gradle.artifactoryonline.com/gradle/libs</id>
    29             <url>http://gradle.artifactoryonline.com/gradle/libs</url>
    30           </mirror>
    31           <mirror>
    32             <id>http://repo.opengeo.org</id>
    33             <url>http://repo.opengeo.org</url>
    34           </mirror>
    35           <mirror>
    36             <id>http://repo.maven.apache.org/maven2</id>
    37             <url>http://repo.maven.apache.org/maven2</url>
    38           </mirror>
    39           <mirror>
    40             <id>http://search.maven.org</id>
    41             <url>http://search.maven.org</url>
    42           </mirror>
    43           <mirror>
    44             <id>http://repo1.maven.org/maven2/</id>
    45             <url>http://repo1.maven.org/maven2/</url>
    46           </mirror>
    47           <mirror>
    48             <id>http://download.osgeo.org/webdav/geotools/</id>
    49             <url>http://download.osgeo.org/webdav/geotools/</url>
    50           </mirror>
    51         </mirrors>
    52       </remoteStorage>
    53       <externalConfiguration>
    54         <proxyMode>ALLOW</proxyMode>
    55         <artifactMaxAge>-1</artifactMaxAge>
    56         <itemMaxAge>1440</itemMaxAge>
    57         <cleanseRepositoryMetadata>false</cleanseRepositoryMetadata>
    58         <downloadRemoteIndex>true</downloadRemoteIndex>
    59         <checksumPolicy>WARN</checksumPolicy>
    60         <repositoryPolicy>RELEASE</repositoryPolicy>
    61         <autoBlockActive>true</autoBlockActive>
    62         <fileTypeValidation>true</fileTypeValidation>
    63         <metadataMaxAge>1440</metadataMaxAge>
    64       </externalConfiguration>
    66 </repository>
  • 相关阅读:
    Ubuntu安装deb软件包错误(依赖关系问题)解决
    scrapy抓取的中文结果乱码解决办法
    删除Git记录里的大文件
    Ubuntu18.04 修改DNS
    linux实现ssh免密码登录
    Vim进阶指南
    查找相同图片并重命名
    Markdown进阶指南
    一眼看穿flatMap和map的区别
    Java8简明指南
  • 原文地址:https://www.cnblogs.com/gao241/p/2682026.html
Copyright © 2020-2023  润新知