今天重置了下虚拟机,yum准备安装gcc编译器,出现如下错误

[root@localhost ~]# yum install -y gcc*
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 3593.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 109 M RSS (447 MB VSZ)
    Started: Thu Jul 26 18:25:02 2018 - 01:38 ago
    State  : Sleeping, pid: 3593
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 109 M RSS (447 MB VSZ)
    Started: Thu Jul 26 18:25:02 2018 - 01:40 ago
    State  : Sleeping, pid: 3593

但是我这是一个新的虚拟机,而且当前就连接了一个ssh用户,也没有使用yum,

显示是yum在锁定状态中Existing lock /var/run/yum.pid,也知道pid是3593 通过kill干掉他

[root@localhost ~]# kill -9 3593

然后再次检查

[root@localhost ~]#** yum repolist **
BDB2053 Freeing read locks for locker 0x9b9: 3593/140359627216704
BDB2053 Freeing read locks for locker 0x9b7: 3593/140359627216704
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.tuna.tsinghua.edu.cn
repo id                                                               repo name                                                                status
base/7/x86_64                                                         CentOS-7 - Base                                                          9,911
extras/7/x86_64                                                       CentOS-7 - Extras                                                          363
updates/7/x86_64                                                      CentOS-7 - Updates                                                       1,004
repolist: 11,278

这样yum可以正常使用

[root@localhost ~]# yum install -y gcc*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
…………
…………
Installed:
  gcc.x86_64 0:4.8.5-28.el7_5.1                 gcc-c++.x86_64 0:4.8.5-28.el7_5.1                   gcc-gfortran.x86_64 0:4.8.5-28.el7_5.1         
  gcc-gnat.x86_64 0:4.8.5-28.el7_5.1            gcc-go.x86_64 0:4.8.5-28.el7_5.1                    gcc-objc.x86_64 0:4.8.5-28.el7_5.1             
  gcc-objc++.x86_64 0:4.8.5-28.el7_5.1          gcc-plugin-devel.x86_64 0:4.8.5-28.el7_5.1         

Dependency Installed:
  cpp.x86_64 0:4.8.5-28.el7_5.1                   glibc-devel.x86_64 0:2.17-222.el7                glibc-headers.x86_64 0:2.17-222.el7              
  gmp-devel.x86_64 1:6.0.0-15.el7                 kernel-headers.x86_64 0:3.10.0-862.9.1.el7       libgfortran.x86_64 0:4.8.5-28.el7_5.1            
  libgnat.x86_64 0:4.8.5-28.el7_5.1               libgnat-devel.x86_64 0:4.8.5-28.el7_5.1          libgo.x86_64 0:4.8.5-28.el7_5.1                  
  libgo-devel.x86_64 0:4.8.5-28.el7_5.1           libmpc.x86_64 0:1.0.1-3.el7                      libmpc-devel.x86_64 0:1.0.1-3.el7                
  libobjc.x86_64 0:4.8.5-28.el7_5.1               libquadmath.x86_64 0:4.8.5-28.el7_5.1            libquadmath-devel.x86_64 0:4.8.5-28.el7_5.1      
  libstdc++-devel.x86_64 0:4.8.5-28.el7_5.1       mpfr-devel.x86_64 0:3.1.1-4.el7                 

Dependency Updated:
  glibc.x86_64 0:2.17-222.el7           glibc-common.x86_64 0:2.17-222.el7   libgcc.x86_64 0:4.8.5-28.el7_5.1   libgomp.x86_64 0:4.8.5-28.el7_5.1  
  libstdc++.x86_64 0:4.8.5-28.el7_5.1  

Complete!


**总结:执行命令中遇到问题基本思路:
首先一定学会分析问题,必须有一个清晰的思路。
首先遇到问题不能害怕,
其次不建议直接去上网搜索,搜了好多,很可能还没解决。
再此分享下我的解决思路,如下三步。希望对大家有帮助,当然我也是在不断地学习中。
看提示(终端显示的错误信息,建议执行方法)
查日志(查看系统日志 /var/log/目录下的日志文件,如果是相关服务,请查看服务的日志文件,比如MySQL数据库的日志文件等)
上谷歌(通过网络查看是否有相同或者相似的问题)**