DB2 常見(jiàn)問(wèn)題排查

2021-08-16 09:40 更新
  • DB2 常見(jiàn)問(wèn)題排查
    • 備份或者還原未完成
      • 問(wèn)題
      • 排查
      • 解決
    • 還原完后不能連接到數(shù)據(jù)庫(kù)
      • 問(wèn)題
      • 排查
      • 解決
    • 空間不足不能執(zhí)行命令
      • 問(wèn)題
      • 排查
      • 解決
    • 事務(wù)日志已經(jīng)滿
      • 問(wèn)題
      • 排查
      • 解決
    • 連接數(shù)據(jù)庫(kù),分配共享內(nèi)容失敗,內(nèi)核限制
      • 問(wèn)題
    • 創(chuàng)建字段 varchar 設(shè)置過(guò)大
      • 問(wèn)題
    • 參考引用

    DB2 常見(jiàn)問(wèn)題排查

    備份或者還原未完成

    問(wèn)題

    執(zhí)行操作,提示如下:

    1. [db2inst@localhost ~]$ db2 deactivate db necc_db
    2. SQL1120N A connection to or activation of database "NECC_DB" cannot be made
    3. because a previous backup or restore is incomplete. SQLSTATE=57019

    排查

    根據(jù) https://www.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.messages.sql.doc/doc/msql01120n.html描述:“因?yàn)橄惹皞浞莼驈?fù)原不完整,所以不能連接或激活數(shù)據(jù)庫(kù) 名稱。”

    解決

    直接刪除了數(shù)據(jù),再執(zhí)行還原該數(shù)據(jù)庫(kù)

    1. [db2inst@localhost ~]$ db2 drop db necc_db
    2. DB20000I The DROP DATABASE command completed successfully.

    還原完后不能連接到數(shù)據(jù)庫(kù)

    問(wèn)題

    從備份中恢復(fù)DB2數(shù)據(jù)庫(kù)(本例是指“NECC_DB”)的拷貝到新的DB2服務(wù)器(本例是指“NECC_DBA”)。用戶已創(chuàng)建一個(gè)新的數(shù)據(jù)庫(kù)連接(指向這個(gè)新的數(shù)據(jù)庫(kù)副本),當(dāng)試圖連接這個(gè)新的數(shù)據(jù)庫(kù)時(shí),提示如下錯(cuò)誤:

    1. [db2inst@localhost ~]$ db2 connect to necc_db
    2. SQL1117N A connection to or activation of database "NECC_DB" cannot be made
    3. because of ROLL-FORWARD PENDING. SQLSTATE=57019

    排查

    出現(xiàn)SQL1117N 由于 ROLL-FORWARD PENDING,不能連接或激活數(shù)據(jù)庫(kù) “NECC_DBA”。

    解決

    將數(shù)據(jù)庫(kù)前滾。

    執(zhí)行:

    db2 rollforward db <database> complete

    如:

    1. [db2inst@localhost ~]$ db2 rollforward db necc_dba complete
    2. Rollforward Status
    3. Input database alias = necc_dba
    4. Number of members have returned status = 1
    5. Member ID = 0
    6. Rollforward status = not pending
    7. Next log file to be read =
    8. Log files processed = -
    9. Last committed transaction = 2016-04-27-09.18.11.000000 UTC
    10. DB20000I The ROLLFORWARD command completed successfully.
    11. [db2inst@localhost ~]$

    空間不足不能執(zhí)行命令

    問(wèn)題

    執(zhí)行 db2 語(yǔ)句創(chuàng)建或者刪除數(shù)據(jù)庫(kù)操作,均出現(xiàn)如下提示

    1. SQL1004C There is not enough storage on the file system to process the command.

    排查

    用戶的磁盤(pán)不夠了。增加用戶磁盤(pán),或者刪除一些數(shù)據(jù),來(lái)增大用戶能使用的空間。

    解決

    刪除了沒(méi)有用的數(shù)據(jù)庫(kù)和老舊的數(shù)據(jù)庫(kù)備份文件。

    事務(wù)日志已經(jīng)滿

    問(wèn)題

    執(zhí)行 db2 語(yǔ)句創(chuàng)建數(shù)據(jù)庫(kù)索引、或者執(zhí)行修改操作,均出現(xiàn)如下提示

    1. DB2 Database Error: ERROR [57011] [IBM][DB2/LINUXX8664] SQL0964C The transaction log for the database is full.

    排查

    事務(wù)日志已滿。

    通過(guò) db2 => get db cfg 語(yǔ)句來(lái)查看日志文件的配置:

    1. Log file size (4KB) (LOGFILSIZ) = 1024
    2. Number of primary log files (LOGPRIMARY) = 13
    3. Number of secondary log files (LOGSECOND) = 12

    解決

    把日志文件的大小和日志文件的數(shù)量擴(kuò)充。

    1. db2 => update db cfg using LOGFILSIZ 10240
    2. DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
    3. SQL1363W Database must be deactivated and reactivated before the changes to
    4. one or more of the configuration parameters will be effective.
    5. db2 => update db cfg using LOGPRIMARY 100
    6. DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
    7. SQL1363W Database must be deactivated and reactivated before the changes to
    8. one or more of the configuration parameters will be effective.
    9. db2 => update db cfg using LOGSECOND 100
    10. DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
    11. db2 =>

    連接數(shù)據(jù)庫(kù),分配共享內(nèi)容失敗,內(nèi)核限制

    問(wèn)題

    連接到數(shù)據(jù)庫(kù)時(shí),出現(xiàn)如下提示

    1. ERROR [57019] [IBM] SQL1084C The database manager failed to allocate shared memory because an operating system kernel memory limit has been reached. SQLSTATE=57019

    http://www.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.messages.sql.doc/doc/msql01084c.html

    創(chuàng)建字段 varchar 設(shè)置過(guò)大

    問(wèn)題

    創(chuàng)建字段時(shí),varchar 設(shè)置為 500 ,報(bào)錯(cuò)

    1. SQL 錯(cuò)誤 [42727]: A table space could not be found with a page size of at least "8192" that authorization ID "DB2INST" is authorized to use.. SQLCODE=-286, SQLSTATE=42727, DRIVER=4.16.53
    2. com.ibm.db2.jcc.am.SqlSyntaxErrorException: A table space could not be found with a page size of at least "8192" that authorization ID "DB2INST" is authorized to use.. SQLCODE=-286, SQLSTATE=42727, DRIVER=4.16.53
    1. db2 => connect to necc_db
    2. Database Connection Information
    3. Database server = DB2/LINUXX8664 10.1.0
    4. SQL authorization ID = DB2INST
    5. Local database alias = NECC_DB
    6. db2 => LIST TABLESPACES SHOW DETAIL
    7. Tablespaces for Current Database
    8. Tablespace ID = 0
    9. Name = SYSCATSPACE
    10. Type = Database managed space
    11. Contents = All permanent data. Regular table space.
    12. State = 0x0000
    13. Detailed explanation:
    14. Normal
    15. Total pages = 32768
    16. Useable pages = 32764
    17. Used pages = 32244
    18. Free pages = 520
    19. High water mark (pages) = 32244
    20. Page size (bytes) = 4096
    21. Extent size (pages) = 4
    22. Prefetch size (pages) = 4
    23. Number of containers = 1
    24. Tablespace ID = 1
    25. Name = TEMPSPACE1
    26. Type = System managed space
    27. Contents = System Temporary data
    28. State = 0x0000
    29. Detailed explanation:
    30. Normal
    31. Total pages = 1
    32. Useable pages = 1
    33. Used pages = 1
    34. Free pages = Not applicable
    35. High water mark (pages) = Not applicable
    36. Page size (bytes) = 4096
    37. Extent size (pages) = 32
    38. Prefetch size (pages) = 32
    39. Number of containers = 1
    40. Tablespace ID = 2
    41. Name = USERSPACE1
    42. Type = Database managed space
    43. Contents = All permanent data. Large table space.
    44. State = 0x0000
    45. Detailed explanation:
    46. Normal
    47. Total pages = 16384
    48. Useable pages = 16352
    49. Used pages = 14048
    50. Free pages = 2304
    51. High water mark (pages) = 14048
    52. Page size (bytes) = 4096
    53. Extent size (pages) = 32
    54. Prefetch size (pages) = 32
    55. Number of containers = 1
    56. Tablespace ID = 3
    57. Name = SYSTOOLSPACE
    58. Type = Database managed space
    59. Contents = All permanent data. Large table space.
    60. State = 0x0000
    61. Detailed explanation:
    62. Normal
    63. Total pages = 8192
    64. Useable pages = 8188
    65. Used pages = 192
    66. Free pages = 7996
    67. High water mark (pages) = 192
    68. Page size (bytes) = 4096
    69. Extent size (pages) = 4
    70. Prefetch size (pages) = 4
    71. Number of containers = 1
    72. db2 =>

    ALTER TABLESPACE tablespacename CONVERT TO LARGE

    參考引用


    以上內(nèi)容是否對(duì)您有幫助:
    在線筆記
    App下載
    App下載

    掃描二維碼

    下載編程獅App

    公眾號(hào)
    微信公眾號(hào)

    編程獅公眾號(hào)