当前位置: 首页 > news >正文

【Centos8】配置网络镜像源

文章目录

    • 配置 yum 源
    • 配置网络 yum 源
      • 备份
      • 下载阿里 centos-base.repo 到 /etc/yum.repos.d/
      • 安装 EPEL 源
      • 测试安装

配置 yum 源

# 检查是否安装了 yum
rpm -qa|grep yum# 查看本地已安装的所有软件包
yum list installed# 查看软件包安装位置
# 查看某个东西的软件包
rpm -qa|grep xxx
# 将出现:
ntpdate-4.2.6p5-29.el7.centos.2.x86_64
# 查看路径
rpm -ql ntpdate-4.2.6p5-29.el7.centos.2.x86_64
# 将出现:
/etc/ntp
/etc/ntp/keys
/etc/ntp/step-tickers
/etc/sysconfig/ntpdate
/usr/lib/systemd/system/ntpdate.service
/usr/libexec/ntpdate-wrapper
/usr/sbin/ntpdate
/usr/share/doc/ntpdate-4.2.6p5
/usr/share/doc/ntpdate-4.2.6p5/COPYRIGHT
/usr/share/man/man8/ntpdate.8.gz

配置网络 yum 源

备份

# 切换路径并查看目录下文件
cd /etc/yum.repos.d
ll
# 应该出现
总用量 40
-rw-r--r--. 1 root root 1664 1023 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 1023 2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 1023 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 1023 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 1023 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 1023 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 1023 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 1023 2020 CentOS-x86_64-kernel.repo# 将所有文件备份到新建文件夹 repo_back 下
# 创建文件夹
mkdir repo_back
# 将所有 .repo 和 .repo.bak 文件移动到 repo_back 下
mv *.repo repo_back/
mv *.repo.bak repo_back/
ll

下载阿里 centos-base.repo 到 /etc/yum.repos.d/

# 下载文件(最后的数字是版本号)
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7
# 或者(recommand)
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repoll
# 应该出现
总用量 4
-rw-r--r--. 1 root root 2523 117 11:25 CentOS-Base.repo
drwxr-xr-x. 2 root root  220 117 11:21 repo_back# 清理缓存
yum clean all
# 应该出现
已加载插件:fastestmirror
正在清理软件源: base extras updates
Cleaning up list of fastest mirrors# 生成新的缓存
yum makecache
# 应该出现
已加载插件:fastestmirror
Determining fastest mirrors* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.comhttp://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; 拒绝连接"
正在尝试其它镜像。
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; 未知的错误"
正在尝试其它镜像。
base                                                                          | 3.6 kB  00:00:00     
extras                                                                        | 2.9 kB  00:00:00     
updates                                                                       | 2.9 kB  00:00:00     
(1/10): base/7/x86_64/group_gz                                                | 153 kB  00:00:00     
(2/10): base/7/x86_64/primary_db                                              | 6.1 MB  00:00:08     
(3/10): extras/7/x86_64/filelists_db                                          | 303 kB  00:00:03     
(4/10): extras/7/x86_64/primary_db                                            | 250 kB  00:00:03     
(5/10): extras/7/x86_64/other_db                                              | 150 kB  00:00:00     
(6/10): base/7/x86_64/other_db                                                | 2.6 MB  00:00:07     
(7/10): base/7/x86_64/filelists_db                                            | 7.2 MB  00:00:17     
(8/10): updates/7/x86_64/filelists_ 58% [===============           ] 1.2 MB/s |  32 MB  00:00:18 ETA 
(8/10): updates/7/x86_64/filelists_db                                         |  13 MB  00:00:23     
(9/10): updates/7/x86_64/other_db                                             | 1.4 MB  00:00:02     
(10/10): updates/7/x86_64/primary_db                                          |  24 MB  00:00:33     
元数据缓存已建立

安装 EPEL 源

