Linux系统在很多时候进行部署服务或者安装软件时,需要安装所需要的依赖包,需要使用yum工具进行依赖包的安装,如果可以连接互联网,yum源的配置就很简单,但是如果是内部网络或者不能连接互连网时,就需要使用本地yum源进行依赖包的安装。下面简单介绍一下本地yum源的配置方法:
PS:本文章只是和配置Centos6.5本地yum原配置,Centos7以上配置有所不同。
准备:
系统:Centos 6.5
工具:Centos 6.5的系统镜像文件 CentOS-6.5-x86_64-bin-DVD1.iso
## 一、将系统镜像文件拷贝至Linux系统中,放到指定位置,本次放到了 /root目录下。
```c
[root@local ~]# ls
CentOS-6.5-x86_64-bin-DVD1.iso
二、创建挂载点,并将系统镜像文件挂载。
挂载命令:
mount -o loop /root/CentOS-6.5-x86_64-bin-DVD1.iso /media/cd
效果图如下:
[root@local ~]# mkdir /media/cd
[root@local ~]# mount -o loop /root/CentOS-6.5-x86_64-bin-DVD1.iso /media/cd
[root@local ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 41G 4.8G 35G 13% /
tmpfs 932M 228K 932M 1% /dev/shm
/dev/sda1 504M 45M 434M 10% /boot
/root/CentOS-6.5-x86_64-bin-DVD1.iso 4.2G 4.2G 0 100% /media/cd
三、修改配置文件,配置文件位置和内容如下
进入/etc/yum.repos.d/目录下修改CentOS-Media.repo配置文件。
PS:centos系统在此目录下有多个yum的配置文件,本地yum配置只留下一个即可。
[root@local ~]# cd /etc/yum.repos.d/
[root@local yum.repos.d]# ls
CentOS-Media.repo
[root@local yum.repos.d]# cat CentOS-Media.repo
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-6. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c6-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c6-media [command]
[c6-media]
name=local
baseurl=file:///media/cd
gpgcheck=0
enabled=1
四、清空原始yum缓存,并重新缓存配置的本地yum源
命令:
(1)、 yum clean all
(2)、 yum repolist
具体效果如下:
[root@local yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: c6-media
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@local yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
c6-media | 4.0 kB 00:00 ...
c6-media/primary_db | 4.4 MB 00:00 ...
repo id repo name status
c6-media CentOS-6 - Media 6,367
repolist: 6,367`
———————————————————————————罪恶的分割线—————————————————————————
引用:[添加链接描述](https://blog.csdn.net/qq_32838955/article/details/104285779)