CentOS系统如何配置本地yum源
此博文以Vmware虚拟软件为环境,进行介绍
1. 配置Vmware虚拟机,将镜像文件连接在虚拟主机上,如下图
做完如上图配置后,点击 "确认" ,打开虚拟主机
2. 编写yum源配置文件之前,将原来的文件进行备份
[root@backup ~]# ll /etc/yum.repos.d/ total 36 -rw-r--r--. 1 root root 1664 Sep 5 2019 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Sep 5 2019 CentOS-CR.repo -rw-r--r--. 1 root root 649 Sep 5 2019 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 Sep 5 2019 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Sep 5 2019 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Sep 5 2019 CentOS-Sources.repo -rw-r--r--. 1 root root 6639 Sep 5 2019 CentOS-Vault.repo
[root@backup ~]# mkdir -p /etc/yum.repos.d/backup
[root@backup ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
[root@backup ~]# ll /etc/yum.repos.d/
total 0
drwxr-xr-x. 2 root root 205 Nov 1 11:58 backup
3. 编写yum源配置文件
vim /etc/yum.repos.d/local.repo [local] name = local baseurl = file:///mnt enabled = 1 gpgcheck = 0
4. 挂载镜像文件
[root@backup yum.repos.d]# mount /dev/cdrom /mnt mount: /dev/sr0 is write-protected, mounting read-only [root@backup yum.repos.d]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sr0 4.4G 4.4G 0 100% /mnt
5. 查看当前可用yum源
[root@backup yum.repos.d]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status !local local 4,067 repolist: 4,067
6. 本地yum源配置完成,可以安装软件