RHEL7解决无法使用YUM源问题,配置EPEL源

 

RHEL7正版改变yum源方法,解决RHEL7正版不能正常yum软件,置换源,CentOS 镜像

切换到root目录先

[root@server1 ~]# rpm -qa|grep yum|xargs rpm -e --nodeps ■ 首先删除所有得原先得yum已安装好得命令
[root@server1 ~]# rpm -qa|grep yum ■ 查看原先安装得yum是否卸载成功

[root@server1 ~]#

<更新于20210506>

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm;
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm;
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm;
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm;
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm;
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm;


■ 用WGET命令从163yum源下载到root目录下面,由于版本会有更新,请去官网使用最新版本 网址

[root@server1 ~]# rm -rf /etc/yum.repos.d/* ■ 删除 /etc/yum.repos.d目录下得所有文件
[root@server1 ~]# mkdir /etc/yum.repos.d/ ■ 如果该目录不存在,自己手动创建这个目录
[root@server1 ~]# rpm -ivh --force --nodeps *.rpm ■ 强行安装所有得root目录下得.rpm包

  • 警告:PackageKit-yum-1.1.10-1.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
  • 准备中... ################################# [100%]
  • 正在升级/安装...
  • 1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 14%]
  • 2:python-urlgrabber-3.10-9.el7 ################################# [ 29%]
  • 3:python-iniparse-0.4-9.el7 ################################# [ 43%]
  • 4:yum-plugin-fastestmirror-1.1.31-5################################# [ 57%]
  • 5:yum-3.4.3-163.el7.centos ################################# [ 71%]
  • 6:PackageKit-yum-1.1.10-1.el7.cento################################# [ 86%]
  • 7:yum-utils-1.1.31-52.el7 ################################# [100%]

[root@server1 ~]# yum-config-manager --add-repo="http://mirrors.163.com/.help/CentOS7-Base-163.repo"      ■ 下载这个文件到/etc/yum.repos.d/目录下

  • 已加载插件:fastestmirror, product-id
  • adding repo from: http://mirrors.163.com/.help/CentOS7-Base-163.repo
  • grabbing file http://mirrors.163.com/.help/CentOS7-Base-163.repo to /etc/yum.repos.d/CentOS7-Base-163.repo
  • repo saved to /etc/yum.repos.d/CentOS7-Base-163.repo

[root@server1 ~]# cd /etc/yum.repos.d/ ■ 切换到该目录下
[root@server1 yum.repos.d]# vim CentOS7-Base-163.repo ■ 编辑该文件 把该文件中得所有得$releasever换成7(:%s/$releasever/7/g)
[root@server1 yum.repos.d]# cd ■ 切换到root目录
[root@server1 ~]# yum clean all ■ 执行这条命令

  • 已加载插件:fastestmirror, product-id, subscription-manager
  • This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  • 正在清理软件源: base extras updates

[root@server1 ~]# yum makecache ■ 再执行这条命令

  • 已加载插件:fastestmirror, product-id, subscription-manager
  • This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  • Determining fastest mirrors
  • base | 3.6 kB 00:00:00
  • extras | 2.9 kB 00:00:00
  • updates | 2.9 kB 00:00:00
  • (7/10): updates/x86_64/filelists_db | 3.3 MB 00:02:07
  • (8/10): updates/x86_64/other_db | 368 kB 00:00:08
  • (9/10): base/x86_64/filelists_db | 7.3 MB 00:05:08
  • updates/x86_64/primary_db | 5.9 MB 00:01:17
  • 元数据缓存已建立

[root@server1 ~]# yum repolist ■ 再执行这条命令,有结果就基本得yum源已经改好了。

  • 已加载插件:fastestmirror, product-id, subscription-manager
  • This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  • Loading mirror speeds from cached hostfile
  • 源标识 源名称 状态
  • base/x86_64 CentOS-7 - Base - 163.com 10,097
  • extras/x86_64 CentOS-7 - Extras - 163.com 307
  • updates/x86_64 CentOS-7 - Updates - 163.com 1,012
  • repolist: 11,416

[root@sever1 ~]# yum -y install bash-completion  ■下个软件试一下 TAB键位自动补齐功能

 

配置EPEL源
通常服务器 有以下四种源。实际上都是基础性质源
* base: mirrors.aliyun.com
* epel: ftp.iij.ad.jp
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com

[root@server1 ~]# yum -y install epel-release ■执行这条命令,直接下载

  • 已加载插件:fastestmirror, product-id, subscription-manager
  • This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  • Loading mirror speeds from cached hostfile
  • 正在解决依赖关系
  • --> 正在检查事务
  • ---> 软件包 epel-release.noarch.0.7-11 将被 安装
  • --> 解决依赖关系完成
  • 总下载量:15 k
  • 安装大小:24 k
  • Downloading packages:
  • 正在安装 : epel-release-7-11.noarch 1/1
  • 验证中 : epel-release-7-11.noarch 1/1
  • 已安装:
  • epel-release.noarch 0:7-11
  • 完毕!

[root@server1 ~]# cd /etc/yum.repos.d/ ■切换到该目录下
[root@server1 yum.repos.d]# ls -a ■安装好epel-release之后会在该目录下出现epel.repo这个文件

  • . .. CentOS7-Base-163.repo epel.repo epel-testing.repo redhat.repo

[root@server1 yum.repos.d]# vim epel.repo ■ 编辑这个文件 参考※1,有得可以不用改更加好用,都试一下就可以
※1 改掉第一块中得下面标颜色得地方,实际就是把两个注释符号换一下
 [epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
... ....

[root@server1 yum.repos.d]# yum repolist  ■ 查看下yum源是否已经多了一个epel

  • 已加载插件:fastestmirror, product-id, subscription-manager
  • This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  • Loading mirror speeds from cached hostfile
  • epel | 5.3 kB 00:00:00
  • (1/3): epel/x86_64/group_gz | 90 kB 00:00:01
  • (2/3): epel/x86_64/updateinfo | 1.0 MB 00:00:17
  • (3/3): epel/x86_64/primary_db | 6.9 MB 00:01:43
  • 源标识 源名称 状态
  • base/x86_64 CentOS-7 - Base - 163.com 10,097
  • epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,509
  • extras/x86_64 CentOS-7 - Extras - 163.com 307
  • updates/x86_64 CentOS-7 - Updates - 163.com 1,012
  • repolist: 24,925

[root@server1 yum.repos.d]# yum list nginx ■看看能不能下载nginx

  • 已加载插件:fastestmirror, product-id, subscription-manager
  • This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  • Loading mirror speeds from cached hostfile
  • 可安装的软件包
  • nginx.x86_64 1:1.16.1-1.el7
     

你可能感兴趣的:(linux,red,hat,rhel7,linux,yum,epel)