CentOS 6.5下更換YUM源 及 搭建YUM本地源服務器


一.換源

唔,由於眾所周知的原因,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=os
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
mirrorlist=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/$basearch
baseurl=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
……
 
         
 
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM