您好,登录后才能下订单哦!
分享几个CentOS7的yum源,
每个做技术的总会经历各种各样的小白时刻,各种各样的窘况,下面分享一下自己的心得:
情况如下,本人一不小心安装了最小化的CentOS 7,(就是没有CRT的上传下载工具,也没有 Wget),又是远程管理,突然间想远程安装一些软件,各种抓狂,想更新一下yum源,居然没有好的方 法 ,下载了阿里和网易的yum源,打开后会面临一个比较尴尬的问题,没有分行,没办法用CRP复制粘 贴,所以本文就给大家一个可以用CRT输进去的yum。
首先说明一下:CentOS 7新添加了一个模块(已加载插件:fastestmirror),这个模块可以自动识别 最近的yum源,不过还是不如写入的yum源速度快。
步骤如下:
1:备份自有的yum源
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.BK
2:清空/etc/yum.repos.d/CentOS-Base.repo,等待新的yum源输入。
echo "" > /etc/yum.repos.d/CentOS-Base.repo
(当然我这只是个人习惯,也可删除后重建,或者用vi编辑器删除该命令的意思是
将一个空格追加到该文件中,并且覆盖之前文件)
3:用vi编辑器打开该文件/etc/yum.repos.d/CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo
4:将下列文件粘贴进去(阿里yum)
# 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-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
5.":wq"退出后,使用yum makecache生成缓存,有可能会失败,这是因为有可能在配置网络的 时候DNS为谷歌的8.8.8.8,该地址对国内个别网站的解析并不完美,所以会提示无法找到主机。
可以编辑/etc/resolv.conf 添加一条"nameserver 114.114.114.114",别问为啥是这个DNS,因为好 记。
6.yum makecache,然后记得yum install wget,然后想更换其他源可以直接用wget。不再举 例。
BUG:在CentOS 7里,修改/etc/resolv.conf,并不能永久修改DNS,不过可以写在网卡里,不过修 改网卡配置文件需要重启网卡才能生效,写在/etc/resolv.conf中会立马生效,在研究中,详情请见 后续博文。
备注:如有疑问请留言,如需转载请注明出处。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。