您好,登錄后才能下訂單哦!
分享幾個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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。