【YashanDB知识库】如何dump数据文件,转换rowid, 查询对应内容

简介: 【YashanDB知识库】如何dump数据文件,转换rowid, 查询对应内容

问题现象

客户环境有时候会遇到文件损坏的情况,需要dump文件,根据rowid查询数据情况。

问题的风险及影响

熟练掌握崖山数据文件dump操作,并识别rowid,在故障的情况下可以快速确认相应的数据情况,查找需要的数据。

问题影响的版本

YashanDB版本所有版本

问题分析和处理过程

1、在故障情况下,直接查询表数据,会遇到YAS-02147的错误。

2、崖山提供dump命令,可以dump出db数据文件,但不包含数据内容。

详细说明见dump | YashanDB Doc (yasdb.com)


3、确认文件id和blockid

在上述命令中,dump的时候需要文件id和blockid。

文件id对应V\$datafile表空间所在的文件id,如下面users表空间文件id是4。

表block对应dba_segments中block起始位置及数量,如下面CUSTOMER从block 131开始,有8个block。

根据上面分析,执行dump命令ALTER SYSTEM DUMP DATAFILE 4 MINBLOCK 131 MAXBLOCK 140,结果如下:

点击查看代码
SQL> ALTER SYSTEM DUMP DATAFILE 4 MINBLOCK 131 MAXBLOCK 140;
Succeed.
SQL> exit
[cod@6c5c2b1ac6f0 trace]$ ls -l
total 8

-rw-rw-r-- 1 cod cod 5541 Jul 30 10:18 yashan_yas_21.trc

[cod@6c5c2b1ac6f0 trace]$ cat yashan_yas_21.trc

*** 2024-07-30 10:17:52.212

Start dump data blocks TS#: 4 FILE#: 4 minblk 132 maxblk 132

Block dump from disk:

warning: disk dump block information is incompleted, file#: 4 blk#: 132 ts#: 4

*** 2024-07-30 10:18:53.922

Start dump data blocks TS#: 4 FILE#: 4 minblk 131 maxblk 140

Block dump from cache:

BUFFER CTRL DUMP

  FILE#: 4 BLK#: 131 TS#: 4

  bucketId: 29579 crNext: 4294967295 hashNext:4294967295

  lruListId: 2 lru: [7546, 7537]

  resStatus: 0 refCount: 1 pcFlag: 0

  scn: 0 ext: 0 node: 0 xsn: 0 ssn: 0

  lastLfn: 0 dtyList: [NULL, NULL]

  truncPoint: [0, 0, 0, 0]

BUFFER CTRL DUMP END

DISK BLOCK DUMP

segment

head: id 0-131, type 33, instance id 0 lsn 5031, checksum: 0, change num 4, isEncrypted 0, isCompressed 0

segType: heap

dataOid: 2486

ssm tree: search entry: 0-129, level: 1

level[0]: ssm block count: 1, current block: 0-128

level[1]: ssm block count: 1, current block: 0-129

level[2]: ssm block count: 1, current block: 0-130

hwm L1: 0-128

hwm L1 node: 7

extents lhwm: block id: 0-136, extent idx: 0, map block: 0-131, offset: 0, blkIdx: 8, used block count: 8. lhwmL1: 0-128

extent ctrl: extent count: 1, block count: 8, map count: 0 , extent map offset: 380

last map block: 63-67108863, offset: 0, extents change number: 0

extents hwm: block id: 0-136, extent idx: 0, offset: 0, unformatted block count: 0, used block count: 8, map block: 63-67108863

extents map: extent count: 1, capacity: 487, next map: 63-67108863, map nodes:

id: 0-128 size: 8

0. L1 block id: 0-128 data block id: 0-132

tail: change num: 4

DISK BLOCK DUMP END

*** 2024-07-30 10:18:53.922

Block dump from disk:

warning: disk dump block information is incompleted, file#: 4 blk#: 132 ts#: 4

*** 2024-07-30 10:18:53.922

Block dump from cache:

BUFFER CTRL DUMP

  FILE#: 4 BLK#: 133 TS#: 4

  bucketId: 29581 crNext: 4294967295 hashNext:4294967295

  lruListId: 2 lru: [7548, 7546]

  resStatus: 0 refCount: 1 pcFlag: 0

  scn: 0 ext: 0 node: 0 xsn: 0 ssn: 0

  lastLfn: 0 dtyList: [NULL, NULL]

  truncPoint: [0, 0, 0, 0]

BUFFER CTRL DUMP END

DISK BLOCK DUMP

heap data

head: id 0-133, type 4, instance id 0 lsn 5029, checksum: 0, change num 1, isEncrypted 0, isCompressed 0

dataOid: 2486, extent change number: 0

