Linux 環境下安裝 Nexus 私服存儲庫

Linux 環境下安裝 Nexus 私服存儲庫

做者:阿東java

公衆號:傑哥的IT之旅node

本文字數:2573字,13圖,預計閱讀時間:7分鐘python

nexus私服存儲庫簡介
Nexus 是一個強大的maven倉庫管理器,它極大地簡化了本地內部倉庫的維護和外部倉庫的訪問。,還能夠用來建立yum、pypi、npm、docker、nuget、rubygems 等各類私有倉庫。linux

nexus私服存儲庫安裝步驟web

系統設置
linux中
# /etc/security/limits.conf 在此文件中添加一下內容
nexus - nofile 65536
須要java 1.8以上環境運行

安裝 JDK 環境docker

# tar -xzf jdk-8u211-linux-x64.tar.gz -C /usr/local/
# vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_211/
export JRE_HOME=/usr/loca/jdk1.8.0_211/jre
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
# source /etc/profile


下載 nexus 安裝包
npm

# wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
# mkdir /opt/nexus
# tar -xzf nexus-3.16.1-02-unix.tar.gz -C /opt/nexus
# useradd nexus #以nexus用戶運行
# chown -R nexus.nexus /opt/nexus

nexus解壓後的兩個文件
nexus-xxx nexus運行須要的文件,如運行腳本、依賴jar包
sonatype-work 該目錄包含nexus生成的配置文件、日誌文件、倉庫文件等

優化配置

1) 配置運行用戶
# cd /nexus/nexus.x.x.x/bin/
# vim nexus.rc
run_as_user="nexus" ----取消註釋

2)能夠手動配置jdk的路徑
若是不配置的話,會使用默認的JAVA_HOME的環境變量
# cd /nexus/nexus.x.x.x/bin/
# vim nexus
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/jdk1.8.0_144 #第14行

3)修改端口
通常使用默認的端口
# cd /nexus/nexusx.x.x.x/bin
# vim nexus-default.properties

4)配置存儲及日誌位置
通常不作修改,使用默認
# cd /nexus/nexusx.x.x.x/bin/
# vim nexus.vmoptions

修改完配置文件、運行vim

# sudo su - nexus
# cd /opt/nexus/nexus.x.x.x/bin
# ./nexus run & #後臺運行
# 使用web頁面進行設置代理倉庫
http://localhost:8081
初始帳戶及密碼:admin/admin123

存儲庫的配置(pypi庫的配置)ruby

Linux 環境下安裝 Nexus 私服存儲庫

配置pypi倉庫步驟:

一、創建官方代理倉庫

二、填寫遠程索引地址時,地址:https://pypi.python.org/ ; http://mirrors.aliyun.com ;https://pypi.tuna.tsinghua.edu.cn; #配置多個國內的資源

三、創建hosted倉庫,用於內部使用的myptpi-hosted

四、創建group倉庫把官方代理配置添加進去

Linux 環境下安裝 Nexus 私服存儲庫

Linux 環境下安裝 Nexus 私服存儲庫

Linux 環境下安裝 Nexus 私服存儲庫

Linux 環境下安裝 Nexus 私服存儲庫
Linux 環境下安裝 Nexus 私服存儲庫

一、使用pip時,使用-i指定倉庫地址,並同時使用--trusted-host參數指定信任主機
pip install -i http://localhost:8081/repository/pypigroup/simple/ --no-cache-dir -r requirements.txt --trusted-host

二、在配置文件中配置私服地址,配置文件地址~/.pip/pip.conf,如不存在則新增該文件。配置文件內容以下
[global]
index-url=nexus.menghuanhua.com:8081/repository/df-pipy-public/simple/
[install]
trusted-host=nexus.menghuanhua.com

npm存儲庫的配置maven

Linux 環境下安裝 Nexus 私服存儲庫

一、建立hosted類型的npm庫
storage: Blob store,下拉選擇前面的建立好的專用blob
hosted:開發環境,運行重複發佈,所以選擇allow rede ploy

二、建立proxy類型的倉庫
proxy:remote storage:遠程倉庫地址,填寫:https://registry.npm.taobao.org

三、建立group類型的npm倉庫
storage:選擇裝用的blob存儲npm-hub
group:將左邊可選的2個倉庫,添加到右邊的members下

驗證使用

一、node環境

二、獲取默認的倉庫地址
# npm config get registry

三、配置私服地址
在nexus的web頁面的repositories/group-npm中查看url

四、經過一下的命令配置
# npm config set registry http://x.x.x.x/repository/group-npm
# npm config get reagistry

五、找一個node相關的項目,安裝編譯
# npm install

本文完。

相關文章
相關標籤/搜索