使用nexus搭建yum仓库

概述

nexus 是一个仓库管理器,除了最经常使用建立maven仓库的功能外,他还能够搭建docker仓库yum源仓库npm pip ruby仓库等等,今天咱们用这个建立一个yum源仓库git

安装nexus

首先安装nexus,我使用的是docker方式,首先clone下面这个项目github

git clone https://github.com/bboysoulcn/awesome-dockercompose.gitdocker

以后进入nexus目录,执行npm

docker-compose up -dvim

nexus安装完成centos

搭建软件源

首先进入nexus 浏览器打开ip:8081浏览器

以后登录,默认帐号密码admin admin123缓存

接着点设置->repository->create repository->yum(proxy)写入下面关键参数ruby

name: 随便写 remote storage: 我写的是中科大软件源,按照道理全部的软件源同级目录均可以https://mirrors.ustc.edu.cn/centos/bash

以后点保存便可

设置centos系统软件源

个人作法是吧原先的软件源所有放入backup文件夹

cd /etc/yum.repos.d mkdir backup mv ./*.repo backup

以后建立一个文件写入下面内容

vim CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://docker.bboysoul.com:8083/repository/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://docker.bboysoul.com:8083/repository/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=http://docker.bboysoul.com:8083/repository/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=http://docker.bboysoul.com:8083/repository/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

最主要就是修改baseurl中的地址,个人和你的可能不同,看状况修改

接着使用

yum clean all

清除全部软件源缓存

yum makecache

建立新的软件源缓存

若是没问题,那么你的仓库就搭建成功了

欢迎关注Bboysoul的博客www.bboysoul.com

Have Fun

相关文章
相关标签/搜索