镜像仓库 Nexus 3.18.1
说明:Nexus是Sonatype提供的仓库管理平台,Nuexus Repository OSS3能够支持Maven、npm、Docker、YUM、Helm等格式数据的存储和发布。
一、安装jdk
1)安装JDK
yum install -y java-1.8.-openjdk*
2)配置环境
vim /etc/profile
# set java environment
export JAVA_HOME=/usr/lib/jvm/java-1.8.-openjdk-1.8.0.222.b10-.el7_6.x86_64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
3)重载
source /etc/profile
echo "source /etc/profile" >> /etc/bashrc java -version
二、安装nexus
2.1 下载
mkdir -p /opt/nexus && cd /opt/nexus wget https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.18.1-01-unix.tar.gz
tar -zxvf nexus-3.18.--unix.tar.gz
mv nexus-3.18.- nexus3.
2.2 配置
2.2.1 修改jdk
vim /opt/data/nexus/nexus3./bin/nexus
INSTALL4J_JAVA_PREFIX="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64"
2.2.2 修改启动用户
vim /opt/data/nexus/nexus3./bin/nexus.rc run_as_user="root"
2.2.3 修改数据和日志存储位置
vim /opt/data/nexus/nexus3./bin/nexus.vmoptions -XX:LogFile=/opt/data/blob-stores/others/sonatype-work/nexus3/log/jvm.log
-Dkaraf.data=/opt/data/blob-stores/others/sonatype-work/nexus3
-Djava.io.tmpdir=/opt/data/blob-stores/others/sonatype-work/nexus3/tmp
2.2.4 查看默认端口
cat /opt/data/nexus/nexus3./etc/nexus-default.properties |grep application-port
2.3 启动
2.3.1 启动脚本
vim /usr/lib/systemd/system/nexus.service [Unit]
Description=nexus service [Service]
Type=forking
LimitNOFILE=
ExecStart=/opt/nexus/nexus3./bin/nexus start
ExecReload=/opt/nexus/nexus3./bin/nexus restart
ExecStop=/opt/nexus/nexus3./bin/nexus stop
Restart=on-failure [Install]
WantedBy=multi-user.target
2.3.2 自启动
将服务加入开机启动
systemctl daemon-reload
systemctl enable nexus
systemctl start nexus
三、安装nginx
3.1 安装
yum install -y nginx
3.2 证书申请
申请ssl证书,并存放在 /etc/nginx/cert 目录下
mkdir /etc/nginx/cert
3.3 配置nginx.conf
vim /etc/nginx/nginx.conf
#注释server,添加如下:
upstream nexusserver{
server 172.16.2.158:;
}
upstream mirrornexus{
server 172.16.2.158:;
}
upstream nexusdocker{
server 172.16.2.158:;
}
说明:
1)8081 为 nexus server 的端口,nexus本身服务程序;
2)6001 为 docker proxy 的端口,作为中央仓库的代理;
3)6000 为 docker hosted 的端口,推送拉取镜像
4)6001 和 6000 需登入后台进行相应的配置生成端口,这里是提前设置好nginx。
3.4 配置服务
3.4.1 服务程序
vim /etc/nginx/conf.d/nexusserver.conf
server {
listen ;
server_name nexus.wmq.com;
ssl on;
ssl_certificate cert/1566822_nexus.wmq.com.pem;
ssl_certificate_key cert/1566822_nexus.wmq.com.key; client_max_body_size ;
index index.html;
location / {
proxy_pass http://nexusserver;
#proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto "https";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen ;
server_name nexus.wmq.com;
client_max_body_size ;
index index.html;
location / {
return https://$server_name$request_uri;
}
}
3.4.2 代理仓库
vim /etc/nginx/conf.d/mirrornexus.conf
server {
listen ;
server_name mirror.nexus.wmq.com;
ssl on;
ssl_certificate cert/mirror.nexus.wmq.com.pem;
ssl_certificate_key cert/mirror.nexus.wmq.com.key; client_max_body_size ;
index index.html;
location / {
proxy_pass http://mirrornexus;
#proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto "https";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen ;
server_name mirror.nexus.wmq.com;
client_max_body_size ;
index index.html;
location / {
return https://$server_name$request_uri;
}
}
3.4.3 镜像仓库
vim /etc/nginx/conf.d/nexusdocker.conf
server {
listen ;
server_name reg.nexus.wmq.com;
ssl on;
ssl_certificate cert/reg.nexus.wmq.pem;
ssl_certificate_key cert/reg.nexus.wmq.key; client_max_body_size ;
index index.html;
location / {
proxy_pass http://nexusdocker;
#proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto "https";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen ;
server_name reg.nexus.wmq.com;
client_max_body_size ;
index index.html;
location / {
return https://$server_name$request_uri;
}
}
3.5 启动 nginx
nginx -t
systemctl enable nginx
systemctl start nginx
3.6 域名解析
nexus.wmq.com、mirror.nexus.wmq.com、reg.nexus.wmq.com 三个域名都解析到 nexus 主机内网地址
四、定时清理镜像
4.1 下载工具
github地址:https://github.com/mlabouardy/nexus-cli
mkdir /opt/nexus/clean-docker-images && cd /opt/nexus/clean-docker-images
wget https://s3.eu-west-2.amazonaws.com/nexus-cli/1.0.0-beta/linux/nexus-cli
chmod +x nexus-cli
4.2 配置
./nexus-cli configure
Enter Nexus Host: http://127.0.0.1:8081
Enter Nexus Repository Name: docker-wmqe
Enter Nexus Username: admin
Enter Nexus Password: *******
会在当前目录生成 .credentials 文件,该文件记录了上面输入的信息。
4.3 脚本
vim clean-docker-images.sh
#! /bin/sh
CLI_HOME=/opt/nexus/clean-docker-images
cd $CLI_HOME
KEEP_VERSION_NUM=
IMAGES=$($CLI_HOME/nexus-cli image ls|grep -v Total) clean_images() {
for imgs in $(echo $IMAGES);
do
echo "清理$imgs";
$CLI_HOME/nexus-cli image delete -name $imgs -keep $KEEP_VERSION_NUM
done
} clean_images
4.4 计划任务
crontab -e
* * * sh /opt/nexus/clean-docker-images/clean-docker-images.sh > /opt/nexus/clean-docker-images/clean-docker-images.log >&
镜像仓库 Nexus 3.18.1的更多相关文章
- 019.nexus搭建docker镜像仓库/maven仓库
一.安装docker CE 参考docker doc https://docs.docker.com/install/linux/docker-ce/centos/ 二.docker启动nexus3 ...
- Kunbernetes从私有仓库nexus拉取镜像
1.docker登陆认证 [root@master ~]# vim /etc/docker/daemon.json { "insecure-registries": [" ...
- 使用Nexus3构建Docker私有镜像仓库
一.安装Nexus3 Nexus3是Sonatype提供的仓库管理平台,Nuexus Repository OSS3能够支持Maven.npm.Docker.YUM.Helm等格式数据的存储和发布:并 ...
- [转]Ubuntu18.04下使用Docker Registry快速搭建私有镜像仓库
本文转自:https://blog.csdn.net/BigData_Mining/article/details/88233015 1.背景 在 Docker 中,当我们执行 docker pull ...
- 6.docker的私用镜像仓库registry
docker方式启动镜像仓库 / # cat /etc/docker/registry/config.yml version: 0.1 log: fields: service: registry s ...
- docker 系列 - 企业级私有镜像仓库Harbor部署(转载)
本文转载自 搜云库 的文章 https://www.jianshu.com/p/7d76850de03f , 感谢作者 3.png 上一篇文章搭建了一个具有基础功能,权限认证.TLS 的私有仓库, ...
- 企业级镜像仓库Harbor
介绍: Habor是由VMWare公司开源的容器镜像仓库.事实上,Habor是在Docker Registry上进行了相应的企业级扩展,从而获得了更加广泛的应用,这些新的企业级特性包括:管理用户界面, ...
- harbor镜像仓库-02-https访问配置
harbor镜像仓库-02-https访问配置 harbordockerhttps harbor搭建部署参考上一章节 harbor镜像仓库-01-搭建部署 Harbor默认使用http,给harbor ...
- Maven setting配置镜像仓库
国内Maven镜像仓库值得收藏 1.配置IDE构建的Maven存放目录(解压目录) 2.配置IDE的User setting file路径,修改setting配置文件 配置本地仓库 <!-- ...
随机推荐
- git操作:查看分支、删除本地分支和远程分支
1.查看本地分支:git branch 2.查看远程分支:git branch -r 或 git branch --remote 3.查看本地和远程的所有分支:git branch -a 4.删除本地 ...
- vulnhub AI: Web: 1
vulnhub AI: Web: 1 提取flag攻略 导入虚拟机,开机. 扫描NAT的C段,确定虚拟机IP和开放端口. 尝试访问该网站 发现什么都没有,抽根烟冷静一下...... 来波目录扫描吧 使 ...
- Web API接口安全了解
2017版OWASP top 10 将API安全纳入其中,足以说明API被广泛使用且安全问题严重.自己尝试整理一下,但限于本人搬砖经验还不足.水平有限,本文只能算是抛砖引玉,希望大伙不吝赐教. 了解W ...
- Centos7 安装腾达U12驱动无线网卡
解决过程: 办法一: CentOS7.3 默认的内核版本较低,为 3.10.0-514.el7.x86_64. 无论是使用腾达官方提供的驱动,还是github 上的驱动(链接 https://gith ...
- Linux文件增删改
Linux目录/文件增删改 创建文件 (1) # touch <文件名称> (2) 花括号展开 touch /root/{1,3,9}.txt touch /root/{0..100}. ...
- 阿里云 OSS文件存储挂到云服务器ESC文件系统中
ossfs能让您在Linux系统中,将对象存储OSS的存储空间(Bucket)挂载到本地文件系统中,您能够像操作本地文件一样操作OSS的对象(Object),实现数据的共享. 使用限制 ossfs使用 ...
- Python 的版本控制
版本控制工具的差异 这里介绍几个工具:pyenv.pyvenv. venv.virtualenv.pyenv-virtualenv virtualenv 是针对python的包的多版本管理,通过将py ...
- dgango
一 mvc与mtv模型 web服务器开发领域里著名的mvc模式,所谓mvc就是把web应用分为模型(M),控制器(C),视图(V),以插件的形式,松耦合的方式连接在一起,模型负责业务对象与数据库的映射 ...
- opencart中文版checkout设置city和county为非必选
opencart中文版在opencart原版进行了一些修改,添加了适合国内使用的设置,但是并不适合国外用户,比如订单页面的收货地址添加了国内的城市和区县,而国外的city和county被删减了,这两项 ...
- Helm 安装Kafka
helm镜像库配置 helm repo add stable http://mirror.azure.cn/kubernetes/charts helm repo add incubator http ...