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

CentOS 8 执行yum命令报错:Failed to set locale, defaulting to C.UTF-8

今天Docker新搞了一个CentOS镜像,在运行基于该镜像的容器,执行yum命令时,遇到了如下报错:

[root@GC Administrator]# yum install -y yum-utils
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream                                                               41  B/s |  38  B     00:00
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

目前使用 docker pull centos 不指定tag,拉取的latest,centos的版本为 8.4.2105

[root@GC Administrator]# cat /etc/redhat-release 
CentOS Linux release 8.4.2105

1. yum镜像源问题

其中 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist 是yum镜像源的问题,这个问题我在之前的一篇文章中已经总结过解决方案。
CentOS 执行yum命令报错【错误:为仓库 ‘appstream‘ 下载元数据失败: …】

你可以参考上述文章进行解决,你也可以直接运行下面的命令进行解决(上述文章中提到的其中一种方案)

# Centos 8 之前版本
# 以 CentOS 7.9.2009 为例
minorver=7.9.2009
sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \-e "s|^#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=https://mirrors.aliyun.com/centos-vault/$minorver|g" \-i.bak \/etc/yum.repos.d/CentOS-*.repo# CentOS 8 版本
# 以 CentOS 8.5.2111 为例
minorver=8.5.2111
sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \-e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever|baseurl=https://mirrors.aliyun.com/centos-vault/$minorver|g" \-i.bak \/etc/yum.repos.d/CentOS-*.repo

2. 语言环境问题

其中Failed to set locale, defaulting to C.UTF-8是系统语言环境问题
下面是解决方案:

1)查看本地安装的语言包

[root@GC ~]# locale -a
C
C.utf8
POSIX

2)安装语言包

安装中文语言包:yum install glibc-langpack-zh
安装英文语言包:yum install glibc-langpack-en

我这里只安装了 中文语言包 👇

[root@GC Administrator]# locale -a
C
C.utf8
POSIX
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8
zh_HK
zh_HK.utf8
zh_SG
zh_SG.gbk
zh_SG.utf8
zh_TW
zh_TW.euctw
zh_TW.utf8

3)设置语言环境

echo "export LC_ALL=zh_CN.utf8" >> /etc/profile
source /etc/profile

从你已安装的语言中,选择你想要设置的语言,我这里选择的是zh_CN.utf8

4)验证语言是否设置成功

