nexus-包管理平台

简介

https://help.sonatype.com/repomanager3
查看支持哪些语言的包管理 https://help.sonatype.com/repomanager3/repository-manager-feature-matrix

nexus是一个包管理工具,比如配置个yum源代理,这样我们每次从公网下载rpm包的时候,都是先请求nexus私服,nexus帮我们从公网下载,并在自己的服务器上换成一份,当我们下次再下载同样的rpm包的时候,就可以直接从nexus私服上离线下载了

安装

Installing and running Nexus Repository Manager is straight-forward. You can either unpack the archive in a directory to which you have full access, or you can install it with a Docker image.

#################################### Java Runtime Environment ####################################
mkdir /as4k; cd /as4k;
wget http://192.168.1.8/chfs/shared/jdk8/jdk-8u231-linux-x64.tar.gz
tar xf jdk-8u231-linux-x64.tar.gz
cat << 'EOF' >> /etc/profile
export JAVA_HOME=/as4k/jdk1.8.0_231
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
EOF
source /etc/profile; jps; java -version


#################################### 下载包并解压 ##################################################

wget http://download.sonatype.com/nexus/3/nexus-3.22.1-02-unix.tar.gz
OR http://192.168.1.8/chfs/shared/linux-pkg/nexus-3.16.1-02-unix.tar.gz
[root@node5 as4k]# tar xf nexus-3.16.1-02-unix.tar.gz 
[root@node5 as4k]# ls
jdk1.8.0_231  jdk-8u231-linux-x64.tar.gz  nexus-3.16.1-02  nexus-3.16.1-02-unix.tar.gz  sonatype-work

解压之后得到两个目录,应用目录nexus-3.16.1-02,数据目录sonatype-work

#################################### 修改配置文件 ##################################################

# sed '/^# INSTALL4J_JAVA_HOME_OVERRIDE/a INSTALL4J_JAVA_HOME_OVERRIDE=/as4k/jdk1.8.0_231' /as4k/nexus-3.16.1-02/bin/nexus | grep -C 2 "^# INSTALL4J_JAVA_HOME_OVERRIDE"
# sed -i '/^# INSTALL4J_JAVA_HOME_OVERRIDE/a INSTALL4J_JAVA_HOME_OVERRIDE=/as4k/jdk1.8.0_231' /as4k/nexus-3.16.1-02/bin/nexus | grep -C 2 "^# INSTALL4J_JAVA_HOME_OVERRIDE"

[root@node5 as4k]# echo >> /as4k/nexus-3.16.1-02/bin/nexus.rc &&  echo 'run_as_user="root"' >> /as4k/nexus-3.16.1-02/bin/nexus.rc
[root@node5 as4k]# cat /as4k/nexus-3.16.1-02/bin/nexus.rc
#run_as_user=""
run_as_user="root"

#################################### 编写nexus.service文件 ###########################################

cat << 'EOF' > /usr/lib/systemd/system/nexus.service
[Unit]
Description=nexus service
After=network.target
  
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/as4k/nexus-3.16.1-02/bin/nexus start
ExecStop=/as4k/nexus-3.16.1-02/bin/nexus stop
Restart=on-abort
User=root
[Install]
WantedBy=multi-user.target
EOF

#################################### 启动并开机自启 ###########################################

systemctl daemon-reload
systemctl start nexus.service
systemctl enable nexus.service
systemctl status nexus.service

#################################### 观察启动日志,端口 ###########################################

[root@nexus3 nexus3]# tail -F /as4k/sonatype-work/nexus3/log/nexus.log

nexus3默认监听在8081端口上

[root@node5 as4k]# netstat -lntup  | grep 8081
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      18810/java          

[root@node5 as4k]# jps
18980 Jps
18810 UnixLauncher

