2013年12月14日 星期六

[研究] 解決 PackageKit 的 yum lock (CentOS 6.5 x64)

[研究] 解決 PackageKit 的 yum lock (CentOS 6.5 x64)

2013-12-14
2017-10-18 更新

有時候使用 yum 相關功能時,會出現 yum lock 問題,而來源是 PackageKit

[root@localhost ~]# yum list | grep hadoop
Existing lock /var/run/yum.pid: another copy is running as pid 3896.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory :  48 M RSS (359 MB VSZ)
    Started: Sat Dec 14 01:17:15 2013 - 7:34:27 ago
    State  : Sleeping, pid: 3896
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory :  48 M RSS (359 MB VSZ)
    Started: Sat Dec 14 01:17:15 2013 - 7:34:29 ago
    State  : Sleeping, pid: 3896
^C

Exiting on user cancel.

[root@localhost ~]#

有時候 yum lock 沒多久就解開了,有時候會等很久,筆者碰過超過一天仍在鎖住的情況。

找出 PackageKit

[root@localhost ~]# ps aux | grep PackageKit
root      3896  0.0  4.8 367904 49592 ?        S    01:17   0:00 /usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py get-packages unknown
root     29945  0.0  0.0 103256   840 pts/1    S+   08:51   0:00 grep PackageKit
[root@localhost ~]#

用 kill -9 去刪除 process

[root@localhost ~]# kill -9 3896

檢查,成功刪除 process 了

[root@localhost ~]# ps aux | grep PackageKit
root     29955  0.0  0.0 103252   836 pts/1    S+   08:53   0:00 grep PackageKit

再次執行,仍被 lock

[root@localhost ~]# yum list | grep hadoop
Existing lock /var/run/yum.pid: another copy is running as pid 3896.
Another app is currently holding the yum lock; waiting for it to exit...
Another app is currently holding the yum lock; waiting for it to exit...
Another app is currently holding the yum lock; waiting for it to exit...

^C

Exiting on user cancel.

一般程序執行時候,lock file 會放在 /var/lock/subsys/ 目錄,但此處沒有 yum 或 python 或 PackageKit

[root@localhost ~]# ls /var/lock/subsys/
abrt-ccpp  auditd            crond      local         network         rpc.statd
abrtd      autofs            cups       lvm2-monitor  NetworkManager  rsyslog
acpid      blk-availability  haldaemon  messagebus    postfix         sshd
atd        certmonger        ip6tables  netfs         rpcbind         udev-post
[root@localhost ~]#

從剛剛的訊息
Existing lock /var/run/yum.pid: another copy is running as pid 3896.
yum 的 lock file 是 /var/run/yum.pid,用 rm -fr 指令刪除

[root@localhost ~]# rm -fr /var/run/yum.pid

再次執行,不再有 lock 訊息

[root@localhost ~]# yum list | grep hadoop
[root@localhost ~]#

PackageKit 是甚麼?它是 GNOME X-Window 底下負責管理/安裝和移除套件的工具,套件名稱為 gnome-packagekit。
Fedora 由 9 開始採用 PackageKit 系統 協助 YUM 作為管理套件,而 gnome-packagekit 亦取替 Pirut 成為 Fedora 的預設套件管理工具。

[root@localhost ~]# yum list | grep gnome-packagekit
gnome-packagekit.x86_64                   2.28.3-7.el6                   @anaconda-CentOS-201311272149.x86_64/6.5
gnome-packagekit-extra.x86_64             2.28.3-7.el6                   base
[root@localhost ~]#

如果不想再碰到 PackageKit 產生 yum lock,且你不會在 GNOME X-Window 底下用圖形介面 (GUI) 管理/安裝和移除套件,可以考慮把它移除。

[root@localhost ~]# yum -y remove gnome-packagekit

********************************************************************************
2017-10-18

CentOS 7.4 x64

有時候強行把 PackageKit 用 kill 刪除,會出問題

[root@localhost ~]# yum -y install iftop
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 2439.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory :  27 M RSS (439 MB VSZ)
    Started: Tue Oct 17 18:54:09 2017 - 00:02 ago
    State  : Running, pid: 2439
^C

Exiting on user cancel.
[root@localhost ~]# ps aux | grep PackageKit
root       2439 24.0 22.8 1143668 228096 ?      RN   18:54   0:02 /usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py get-updates none
root       2464  0.0  0.0 112660   972 pts/1    R+   18:54   0:00 grep --color=auto PackageKit
[root@localhost ~]# kill -9 2439
[root@localhost ~]# yum -y install iftop
error: rpmdb: BDB0113 Thread/process 2439/139840667322176 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 -  (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed
[root@localhost ~]# yum -y install iftop
error: rpmdb: BDB0113 Thread/process 2439/139840667322176 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 -  (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed
[root@localhost ~]# yum -y check-update
error: rpmdb: BDB0113 Thread/process 2439/139840667322176 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 -  (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed
[root@localhost ~]#


(完)

沒有留言:

張貼留言