新增:《解决 CentOS 8 执行 yum install 报 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist 的问题》
This commit is contained in:
@@ -426,6 +426,14 @@ mkdir -p 目录路径
|
||||
rm -rf 文件名/目录名
|
||||
```
|
||||
|
||||
如果想删除指定目录下除某个文件及某个目录之外的所有文件,可以试试通配符匹配:
|
||||
|
||||
```shell
|
||||
# 但使用前先记得开启通配符功能,可以通过 shopt -s 查看是否开启了,on 表示已经开启
|
||||
# shopt -s extglob
|
||||
rm -rf !(target_file|target_dir)
|
||||
```
|
||||
|
||||
### 复制文件或目录
|
||||
|
||||
```shell
|
||||
|
@@ -264,3 +264,40 @@ docker version
|
||||
docker info
|
||||
```
|
||||
|
||||
## docker-compose命令
|
||||
|
||||
### 启动并后台运行所有的服务
|
||||
|
||||
```shell
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### 停止并删除容器、网络、卷、镜像
|
||||
|
||||
```shell
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### 列出项目中目前的所有容器
|
||||
|
||||
```shell
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
### 停止容器
|
||||
|
||||
```shell
|
||||
docker-compose stop 容器名
|
||||
```
|
||||
|
||||
### 启动容器
|
||||
|
||||
```shell
|
||||
docker-compose start 容器名
|
||||
```
|
||||
|
||||
### 修改 yml 文件后,重新启动并后台运行
|
||||
|
||||
```shell
|
||||
docker-compose up --force-recreate -d
|
||||
```
|
||||
|
@@ -21,13 +21,13 @@ tags:
|
||||
1. 软件更新
|
||||
|
||||
```shell
|
||||
yum update
|
||||
yum -y update
|
||||
```
|
||||
|
||||
2. 安装 yum-utils
|
||||
|
||||
```shell
|
||||
yum install -y yum-utils device-mapper-persistent-data lvm2
|
||||
yum -y install yum-utils device-mapper-persistent-data lvm2
|
||||
```
|
||||
|
||||
3. 设置 yum 软件源
|
||||
|
75
docs/categories/issues/2022/10/25/解决CentOS8执行yum安装报错.md
Normal file
75
docs/categories/issues/2022/10/25/解决CentOS8执行yum安装报错.md
Normal file
@@ -0,0 +1,75 @@
|
||||
---
|
||||
title: "解决 CentOS 8 执行 yum install 报 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist 的问题"
|
||||
author: 查尔斯
|
||||
date: 2022/10/25 21:20
|
||||
categories:
|
||||
- Bug万象集
|
||||
tags:
|
||||
- Linux
|
||||
- CentOS
|
||||
---
|
||||
|
||||
# 解决 CentOS 8 执行 yum install 报 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist 的问题
|
||||
|
||||
## 问题描述
|
||||
|
||||
**C:** 今天,笔者在一台刚重装了 CentOS 8.2 操作系统的云服务器上正打算安装一下 Docker,结果开局安装依赖的环节就报错了。
|
||||
|
||||
```
|
||||
CentOS Linux 8 - AppStream
|
||||
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
|
||||
```
|
||||
|
||||

|
||||
|
||||
<!-- more -->
|
||||
|
||||
## 原因分析
|
||||
|
||||
首先排除掉是安装 Docker 引起的错误,因为笔者起初还尝试了下把三个依赖分开安装,想看看是不是由于某个依赖安装引起的,最终发现无论执行 yum 安装哪一个包都会报这个错。
|
||||
|
||||
而从报错信息的字面意思来看,应该是和 yum 的镜像源有关。
|
||||
|
||||
```
|
||||
错误:从仓库 ‘appstream’ 下载元数据失败:无法准备内部镜像列表:镜像列表中没有 url
|
||||
```
|
||||
|
||||
这可就触碰到笔者的盲区部分了,最不擅长的就是这类 Linux 系统的初始配置,所以笔者搜索了一下,发现了一个较为靠谱的答案。
|
||||
|
||||
> 2020 年 12 月 8 号,CentOS 官方宣布了停止维护 CentOS Linux 的计划,并推出了 CentOS Stream 项目,CentOS Linux 8 作为 RHEL 8 的复刻版本,生命周期缩短,于 2021 年 12 月 31 日停止更新并停止维护(EOL),更多的信息可以查看 CentOS 官方公告。[1]
|
||||
|
||||
## 解决方案
|
||||
|
||||
解决起来也较为容易,那就是如果需要更新 CentOS,需要将镜像从 mirror.centos.org 更改为 vault.centos.org。
|
||||
|
||||
1. 进入 yum 的 repos 目录
|
||||
|
||||
```shell
|
||||
cd /etc/yum.repos.d/
|
||||
```
|
||||
|
||||
2. 替换镜像
|
||||
|
||||
```shell
|
||||
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
|
||||
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
|
||||
```
|
||||
|
||||
3. 生成缓存
|
||||
|
||||
```shell
|
||||
yum makecache
|
||||
```
|
||||
|
||||
4. 更新
|
||||
|
||||
```shell
|
||||
yum -y update
|
||||
```
|
||||
|
||||
等待更新完之后,再执行 yum 安装就正常了。
|
||||
|
||||
## 参考资料
|
||||
|
||||
1. 【已解决】Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorlist:https://blog.csdn.net/weixin_43252521/article/details/124409151
|
||||
1. CentOS Project shifts focus to CentOS Stream:https://blog.centos.org/2020/12/future-is-centos-stream/
|
Binary file not shown.
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 194 KiB |
Reference in New Issue
Block a user