1. First back up CentOS -Base.repo, if the 163 source has not been added before, this step can be omitted
cd /etc/yum.repos.d/ mv CentOS-Base.repo CentOS-Base.repo.backup
2. Download the 163 source
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
3. Change the downloaded file to the source file
mv CentOS6-Base-163.repo CentOS-Base.repo
4. Run the following command to generate the cache
yum clean all yum makecache
yum makecache may have the following error:
Loaded plugins: refresh-packagekit, security http://mirrors.163.com/centos/6Server/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 -"The requested URL returned error: 404 Not Found" Trying other mirror. Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
We try to enter http://mirrors .163.com/centos...
The result is still: 404 Not Found
At this time we entered http://mirrors.163.com/centos/ and found: there are 6 6.0-6.8 in the directory directory, there is no 6Server directory. Guess $releasever was incorrectly compiled to: 6Server; it should be 6.4 in the correct case. (Mine is CentOs6.4)
We need to modify all $releasever in CentOS-Base.repo to 6.4:
vi CentOS-Base.repo # 在末行模式下执行以下: :%s/$releasever/6.4 # Esc -> Shift+: 进入末行模式 # 修改完保存退出:Esc -> Shift+: -> wq
Rerun
yum makecache
Haha, maybe An error similar to the previous one still occurs, as follows:
Loaded plugins: refresh-packagekit, security http://mirrors.163.com/centos/6.4/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 -"The requested URL returned error: 404 Not Found" Trying other mirror. Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
Enter http://mirrors.163.com/centos/ again and find that there are only readme files in the 6.4 directory, while there are complete files in the 6 directory. . So we need to modify it again: change all 6.4 to 6 (if you are afraid of the trouble of modifying each one, you can re-download the source file) as follows:
rm -rf CentOS-Base.repo # 先删除6.4的源文件 wget http://mirrors.163.com/.help/CentOS6-Base-163.repo # 把下载文件改成源文件 mv CentOS6-Base-163.repo CentOS-Base.repo yum clean all yum makecache
Done! ! ! ! !