centos--Linux系统重新配置repo、epel、yum源

系统:#命令hostnamectl

Virtualization: vmware

Operating System: CentOS Linux 7 (Core)

CPE OS Name: cpe:/o:centos:centos:7

Kernel: Linux 3.10.0-693.el7.x86_64

Architecture: x86-64

注意:此操作需要联网,并且用到wget软件包,没有使用命令:sudo yum  -y  install  wget去安装

1.1移除系统自带的yum仓库

[root@localhost ]# cd /etc/yum.repos.d    ###进入到yum仓库的目录

[root@localhost yum.repos.d]# ls

CentOS-Base.repo  CentOS-fasttrack.repo  CentOS-Vault.repo     mysql-community-source.repo  CentOS-CR.repo       CentOS-Media.repo   CentOS-Debuginfo.repo  CentOS-Sources.repo    mysql-community.repo

[root@localhost yum.repos.d]# mv C* ../bak   ###发现系统自带的yum仓库,创建个bak目录,把系统自带地yum 仓库,全部移地bak目录中

[root@localhost yum.repos.d]# ls

 mysql-community.repo  mysql-community-source.repo

1.2 Linux配置阿里云开源镜像的epel源

在阿里开源镜像中下载相应的repo文件

1.2.1

[root@localhost etc]# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo

--2024-07-18 13:47:14--  http://mirrors.aliyun.com/repo/epel-7.repo

Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 183.204.85.214, 183.204.85.217, 183.204.85.215, ...

Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|183.204.85.214|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 664 [application/octet-stream]

Saving to: ‘/etc/yum.repos.d/epel-7.repo’

100%[===========================================================>] 664         --.-K/s   in 0s      

2024-07-18 13:47:15 (69.9 MB/s) - ‘/etc/yum.repos.d/epel-7.repo’ saved [664/664]

1.2.2

[root@localhost yum.repos.d]#  wget http://mirrors.aliyun.com/repo/Centos-7.repo

--2024-07-18 14:10:13--  http://mirrors.aliyun.com/repo/Centos-7.repo

Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 183.204.83.224, 183.204.83.228, 183.204.83.226, ...

Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|183.204.83.224|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 2523 (2.5K) [application/octet-stream]

Saving to: ‘Centos-7.repo’

100%[===========================================================>] 2,523       --.-K/s   in 0.005s  

2024-07-18 14:10:13 (482 KB/s) - ‘Centos-7.repo’ saved [2523/2523]

[root@localhost yum.repos.d]# ls

Centos-7.repo  epel-7.repo  mysql-community.repo  mysql-community-source.repo

###再次查看,发现已经下载Centos-7.repo&epel-7.repo文件

1.3 安装epel源

[root@localhost yum.repos.d]# yum install -y epel-release

Loaded plugins: fastestmirror, langpacks

base                                                                          | 3.6 kB  00:00:00     

epel                                                                          | 4.3 kB  00:00:00     

extras                                                                        | 2.9 kB  00:00:00     

mysql-connectors-community                                                    | 2.6 kB  00:00:00     

mysql-tools-community                                                         | 2.6 kB  00:00:00     

mysql57-community                                                             | 2.6 kB  00:00:00     

updates                                                                       | 2.9 kB  00:00:00     http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"

Trying other mirror.

base/7/x86_64/primary_db       FAILED                                          

http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Name or service not known"

Trying other mirror.

(9/10): base/7/x86_64/primary_db                                              | 6.1 MB  00:00:10     

(10/10): updates/7/x86_64/primary_db                                          |  27 MB  00:00:50     

Determining fastest mirrors

 * base: mirrors.aliyuncs.com

 * extras: mirrors.aliyuncs.com

 * updates: mirrors.aliyuncs.com

Resolving Dependencies

--> Running transaction check

---> Package epel-release.noarch 0:7-14 will be installed

--> Finished Dependency Resolution

Installing:

 epel-release                 noarch                 7-14                 epel                  15 k

Transaction Summary

===============================================================================

*************省略

Installed:

  epel-release.noarch 0:7-14                                                                         

Complete!

1.4 清除缓存,重新生成缓存

                                                                       

[root@localhost yum.repos.d]# yum clean all

Loaded plugins: fastestmirror, langpacks

Repository epel is listed more than once in the configuration

Repository epel-debuginfo is listed more than once in the configuration

Repository epel-source is listed more than once in the configuration

Cleaning repos: base epel extras mysql-connectors-community mysql-tools-community mysql57-community

              : updates

Cleaning up everything

Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos

Cleaning up list of fastest mirrors

[root@localhost yum.repos.d]# yum makecache

Loaded plugins: fastestmirror, langpacks

Repository epel is listed more than once in the configuration

Repository epel-debuginfo is listed more than once in the configuration

Repository epel-source is listed more than once in the configuration

base                                                                          | 3.6 kB  00:00:00     

epel                                                                          | 4.3 kB  00:00:00     

extras                                                                        | 2.9 kB  00:00:00     

mysql-connectors-community                                                    | 2.6 kB  00:00:00     

mysql-tools-community                                                         | 2.6 kB  00:00:00     

mysql57-community                                                             | 2.6 kB  00:00:00     

updates                                                                       | 2.9 kB  00:00:00     

(1/25): base/7/x86_64/group_gz                                                | 153 kB  00:00:00     

(2/25): base/7/x86_64/primary_db                                              | 6.1 MB  00:00:15     

*******

(24/25): updates/7/x86_64/other_db                                            | 1.6 MB  00:00:04     

(25/25): updates/7/x86_64/primary_db                                          |  27 MB  00:01:10     

Determining fastest mirrors

 * base: mirrors.aliyun.com

 * extras: mirrors.aliyun.com

 * updates: mirrors.aliyun.com

Metadata Cache Created

1.5 测试epel源是否可用------>安装ansible

[root@localhost yum.repos.d]# yum install -y ansible  ###安装ansible

Loaded plugins: fastestmirror, langpacks

Repository epel is listed more than once in the configuration

Repository epel-debuginfo is listed more than once in the configuration

Repository epel-source is listed more than once in the configuration

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * extras: mirrors.aliyun.com

 * updates: mirrors.aliyun.com

Resolving Dependencies

--> Running transaction check

---> Package ansible.noarch 0:2.9.27-1.el7 will be installed

*******

*******

*******

Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

Importing GPG key 0xF4A80EB5:

 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"

 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5

 From       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : python-markupsafe-0.11-10.el7.x86_64                                             1/10

 *****

  Verifying  : python-markupsafe-0.11-10.el7.x86_64                                            10/10

Installed:

  ansible.noarch 0:2.9.27-1.el7                                                                      

Dependency Installed:

  PyYAML.x86_64 0:3.10-11.el7                       libyaml.x86_64 0:0.1.4-11.el7_0                 

  python-babel.noarch 0:0.9.6-8.el7                 python-jinja2.noarch 0:2.7.2-4.el7              

  python-markupsafe.x86_64 0:0.11-10.el7            python-paramiko.noarch 0:2.1.1-9.el7            

  python2-httplib2.noarch 0:0.18.1-3.el7            python2-jmespath.noarch 0:0.9.4-2.el7           

  sshpass.x86_64 0:1.06-2.el7                      

Complete!

 ######完成安装,说明epel源可用

OK!

1.6安装zstd

yum install -y  zstd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值