创建局域网的基于base的私有yum源
仓库服务器配置
[root@repo-server ~]#yum -y install httpd
[root@repo-server ~]#systemctl enable --now httpd
[root@repo-server ~]#mkdir /var/www/html/centos/{8,7,6}/x86_64 -pv
[root@repo-server ~]#mount /dev/sr0 /mnt/
[root@repo-server ~]#cp -a /mnt/* /var/www/html/centos/8/x86_64/
#可以不用复制,直接挂载,但需要设为开机自动挂载即可
#添加两块光盘驱动
[root@repo-server ~]#lsblk
[root@repo-server ~]#umount /sr0
[root@repo-server ~]#echo "- - -" > /sys/class/scsi_host/host0/scan
[root@repo-server ~]#mount /dev/sr1 /mnt/
[root@repo-server ~]#cp -a /mnt/* /var/www/html/centos/7/x86_64/
[root@repo-server ~]#umount /sr1
[root@repo-server ~]#echo "- - -" > /sys/class/scsi_host/host0/scan
[root@repo-server ~]#mount /dev/sr2 /mnt/
[root@repo-server ~]#cp -a /mnt/* /var/www/html/centos/6/x86_64/
#验证:打开浏览器输入主机IP进行访问,看能否出现yum仓库,能访问即可
#yum客户端配置
在centos 8上修改yum的base和appstream源
[root@centos8 yum.repos.d]# cat base.repo
[base]
name=CentOS-$releasever Base
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
https://mirrors.huaweicloud.com/centos/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=0
[AppStream]
name=CentOS-$releasever Appstream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
https://mirrors.huaweicloud.com/centos/$releasever/AppStream/$basearch/os/
enabled=1
gpgcheck=0
[epel]
name=CentOS-$releasever Epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch/
https://mirrors.huaweicloud.com/epel/$releasever/Everything/$basearch/
enabled=1
gpgcheck=0
[extras]
name=CentOS-$releasever Extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
https://mirrors.huaweicloud.com/centos/$releasever/extras/$basearch/os/
enabled=1
gpgcheck=0
[root@repo-server ~]#cat /etc/yum.repos.d/test.repo
[base]
name=Base
baseurl=http://10.0.0.8/centos/8/x86_64/BaseOS/
enabled=1
gpgcheck=0
[AppStream]
name=Appstream
baseurl=http://10.0.0.8/centos/8/x86_64/AppStream/
enabled=1
gpgcheck=0
#下载阿里云的epel源,制作私有yum源
[root@repo-server ~]#mkdir -pv /var/www/html/epel/{8,7,6}/x86_64
[root@repo-server ~]#dnf reposync --repoid=epel --download-metadata -p /var/www/html/epel/{8,7,6}/x86_64/
[root@repo-server ~]#ls /var/www/html/epel/{8,7,6}/x86_64/epel/
#下载相关的key文件
[root@repo-server ~]#wget -P /var/www/html/epel/ https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-8
[root@centos8 ~]#systemctl start httpd
[root@repo-client ~]#cat /etc/yum.repos.d/test.repo
[base]
name=Base
baseurl=http://10.0.0.8/centos/8/x86_64/BaseOS/
enabled=1
gpgcheck=0
[AppStream]
name=Appstream
baseurl=http://10.0.0.8/centos/8/x86_64/AppStream/
enabled=1
gpgcheck=0
[epel]
name=Epel
baseurl=http://10.0.0.8/epel/8/x86_64/epel/
enabled=1
gpgcheck=0
[root@repo-client ~]#yum repolist
#下载阿里云的extras源,制作私有yum源
[root@repo-server ~]#yum repolist
[root@repo-server ~]#dnf reposync --repoid=extras --download-metadata -p /var/www/html/centos/{8,7,6}/extras/x86_64
[root@repo-server ~]#ls /var/www/html/centos/{8,7,6}/extras/x86_64/extras/
[root@repo-server ~]#yum repolist
[root@repo-server ~]#cat /etc/yum.repos.d/test.repo
[base]
name=Base
baseurl=http://10.0.0.8/centos/8/x86_64/BaseOS/
enabled=1
gpgcheck=0
[AppStream]
name=Appstream
baseurl=http://10.0.0.8/centos/8/x86_64/AppStream/
enabled=1
gpgcheck=0
[epel]
name=Epel
baseurl=http://10.0.0.8/epel/8/x86_64/epel/
enabled=1
gpgcheck=0
[extras]
name=Extras
baseurl=http://10.0.0.8/centos/8/extras/x86_64/extras/
enabled=1
gpgcheck=0
#在centos 7/6上修改yum源即可,以centos 7为例:
[root@centos7 ~]#mv /etc/yum.repos.d/base.repo /etc/yum.repos.d/base.repo.bak
[root@centos7 ~]#scp root@10.0.0.8:/etc/yum.repos.d/test.repo /etc/yum.repos.d/
#将test.repo中的版本号改为7
[root@centos7 ~]#vim /etc/yum.repos.d/test.repo
[root@centos7 ~]#yum clean all
[root@centos7 ~]#yum repolist
[root@centos7 ~]#cat /etc/yum.repos.d/test.repo
[base]
name=Base
baseurl=http://10.0.0.8/centos/7/x86_64/BaseOS/
enabled=1
gpgcheck=0
[AppStream]
name=Appstream
baseurl=http://10.0.0.8/centos/7/x86_64/AppStream/
enabled=1
gpgcheck=0
[epel]
name=Epel
baseurl=http://10.0.0.8/epel/7/x86_64/epel/
enabled=1
gpgcheck=0
[extras]
name=Extras
baseurl=http://10.0.0.8/centos/7/extras/x86_64/extras/
enabled=1
gpgcheck=0
验证:在浏览器上能访问即可