yum:command not found

执行yum 命令时 提示yum命令找不到

[root@nfs ~]# yum install -y inotify-tools
-bash: yum: command not found

一、打开清华大学镜像 站https://mirrors.tuna.tsinghua.edu.cn(或其他)
进入路径:https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/
注意:找到对应自己centos系统的版本
找到以下rpm软件包:

python-iniparse-0.4-9.el7.noarch.rpm
yum-3.4.3-163.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm

二、安装rpm包

[root@nfs ~]# rpm -ivh python*
warning: package python-iniparse-0.4-9.el7.noarch was already added, skipping python-iniparse-0.4-9.el7.noarch
Preparing...                          ################################# [100%]
	package python-iniparse-0.4-9.el7.noarch is already installed
[root@nfs ~]# rpm -ivh yum*
warning: package yum-metadata-parser-1.1.4-10.el7.x86_64 was already added, skipping yum-metadata-parser-1.1.4-10.el7.x86_64
Preparing...                          ################################# [100%]
Updating / installing...
   1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 33%]
   2:yum-plugin-fastestmirror-1.1.31-5################################# [ 67%]
   3:yum-3.4.3-163.el7.centos         ################################# [100%]

三、yum源优化

root@nfs ~]# cd /etc/yum.repos.d/
[root@nfs yum.repos.d]# ls
CentOS-Base.repo      CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo  epel.repo
CentOS-Base.repo.bak  CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo
[root@nfs yum.repos.d]# rm -rf*
[root@nfs yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2020-01-14 16:22:43--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 111.32.173.225, 111.32.172.238, 111.32.172.240, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|111.32.173.225|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

100%[=====================================================================>] 2,523       --.-K/s   in 0s      

2020-01-14 16:22:43 (156 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]
[root@nfs yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
--2020-01-14 16:25:18--  http://mirrors.aliyun.com/repo/epel-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 111.32.173.233, 183.201.230.245, 111.32.172.240, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|111.32.173.233|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 664 [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/epel.repo’

100%[=====================================================================>] 664         --.-K/s   in 0s      

2020-01-14 16:25:23 (37.0 MB/s) - ‘/etc/yum.repos.d/epel.repo’ saved [664/664]

[root@nfs yum.repos.d]# ls
CentOS-Base.repo  epel.repo

四、执行下载测试

[root@nfs yum.repos.d]# yum install -y rsync
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
epel                                                                                    | 5.3 kB  00:00:00     
(1/3): epel/x86_64/group_gz                                                             |  90 kB  00:00:00     
^C/3): epel/x86_64/updateinfo            17% [=====                          ] 321 kB/s | 1.4 MB  00:00:21 ETA 

Exiting on user cancel
[root@nfs yum.repos.d]# yum install -y cowsay
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
epel/x86_64/primary_db                                                                  | 6.9 MB  00:00:11     
Resolving Dependencies
--> Running transaction check
---> Package cowsay.noarch 0:3.04-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                  Arch                     Version                        Repository              Size
===============================================================================================================
Installing:
 cowsay                   noarch                   3.04-4.el7                     epel                    42 k

Transaction Summary
===============================================================================================================
Install  1 Package

Total download size: 42 k
Installed size: 77 k
Downloading packages:
cowsay-3.04-4.el7.noarch.rpm                                                            |  42 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : cowsay-3.04-4.el7.noarch                                                                    1/1 
  Verifying  : cowsay-3.04-4.el7.noarch                                                                    1/1 

Installed:
  cowsay.noarch 0:3.04-4.el7                                                                                   

Complete!
发布了11 篇原创文章 · 获赞 1 · 访问量 266

猜你喜欢

转载自blog.csdn.net/octtom/article/details/103974282