【nexus&yum】CentOS7.x上从客户端往nexus的yum仓库推rpm

一、实验背景

 

用nexus oss进行yum代理,所缓存的数据都是yum源的数据。

如果需要使用特定版本或者自己编译的包,这种方法就不灵了。

本文讲述nexus oss创建hosted类型yum仓库,hosted类型是自建仓库,上传rpm包后会生成repodata文件。

 

nexus oss和nexus pro有什么区别?

 

二、实验环境

 

操作系统: CentOS7.5 Minimal

nexusServer: 192.168.1.107

nexusClient:192.168.1.103

 

三、创建hosted类型yum仓库

 

CentOS7.x上用nexus搭建yum私有仓库

https://www.jianshu.com/p/0255cd957e15

 

1.创建blob存储,为其创建一个单独的存储空间,命名为yum

 

 

2.创建hosted类型的yum仓库

 

Name::定义一个名称yumDev

Storage:Blob store,我们下拉选择前面创建好的专用blob:yum。

Hosted:开发环境,我们运行重复发布,因此Delpoyment policy 我们选择Allow redeploy

 

 

四、创建role和user

Roles

https://help.sonatype.com/repomanager3/security/roles

Privileges

https://help.sonatype.com/repomanager3/security/privileges

Users

https://help.sonatype.com/repomanager3/security/users

 

nexus中role是一组权限(privilege)的集合,可以授予创建的用户,做权限控制。

nexus中默认的 role 有 nx-admin  和 nx-anonymous

 

 

nexus中默认的 user 有 admin  和 anonymous

 

 

我们创建一个nx-yum的role,然后授予创建的test用户,根据需要授予相应的权限。

 

 

 

用户名密码:test/Test@123

 

五、客户端rpm包上传测试

从服务端web界面获取hosted类型仓库地址:http://192.168.1.107:8081/repository/yumDev/

 

# curl -v --user 'test:Test@123' --upload-file httpd-2.4.6-88.el7.centos.x86_64.rpmhttp://192.168.1.107:8081/repository/yumDev/httpd-2.4.6-88.el7.centos.x86_64.rpm

如果rpm较多,写一个脚本遍历循环上传

仓库第一次上传文件时,会自动生成repodata文件,以后上传的文件会间隔一段时间后生成,可点击Rebuild Index重建repodata。

如果某个包已不再需要,可在Brose中选择该文件,然后Delete asset删除之。

如果某个仓库不再需要,可选Delete repository删除之。

当然,我们没法通过上传一个 httpd-2.4.6-88.el7.centos.x86_64.rpm 到nexus服务端,然后再客户端下载http,会报缺少依赖!

yum仓库会自动分析解决依赖,前提是你已经需要安装的主包及其依赖全部上传!

nexusyum仓库的方便之处是我们上传rpm主包及其依赖,它会自动定时createrepo创建清单文件,而不用手动了!

 

六、测试将一个软件主包及其依赖全部上传到nexus的yum仓库

 

在一台联网的和nexusServer互通的服务器上下载ceph主包及其依赖

 

添加ceph官方yum镜像仓库

#  vim   /etc/yum.repos.d/ceph.repo

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

[Ceph]

name=Ceph packages for $basearch

baseurl=http://mirrors.163.com/ceph/rpm-luminous/el7/$basearch

enabled=1

gpgcheck=1

type=rpm-md

gpgkey=https://download.ceph.com/keys/release.asc

priority=1

[Ceph-noarch]

name=Ceph noarch packages

baseurl=http://mirrors.163.com/ceph/rpm-luminous/el7/noarch

enabled=1

gpgcheck=1

type=rpm-md

gpgkey=https://download.ceph.com/keys/release.asc

priority=1

[ceph-source]

name=Ceph source packages

baseurl=http://mirrors.163.com/ceph/rpm-luminous/el7/SRPMS

enabled=1

gpgcheck=1

type=rpm-md

gpgkey=https://download.ceph.com/keys/release.asc

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

# yum clean all

# yum repolist 

# yum list all |grep ceph

# yum  -y install epel-release 

# yum -y install yum-utils 

# yum -y install createrepo 

# mkdir /root/cephDeps 

# repotrack  ceph ceph-mgr ceph-mon ceph-mds ceph-osd ceph-fuse ceph-radosgw  -p  /root/cephDeps

#  ll  /root/cephDeps 

 

用脚本将ceph主包及其依赖上传到nexusServer的yum仓库

#  vim  push_rpm.sh

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

#!/bin/bash

parent_path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )

cd "$parent_path"

for rpm in  $(ls  -l  *.rpm | awk  '{print $9}')

do

  curl -v --user 'test:Test@123' --upload-file $rpm  http://192.168.1.107:8081/repository/yumDev/$rpm

  if [ $? -ne 0 ]; then

    exit 1

  fi

done

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

 

# sh  push_rpm.sh 

 

客户端测试从hosted仓库下载rpm

在客户端创建仓库文件

# vim   /etc/yum.repos.d/nexus.repo

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

[nexus]

name=Nexus Yum Repository

baseurl=http://192.168.1.107:8081/repository/yumDev/

enabled=1

gpgcheck=0

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

注:此出客户端的仓库文件中的 baseurl=http://192.168.1.107:8081/repository/yumDev/ 后面没有$releasever/os/$basearch/

#  yum clean all 

# yum repolist 

# yum -y install ceph ceph-mds ceph-mgr ceph-osd ceph-mon

 

七、参考

 

CentOS7.x上用nexus搭建yum私有仓库

https://www.jianshu.com/p/0255cd957e15

 

Nexus OSS配置hosted类型yum仓库

https://qgdlsj.com/nexus-oss-yum-hosted

 

用Nexus自建Yum Repository代理

https://edxi.github.io/2018/04/16/NexusYum

 

CentOS7.x上ceph单机的离线部署和cephFS文件系统的使用

https://www.jianshu.com/p/b8f085ca0307

 

RPM Repositories

https://www.jfrog.com/confluence/display/RTF/RPM+Repositories

 

Nexus Repository Manager OSS

https://www.sonatype.com/nexus-repository-oss

 

Yum Repositories

https://help.sonatype.com/repomanager3/formats/yum-repositories

 

Nexus Repository Manager 3.5: Yum Proxy Support Now Available

https://blog.sonatype.com/nexus-repository-manager-3.5

 

Nexus Repository OSS 3安装配置使用

http://shiyanjun.cn/archives/1768.html

 

Nexus Repository OSS 3.x简介

https://note.qidong.name/2017/08/nexus-repository-oss

 

Nexus Repository Manager OSS 3.x 安装配置

https://blog.csdn.net/chenfei2341/article/details/80431700

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值