记录Centos中yum安装中文语言包报:Cannot find a valid baseurl for repo: base/7/x86_64错误

提示错误:

解决方案:

第一步  排除网络问题:
ping baidu.com

成功如下:

第二步  排除DNS配置问题:
 nslookup google.com

成功如下:

第三步  查看mirrorlist.txt是否存在:

发现丢失,本人路径在这:/var/cache/yum/x86_64/7,这个路径下有三个文件夹,如下图:

发现每个文件下的mirrorlist.txt不存在,在每个文件夹下创建新的mirrorlist.txt。 

本人创建文件用的vimcd到当前路径,直接运行命令 vim mirrorlist.txt即可,直接生成新的文件,把如下代码写入保存:

# CentOS-Base.repo
#
#  This file is part of the CentOS Software Repositories.
#
#  CentOS-Base.repo is the configuration file for all of the default
#  repositories in the CentOS software distribution.
#
#  The mirror system uses the connecting IP address of the client and the
#  update status of each mirror to pick mirrors that are updated to and
#  geographically close to the client.  You should use this for CentOS
#  updates unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
 
[base]
name=CentOS-$releasever - Base
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

创建生成 mirrorlist.txt之后,运行如下代码:

echo "http://vault.centos.org/7.6.1810/os/x86_64/" > /var/cache/yum/x86_64/7/base/mirrorlist.txt
echo "http://vault.centos.org/7.6.1810/extras/x86_64/" > /var/cache/yum/x86_64/7/extras/mirrorlist.txt
echo "http://vault.centos.org/7.6.1810/updates/x86_64/" > /var/cache/yum/x86_64/7/updates/mirrorlist.txt

注意!!!记得修改代码中的 7.6.1810 为自己的Centos版本号,查看版本号可以用如下代码

cat /etc/redhat-release

运行完下图所示:

再次运行yum安装命令成功:

最后附yum安装中文包指南:
yum install -y kde-l10n-Chinese  #安装命令
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8    #配置
locale -a    #查看是否配置成功

locake -a运行结果:

另外:如果用上面代码配置不成功的话,可以进入root目录下修改.bashrc文件:

vim .bashrc 
#在该文件中加入以下代码即可
export LANG=zh_CN.utf8
export LC_ALL=zh_CN.utf8

用 locale 命令查看是否成功,成功如下


 

  • 8
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值