概述
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