block scn: 0, map block: 0-128, slot: 5, freeness: 5

rows: 0, dirs: 0, xslots: 0, si xslots: 0, free size: 8108, free begin: 80, free end: 8188 free dir: 4095

tail: change num: 1

DISK BLOCK DUMP END

*** 2024-07-30 10:18:53.922

Block dump from cache:

BUFFER CTRL DUMP

  FILE#: 4 BLK#: 134 TS#: 4

  bucketId: 29582 crNext: 4294967295 hashNext:4294967295

  lruListId: 2 lru: [4294967295, 7547]

  resStatus: 0 refCount: 1 pcFlag: 0

  scn: 0 ext: 0 node: 0 xsn: 0 ssn: 0

  lastLfn: 0 dtyList: [NULL, NULL]

  truncPoint: [0, 0, 0, 0]

BUFFER CTRL DUMP END

DISK BLOCK DUMP

heap data

head: id 0-134, type 4, instance id 0 lsn 5029, checksum: 0, change num 1, isEncrypted 0, isCompressed 0

dataOid: 2486, extent change number: 0

block scn: 0, map block: 0-128, slot: 6, freeness: 5

rows: 0, dirs: 0, xslots: 0, si xslots: 0, free size: 8108, free begin: 80, free end: 8188 free dir: 4095

tail: change num: 1

DISK BLOCK DUMP END

*** 2024-07-30 10:18:53.922

Block dump from cache:

BUFFER CTRL DUMP

  FILE#: 4 BLK#: 135 TS#: 4

  bucketId: 29583 crNext: 4294967295 hashNext:4294967295

  lruListId: 1 lru: [4294967295, 7543]

  resStatus: 0 refCount: 1 pcFlag: 0

  scn: 0 ext: 0 node: 0 xsn: 0 ssn: 0

  lastLfn: 0 dtyList: [NULL, NULL]

  truncPoint: [0, 0, 0, 0]

BUFFER CTRL DUMP END

DISK BLOCK DUMP

heap data

head: id 0-135, type 4, instance id 0 lsn 5030, checksum: 0, change num 4, isEncrypted 0, isCompressed 0

dataOid: 2486, extent change number: 0

block scn: 581620909456666624, map block: 0-128, slot: 7, freeness: 1

rows: 1, dirs: 1, xslots: 2, si xslots: 0, free size: 2022, free begin: 6116, free end: 8138 free dir: 4095

row[0]: size: 6036 xslot id: 0 columns: 3 format/link/migr/deleted/compact:1/0/0/0/0

xslot[0]: xid: 25-11349-1 active: 0 owscn: 0 fastcommit: 1 ura: block: 0-15758, ver: 0, dir: 1 ssn: 3055202304 fsc: 21794 mfb: 2066 scn: 581620909456666624

xslot[1]: xid: 0-0-0 active: 0 owscn: 0 fastcommit: 0 ura: block: 0-0, ver: 0, dir: 0 ssn: 0 fsc: 0 mfb: 0 scn: 0

tail: change num: 4

DISK BLOCK DUMP END

*** 2024-07-30 10:18:53.922

Block dump from disk:

DISK BLOCK DUMP

unknown

head: id 0-136, type 0, instance id 0 lsn 9, checksum: 999298229, change num 0, isEncrypted 0, isCompressed 0

unknown type 0

tail: change num: 0

DISK BLOCK DUMP END

*** 2024-07-30 10:18:53.922

Block dump from disk:

DISK BLOCK DUMP

unknown

head: id 0-137, type 0, instance id 0 lsn 9, checksum: 3105528825, change num 0, isEncrypted 0, isCompressed 0

unknown type 0

tail: change num: 0

DISK BLOCK DUMP END

*** 2024-07-30 10:18:53.922

Block dump from disk:

DISK BLOCK DUMP

unknown

head: id 0-138, type 0, instance id 0 lsn 9, checksum: 996768988, change num 0, isEncrypted 0, isCompressed 0

unknown type 0

tail: change num: 0

DISK BLOCK DUMP END

*** 2024-07-30 10:18:53.922

Block dump from disk:

DISK BLOCK DUMP

unknown

head: id 0-139, type 0, instance id 0 lsn 9, checksum: 3118723984, change num 0, isEncrypted 0, isCompressed 0

unknown type 0

tail: change num: 0

DISK BLOCK DUMP END

*** 2024-07-30 10:18:53.922

Block dump from disk:

DISK BLOCK DUMP

unknown

head: id 0-140, type 0, instance id 0 lsn 9, checksum: 979551335, change num 0, isEncrypted 0, isCompressed 0

unknown type 0

tail: change num: 0

DISK BLOCK DUMP END


分析数据发现135的块中存在数据:


4、转换ROWID,查询数据内容

