npm内网私服部署文档
前提准备
-
内网服务器:162.16.6.148
-
操作系统 CentOS7.4
-
nexus-oss版本:nexus-3.14.0-04-unix.tar.gz
-
JDK版本:JDK8(jdk-8u191-linux-x64.tar.gz)
-
安装目录:/opt/software/nexus
-
应用目录:/opt/software/nexus/nexus-3.14.0-04
-
组件目录:/opt/software/nexus/sonatype-work
-
应用目录软链接:/opt/software/nexus/nexus
-
端口:8081(软件默认)
-
nexus默认管理用户:admin/admin123
nexus常用操作
/opt/software/nexus/nexus/bin/nexus {start|stop|run|run-redirect|status|restart|force-reload}
安装步骤
安装JDK8
-
将jdk-8u191-linux-x64.tar.gz 复制到 /usr/java/下,并解压:tar -xzvf jdk-8u191-linux-x64.tar.gz
image.png -
在/etc/profile文件配置环境变量:
export JAVA_HOME=/usr/java/jdk1.8.0_191
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
image.png
- 测试是否成功
java -version
image.png
安装nexus
- 创建安装目录:
mkdir -p /opt/software/nexus
- 解压压缩包:
tar -xvf nexus-3.14.0-04-unix.tar.gz -C /opt/software/nexus/
- 创建应用目录软链接:
ln -s /opt/software/nexus/nexus-3.14.0-04 /opt/software/nexus/nexus
- 启动nexus:
/opt/software/nexus/nexus/bin/nexus start
nexus管理平台
-
使用默认密码登录 admin/admin123,并修改管理员密码
-
创建NPM仓库
1、选择创建
image.png2、选择创建代理仓库,选择“npm(proxy)”
image.png3、填写代理信息,然后点击“Create repository”提交
image.png4、再选择创建存储库组,选择“npm(group)”
image.png5、填写存储库组信息,然后点击“Create repository”提交
![image.png](https://img.haomeiwen.com/i3154986/a2a29e37d6160146.png?imageMogr2/auto-
orient/strip%7CimageView2/2/w/1240)6、添加权限验证,不然偶尔会报401的权限错误
image.png7、至此,已创建好npm私服。
-
配置npm,将registry指向本地私服
1、在控制台执行如下:
npm config set registry "http://162.16.6.148:8081/repository/bcsnpm/"
2、检查设置成功,查看npm配置:
npm config list
image.png
-
验证NPM私服是否可用
1、控制台执行:
npm i -loglevel info http-server
配置域名解析:
内网设置了只允许访问IP白名单,因此对于 registry.npmjs.org 的访问,需要手动设置域名解析。
配置 /etc/hosts
设置清理任务(Cleanup Policies):
1、选择创建清理任务(Create Cleanup Policies)
image.png2、填写清理任务信息
image.png3、预览清理任务执行结果
image.png4、保存并创建清理任务(Create Cleanup Policies)
image.png5、在仓库中绑定清理任务,保存即可。点击“Save”
image.png设置定时任务(Tasks):
1、选择创建Task(Create task)
image.png2、选择一个类型,在此选择“Admin - Compact blob store Task”
3、填写任务信息,并提交创建
image.png其它
- 管理平台提示
System Requirement: max file descriptors [4096] likely too low, increase to at least [65536]
,参考 官方解决方案 需要在文件/etc/security/limits.conf
中设置如下:
nexus - nofile 65536
网友评论