CentOS下更换yum源

来源:互联网 发布:医学大数据 职业病 编辑:程序博客网 时间:2024/04/28 22:25

首先进入yum源配置目录

cd /etc/yum.repos.d

备份系统自带的yum源

mv CentOS-Base.repo CentOS-Base.repo.bk

根据 wiki.ubuntu.org.cn/源列表 的镜像地址列表,找一个喜欢的镜像源。
http://mirrors.aliyun.com/

http://mirrors.aliyun.com/help/centos
下载新的CentOS-Base.repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean allyum makecache   #生成缓存

yum更换源后,发现redis都下不了
这是因为缺少了扩展包 EPEL(Extra Packages for Enterprise Linux),可以用 yum repolist 命令检查下。

安装epel包

rpm -ivh http://mirrors.aliyun.com/epel/6Server/i386/epel-release-6-8.noarch.rpm

也可以用这个http://mirrors.aliyun.com/repo/epel-6.repo
repolist检查下:

[root@dev4svn /]# yum repolistLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirror01.idc.hinet.net * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comrepo id           reponame base              CentOS-6 - Base - mirrors.aliyun.com   epel              Extra Packages for Enterprise Linux 6 - i386      extras            CentOS-6 - Extras - mirrors.aliyun.com                 updates           CentOS-6 - Updates - mirrors.aliyun.com          repolist: 15,572

有Extra Packages for Enterprise Linux 6 - i386 表示EPEL安装好了

[root@dev4svn /]# find / -name "redis*"/etc/yum.repos.d/redis-2.8.19-2.el7.x86_64.rpm/etc/redis.conf/etc/logrotate.d/redis/etc/rc.d/init.d/redis/usr/share/doc/redis-2.4.10/usr/bin/redis-benchmark/usr/bin/redis-check-dump/usr/bin/redis-cli/usr/bin/redis-check-aof/usr/sbin/redis-server/var/run/redis/var/log/redis/var/lib/redis

测试一下redis

reids-server /etc/redis.confredis-benchmark -h localhost -p 6379 -c 100 -n 100000#100个并发连接,100000个请求,检测host为localhost 端口为6379的redis服务器性能

RedHat使用CentOS源

删除redhat原有的yum

rpm -aq|grep yum|xargs rpm -e --nodeps 

下载CentOS的yum安装文件

wget http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpmwget http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm wget http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpmwget http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-3.2.29-69.el6.centos.noarch.rpm

安装CentOS的yum

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpmrpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpmrpm -ivh yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm  yum-3.2.29-69.el6.centos.noarch.rpm#最后两个包必需同时安装,否则会相互依赖 

更新yum源文件

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo cd /etc/yum.repos.dcp rhel-source.repo rhel-source.repo.backvi rhel-source.repo

把文件里面的$releasever全部替换为版本号,即6 最后保存。

# 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 - Base - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/6/os/$basearch/        http://mirrors.aliyuncs.com/centos/6/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=osgpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#released updates [updates]name=CentOS-$releasever - Updates - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/6/updates/$basearch/        http://mirrors.aliyuncs.com/centos/6/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updatesgpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#additional packages that may be useful[extras]name=CentOS-$releasever - Extras - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/6/extras/$basearch/        http://mirrors.aliyuncs.com/centos/6/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extrasgpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages[centosplus]name=CentOS-6 - Plus - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/6/centosplus/$basearch/        http://mirrors.aliyuncs.com/centos/6/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users[contrib]name=CentOS-6 - Contrib - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/6/contrib/$basearch/        http://mirrors.aliyuncs.com/centos/6/contrib/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contribgpgcheck=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

更新yum源

yum updaterpm -ivh http://mirrors.aliyun.com/epel/6Server/i386/epel-release-6-8.noarch.rpm
0 0