CentOS安装Nexus:(一)安装Maven私服

一、概述

使用Nexus搭建私服的主要背景是:我们做的是内容管理平台EMC Documentum产品的二次开发有很多平台所特有的第三方jar包需要管理,同时需要用Nexus简化内部仓库的维护和外部仓库的访问。有了私服之后,当 Maven 需要下载构件时,直接请求私服,私服上存在则下载到本地仓库;否则,私服请求外部的远程仓库,将构件下载到私服,再提供给本地仓库下载。


二、前期准备

操作系统:CentOS Linux release 7.2.1511 (Core)

Nexus版本:nexus-2.14.0-01-bundle.tar.gz

Nexus下载路径:http://www.sonatype.org/nexus/archived/

JDK版本:jdk-8u101-linux-x64.rpm


三、解压Nexus

[java]  view plain  copy
  1. [root@localhost opt]# tar zxvf nexus-2.14.0-01-bundle.tar.gz  

注意:安装nexus,本地仓库默认的jar包存储位置是:/sonatype-work/nexus/storage/central。由于Central仓库占用存储较大,所以要注意存储位置。


四、移动到合适的位置:/usr/local

[java]  view plain  copy
  1. [root@localhost opt]# mv nexus-2.14.0-01 /usr/local  
[java]  view plain  copy
  1. [root@localhost opt]# mv sonatype-work/ /usr/local  


五、修改配置文件1:/usr/local/nexus-2.14.0-01/conf/nexus.properties

[java]  view plain  copy
  1. # Sonatype Nexus  
  2. # ==============  
  3. # This is the most basic configuration of Nexus.  
  4.   
  5. # Jetty section</span>  
[java]  view plain  copy
  1. #配置端口信息  
  2. application-port=8081  
  3. application-host=0.0.0.0  
  4. nexus-webapp=${bundleBasedir}/nexus  
[java]  view plain  copy
  1. <span style="font-size:14px;"><span style="font-size:10px;">#配置nexus应用名称,不用修改  
  2. nexus-webapp-context-path=/nexus  
  3.   
  4. # Nexus section  
  5. nexus-work=${bundleBasedir}/../sonatype-work/nexus  
  6. runtime=${bundleBasedir}/nexus/WEB-INF  
  7.   
  8. # orientdb buffer size in megabytes  
  9. storage.diskCache.bufferSize=4096  

六、修改配置文件2:

/usr/local/nexus-2.14.0-01/bin/nexus

[java]  view plain  copy
  1. # Set this to the root of the Nexus installation  
[java]  view plain  copy
  1. #建议使用绝对路径  
  2. NEXUS_HOME="/usr/local/nexus-2.14.0-01"  
  3.   
  4. # If specified, the Wrapper will be run as the specified user.  
  5.   
  6. # IMPORTANT - Make sure that the user has the required privileges to write into the Nexus installation directory.  
  7.   
  8. # NOTE - This will set the user which is used to run the Wrapper as well as  
  9. #  the JVM and is not useful in situations where a privileged resource or  
  10. #  port needs to be allocated prior to the user being changed.  
[java]  view plain  copy
  1. #设置为root用户启动,如果需要可设置为其他用户启动,不过需要用户赋予nexus home目录的操作权限  
  2. RUN_AS_USER=root  

七、启动Nexus

[java]  view plain  copy
  1. [root@localhost bin]# ./nexus start    
  2. ****************************************  
  3. WARNING - NOT RECOMMENDED TO RUN AS ROOT  
  4. ****************************************  
  5. Starting Nexus OSS...  
  6. Started Nexus OSS.  
  7. [root@localhost bin]#  

注意,这里不建议使用root用户来运行nexus,使用其他用户我们需要考虑一下文件系统的权限问题,不然程序可能无法启动,报出Permissiondenied错误 ,使用root用户执行如下命令 :

