关于yum lock

关于yum lock 
今天在使用yum 的时候遇到了一个问题,我先是remove 了mysql 数据库,然后打算重新安装。出现了下面的提示。
[root@zeng ~]# yum install mysql
Loaded plugins: fastestmirror, refresh-packagekit
Existing lock /var/run/yum.pid: another copy is running as pid 2678.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory :  30 M RSS ( 43 MB VSZ)
    Started: Tue May  8 02:59:33 2012 - 00:09 ago
    State  : Uninterruptible, pid: 2678
查看是什么进程hold the yum lock。
[root@zeng ~]# ps aux|grep yum
root      2678 39.4  7.3 104060 88496 ?        S    02:59   0:33 /usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py update-system yes
root      2693  0.0  0.0   4308   756 pts/0    S+   03:00   0:00 grep yum
有三种方式(可能还有其他)一种是等,网络上看到一个例子说等了2天还没有释放。第二种是重启系统,这对于服务器来说可不是好消息。第三种是kill 掉,不过这种方式有点风险,可能会导致yum 不可用,因为伤害到rpm database。我现在选择 kill 掉那个持有yum lock 的锁。
[root@zeng ~]# kill -9 2678
[root@zeng ~]# ps aux|grep yum
root      2722  0.0  0.0   4308   756 pts/0    S+   03:02   0:00 grep yum
还好没有出现异常。如果出现异常可以重启系统这样yum又可以正常使用了,或者可以试试restart yum 服务(这种方法没试过)。
[root@zeng ~]# yum list gcc
Freeing read locks for locker 0x41e0: 2678/3079218880
Freeing read locks for locker 0x41e2: 2678/3079218880
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * extras: mirror01.idc.hinet.net
 * updates: mirror01.idc.hinet.net
Installed Packages
gcc.i686                                                                  4.4.6-3.el6                                                                   @base

请使用浏览器的分享功能分享到微信等