使用nexus搭建yum仓库

为什么80%的码农都做不了架构师?>>>   hot3.png

使用nexus搭建yum仓库_第1张图片

概述

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

转载于:https://my.oschina.net/u/3778921/blog/3040247

你可能感兴趣的:(使用nexus搭建yum仓库)