1. 程式人生 > >yum倉庫源搭建

yum倉庫源搭建

本地yum源搭建

cd源  mount /dev/sr0 /mnt   

 vim  /etc/yum.repos.d/base.repo

[centos-base]
name=centos7
#baseurl=file:///var/www/html/centos/
baseurl=file:///mnt
enabled=1
gpgcheck=0

yum clean all

yum makecache

yum repolist

iso源  mount -o loop centos7.4.iso /mnt  同上

http源  服務端:cp  -R  /mnt/*  /var/www/html/centos

createrepo /var/www/html/centos

yum install -y httpd

ps -ef |grep httpd && netstat -antup |grep 80

getenforce 0 && systemctl stop firewalld.service

客戶端:vim /etc/yum.repos.d/base.repo

[centos-base]
name=centos7
baseurl=http://192.168.0.1/centos/
enabled=1
gpgcheck=0

yum clean all

yum makecache

yum repolist

同步外網yum源

使用reposync工具可以同步幾乎所有的yum源,同步外網yum源軟體至本地

wget http://mirrors.163.com/.help/CentOS7-Base-163.repo 

mv  CentOS7-Base-163.repo  /etc/yum.repos.d/centos.repo

yum clean all

yum makecache

安裝reposync工具

yum install -y createrepo

通過reposync命令工具獲取外網yum源所有軟體包,-r指定repolist id,預設不加-r表示獲取玩玩所有yum軟體包,-p 指定下載軟體的路徑

reposync  -r base -p /var/www/html/centos/

reposync  -r updates -p /var/www/html/centos/

通過createrepo命令更新本地yum倉庫源

createrepo /var/www/html/centos/

修改本地yum源配置檔案

vim centos.repo

centos-base]
name=centos7
baseurl=file:///var/www/html/centos/
#baseurl=file:///mnt
enabled=1
gpgcheck=0