In the CentOS VM provided by the company, there is only one build.repo under/ETC/YUM.REPOS.D, and the Yum source provided is only a few sources within the company, and many packages are not found in these sources. To add a different source, the following post describes how to add Zhong Ke, Sohu, and 163 yum sources to CentOS: http://www.husw.net/blog/post/1386/. Excerpts are as follows:
This article describes the Yum source supported version of the CentOS 6 series, which theoretically supports the RHEL6 series.
The Update method is as follows:
Enter the Yum source configuration directory First
Cd/etc/yum.repos.d
The Yum source that comes with the backup system
MV Centos-base.repo Centos-base.repo.save
Download other faster Yum sources
Zhong Ke's yum Source:
wget Http://centos.ustc.edu.cn/CentOS-Base.repo
163 of Yum Sources:
wget Http://mirrors.163.com/.help/CentOS-Base-163.repo
Sohu's Yum Source
wget Http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
After updating the Yum source, it is recommended to update it so that the operation takes effect immediately.
Yum Makecache
[Yasi]:In the last step, the loaded plugins:fastestmirrorrepository base is listed more than once in the configurationrepository updates are L Isted more than once in the Configurationrepository extras are listed more than once in the Configurationrepository CENTOSP LUs is listed more than once in the Configurationrepository contrib are listed more than once in the configurationloading m Irror speeds from Cached Hostfile * addons:mirrors.163.com * base:mirror.metrocast.net * extras:mirror.beyondhosting.ne T * fasttrack:centos.vipernetworksystems.com * updates:centos.vipernetworksystems.comhttp://mirrors.163.com/centos/6/addons/x86_64/repodata/repomd.xml: [Errno] Pycurl ERROR-"The requested URL Returned error:404 "Trying other mirror.http://mirror.centos.org/centos/6/addons/x86_64/repodata/repomd.xml: [Errno] Pycurl ERROR-"The requested URL returned error:404 "Trying other mirror.Error:cannot Retrieve repository metadata (Repomd.xml) for repository:addons. Verify its path and try againThe reason is thathttp://mirrors.163.com/centos/6/addons/x86_64/repodata/repomd.xml and http://mirror.centos.org/centos/ 6/addons/x86_64/repodata/repomd.xml does not exist and may be updated. The workaround is to
find the available URLs to replace them, or to comment out the entire item in the corresponding. repo file . I use the latter here.
For example, in Centos-base-163.repo, comment out the entire addon item
#[addons] #name =centos-$releasever-addons-163.com #mirrorlist =http:// mirrorlist.centos.org/?release= $releasever &arch= $basearch &repo=addons #baseurl =http:// mirrors.163.com/centos/$releasever/addons/$basearch/ #gpgcheck =1 #pgkey =file:///etc/pki/ Rpm-gpg/rpm-gpg-key-centos-5
comment out the following in Centos-base-sohu.repo
#[addons] #name =centos-$releasever-addons-sohu.com #mirrorlist =http:// mirrorlist.centos.org/?release= $releasever &arch= $basearch &repo=addons #baseurl =http:// mirrors.sohu.com/centos/$releasever/addons/$basearch/ #gpgcheck =1 #gpgkey =file:///etc/pki/ Rpm-gpg/rpm-gpg-key-centos-5centos-base-sohu.repo
Then, execute the Yum makecache. After that, Yum can find the packages I want to install, such as GDB, Subversion, gcc-c++, and so on.
Note:
Sometimes you can't find a package with Yum list xxx, you can try Yum search xxx。 For example, yum list vim reports error:no matching Packages to list. and Yum search vim returns:
vim-x11.x86_64:the vim version of the VI editor for the X Window systemvim-common.x86_64:the Common Files needed By any version of the Vim editorvim-enhanced.x86_64:a version of the Vim editor which includes recent enhancementsvim-m Inimal.x86_64:a minimal version of the VIM editor
Yum replacement Source (1)--yum cannot find the installation package