• yum을 하였을 때 databases가 lock이 발생하여 yum으로 패키지 설치 불가
  • yum으로 설치가 불가능하면, 패키지 관리 및 서비스 운영에 문제 발생

yum database is locked 문제 발생

$ yum install -y sysstat
...생략...
Total size: 315 k
Installed size: 1.1 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Traceback (most recent call last):
  File "/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 375, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 281, in main
    return_code = base.doTransaction()
  File "/usr/share/yum-cli/cli.py", line 817, in doTransaction
    resultobject = self.runTransaction(cb=cb)
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1834, in runTransaction
    lastdbv = self.history.last()
  File "/usr/lib/python2.7/site-packages/yum/history.py", line 1271, in last
    ret = self.old([], 1, complete_transactions_only)
  File "/usr/lib/python2.7/site-packages/yum/history.py", line 1220, in old
    executeSQL(cur, sql, params)
  File "/usr/lib/python2.7/site-packages/yum/sqlutils.py", line 166, in executeSQLQmark
    return cursor.execute(query)
sqlite3.OperationalError: database is locked

yum database is locked 해결 명령어

  • /var/lib/yum/history 디렉토리 내용 확인

    $ ls /var/lib/yum/history/  
    2021-11-15/ history-2021-11-15.sqlite history-2021-11-15.sqlite-journal
  • /var/lib/yum/history 디렉토리 삭제

    $ rm -rf /var/lib/yum/history

해결 결과 → yum으로 설치 가능

  • yum으로 패키지 설치 가능

    $ yum install -y sysstat
    Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
    
    This system is not registered with an entitlement server. You can use subscription-manager to register.
    
    Loading mirror speeds from cached hostfile
    * base: mirror.kakao.com
    * epel: ftp.riken.jp
    * extras: mirror.kakao.com
    * updates: mirror.kakao.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package sysstat.x86_64 0:10.1.5-19.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ============================================================================
    Package                    Arch                              Version                               Repository                            Size
    ============================================================================
    Installing:
    sysstat                    x86_64                           10.1.5-19.el7                      base                                     315 k
    
    Transaction Summary
    ============================================================================
    Install  1 Package
    
    Total size: 315 k
    Installed size: 1.1 M
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Installing : sysstat-10.1.5-19.el7.x86_64                                                                                          1/1
    Verifying  : sysstat-10.1.5-19.el7.x86_64                                                                                          1/1
    
    Installed:
    sysstat.x86_64 0:10.1.5-19.el7
    
    Complete!

참고 URL : https://stackoverflow.com/questions/48037629/yum-database-is-locked

  • 패키지에 따라 의존성 문제로 되돌릴 수 없는 경우가 발생 → 주의 필요
  • 설정파일들은 패키지 설치/삭제 시 되돌리지 못할 수 있으므로 백업 필요

 

지금까지 설치한 yum 내용 확인

  • yum 명령을 사용해서 패키지를 설치하거나 업데이트를 하면 ID가 하나씩 증가
  • 각 항목의 세부사항을 알고 싶은면 info 옵션을 사용
    $ yum history
    Loaded plugins: fastestmirror
    ID     | Login user               | Date and time    | Action(s)      | Altered
    -------------------------------------------------------------------------------
      47 | root              | 2012-08-25 16:09 | Install        |    1
      46 | root              | 2012-08-20 17:00 | Install        |    1
      45 | root              | 2012-08-20 09:07 | Install        |    1
      44 | root              | 2012-08-20 09:06 | Install        |    3
      43 | root              | 2012-08-20 09:05 | Install        |    8
      42 | root              | 2012-08-05 15:51 | Install        |    1
      41 | root              | 2012-08-05 15:47 | Install        |    1
      40 | root              | 2012-08-05 15:41 | Install        |    2
      39 | root              | 2012-08-05 15:24 | Install        |    1
      38 | root              | 2012-08-05 15:18 | Install        |    1
      37 | root              | 2012-08-05 15:14 | Install        |    3
      36 | root              | 2012-08-05 14:53 | I, U            |  195 EE
      35 | root              | 2012-08-05 14:52 | Install        |    3
      34 | root              | 2012-01-19 11:20 | I, U            |   42 EE
      33 | root              | 2012-03-07 15:22 | Install        |    8
      32 | root              | 2011-12-26 14:04 | Install        |    1
      31 | root              | 2011-12-26 13:11 | Install        |   18
      30 | root              | 2011-12-26 11:31 | Install        |    1
      29 | root              | 2011-12-26 11:18 | Install        |   12 EE
      28 | root              | 2011-12-21 17:59 | Install        |    1

 

yum 명령을 사용해서 설치한 history의 세부 내용 출력

$ yum history info 47
Loaded plugins: fastestmirror
Transaction ID : 47
Begin time     : Sat Aug 25 16:09:43 2012
Begin rpmdb    : 586:e318ebe25b7f3c641234d8aec7f55b25e005ba00
End time       :                           (0 seconds)
End rpmdb      : 587:870ce250959935e6a5968fbb5928c1378daedda7
User           : root
Return-Code    : Success
Command Line   : install dosfstools
Transaction performed with:
    Installed     rpm-4.8.0-27.el6.x86_64                       @base
    Installed     yum-3.2.29-30.el6.centos.noarch               @base
    Installed     yum-plugin-fastestmirror-1.1.30-14.el6.noarch @base
Packages Altered:
    Install dosfstools-3.0.9-4.el6.x86_64 @base
history info

 

yum 명령어 실수로 rollback이 필요한 경우

  • ID 47에서 46으로 되돌림
    $ yum history rollback 46
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: centos.tt.co.kr
    * extras: centos.tt.co.kr
    * updates: centoso4.centos.org
    base                                                     | 3.7 kB     00:00
    extras                                                   | 3.5 kB     00:00
    nodejs-stable                                            | 2.9 kB     00:00
    updates                                                  | 3.5 kB     00:00
    updates/primary_db                                       | 4.0 MB     00:08
    Rollback to transaction 46, from Mon Aug 20 17:00:17 2012
     Undoing the following transactions: 47
       Install dosfstools-3.0.9-4.el6.x86_64 @base
    Resolving Dependencies
    --> Running transaction check
    ---> Package dosfstools.x86_64 0:3.0.9-4.el6 will be erased
    --> Finished Dependency Resolution
    Dependencies Resolved
    =======================================================================
    Package             Arch            Version               Repository      Size
    =======================================================================
    Removing:
    dosfstools          x86_64          3.0.9-4.el6           @base          197 k
    Transaction Summary
    =======================================================================
    Remove        1 Package(s)
    Installed size: 197 k
    Is this ok [y/N]: y
    Downloading Packages:
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
     Erasing    : dosfstools-3.0.9-4.el6.x86_64                                1/1
     Verifying  : dosfstools-3.0.9-4.el6.x86_64                                1/1
    Removed:
     dosfstools.x86_64 0:3.0.9-4.el6
    Complete!

+ Recent posts