[root@GC Administrator]# yum install -y yum-utils
Last metadata expiration check: 0:17:50 ago on 2023年08月25日 星期五 14时06分57秒.
Dependencies resolved.
========================================================================================================================Package                                 Architecture          Version                      Repository             Size
========================================================================================================================
Installing:yum-utils                               noarch                4.0.18-4.el8                 baseos                 71 k
Installing dependencies:dbus-glib                               x86_64                0.110-2.el8                  baseos                127 kdnf-plugins-core                        noarch                4.0.18-4.el8                 baseos                 69 kpython3-dateutil                        noarch                1:2.6.1-6.el8                baseos                251 kpython3-dbus                            x86_64                1.2.4-15.el8                 baseos                134 kpython3-dnf-plugins-core                noarch                4.0.18-4.el8                 baseos                234 kpython3-six                             noarch                1.11.0-8.el8                 baseos                 38 kTransaction Summary
========================================================================================================================
Install  7 PackagesTotal download size: 925 k
Installed size: 2.3 M
Downloading Packages:
(1/7): dnf-plugins-core-4.0.18-4.el8.noarch.rpm                                         145 kB/s |  69 kB     00:00
(2/7): dbus-glib-0.110-2.el8.x86_64.rpm                                                 256 kB/s | 127 kB     00:00
(3/7): python3-dateutil-2.6.1-6.el8.noarch.rpm                                          363 kB/s | 251 kB     00:00
(4/7): python3-dbus-1.2.4-15.el8.x86_64.rpm                                             404 kB/s | 134 kB     00:00
(5/7): python3-six-1.11.0-8.el8.noarch.rpm                                              225 kB/s |  38 kB     00:00
(6/7): python3-dnf-plugins-core-4.0.18-4.el8.noarch.rpm                                 536 kB/s | 234 kB     00:00
(7/7): yum-utils-4.0.18-4.el8.noarch.rpm                                                299 kB/s |  71 kB     00:00
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   879 kB/s | 925 kB     00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing        :                                                                                                1/1Installing       : python3-six-1.11.0-8.el8.noarch                                                                1/7Installing       : python3-dateutil-1:2.6.1-6.el8.noarch                                                          2/7Installing       : dbus-glib-0.110-2.el8.x86_64                                                                   3/7Running scriptlet: dbus-glib-0.110-2.el8.x86_64                                                                   3/7Installing       : python3-dbus-1.2.4-15.el8.x86_64                                                               4/7Installing       : python3-dnf-plugins-core-4.0.18-4.el8.noarch                                                   5/7Installing       : dnf-plugins-core-4.0.18-4.el8.noarch                                                           6/7Installing       : yum-utils-4.0.18-4.el8.noarch                                                                  7/7Running scriptlet: yum-utils-4.0.18-4.el8.noarch                                                                  7/7Verifying        : dbus-glib-0.110-2.el8.x86_64                                                                   1/7Verifying        : dnf-plugins-core-4.0.18-4.el8.noarch                                                           2/7Verifying        : python3-dateutil-1:2.6.1-6.el8.noarch                                                          3/7Verifying        : python3-dbus-1.2.4-15.el8.x86_64                                                               4/7Verifying        : python3-dnf-plugins-core-4.0.18-4.el8.noarch                                                   5/7Verifying        : python3-six-1.11.0-8.el8.noarch                                                                6/7Verifying        : yum-utils-4.0.18-4.el8.noarch                                                                  7/7Installed:dbus-glib-0.110-2.el8.x86_64      dnf-plugins-core-4.0.18-4.el8.noarch          python3-dateutil-1:2.6.1-6.el8.noarchpython3-dbus-1.2.4-15.el8.x86_64  python3-dnf-plugins-core-4.0.18-4.el8.noarch  python3-six-1.11.0-8.el8.noarchyum-utils-4.0.18-4.el8.noarchComplete!

OK,搞定~

http://www.lryc.cn/news/148876.html

相关文章:

  • 8. 损失函数与反向传播
  • Angular安全专辑之四 —— 避免服务端可能的资源耗尽(NodeJS)
  • Servlet学习总结(Request请求与转发,Response响应,Servlet生命周期、体系结构、执行流程等...)
  • 雅思写作 三小时浓缩学习顾家北 笔记总结(二)
  • Element Plus 日期选择器的使用和属性
  • 中国五百强企业用泛微为合同加速,提升数字化办公水平
  • Vue3 QRCode生成
  • 2023年8月随笔之有顾忌了
  • 正中优配:红筹股是啥意思?
  • 《Linux从练气到飞升》No.19 进程等待
  • OpenCV
  • hadoop解决数据倾斜的方法
  • 打造坚不可摧的代码堡垒 - 搭建GitLab私有仓库完全指南
  • linux把文件压缩/解压成.tar.gz/tar/tgz等格式的命令大全
  • 用户角色权限demo后续出现问题和解决
  • SpringBoot在IDEA里实现热部署
  • 浅谈Linux中的mkdir -p
  • 设计模式—职责链模式(Chain of Responsibility)
  • vue小测试之拖拽、自定义事件
  • 时序预测 | MATLAB实现DBN-SVM深度置信网络结合支持向量机时间序列预测(多指标评价)
  • Python中异步编程是什么意思? - 易智编译EaseEditing
  • 【JS真好玩】自动打字机效果
  • 宠物赛道,用AI定制宠物头像搞钱项目教程
  • 基于vue和element的脚手架【vue-element-admin 和vue-element-plus-admin 】
  • 推荐Java开发常用的工具类库google guava
  • stencilJs学习之构建 Drawer 组件
  • hbase 国内镜像 极速下载
  • Linux驱动——Tiny4412芯片_Source Insight的下载+Linux3.5内核下工程的创建
  • rust交叉编译 在mac下编译linux和windows
  • linux离线环境安装redis