centos6.7不联网的情况下安装配置本地yum源以及能联网的情况下 配置网络yum源

1  cd /

2 mkdir -p /app/ios

3  cd /opt     mkdir ios

4   把下载好的centos-6.7-x86_64-bin-dvd1.iso  上传到 /opt/ios目录下

5 把光盘挂载到 /app/ios目录下

  mount -o loop /opt/ios/CentOS-6.7-x86_64-bin-DVD1.iso /app/ios

二 配置本地yum源 

cd /etc/yum.repos.d/   #进入yum配置目录

vi  CentOS-Media.repo   #编辑配置文件,添加以下内容

[c6=media]
name=CentOS-$releasever - Media #自定义名称(无需修改)
baseurl=file:///app/iso/ #本地光盘挂载路径
gpgcheck=0 #检查GPG-KEY,0为不检查,1为检查
enabled=1 #启用yum源,0为不启用,1为启用
# gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

注意:CentOS需要将/etc/yum.rpos. d/目录下的CentOS-Base.repo  CentOS-Debuginfo.repo文件进行改名,这样就可以绕过网络进行本地源的安装。
       具体命令如下:

     mv CentOS-Base.repo CentOS-Base.repo.bak

     mv CentOS-Vault.repo  CentOS-Vault.repo.bak

     mv CentOS-Debuginfo.repo  CentOS-Debuginfo.repo.bak

  

三、清除yum缓存 yum clean all

      测试本地源的指定是否成功 yum install gcc

 

vi /etc/rc.d/rc.local ###########开机自动挂载###
写入:
mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/source7.0
mount /iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/source7.2
:wq

chmod +x /etc/rc.d/rc.local

 

===========================================================================网络yum源配置说明================================================================

在本地配置好yum源之后,网络yum源一直提示阿里云镜像错误,然后查找了好多资料.找到了新镜像,希望能帮到遇到同样问题的人

2020年11月30日 centos6各大开源镜像站已经停止维护了 但是阿里源还是可以用的 因为他的centos-vault仓库里放了之前版本的centos的包

只需要在centos命令行界面下执行一下几条命令

sed -i "s|enabled=1|enabled=0|g" /etc/yum/pluginconf.d/fastestmirror.conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo 
yum clean all
yum makecache

然后在现在你会发现速度还是之前的速度
       下面再附上这个repo文件的内容

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#released updates 
[updates]
name=CentOS-6.10 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#additional packages that may be useful
[extras]
name=CentOS-6.10 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.10 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-6.10 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

 

posted @ 2019-03-05 15:19  Samuel-Leung  阅读(1635)  评论(0编辑  收藏  举报