[root@node5 as4k]# systemctl status nexus.service | cat 
● nexus.service - nexus service
   Loaded: loaded (/usr/lib/systemd/system/nexus.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2020-04-26 19:12:57 CST; 6min ago
 Main PID: 18810 (java)
   CGroup: /system.slice/nexus.service
           └─18810 /as4k/jdk1.8.0_231/bin/java -server -Dinstall4j.jvmDir=/as4k/jdk1.8.0_231 -Dexe4j.moduleName=/as4k/nexus-3.16.1-02/bin/nexus -XX:+UnlockDiagnosticVMOptions -Dinstall4j.launcherId=245 -Dinstall4j.swt=false -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Xms1200M -Xmx1200M -XX:MaxDirectMemorySize=2G -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -XX:+LogVMOutput -XX:LogFile=../sonatype-work/nexus3/log/jvm.log -XX:-OmitStackTraceInFastThrow -Djava.net.preferIPv4Stack=true -Dkaraf.home=. -Dkaraf.base=. -Dkaraf.etc=etc/karaf -Djava.util.logging.config.file=etc/karaf/java.util.logging.properties -Dkaraf.data=../sonatype-work/nexus3 -Djava.io.tmpdir=../sonatype-work/nexus3/tmp -Dkaraf.startLocalConsole=false -Di4j.vpt=true -classpath /as4k/nexus-3.16.1-02/.install4j/i4jruntime.jar:/as4k/nexus-3.16.1-02/lib/boot/nexus-main.jar:/as4k/nexus-3.16.1-02/lib/boot/org.apache.karaf.main-4.0.9.jar:/as4k/nexus-3.16.1-02/lib/boot/org.osgi.core-6.0.0.jar:/as4k/nexus-3.16.1-02/lib/boot/org.apache.karaf.diagnostic.boot-4.0.9.jar:/as4k/nexus-3.16.1-02/lib/boot/org.apache.karaf.jaas.boot-4.0.9.jar com.install4j.runtime.launcher.UnixLauncher start 9d17dc87 0 0 org.sonatype.nexus.karaf.NexusMain

Apr 26 19:12:57 node5 systemd[1]: Starting nexus service...
Apr 26 19:12:57 node5 nexus[18663]: WARNING: ************************************************************
Apr 26 19:12:57 node5 nexus[18663]: WARNING: Detected execution as "root" user.  This is NOT recommended!
Apr 26 19:12:57 node5 nexus[18663]: WARNING: ************************************************************
Apr 26 19:12:57 node5 nexus[18663]: Starting nexus
Apr 26 19:12:57 node5 systemd[1]: Started nexus service.


#################################### 访问WEB页面 ###########################################

默认账号密码 admin / admin123
http://localhost:8081

配置

目录结构

比如要改默认的存储路径

https://help.sonatype.com/repomanager3/installation/directories

Installation Directory
    LICENSE.txt
    NOTICE.txt
    bin
    deploy
    etc
    lib
    public
    system

Data Directory
    The data directory is found by default at ../sonatype-work/nexus3.

Configuring the Runtime Environment

https://help.sonatype.com/repomanager3/installation/configuring-the-runtime-environment

System Requirements

https://help.sonatype.com/repomanager3/system-requirements

硬件配置推荐,内存分配之类

Yum Repositories



配置仓库
[root@node4 yum.repos.d]# cat /etc/yum.repos.d/nexus.repo 
[nexusrepo]
name=Nexus Repository
#baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
baseurl=http://192.168.1.119:8081/repository/xyum-proxy/$releasever/os/$basearch/
enabled=1
gpgcheck=0

安装php测试
yum install php

到web界面查看已经换存的离线rpm包

实践-配置阿里云repo


http://mirror.centos.org/centos/
http://mirrors.aliyun.com/centos
http://mirrors.aliyun.com/epel


###################### 阿里云YUM源替换为内网NEXUS代理源 ##################################


cat << 'EOF' > /etc/yum.repos.d/base.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
#baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
baseurl=http://192.168.1.112:8081/repository/aliyun-base/$releasever/os/$basearch/
gpgcheck=0

[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
#baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
baseurl=http://192.168.1.112:8081/repository/aliyun-base/$releasever/updates/$basearch/
gpgcheck=0

[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
#baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
baseurl=http://192.168.1.112:8081/repository/aliyun-base/$releasever/extras/$basearch/
gpgcheck=0
EOF


cat << 'EOF' > /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://mirrors.aliyun.com/epel/7/$basearch
baseurl=http://192.168.1.112:8081/repository/aliyun-epel/7/$basearch
enabled=1
gpgcheck=0
EOF

#######################################################################################

yum clean all
yum repoinfo

安装PHP测试
yum install php




扩展阅读

常见的几种开源镜像仓库介绍
https://blog.csdn.net/Andriy_dangli/article/details/84381383

https://mindmajix.com/10-repository-management-devops-tools

使用Nexus Repository 3的十二个理由
https://blog.csdn.net/liumiaocn/article/details/62050525

Nexus 3 Docker仓库(hosted、proxy、group)模式 讲解
https://blog.csdn.net/weixin_41806245/article/details/87812500

Nexus3最佳实践系列:搭建Docker私有仓库
https://zhang.ge/5139.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凯尔kyle

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值