DB2 常见问题排查

    排查

    根据 描述:“因为先前备份或复原不完整,所以不能连接或激活数据库 名称。”

    解决

    直接删除了数据,再执行还原该数据库

    1. DB20000I The DROP DATABASE command completed successfully.

    还原完后不能连接到数据库

    问题

    从备份中恢复DB2数据库(本例是指“NECC_DB”)的拷贝到新的DB2服务器(本例是指“NECC_DBA”)。用户已创建一个新的数据库连接(指向这个新的数据库副本),当试图连接这个新的数据库时,提示如下错误:

    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

    出现SQL1117N 由于 ROLL-FORWARD PENDING,不能连接或激活数据库 “NECC_DBA”。

    解决

    将数据库前滚。

    执行:

    如:

    问题

    执行 db2 语句创建或者删除数据库操作,均出现如下提示

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

    排查

    用户的磁盘不够了。增加用户磁盘,或者删除一些数据,来增大用户能使用的空间。

    删除了没有用的数据库和老旧的数据库备份文件。

    事务日志已经满

    问题

    执行 db2 语句创建数据库索引、或者执行修改操作,均出现如下提示

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

    排查

    通过 db2 => get db cfg 语句来查看日志文件的配置:

    解决

    把日志文件的大小和日志文件的数量扩充。

    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 =>

    连接到数据库时,出现如下提示

    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

    创建字段 varchar 设置过大

    问题

    创建字段时,varchar 设置为 500 ,报错

    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. Type = Database managed space
    10. Contents = All permanent data. Regular table space.
    11. State = 0x0000
    12. Detailed explanation:
    13. Normal
    14. Total pages = 32768
    15. Useable pages = 32764
    16. Used pages = 32244
    17. Free pages = 520
    18. High water mark (pages) = 32244
    19. Page size (bytes) = 4096
    20. Extent size (pages) = 4
    21. Prefetch size (pages) = 4
    22. Number of containers = 1
    23. Tablespace ID = 1
    24. Name = TEMPSPACE1
    25. Type = System managed space
    26. Contents = System Temporary data
    27. State = 0x0000
    28. Detailed explanation:
    29. Normal
    30. Total pages = 1
    31. Useable pages = 1
    32. Used pages = 1
    33. Free pages = Not applicable
    34. Page size (bytes) = 4096
    35. Extent size (pages) = 32
    36. Prefetch size (pages) = 32
    37. Number of containers = 1
    38. Tablespace ID = 2
    39. Type = Database managed space
    40. Contents = All permanent data. Large table space.
    41. State = 0x0000
    42. Detailed explanation:
    43. Normal
    44. Total pages = 16384
    45. Useable pages = 16352
    46. Used pages = 14048
    47. Free pages = 2304
    48. High water mark (pages) = 14048
    49. Page size (bytes) = 4096
    50. Extent size (pages) = 32
    51. Prefetch size (pages) = 32
    52. Number of containers = 1
    53. Tablespace ID = 3
    54. Name = SYSTOOLSPACE
    55. Type = Database managed space
    56. Contents = All permanent data. Large table space.
    57. State = 0x0000
    58. Detailed explanation:
    59. Normal
    60. Total pages = 8192
    61. Useable pages = 8188
    62. Used pages = 192
    63. Free pages = 7996
    64. High water mark (pages) = 192
    65. Page size (bytes) = 4096
    66. Extent size (pages) = 4
    67. Prefetch size (pages) = 4
    68. Number of containers = 1
    69. db2 =>

    ALTER TABLESPACE tablespacename CONVERT TO LARGE