yum源配置、epel源配置
关键词:yum源,本地yum源,网络yum源
【1】配置本地yum源
1、挂载好光盘到/redhat/mnt/mnt下
mount /dev/cdrom /mnt
2、操作
cd /etc/yum.repos.d/
ll
#新建一个文件,修改内容
vim base.repo
代码参考:
echo "/dev/sde /mnt btrfs defaults 0 0" >> /etc/fstab 添加repo文件 cp CentOS7-Base-163.repo local_yum.repo 复制一个原来的repo源 vim local_yum.repo 编辑 添加以下内容到local_yum.repo [local_yum] name=local_yum baseurl=file:///mnt gpgcheck=0 enabled=1 yum clean all 清空缓存
【2】配置网络yum源
相关源地址:
阿里云Yum源的CentOS 6网址:http://mirrors.aliyun.com/centos/6/
中科大Yum源的CentOS 6网址:http://centos.ustc.edu.cn/centos/6/
网易Yum源的CentOS 6网址:http://mirrors.163.com/centos/6/
清华Yum源的CentOS 6网址:https://mirrors.tuna.tsinghua.edu.cn/centos/6/
参考于:
http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD
(2.1)备份下载源repo文件
1、备份原文件 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak 2、下载新的repo文件 CentOS 5 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo CentOS 6 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo CentOS 7 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 网易源centos6 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
(2.2)查看配置核验
[root@rac1 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo --2017-10-14 23:18:31-- http://mirrors.163.com/.help/CentOS6-Base-163.repo 正在解析主机 mirrors.163.com... 123.58.190.209, 123.58.190.228, 123.58.190.234, ... 正在连接 mirrors.163.com|123.58.190.209|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:2006 (2.0K) [application/octet-stream] 正在保存至: “/etc/yum.repos.d/CentOS-Base.repo” 100%[=========================================================>] 2,006 --.-K/s in 0.001s 2017-10-14 23:18:31 (1.90 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2006/2006])
核验:----------
下载成功后,加载缓存 yum clean all yum makecache #yum update #更新yum源到本地 #安装现在的yum源,这一步也是测试新安装的yum源有没有安装成功 yum install yum
----------
(2.3)故障处理
1、如果报域名解析失败:
[root@RAC01 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo --2017-10-14 01:22:16-- http://mirrors.aliyun.com/repo/Centos-6.repo
正在解析主机 mirrors.aliyun.com... 失败:域名解析暂时失败。 wget: 无法解析主机地址 “mirrors.aliyun.com”
2、新增dns域名地址
新增下面一条内容:
[root@RAC01 yum.repos.d]# vi /etc/resolv.conf nameserver 8.8.8.8
【3】epel源
EPEL源-是什么?为什么安装? EPEL (Extra Packages for Enterprise Linux)是基于Fedora的一个项目,为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS和Scientific Linux. 使用很简单: 1. 首先需要安装一个叫”epel-release”的软件包,这个软件包会自动配置yum的软件仓库。当然你也可以不安装这个包,自己配置软件仓库也是一样的。 #用于RHEL5系列 wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm rpm -ivh epel-release-5-4.noarch.rpm #用于RHEL6系列 wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm rpm -ivh epel-release-6-5.noarch.rpm 2. 安装完成之后你就可以直接使用yum来安装额外的软件包了 yum clean all yum makecache yum install nginx pure-ftpd 3.直接自己手工添加软件仓库配置文件 vi /etc/yum.repos.d/epel.repo [epel] name=epel mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-releasever&arch=releasever&arch=basearch enabled=1 gpgcheck=0 CentOS6.5添加阿里云的EPEL源 yum localinstall --nogpgcheck http://mirrors.aliyun.com/epel/6/x86_64/epel-release-6-8.noarch.rpm 安装阿里云EPEL源 1、首先卸载以前装的epel以免影响 rpm -e epel-release 2、 下载阿里提供的epel wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-6.repo 3、yum clean all 4、yum makecache 阿里云源安装示例: 1、备份(如有配置其他epel源) 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 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 来源:https://www.cnblogs.com/fps2tao/p/7580188.html
【4】centos 6/7 自动更换为阿里云源
vim auto_yum.sh
#!/bin/bash #centos 6 7 自动更换 为阿里云源 bkrepo() { mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup } up6() { 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 clean all yum makecache } up7() { 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 clean all yum makecache } uprepo() { case $1 in 6) bkrepo touch /etc/yum.repos.d/{CentOS-Base,epel}.repo up6 ;; 7) bkrepo touch /etc/yum.repos.d/{CentOS-Base,epel}.repo up7 ;; *) echo "Can't recognize your system" ;; esac } Ver=`awk '{split($(NF-1),v,".");print v[1]}' /etc/centos-release` read -t 60 -p "Are you sure to replace the YUM source? yes or no:" chrepo ch=`echo "$chrepo" | tr 'A-Z' 'a-z'` if [ $ch == "yes" ]; then uprepo $Ver fi
自动替换centos7的yum源为阿里云源:
./auto_yum.sh 7
【5】yum 小技巧
(5.1)查看命令是哪个包 yum provides cmd
yum provides ifconfig //如果ifconfig命令不存在,可以通过yum查询该命令来自于哪个软件包
(5.2)查看Yum安装是否成功 yum repolist -v