1、准备及说明:
我用一台虚拟机作为yum源服务器(centos7.6),演示如何搭建yum源服务器。
2、识别挂载光盘
在CentOS6版本系统中,有一个“神奇”的目录/misc可实现光盘的自动挂载,但在CentOS7版本中
默认并不支持此服务, 需要手动安装autofs服务
yum install -y autofs 安装autofs
systemctl start autofs 启动autofs
cd /misc/cd
[root@centos7 /misc/cd]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 50G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 20G 0 part /data
sr0 11:0 1 3.7G 0 rom /misc/cd
sr1 11:1 1 10G 0 rom
3、安装http服务并启动
yum install -y httpd
systemctl start httpd
使用ip访问httpd服务,如下图
创建网页目录
mkdir -p /var/www/html/centos/{6,7}/os/x86_64
[root@centos7 ~]#tree /var/www/html/
/var/www/html/
└── centos
├── 6
│ └── os
│ └── x86_64
└── 7
└── os
└── x86_64
4、挂载镜像
mount /dev/sr0 /var/www/htm/centos/6/os/x86_64
mount /dev/sr1 /var/www/htm/centos/7/os/x86_64
5、配置服务器yum仓库
[root@centos7 ~]#vim /etc/yum.repos.d/base.repo
[lx]
name=httprepo
baseurl=http://192.168.1.10/centos/7/os/x86_64
gpgcheck=0
yum clean 清除yum缓存
[root@centos7 ~]#yum repolist 查看yum仓库
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
lx httprepo 10,019
repolist: 10,019