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源的四千多个多了不少!

 

posted @ 2019-06-03 14:11  Rich七哥  阅读(6320)  评论(1编辑  收藏  举报