Create Local Repository for Yum

2024-11-21 linux yum

建立本地yum倉庫

生一個CentOS7 的環境

local repository

環境

CentOS 7

100GB 存放空間

安裝工具

yum install yum-utils createrepo -y

啟用 EPEL

sudo yum install epel-release
sudo yum update

檢查

yum repolist

yum-config-manager
–add-repo
https://download.docker.com/linux/centos/docker-ce.repo

下載

reposync -l --repoid=base --repoid=extras --repoid=updates --download_path=/var/www/html/centos/7 --download-metadata
reposync -l --repoid=epel --download_path=/var/www/html/centos/  --download-metadata --newest-only
reposync -l --repoid=docker-ce-stable --download_path=/var/www/html/centos/ --download-metadata --newest-only
  • –gpgcheck

檢查GPG,失敗澤刪除檔案

gpgcheck是gpg簽名是否開啟的選項名稱,1是開啟,0是不開啟,一般內部部署軟體包下載可以關掉。

  • –newest-only

只抓最新的檔案

建立本地yum倉庫

mkdir -p /home/yum/local/

建立repo檔案

/etc/yum.repos.d/local.repo

[Local]
name=Local Yum
baseurl=file:///home/yum
gpgcheck=0
enabled=1
[DVD]
name=DVD Yum
baseurl=file:///mnt/iso
gpgcheck=0
enabled=1

安裝 createrepo

yum install createrepo

同步

rsync -avh –exclude=logs /mnt/Intranet/centos7/docker-ce-stable [email protected]:/home/yum/local/ rsync -avh –exclude=logs /mnt/Intranet/centos7/7/extras/Packages/*.rpm [email protected]:/home/yum/local/extras

建立索引

createrepo /home/yum
yum makecache

參考資料

企業生產環境都需要的「自建Yum源」