随记:RHEL修改yum源

安装了RHEL6.2准备学习邮件系统安装配置,发现忘记安装C环境,准备yum一下又悲催的发现yum不能用。对于我这种懒人,最不耐烦就是一个个的去下载各种包,还是决定拿yum开刀

由于RHEL默认的yum源需要注册(有费用,对于我等学习型选手实在没必要),但又想使用yum方便安装些软件,于是只能考虑修改更新源(其实默认的站点在国外,改成国内的反而更好)。那么理所当然的想到了RedHat的全职小弟CentOS

我使用的是网易镜像

下载repo文件

cd /etc/yum.repos.d     

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

mv CentOS6-Base-163.repo CentOS-Base.repo     //不改名我第一次试不行,改完好了,不知道是不是名字的问题

修改repo文件

vi CentOS-Base.repo

:%s/\$releasever/6/g     //把版本变量替换成6,整个文件如下

   1: # CentOS-Base.repo
   2: #
   3: # The mirror system uses the connecting IP address of the client and the
   4: # update status of each mirror to pick mirrors that are updated to and
   5: # geographically close to the client.  You should use thisfor CentOS updates
   6: # unless you are manually picking other mirrors.
   7: #
   8: # If the mirrorlist= does not work for you, as a fall back you can try the 
   9: # remarked out baseurl= line instead.
  10: #
  11: #
  12:
  13: [base]
  14: name=CentOS-6 - Base - 163.com
  15: baseurl=http://mirrors.163.com/centos/6/os/$basearch/
  16: #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  17: gpgcheck=1
  18: gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
  19:
  20: #released updates 
  21: [updates]
  22: name=CentOS-6 - Updates - 163.com
  23: baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
  24: #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  25: gpgcheck=1
  26: gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
  27:
  28: #additional packages that may be useful
  29: [extras]
  30: name=CentOS-6 - Extras - 163.com
  31: baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
  32: #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  33: gpgcheck=1
  34: gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
  35:
  36: #additional packages that extend functionality of existing packages
  37: [centosplus]
  38: name=CentOS-6 - Plus - 163.com
  39: baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
  40: #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  41: gpgcheck=1
  42: enabled=0
  43: gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
  44:
  45: #contrib - packages by Centos Users
  46: [contrib]
  47: name=CentOS-6 - Contrib - 163.com
  48: baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
  49: #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
  50: gpgcheck=1
  51: enabled=0
  52: gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
  53:

导入GPG key

rpm --import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

好了,打完收工,测试下

yum clean all

yum makecache

都通过了

 

补充:

细看文件结构其实很简单

name=               //系统名称(标示而已)

baseurl=            //url地址

gpgcheck=         //gpg检查,可选,若为1则后面要制定gpgkey位置,如无默认为0

enabled=           //可选,如无则默认为1,

gpgkey=           //gpgkey地址

如此完全可以构建基于本地光盘的yum(当然只是基本的安装包)

echo "[base]">local.repo
echo "name=RHEL6" >>local.repo
echo "baseurl=file:///mnt/Server" >>local.repo
echo "enabled=1" >>local.repo

mount /dev/sr0 /mnt

 

 

 

 

你可能感兴趣的:(linux,yum)