CentOS 6.5下更換YUM源 及 搭建YUM本地原始伺服器

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   使用   ar   檔案   

一.換源

唔,由於眾所周知的原因,CentOS本身提供的好多YUM源路徑下載速度是很慢的。所以,換源。

# cd /etc/yum.repos.d
# cp CentOS-Base.repo CentOS-Base.repo.backup# vim CentOS-Base.repo

正常情況下,CentOS-Base.repo這個檔案用的是mirrorlist的方式擷取源路徑然後再下載源包的,不用管他,刪掉這幾行

 

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osmirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesmirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

 

 

把下面這幾行的#去掉

#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/

然後把其中的mirror.centos.org換成國內原始伺服器的地址就好了

比如換成阿里源

baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearchbaseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/

國內還有一些不錯的原始伺服器

中科大源http://mirrors.ustc.edu.cn/centos網易源http://mirrors.163.com/centos/搜狐源http://mirrors.sohu.com/centos/

二.搭建本地原始伺服器

在實驗室人多的時候下載東西是很不道德的,所以很多時候我要搭建伺服器下載東西都是很麻煩的。可是晚上的時候實驗室網路又沒有人使用,所以我就想搭建一個本地原始伺服器來用,也能方便師兄師姐師弟師妹們快速更新。

首先要下載兩個軟體# yum install createrepo httpd

然後啟動http伺服器
# service httpd start
# chkconfig httpd on

進入http的目錄下
cd /var/www/html/
mkdir centos
cd centos

顯示源列表
# yum repolist

一般會有base,update,extras,epel等

選擇一個下載,全都要下載的
# reposync --repoid=base

全部下載完後當前檔案夾下會多出來幾個檔案夾,修改一下使用者組和許可權

# chown -R yourname:yourgroup /var/www/html/centos
# chmod -R 755 /var/www/html/centos

用下面的命令在centos的每個目錄下建立檔案庫
$ createrepo /var/www/html/centos/base

成功之後就可以修改.repo檔案中的路徑了
[base]
……
baseurl=http://localhost/centos/base
……
[update]
……
baseurl=http://localhost/centos/update
……
 
[extras]
……
baseurl=http://localhost/centos/extras
……

 
 

 

CentOS 6.5下更換YUM源 及 搭建YUM本地原始伺服器

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.