1.查看centos版本,下载对应iso文件
[root@data-service media]# cat /etc/issue
CentOS release 6.6 (Final)
Kernel \r on an \m
2.把iso文件传到服务器,可使用ftp工具,服务器之间传可用scp命令
3.挂载iso文件
#mkdir /media/centos-6.6 如果文件夹不存在则创建一个
mount -o loop CentOS-6.6-x86_64-bin-DVD1.iso /media/centos-6.6/
开机自动挂载需要单独配置
4.编辑repo文件
首先把原来存在的repo文件移除备份
mkdir /etc/yum.repo.d/bk
mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bk
编写自己的repo文件
vim /etc/yum.repo.d/local.repo
内容如下
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/centos-6.6
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enable表示是否启用,baseurl为路径
5.更新缓存
yum clean all
yum makecache
[root@paper-mainServer-500G admin]# yum clean all Loaded plugins: fastestmirror,refresh-packagekit,security Cleaning repos: c6-media Cleaning up Everything Cleaning up list of fastest mirrors [root@paper-mainServer-500G admin]# yum makecache Loaded plugins: fastestmirror,security Determining fastest mirrors c6-media | 4.0 kB 00:00 ... c6-media/group_gz | 216 kB 00:00 ... c6-media/filelists_db | 6.0 MB 00:00 ... c6-media/primary_db | 4.5 MB 00:00 ... c6-media/other_db | 2.8 MB 00:00 ... Metadata Cache Created
6.到此yum本地源配置结束