建立私有仓库

创建局域网的基于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

验证:在浏览器上能访问即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值