Open bingooyong opened 3 years ago
以下为修改Centos6.5的yum源:
[root@keepmydream ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.下载新的CentOS-Base.repo 到/etc/yum.repos.d/
Centos5地址:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
Centos6地址:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
Centos7地址:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
#!/bin/bash
#一键自动部署安装阿里云yum镜像源
#Date:2020.04.17
#set -euo pipefail
#判断yum源安装是否完成,并将输出结果写入日志
install_result(){
if [ $? -eq 0 ];then
echo "安装 aliyun yum源成功"
else
echo "安装 aliyun yum源失败"
exit 1
fi
}
#检查网络情况
ping -c 1 developer.aliyun.com >/dev/null && ping -c 1 www.baidu.com >/dev/null &&
[ $? -eq 0 ] && echo "网络检测正常,正在进行下一步" || echo “网络异常,请检查当前网络情况”
#检查wget命令是否安装
wget --version >/dev/null || yum install wget -y
#备份系统yum文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
#获取当前系统型号
Centos_Version=`cat /etc/redhat-release |awk -F"[. ]+" '{print $4}'`
echo "正在为您安装Centos ${Centos_Version} 阿里云镜像源,请稍等..."
#通过wget方式下载阿里云yum源、epel源
case ${Centos_Version} in
6)
yum_6="wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo"
epel_6="wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo"
${yum_6} && ${epel_6}
install_result # 调用结果判断函数
;;
7)
yum_7="wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo"
epel_7="wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo"
${yum_7} && ${epel_7}
install_result # 调用结果判断函数
;;
8)
yum_8="wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo"
epel_8="yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm"
${yum_8} && ${epel_8}
install_result # 调用结果判断函数
#将repo配置中的地址替换为阿里云镜像站地址
sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
;;
*)
echo "获取该系统版本信息为为:${Centos_Version},请检查当前系统信息"
exit 1
;;
esac
#yum缓存
echo "正在进行yum makecache, 请勿操作..."
yum clean all >/dev/null && yum makecache fast >>Dev_install_yum.log
if [ $? -eq 0 ];then
echo "清除yum源或生成yum缓存成功"
else
echo "清除yum源或生成yum缓存失败"
echo "清除yum源或生成yum缓存失败"
fi
[root@localhost ~]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,584
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 468
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1,969
repolist: 26,093
配置参考:http://mirrors.aliyun.com/help/epel
## 1、备份(如有配置其他epel源)
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
## 2、下载新repo 到/etc/yum.repos.d/
# epel(RHEL 7)
wget-O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# epel(RHEL 6)
wget-O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
# epel(RHEL 5)
wget-O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
yum clean all
yum makecache
CentOS 7 关闭图形界面
查看/etc/inittab如下:
新版本的CentOS 系统里使用’targets’ 取代了运行级别的概念。系统有两种默认的’targets’: 多用户.target 对应之前版本的3 运行级别; 而图形.target 对应之前的5运行级别。
查看默认的target,执行:
开机以命令模式启动,执行:
开机以图形界面启动,执行: