1.优化镜像自带的yum源为国内源
这里通过自己编写的脚本直接进行替换:
#!/bin/bash
#创建一个备份yum源的文件夹
mkdir /etc/yum.repos.d/backup/
#将原有yum源备份到创建的备份文件夹
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
#第一种情况:CentOS版本为6时,替换为CentOS6对应的yum源
if [ `uname -r |awk -F. '{ print $1 }'` -eq 2 ];then
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum makecache
fi
#第二种情况:当系统为CentOS7时,替换yum源为CentOS7的yum源
if [ `uname -r |awk -F. '{ print $1 }'` -eq 3 ];then
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum makecache
fi
浙公网安备 33010602011771号