数据库检测工具

    • sdbdmsdump 不需要与数据库连接。
    • 运行 sdbdmsdump 命令的用户必须对数据库的数据与索引文件拥有读权限。
    • sdbdmsdump 在当前目录下检测所有集合空间和集合的文件结构,格式化输出数据和索引文件的检测结果至 文件

      1. $ sdbdmsdump -d . -o output.txt -v true -a all -t true -i true -b true -p true
    • 指定数据文件目录 /opt/sequoiadb/database/data/11830,指定操作为“inspect”检测并报告数据损坏信息,格式化输出集合空间 sample 的数据文件检测结果至 outputdata.txt 文件

      1. $ sdbdmsdump -d /opt/sequoiadb/database/data/11830 -o outputdata.txt -v true -c sample -a inspect -t true
      1. Inspect collection space ./sample.1.data
      2. Inspect Storage Unit Header: sample
      3. Inspect Storage Unit Header Done without Error
      4. Inspect Space Management Extent:
      5. Inspect Space Management Extent Done without Error
      6. Inspect Metadata Management Extent:
      7. Inspect Metadata Management Extent Done
      8. Inspect Data for collection [0 : employee]
      9. ****The collection data info****
      10. Total Record : 300000
      11. Total Data Pages : 1180
      12. Total Data Free Space : 41296
      13. Total OVF Record : 0
      14. Total Compressed Record: 84317
      15. Inspect Space Management Extent:
      16. Inspect Space Management Extent Done without Error
    • 指定索引文件目录 /opt/sequoiadb/database/data/11830,指定操作为“inspect”检测并报告数据损坏信息,输出集合空间 sample 的索引数据检测结果至 outputindex.txt 文件

      1. $ sdbdmsdump -d /opt/sequoiadb/database/data/11830 -x /opt/sequoiadb/database/data/11830 -o outputindex.txt -v true -c sample -a inspect -i true

      生成结果文件 outputindex.txt,记录集合空间 sample 索引文件中 Header 段、SME 空间管理段、数据段检测结果,以及该集合空间下所有集合的索引信息(如索引页、索引空闲空间、唯一索引个数等),无损坏则检查结果记录为 “without Error” ,显示内容可能如下:

    • 指定数据文件目录 /opt/sequoiadb/database/data/11830,指定集合空间 sample 设定操作数据文件,指定操作为“dump”将数据页格式化并输出至 outputdump.txt 文件

      1. $ sdbdmsdump -d /opt/sequoiadb/database/data/11830 -o outputdump.txt -v true -c sample -a dump -t true

      生成结果文件 outputdump.txt,记录集合空间 sample 数据文件中 Header 段、SME 空间管理段、MME 元数据管理段和数据段存储结构信息,首先在输出的头部写入命令参数

      1. Run Options :
      2. Database Path : /opt/sequoiadb/database/data/11830
      3. Index path : /opt/sequoiadb/database/data/11830
      4. Lobm path : /opt/sequoiadb/database/data/11830
      5. Lob path : /opt/sequoiadb/database/data/11830
      6. Output File : outputdump.txt
      7. Verbose : True
      8. CS Name : sample
      9. CL Name : {all}
      10. Action : dump
      11. Repaire :
      12. Dump Options :
      13. Dump Data : True
      14. Dump Index : False
      15. Dump Lob : False
      16. Start Page : -1
      17. Num Pages : 1
      18. Show record: False
      19. Only Meta : False
      20. Balance : False
      21. force : False
      1. Dump collection space /opt/sequoiadb/database/data/11830/sample.1.data
      2. Storage Unit Header Dump:
      3. 0x0000000000000000 : 5344 4244 4154 4100 0300 0000 0000 0100 SDBDATA.........
      4. 0x0000000000000010 : 4109 0000 7465 7374 0000 0000 0000 0000 A...sample......
      5. 0x0000000000000020 : 0000 0000 0000 0000 0000 0000 0000 0000 ................
      6. *……
      7. *
      8. Eye Catcher : SDBDATA
      9. Version : 3
      10. Page Size : 65536
      11. Total Size : 2369
      12. SU Name : sample
      13. CS Unique ID: 376
      14. HWM of Col : 2
      15. Page Num : 2048
      16. Secret value: 0x5c8a050f5c19b9e6 (6668147761803278822)
      17. Lob Page Sz : 262144
      18. Lob Flag : 0
      19. Commit Flag : 1
      20. Commit LSN : 0x00000000c5744ed8 (3312733912)
      21. Commit Time : 2019-03-14-16.04.29.987000 (1552550669987)

      格式化输出 SME 段可视化结果,显示这个存储单元中已经被占用和未被占用的数据页(0 表示该数据页空闲,1 表示数据页被使用)

      1. Space Management Extent Dump:
      2. 0000000000 - 0000001250 [ 0x01 (Occupied) ]
      3. 0000001251 - 0134217727 [ 0x00 (Free) ]
      4. Total: 134217728, Allocated: 2048, Used: 1251
      5. Has errors: FALSE

      最后输出 MME 段格式化数据,在 MME 中首先对该集合空间中每个集合打印其 1024 字节的裸元数据,同时输出格式化数据

      对于该集合空间中的每个集合,格式化其元数据块和数据块与索引块(由于数据量较大,部分内容以“……”省略)

      1. Dump Meta Extent for Collection [0]
      2. ExtentID: 0x00000000 (0)
      3. 0x0000000000000000 : 4D45 0900 0000 0101 0000 0100 0100 0000 ME..............
      4. 0x0000000000000010 : 0900 0000 1102 0000 FFFF FFFF FFFF FFFF ................
      5. 0x0000000000000020 : FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................
      6. *
      7. 0x0000000000080010 : 0000 0000 0000 0000 0000 0000 0000 0000 ................
      8. *
      9. Meta Extent Header :
      10. Eye Catcher : ME
      11. Extent Size : 9
      12. CollectionID : 0
      13. Flag : 0x01 (InUse)
      14. Version : 1
      15. Segment num : 65536
      16. Used seg num : 1
      17. Segment extent info :
      18. 0 : [0x00000009, 0x00000211]
      19. Used segment num: 1, has error: FALSE
      20. Dump Data for Collection [0]
      21. ExtentID: 0x00000009 (9)
      22. 0x0000000000000000 : 4445 0100 0000 0101 0000 0000 FFFF FFFF DE..............
      23. 0x0000000000000010 : 0A00 0000 C100 0000 2400 0000 94FD 0000 ........$.......
      24. 0x0000000000000020 : 1801 0000 004F 0100 2400 0000 FFFF FFFF .....O..$.......
      25. 0x0000000000000030 : 7401 0000 1D01 0000 075F 6964 005C 8B45 t........_id.\.E
      26. 0x0000000000000040 : 8063 6827 1E68 4E33 AA10 6100 0000 0000 .ch'.hN3..a.....
      27. 0x0000000000000050 : 1062 0000 0000 0002 6300 F200 0000 7364 .b......c.....sd
      28. 0x0000000000000060 : 6761 7364 6773 6161 6173 6467 6767 6767 gasdgsaaasdggggg
      29. 0x0000000000000070 : 6767 6767 6767 6767 6767 6767 6767 6767 gggggggggggggggg
      30. *
      31. 0x0000000000000140 : 6767 6767 6767 6767 6767 6767 6767 3000 gggggggggggggg0.
      32. 0x0000000000000150 : 0000 0000 0000 0000 0000 0000 0000 0000 ................
      33. *
      34. ……
      35. Data Extent Header:
      36. Eye Catcher : DE
      37. Extent Size : 1
      38. CollectionID : 0
      39. Flag : 0x01 (InUse)
      40. Version : 1
      41. Logic ID : 13
      42. PrevExtent : 0x00000015 (21)
      43. NextExtent : 0x00000017 (23)
      44. Record Count : 192
      45. First Record : 0x00000024 (36)
      46. Last Record : 0x0000fdd0 (64976)
      47. Free Space : 220
      48. ExtentID: 0x00000017 (23)
      49. 0x0000000000000000 : 4445 0100 0000 0101 0E00 0000 1600 0000 DE..............
      50. 0x0000000000000010 : 1800 0000 C000 0000 2400 0000 D0FD 0000 ........$.......
      51. 0x0000000000000020 : DC00 0000 0053 0100 2400 0000 FFFF FFFF .....S..$.......
      52. 0x0000000000000050 : 1062 0081 0A00 0002 6300 F500 0000 7364 .b......c.....sd
      53. 0x0000000000000060 : 6761 7364 6773 6161 6173 6467 6767 6767 gasdgsaaasdggggg
      54. 0x0000000000000070 : 6767 6767 6767 6767 6767 6767 6767 6767 gggggggggggggggg
      55. ……
    • 指定索引文件目录 /opt/sequoiadb/database/data/11830,指定集合空间 sample 设定操作索引文件,指定操作为“dump”将索引数据页格式化并输出至 indexdump.txt 文件

      1. $ sdbdmsdump -d /opt/sequoiadb/database/data/11830 -x /opt/sequoiadb/database/data/11830 -o indexdump.txt -v true -c sample -a dump -i true
      1. Dump Index Def for Collection [0]
      2. Index [ 0 ] : 0x00000000
      3. 0x0000000000000000 : 4943 0000 0000 0101 0000 0000 0500 0000 IC..............
      4. 0x0000000000000010 : FFFF FFFF 0100 0000 0000 0000 5200 0000 ............R...
      5. 0x0000000000000020 : 075F 6964 005C 8B45 7973 CE93 6736 B8E3 ._id.\.Eys..g6..
      6. 0x0000000000000030 : DB03 6B65 7900 0E00 0000 105F 6964 0001 ..key......_id..
      7. 0x0000000000000040 : 0000 0000 026E 616D 6500 0400 0000 2469 .....name.....$i
      8. 0x0000000000000050 : 6400 0875 6E69 7175 6500 0110 7600 0000 d..unique...v...
      9. 0x0000000000000060 : 0000 0865 6E66 6F72 6365 6400 0100 0000 ...enforced.....
      10. 0x0000000000000070 : 0000 0000 0000 0000 0000 0000 0000 0000 ................
      11. *
      12. Eye Catcher : IC
      13. Index Flags : 0 (Normal)
      14. CollectionID : 0
      15. Flag : 0x01 (InUse)
      16. Version : 1
      17. Logical ID : 0
      18. Root Ext : 0x00000005 (5)
      19. Scan extent LID : 0xffffffff (-1)
      20. Type : 1 (Positive)
      21. Index Def : { "_id": { "$oid": "5c8b457973ce936736b8e3db" }, "key": { "_id": 1 }, "name": "$id", "unique": true, "v": 0, "enforced": true }
      22. Index [ 1 ] : 0x00000002
      23. 0x0000000000000000 : 4943 0000 0000 0101 0100 0000 0700 0000 IC..............
      24. 0x0000000000000010 : FFFF FFFF 0100 0000 0000 0000 3F00 0000 ............?...
      25. 0x0000000000000020 : 075F 6964 005C 8B45 7873 CE93 7236 B8E3 ._id.\.Exs..r6..
      26. 0x0000000000000030 : E303 6B65 7900 0C00 0000 1061 0001 0000 ..key......a....
      27. 0x0000000000000040 : 0000 026E 616D 6500 0700 0000 2473 6861 ...name.....$sha
      28. 0x0000000000000050 : 7264 0010 7600 0000 0000 0000 0000 0000 rd..v...........
      29. 0x0000000000000060 : 0000 0000 0000 0000 0000 0000 0000 0000 ................
      30. *

      索引页则类似如下(由于数据量较大,相似内容以“……”省略):

      1. Index Dump for Collection [00], Index [00]
      2. Dump Index Page 5:
      3. 0x0000000000000000 : 4945 3100 0000 0100 FFFF FFFF 82FD 5EFA IE1...........^.
      4. 0x0000000000000010 : 6000 0000 0100 0000 1300 0000 E494 0000 `...............
      5. 0x0000000000000020 : F2FF 0000 0400 0000 1E00 0000 4C2D 0000 ............L-..
      6. 0x0000000000000030 : E5FF 0000 0800 0000 2800 0000 B4C4 0000 ........(.......
      7. 0x0000000000000040 : D8FF 0000 0A00 0000 3300 0000 1C5D 0000 ........3....]..
      8. 0x0000000000000050 : CBFF 0000 0C00 0000 3D00 0000 84F4 0000 ........=.......
      9. 0x0000000000000060 : BEFF 0000 0E00 0000 4800 0000 EC8C 0000 ........H.......
      10. 0x0000000000000070 : B1FF 0000 1000 0000 5300 0000 5425 0000 ........S...T%..
      11. 0x0000000000000080 : A4FF 0000 1200 0000 5D00 0000 BCBC 0000 ........].......
      12. 0x0000000000000090 : 97FF 0000 1300 0000 6800 0000 2455 0000 ........h...$U..
      13. ……
      14. Index Extent Header:
      15. Eye Catcher : IE
      16. Total Keys : 49
      17. CollectionID : 0
      18. Flag : 0x01 (InUse)
      19. Version : 0
      20. Parent Ext : 0xffffffff (-1) (root)
      21. Free Offset : 0x0000fd82 (64898)
      22. Total Free : 0x0000fa5e (64094)
      23. Right Child : 0x00000060 (96)
      24. Dump Index Page 1:
      25. 0x0000000000000000 : 4945 F107 0000 0100 0500 0000 C298 9E19 IE..............
      26. 0x0000000000000010 : FFFF FFFF FFFF FFFF 0900 0000 2400 0000 ............$...
      27. 0x0000000000000020 : F2FF 0000 FFFF FFFF 0900 0000 7401 0000 ............t...