[r[email protected] yum.repos.d]# mkdir -p /repo/iso
[[email protected] yum.repos.d]# mkdir -p /mnt/cdrom 建立光驱的挂载目录
[[email protected] yum.repos.d]# mkdir -p /repo/centos 本地ISO的挂载目录
2.可以直接上传ISO文件或者挂载本地光盘!
- 挂载ISO文件
[[email protected] yum.repos.d]# mount -t iso9660 /dev/cdrom /mnt/cdrom
[[email protected] yum.repos.d]# mount -o loop /repo/iso/CentOS-6.7-x86_64-bin-DVD2.iso /repo/centos
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 44G 12G 31G 27% /
tmpfs 1.2G 72K 1.2G 1% /dev/shm
/dev/sda1 113M 41M 67M 38% /boot
/dev/sda3 3.8G 10M 3.6G 1% /tmp
/repo/iso/CentOS-6.7-x86_64-bin-DVD1.iso
3.7G 3.7G 0 100% /repo/centos
- 确保系统中已经安装了yum相关软件包
[[email protected] ~]# rpm -qa |grep yum
yum-3.2.29-69.el6.centos.noarch
yum-plugin-security-1.1.30-30.el6.noarch
PackageKit-yum-0.5.8-25.el6.x86_64
yum-utils-1.1.30-30.el6.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64
PackageKit-yum-plugin-0.5.8-25.el6.x86_64
yum-plugin-fastestmirror-1.1.30-30.el6.noarch
版本号可能有所不同, 如果缺少, 请自行安装(这些包基本都默认安装了). - 编辑repo文件
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# ll
total 24
-rw-r--r--. 1 root root 1991 Aug 4 2015 CentOS-Base.repo
-rw-r--r--. 1 root root 647 Aug 4 2015 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 289 Aug 4 2015 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Aug 4 2015 CentOS-Media.repo
-rw-r--r--. 1 root root 6259 Aug 4 2015 CentOS-Vault.repo
[[email protected] yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[[email protected] yum.repos.d]# mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak
[[email protected] yum.repos.d]# mv CentOS-fasttrack.repo CentOS-fasttrack.repo.bak
[[email protected] yum.repos.d]# mv CentOS-Vault.repo CentOS-Vault.repo.bak
[[email protected] yum.repos.d]# ll
total 28
-rw-r--r--. 1 root root 1991 Aug 4 2015 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 647 Jun 1 22:48 CentOS-Debuginfo.repo.bak
-rw-r--r--. 1 root root 289 Aug 4 2015 CentOS-fasttrack.repo.bak
-rw-r--r--. 1 root root 630 Aug 4 2015 CentOS-Media.repo
-rw-r--r--. 1 root root 6259 Aug 4 2015 CentOS-Vault.repo.bak
说明:/etc/yum.repos.d/ 下的文件都是有用的,防止以后有用,这里我们mv改名做备份。
CentOS-Media 这个是使用光盘挂载后调用的文件
CentOS-Base 这个是联网后基础的源
CentOS-Vault 这个是最近新版本的加入的老版本的yum源配置
CentOS-Debuginfo debug包尤其和内核相关的更新和软件安装
[[email protected] yum.repos.d]# cat rhel6-public.repo
[rhel6]
name=rhel6
baseurl=file:///mnt/cdrom
enabled=0
gpgcheck=1
备注:enabled=1启用本地yum源,有时候当用1时会报如下错误:Errno 14 Could not open/read repomd.xml 错误,此时需要将enabled=0即可解决!
6.清空yum缓存
[[email protected] yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: c6-media
Cleaning up Everything
[[email protected] yum.repos.d]# yum makecache
Metadata Cache Created
7.生成列表
[[email protected] yum.repos.d]# yum list
- 安装
[[email protected] yum.repos.d]# yum -y install autoconf automake binutils-devel bison cpp dos2unix ftp gcc gcc-c++ lrzsz python-devel
原文地址:http://blog.51cto.com/1146695/2164399