【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.repo

ll
# 应该出现
总用量 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.com

http://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

你可能感兴趣的:(linux,centos,网络,linux)