[java]  view plain  copy
  1. chmod -R o+w {nexus-home}/   
{nexus-home}表示nexus的根目录 
上面的命令将nexus整个文件夹(包括其子文件和子文件夹)向普通用户开放了write权限,于是我们就可以使用普通用户执行nexus脚本了,执行命令./nexusstart 


八、查看启动日志:

[java]  view plain  copy
  1. [root@localhost logs]# pwd  
  2. /usr/local/nexus-2.14.0-01/logs  
  3. [root@localhost logs]# ls  
  4. wrapper.log  
  5. [root@localhost logs]# tail -f wrapper.log   
  6. jvm 1    | 2016-10-17 06:29:45,193-0400 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.configuration.ModelUtils - Loading model /usr/local/sonatype-work/nexus/conf/lvo-plugin.xml  
  7. jvm 1    | 2016-10-17 06:29:45,407-0400 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.webresources.internal.WebResourceServiceImpl - Discovered 1971 resources  
  8. jvm 1    | 2016-10-17 06:29:45,408-0400 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.webresources.internal.WebResourceServlet - Max-age: 30 days (2592000 seconds)  
  9. jvm 1    | 2016-10-17 06:29:45,430-0400 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.bootstrap.jetty.InstrumentedSelectChannelConnector - Metrics enabled  
  10. jvm 1    | 2016-10-17 06:29:45,441-0400 INFO  [jetty-main-1] *SYSTEM org.eclipse.jetty.server.AbstractConnector - Started InstrumentedSelectChannelConnector@0.0.0.0:8081  
  11. jvm 1    | 2016-10-17 06:29:45,441-0400 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Running  
  12. jvm 1    | 2016-10-17 06:29:45,441-0400 INFO  [WrapperListener_start_runner] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Started  

日志:*SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Started则启动成功


九、配置成服务并开机启动

[java]  view plain  copy
  1. [root@localhost bin]# pwd  
  2. /usr/local/nexus-2.14.0-01/bin  
  3. [root@localhost bin]# cp nexus /etc/rc.d/init.d/    
  4. [root@localhost bin]# cd /etc/rc.d/init.d/  
  5. [root@localhost init.d]# ls  
  6. functions  jexec  netconsole  network  nexus  README  
  7. [root@localhost init.d]# chkconfig --add nexus    
  8. [root@localhost init.d]# chkconfig --list | grep nexus   
  9.   
  10. 注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。   
  11.       如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。  
  12.       欲查看对特定 target 启用的服务请执行  
  13.       'systemctl list-dependencies [target]'。  
  14.   
  15. nexus           0:关 1:关 2:开 3:开 4:开 5:开 6:关  
  16. [root@localhost init.d]# chkconfig nexus on    
  17. [root@localhost init.d]# chkconfig --list | grep nexus   
  18.   
  19. 注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。   
  20.       如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。  
  21.       欲查看对特定 target 启用的服务请执行  
  22.       'systemctl list-dependencies [target]'。  
  23.   
  24. nexus           0:关 1:关 2:开 3:开 4:开 5:开 6:关  
  25. [root@localhost init.d]#   


十、访问与启停

访问地址:http://ip:8081/nexus

启动:service nexus start

停止:service nexus stop

重启:service nexus restart


十一、常见问题

1,地址不能访问,可能原因防火墙问题,解决办法如下:

[java]  view plain  copy
  1. /sbin/iptables -I INPUT -p tcp --dport 8081 -j ACCEPT  
  2. /etc/rc.d/init.d/iptables save  
  3. /etc/init.d/iptables restart  

2,配置成服务启动时遇到的错误,如下:

[java]  view plain  copy
  1. [root@localhost init.d]# service nexus stop  
  2. Missing platform binary: /etc/rc.d/init.d/../bin/jsw/linux-x86-64/wrapper  
解决办法:vi /etc/rc.d/init.d/nexus

[java]  view plain  copy
  1. # Set this to the root of the Nexus installation  
  2. #此处最好设置为绝对路径  
  3. NEXUS_HOME="/usr/local/nexus-2.14.0-01"  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值