yum 命令无法使用

一、yum 命令无法使用

[root@localhost ~]# yum install git
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error 
14: curl#7 - "Failed to connect to 2001:1b48:203::4:10: Network is unreachable"


 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo= ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable 
        or
            subscription-manager repos --disable=

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

解决办法:
1、排除是否安装了yum命令(有出现命令介绍说明安装了yum命令)

yum -help

2、确认是yum命令的问题,看出错信息: Network is unreachable,网络的问题—》网卡没有跟随系统启动,所以设置网卡跟随系统启动

找到网卡:
[root@localhost network-scripts]# ifconfig
enp0s3: flags=4163  mtu 1500
        inet 192.168.1.111  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::aaa6:de:84ef:4350  prefixlen 64  scopeid 0x20
        ether 08:00:27:90:6d:12  txqueuelen 1000  (Ethernet)
        RX packets 5268  bytes 511652 (499.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2124  bytes 381701 (372.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4  bytes 344 (344.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 344 (344.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:55:79:f5  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

3、找到网卡配置文件(ifcfg-enp0s3)之后修改参数:ONBOOT=no改为yes(如果没有配置文件,自己创建一个)

vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
---------------------------------------------------------------------
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=d4dae77b-4cbe-4234-93cd-9b0b3b7103ed
DEVICE=enp0s3
ONBOOT=yes   #修改此处参数将no改为yes
IPADDR=192.168.1.23
PREFIX=24
GATEWAY=192.168.1.1
IPV6_PRIVACY=no
ZONE=public

4、重启网络:service network restart

5、检验:yum install 你要安装的服务

你可能感兴趣的:(linux)