使用nexus搭建yum仓库

bboysoul 2019-04-22

系统软件 linux docker yum centos file nexus

概述

nexus 是一个仓库管理器,除了最常用创建maven仓库的功能外,他还可以搭建docker仓库yum源仓库npm pip ruby仓库等等,今天我们用这个创建一个yum源仓库

安装nexus

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

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

之后进入nexus目录,执行

docker-compose up -d

nexus安装完成

搭建软件源

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

之后登陆,默认账号密码admin admin123

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

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

之后点保存即可

设置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

登录 后评论
下一篇
我是小助手
30097人浏览
2019-07-31
相关推荐
Nexus的搭建以及使用
748人浏览
2014-07-04 17:20:00
使用nexus搭建Maven私服
936人浏览
2016-08-12 14:08:00
Sonatype Nexus 搭建Maven 私服
545人浏览
2014-01-06 14:29:37
Maven搭建私服
973人浏览
2018-08-03 23:40:00
Nexus 搭建本地仓库(私服)
407人浏览
2018-01-08 18:02:00
Nexus搭建Maven私服
6009人浏览
2015-07-02 20:46:00
Nexus搭建Maven私服
1494人浏览
2015-07-02 20:46:00
搭建Maven私服(使用Nexus)
25519人浏览
2016-03-02 14:48:01
0
0
0
4701