1. 程式人生 > >linux 快速安裝yum源

linux 快速安裝yum源

1、虛擬機器安裝後第一步先掛載mount /dev/cdrom /mnt
如果掛載出錯可以關機再啟動
2、備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
3、再裝wget
rpm -ivh /mnt/Packages/wget-1.12-8.el6.x86_64.rpm
4、下載新的CentOS-Base.repo 到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
5、之後執行yum makecache生成快取


真實伺服器有時候系統自帶wget,也不用掛載,直接執行下兩布就OK:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

 

 

-bash: yum: command not found 錯誤

 

             在學習Linux時,誤把yum命令給刪除了,在百度了好幾篇文章,但沒能解決……............

檢視有無 yum安裝包 ,有的話解除安裝:

檢視:rpm -qa |grep yum

解除安裝:rpm -aq|grep yum|xargs rpm -e --nodeps

第一步: 到這個網站去下載如下RPM包 :http://mirrors.163.com/centos/6/os/x86_64/Packages/

cd /etc/yum.repo.d/
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-cron-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm

第二步:下載完成後安裝:
rpm -ivh --force --nodeps python-urlgrabber-3.9.1-11.el6.noarch.rpm
rpm -ivh --force --nodeps yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh --force --nodeps yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm yum-3.2.29-81.el6.centos.noarch.rpm

注意:注意最後兩個包必需同時安裝,否則會相互依賴 

第三步:下載阿里雲的yum源:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo  

 

下載以後生成快取,命令:

yum makecache 

 

如果有提示錯誤,執行下面的命令:[Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"

sed -i 's/\$releasever/6/' CentOS-Base.repo 備註:把檔案裡的$releasever替換為6

 

最後:重新生成快取,數字不為0,就OK了:

yum clean all

yum makecache

 

好了,就到這了!希望可以幫到你!