yum list | grep epel-release
# 应该出现
epel-release.noarch                         7-11                       extras   yum install -y epel-release
# 应该出现
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成依赖关系解决===================================================================================================== Package                     架构                  版本                  源                     大小
=====================================================================================================正在安装:epel-release                noarch                7-11                  extras                 15 k事务概要
=====================================================================================================安装  1 软件包总下载量:15 k
安装大小:24 k
Downloading packages:
epel-release-7-11.noarch.rpm                                                  |  15 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在安装    : epel-release-7-11.noarch                                                         1/1 验证中      : epel-release-7-11.noarch                                                         1/1 已安装:epel-release.noarch 0:7-11                                                                         完毕!# 检查是否生成 epel.repo 和 epel-testing.repo!
ll# 清理缓存
yum clean all
# 应该出现
已加载插件:fastestmirror
正在清理软件源: base epel extras updates
Cleaning up list of fastest mirrors# 生成新的缓存
yum makecache
# 应该出现
已加载插件:fastestmirror
Determining fastest mirrors
epel/x86_64/metalink                                                          | 7.6 kB  00:00:00     * base: mirrors.aliyun.com* epel: mirrors.bfsu.edu.cn* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
base                                                                          | 3.6 kB  00:00:00     
https://mirror.01link.hk/epel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#60 - "Peer's Certificate has expired."
正在尝试其它镜像。
It was impossible to connect to the CentOS servers.
This could mean a connectivity issue in your environment, such as the requirement to configure a proxy,
or a transparent proxy that tampers with TLS security, or an incorrect system clock.
You can try to solve this issue by using the instructions on https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.epel                                                                          | 4.7 kB  00:00:00     
extras                                                                        | 2.9 kB  00:00:00     
updates                                                                       | 2.9 kB  00:00:00     
(1/16): base/7/x86_64/group_gz                                                | 153 kB  00:00:00     
(2/16): base/7/x86_64/primary_db                                              | 6.1 MB  00:00:05     
(3/16): epel/x86_64/group_gz                                                  |  99 kB  00:00:00     
(4/16): epel/x86_64/prestodelta                                               | 2.9 kB  00:00:00     
(5/16): epel/x86_64/primary_db                                                | 7.0 MB  00:00:09     
(6/16): base/7/x86_64/other_db                                                | 2.6 MB  00:00:09     
(7/16): extras/7/x86_64/filelists_db                                          | 303 kB  00:00:00     
(8/16): extras/7/x86_64/primary_db                                            | 250 kB  00:00:00     
(9/16): extras/7/x86_64/other_db                                              | 150 kB  00:00:00     
(10/16): epel/x86_64/updateinfo                                               | 1.0 MB  00:00:17     
(11/16): updates/7/x86_64/filelists_db                                        |  13 MB  00:00:18     
(12/16): updates/7/x86_64/other_db                                            | 1.4 MB  00:00:03     
(13/16): base/7/x86_64/filelists_db 68% [=================-        ] 1.2 MB/s |  53 MB  00:00:19 ETA 
(13/16): epel/x86_64/other_db                                                 | 3.4 MB  00:00:36     
(14/16): updates/7/x86_64/primary_db                                          |  24 MB  00:00:36     
(15/16): epel/x86_64/filelists_db                                             |  12 MB  00:01:00     
(16/16): base/7/x86_64/filelists_db                                           | 7.2 MB  00:02:02     元数据缓存已建立# 检查仓库是否启用!
yum repolist enabled
# 应该出现
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* epel: mirrors.bfsu.edu.cn* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
源标识                          源名称                                                         状态
base/7/x86_64                   CentOS-7 - Base - mirrors.aliyun.com                           10,072epel/x86_64                     Extra Packages for Enterprise Linux 7 - x86_64                 13,791extras/7/x86_64                 CentOS-7 - Extras - mirrors.aliyun.com                            518updates/7/x86_64                CentOS-7 - Updates - mirrors.aliyun.com                         5,367repolist: 29,748# 查看所有仓库!
yum repolist all
# 应该出现
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* epel: mirrors.bfsu.edu.cn* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
源标识                        源名称                                                     状态
base/7/x86_64                 CentOS-7 - Base - mirrors.aliyun.com                       启用: 10,072centosplus/7/x86_64           CentOS-7 - Plus - mirrors.aliyun.com                       禁用
contrib/7/x86_64              CentOS-7 - Contrib - mirrors.aliyun.com                    禁用
epel/x86_64                   Extra Packages for Enterprise Linux 7 - x86_64             启用: 13,791epel-debuginfo/x86_64         Extra Packages for Enterprise Linux 7 - x86_64 - Debug     禁用
epel-source/x86_64            Extra Packages for Enterprise Linux 7 - x86_64 - Source    禁用
epel-testing/x86_64           Extra Packages for Enterprise Linux 7 - Testing - x86_64   禁用
epel-testing-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 - 禁用
epel-testing-source/x86_64    Extra Packages for Enterprise Linux 7 - Testing - x86_64 - 禁用
extras/7/x86_64               CentOS-7 - Extras - mirrors.aliyun.com                     启用:    518updates/7/x86_64              CentOS-7 - Updates - mirrors.aliyun.com                    启用:  5,367repolist: 29,748

测试安装

# 下载
yum install -y httpd
# 卸载
yum erase httpd -y
http://www.lryc.cn/news/253338.html

相关文章:

  • 深入学习Synchronized各种使用方法
  • 【idea】设置鼠标滚轮控制缩放大小
  • 合并两个有序数组(leetcode_刷题1)
  • 麒麟linux将图片批量生成PDF的方法
  • Linux——vim编辑文件时——.swp文件解决方案
  • 【Maven】清理 maven 仓库
  • APOLLO自动驾驶技术沙龙:未来已来,共创智能交通新时代
  • Java面试题12
  • ubuntu上创建服务启动python脚本
  • 51单片机制作数字频率计
  • java中强引用、软引用、弱引用、虚引用的区别是什么?
  • springboot -事务管理
  • 商城系统通过Kafka消息队列,实现订单的处理和状态更新
  • IntelRealSense深度相机D455在ROS1运行中的消息内容
  • 公有云迁移研究——AWS Translate
  • 【laBVIEW学习】4.声音播放,自定义图标,滚动条设置,保存参数以及恢复参数
  • 《论文阅读》使用条件变分自动编码器学习神经对话模型的语篇水平多样性 2017 ACL
  • 【win32_003】不同字符集下的通用字符串语法TCHAR、TEXT、PTSTR、PCTSTR
  • 《漫长的等待》—— 读后感
  • 基于ROPNet项目训练modelnet40数据集进行3d点云的配置
  • 力扣215. 数组中的第K个最大元素
  • 轻量封装WebGPU渲染系统示例<40>- 多层材质的Mask混合(源码)
  • 程序员的实用网站导航与推荐
  • 上午面了个腾讯拿 38K 出来的,让我见识到了基础的天花板
  • 【halcon】C# halcon 内存暴增
  • LeetCode130. Surrounded Regions
  • 【实战教程】PHP如何轻松对接腾讯云COS,实现文件上传下载?
  • pytorch学习10-网络模型的保存和加载
  • SQL Server 2016(分离和附加数据库)
  • 用友U8 Cloud RegisterServlet SQL注入漏洞复现