Redhat7 CentOS7安裝阿里雲的yum源


先說CentOS的

1、備份

[root@harry ~]# cd /etc/yum.repos.d/
[root@harry yum.repos.d]# mkdir repo_bak [root@bogon yum.repos.d]# mv *.repo repo_bak/ [root@bogon yum.repos.d]# ls repo_bak

2、下載新的CentOS-Base.repo 到/etc/yum.repos.d/[root@harry

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

[root@ yum.repos.d]# ls
CentOS-Base.repo repo_bak

3、之后運行yum clean all 清除緩存,運行 yum makecache 生成新的緩存

yum clean all
yum makecache

安裝EPEL(Extra Packages for Enterprise Linux )源

4、安裝EPEL源

[root@ yum.repos.d]# yum list | grep epel-release
epel-release.noarch                         7-9                        extras   
[root@bogon yum.repos.d]# yum install -y epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-9 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================
 Package                             Arch                          Version                    Repository                     Size
==================================================================================================================================
Installing:
 epel-release                        noarch                        7-9                        extras                         14 k

Transaction Summary
==================================================================================================================================
Install  1 Package

Total download size: 14 k
Installed size: 24 k
Downloading packages:
epel-release-7-9.noarch.rpm                                                                                |  14 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-9.noarch                                                                                        1/1 
  Verifying  : epel-release-7-9.noarch                                                                                        1/1 

Installed:
  epel-release.noarch 0:7-9                                                                                                       

Complete!
[root@harry yum.repos.d]# ls                      #多了epel.repo和epel-testing.repo
CentOS-Base.repo  epel.repo  epel-testing.repo  repo_bak

 

5、再次運行yum clean all 清除緩存,運行 yum makecache 生成新的緩存

6、查看啟用的yum源和所有的yum源

yum repolist enabled 
 yum repolist all     
 
 
 
然后說Redhat的

由於Red Hat Enterprise Linux7的更新包只對注冊的用戶生效,所以需要自己手動改成Centos的更新包,Centos幾乎和和Redhat是一樣的,所以無需擔心軟件包的兼容問題。

首先查看redhat7系統本身安裝的yum軟件包 ,redhat本身安裝了6個關於yum的軟件包,我們需要把它給卸載!

rpm -qa | grep yum


卸載這些軟件包的指令   

rpm -qa | grep yum | xargs rpm -e --nodeps #不檢查依賴關系,直接卸載


然后重新安裝centos的yum軟件包 ,把軟件包放到統一的文件夾里,然后安裝,安裝完后可以看到centos安裝包已經安裝好。這里我看其他很多人的教程給的centos的yum的安裝包的鏈接都是不可用了,后來我自己到國外的網站找了幾個可用的安裝包。

鏈接: https://pan.baidu.com/s/10IrBjM5j_TJT0Qc2aW64Cg   提取碼: i4pe

rpm -ivh * # 安裝該目錄下所有rpm包
rpm -qa | grep yum # 查詢是否安裝好


安裝完centos的yum軟件包后,就可以去修改 /etc/yum.repos.d/ 下的文件了,這里和配置本地yum源修改一樣

[base]
name= yum repo
baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
enabled=1
gpgcheck=0
配置完保存退出,清除yum緩存,查看yum中的包有多少,這里可以看到有11056個,比本地yum源的四千多個多了不少!

 


免責聲明!

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



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