查看ROWID说明:ROWID UROWID | YashanDB Doc (yasdb.com)

对应:

dataoid 为2486

spaceid为4

fileid为0(同个表空间可能有多个数据文件)

blockid为135

dir为0

最终拼接的rowid为2486:4:0:135:0,根据rowid查询结果如下:

相关文章
|
1月前
|
存储 API 开发者
百宝箱开放平台 ✖️ 查询知识库文件列表
通过调用该接口,开发者可查询指定知识库中的文件列表,支持分页参数设置,需提供Authorization令牌及知识库ID,返回文件信息包括名称、大小等,并附带错误码说明。
115 4
|
1月前
|
API 开发者
百宝箱开放平台 ✖️ 查询知识库文件的构建状态
本接口用于查询目标文件在知识库中的构建状态,需提供documentId并配置有效token。支持查看初始化、处理中、成功、失败等状态,并返回详细错误信息以便排查问题。
103 4
|
1月前
|
JSON API 开发工具
百宝箱开放平台 ✖️ 添加知识库文件
本接口用于将已上传的文件添加至指定知识库。调用前需通过文件上传接口获取fileId,并确保token有效。请求需包含datasetId和fileId,支持txt、pdf、md等格式,单文件不超过20M,最多2万行数据。
151 4
|
1月前
|
存储 API 开发者
蚂蚁开放平台 ✖️ 查询知识库列表
通过调用该接口,开发者可查询租户内知识库列表,支持分页参数配置,需提供有效授权令牌。返回信息包含知识库ID、名称、描述及存储大小等。
104 4
|
1月前
|
JSON API 数据格式
百宝箱开放平台 ✖️ 删除知识库文件
本接口用于删除知识库中指定文件,调用前需解除文件与智能体应用的关联。通过DELETE请求发送documentId参数,并在请求头中携带Authorization令牌完成身份验证。
101 3
|
8月前
|
SQL 存储 关系型数据库
【YashanDB知识库】共享从 MySQL异常处理CONTINUE HANDLER的改写方法
【YashanDB知识库】共享从 MySQL异常处理CONTINUE HANDLER的改写方法
|
7月前
|
SQL 测试技术 数据库
【YashanDB知识库】IMP跨网络导入慢问题
问题现象:290M数据,本地导入2分钟,跨机导入耗时显著增加(最高30分钟)。 原因分析:`imp`逐条SQL通过网络传输至yashanDB执行,交互频繁导致性能下降。 影响版本:客户测试环境22.2.8.3。 解决方法:将导入文件上传至与yashanDB同机后使用`imp`,减少网络延迟。 经验总结:优化`imp`工具,支持直接上传文件至服务器端执行,降低网络依赖。
|
7月前
|
监控 数据库
【YashanDB 知识库】ycm 托管数据库时报错 OM host ip:127.0.0.1 is not support join to YCM
在托管数据库时,若 OM 的 IP 被设置为 127.0.0.1,将导致无法托管至 YCM,并使数据库失去监控。此问题源于安装时修改了 OM 的监听 IP。解决方法包括:将 OM 的 IP 修改为本机实际 IP 或 0.0.0.0,同时更新 env 文件及 yasom 后台数据库中的相关配置。经验总结指出,应避免非必要的后台 IP 修改,且数据库安装需遵循规范,不使用仅限本机访问的 IP(如 127.0.0.1)。
|
7月前
|
监控 网络安全 数据库
YashanDB 知识库:ycm 纳管主机安装 YCM-AGENT 时报错 “任务提交失败,无法连接主机”
在安装 ycm-agent 纳管主机时,可能出现因端口未开放导致的报错问题。此问题会阻止 YCM 对主机和数据库的监控功能,影响版本为 `yashandb-cloud-manager-23.2.1.100-linux-aarch64.tar`。原因是目标主机(如 10.149.223.121)未开放 9070 或 9071 端口。解决方法包括关闭防火墙、添加白名单或开放指定端口,需与管理员确认操作。处理过程涉及网络检查、端口测试等步骤。端口问题解决后,若再次安装报唯一键错误,需先移除失败主机再重试。
|
7月前
|
监控 Java Shell
【YashanDB 知识库】ycm 托管数据库时,数据库非 OM 安装无法托管
本文主要介绍了因数据库未按规范使用 yasboot 安装导致的问题及解决方法。问题表现为无 yasom 和 yasagent 进程,且目录结构缺失,致使 ycm 无法托管与监控。分析发现可能是数据库版本旧或安装不规范引起。解决方法为先生成配置文件,安装 yasom 和 yasagent,再生成并修改托管配置模板,最终通过命令完成托管至 yasom 和 ycm。总结强调了按规范安装数据库的重要性以避免类似问题。