ob_admin解析指定表的sstable文件

【 使用环境 】测试环境
【 OB or 其他组件 】
【 使用版本 】
【问题描述】ob_admin 解析指定表的宏块文件时,不符合预期
【复现路径】
obclient(root@(none))[oceanbase]> select * from cdb_ob_table_locations where table_name=‘dept’ and database_name=‘test’\G;
*************************** 1. row ***************************
TENANT_ID: 1008
DATABASE_NAME: test
TABLE_NAME: dept
TABLE_ID: 500255
TABLE_TYPE: USER TABLE
PARTITION_NAME: NULL
SUBPARTITION_NAME: NULL
INDEX_NAME: NULL
DATA_TABLE_ID: NULL
TABLET_ID: 200142
LS_ID: 1001
ZONE: zone1
SVR_IP: 192.168.96.12
SVR_PORT: 2882
ROLE: LEADER
REPLICA_TYPE: FULL
DUPLICATE_SCOPE: NONE
OBJECT_ID: 500255
TABLEGROUP_NAME: NULL
TABLEGROUP_ID: NULL
SHARDING: NULL
1 row in set (0.229 sec)

ERROR: No query specified

obclient(root@(none))[oceanbase]> select * from __all_virtual_tablet_sstable_macro_info where tablet_id=200142\G;
*************************** 1. row ***************************
svr_ip: 192.168.96.12
svr_port: 2882
tenant_id: 1008
ls_id: 1001
tablet_id: 200142
end_log_scn: 1781373602341127497
macro_idx_in_sstable: 0
macro_logic_version: 1781373602341127497
macro_block_idx: 4697
data_seq: 0
row_count: 4
original_size: 220
encoding_size: 171
compressed_size: 137
occupy_size: 457
micro_block_count: 1
data_checksum: 1232337725
macro_range: (MIN ; 40]
macro_block_type: data_block
compressor_name: zstd_1.3.8
row_store_type: encoding_row_store
*************************** 2. row ***************************
svr_ip: 192.168.96.12
svr_port: 2882
tenant_id: 1008
ls_id: 1001
tablet_id: 200142
end_log_scn: 1781628832964684545
macro_idx_in_sstable: 0
macro_logic_version: 1781628832964684545
macro_block_idx: 1219
data_seq: 0
row_count: 1
original_size: 60
encoding_size: 60
compressed_size: 57
occupy_size: 337
micro_block_count: 1
data_checksum: 2859638153
macro_range: (MIN ; 99]
macro_block_type: data_block
compressor_name: lz4_1.0
row_store_type: flat_row_store
2 rows in set (1.182 sec)

ERROR: No query specified

[root@ocp log]# export OB_ADMIN_LOG_DIR=/root/log/
[root@ocp log]# ob_admin dumpsst -d macro_block -f /root/kk/oceanbase/store/sstable/block_file -a 1219
succ to open, filename=/root/log//ob_admin.log, fd=5, wf_fd=2
succ to open, filename=/root/log//ob_admin_rs.log, fd=6, wf_fd=2
[root@ocp log]# ll
total 80
-rw-r–r-- 1 root root 78234 Jun 30 14:14 ob_admin.log
-rw-r–r-- 1 root root 0 Jun 30 14:14 ob_admin_rs.log
ob_admin.log (76.4 KB)

【备注】基于 LLM 和开源文档 RAG 的论坛小助手已开放测试,在发帖时输入 [@论坛小助手] 即可召唤小助手,欢迎试用!

1 个赞

从您描述的问题来看,您在使用ob_admin工具解析指定表的sstable宏块文件时遇到了一些错误。这些错误信息提示“clock generator not inited”以及“failed to get fallback tenant config”,通常指向的是OceanBase内部的一些配置或初始化问题。不幸的是,对于这类具体的错误,obdiag直接提供的根因分析场景并不完全匹配,但通过收集相关日志仍然有助于进一步诊断这些问题。

因此,我建议首先通过obdiag工具来收集更详细的日志信息,这将帮助我们更好地理解问题所在。基于您的情况,下面是一些建议使用的命令:

日志采集场景: 未知问题
日志采集命令: obdiag gather scene run --scene=observer.unknown

这条命令会收集尽可能多的相关日志和其他系统信息,以便于深入分析问题的根本原因。

请您执行上述命令后上传收集到的日志压缩包给我们,这样可以帮助我们更快地定位并解决问题。

此外,为了让我们能够更准确地理解和解决这个问题,请您回答以下几个问题:

  1. 您是否是在特定条件下遇到该错误(例如,仅当尝试访问某个具体表时),还是所有操作都受到影响?
  2. 这些错误发生之前是否有对集群进行过任何调整或更新?比如升级、扩容等。
  3. 是否可以提供出现错误时完整的日志片段(如果有的话),特别是与报错相关的部分?
  4. 当前OceanBase集群版本是多少?以及您所使用的ob_admin工具版本是什么?

希望以上步骤能帮到您,如果有其他疑问也欢迎随时联系我们。

附上敏捷诊断工具 obdiag 使用帮助链接

不符合预期 具体哪里不符合预期呢?

ob_admin解析出来的不是dept这个表的数据吧,看着都是ob的日志

ob的版本是哪个
SHOW VARIABLES like ‘version_comment’;

obclient(root@(none))[oceanbase]> show variables like ‘%version%’;
±------------------------±------------------------------------------------------------------------------------------------------------------+
| Variable_name | Value |
±------------------------±------------------------------------------------------------------------------------------------------------------+
| ob_last_schema_version | 0 |
| protocol_version | 10 |
| tls_version | |
| version | 5.7.25-OceanBase_CE-v4.2.1.10 |
| version_comment | OceanBase_CE 4.2.1.10 (r110000072024112010-28c1343085627e79a4f13c29121646bb889cf901) (Built Nov 20 2024 10:10:50) |
| version_compile_machine | |
| version_compile_os | |
±------------------------±------------------------------------------------------------------------------------------------------------------+
7 rows in set (0.003 sec)

Config file doesn’t exist, read from command line(path=“etc/observer.config.bin”, ret=-4027)

fail to load config(ret=-4027)

Fail to executor cmd, (ret=-4027)
看着是失败 退出了
在 observer 安装目录(有 etc/observer.config.bin 的目录)执行
cd /root/kk/oceanbase # observer 安装根目录
./bin/ob_admin dumpsst -d macro_block
-f /root/kk/oceanbase/store/sstable/block_file
-a 1219
-q 2>/dev/null | tee dept_macro_1219.txt

[root@ocp oceanbase]# cd etc
[root@ocp etc]# ll
total 42544
-rw-r–r-- 1 root root 6748938 Jun 4 2025 default_srs_data_mysql.sql
-rw-r–r-- 1 root root 161733 Jun 4 2025 fill_help_tables-ob.sql
-rw-r----- 1 root root 1052 Sep 4 2025 observer.config.bin
-rw-r----- 1 root root 977 Sep 4 2025 observer.config.bin.history
-rwxr-xr-x 1 root root 32156168 Jun 4 2025 obshell
-rw-r–r-- 1 root root 2908 Jun 4 2025 oceanbase_upgrade_dep.yml
-rw-r–r-- 1 root root 4182391 Jun 4 2025 timezone_V1.log
-rw-r–r-- 1 root root 28394 Jun 4 2025 upgrade_checker.py
-rw-r–r-- 1 root root 16730 Jun 4 2025 upgrade_health_checker.py
-rw-r–r-- 1 root root 119648 Jun 4 2025 upgrade_post.py
-rw-r–r-- 1 root root 119647 Jun 4 2025 upgrade_pre.py
[root@ocp etc]# cd …
[root@ocp oceanbase]# ./bin/ob_admin dumpsst -d macro_block -f /root/kk/oceanbase/store/sstable/block_file -a 1219 -q 2>/dev/null | tee dept_macro_1219.txt
[root@ocp oceanbase]# ll
total 20
drwxr-xr-x 2 root root 4096 Jun 4 2025 admin
drwxr-xr-x 2 root root 8192 Jun 28 09:07 audit
drwxr-xr-x 2 root root 111 Jun 30 14:49 bin
-rw-r–r-- 1 root root 0 Jun 30 14:50 dept_macro_1219.txt
drwxr-xr-x 2 root root 308 Sep 4 2025 etc
drwxr-xr-x 2 root root 64 Sep 4 2025 etc2
drwxr-xr-x 2 root root 64 Sep 4 2025 etc3
drwxr-xr-x 2 root root 122 Jun 4 2025 lib
drwxr-xr-x 2 root root 4096 Jun 30 14:46 log
drwxr-xr-x 2 root root 84 Jun 4 2025 log_obshell
drwxr-xr-x 2 root root 150 Jun 28 09:08 run
drwxr-xr-x 5 root root 45 Jun 4 2025 store
[root@ocp oceanbase]# cat dept_macro_1219.txt ----这个文件是空的

我这是给你举个例子 你这个block_file在这个文件下么?

在的,[root@ocp oceanbase]# ll /root/kk/oceanbase/store/sstable/block_file
-rw-r–r-- 1 root root 26843545600 Jun 30 14:45 /root/kk/oceanbase/store/sstable/block_file

cd /root/kk/oceanbase

./bin/ob_admin dumpsst -d macro_block
-f /root/kk/oceanbase/store
-a 1219
-q 2>&1 | tee dept_macro_1219.txt

– 1. 看退出码
echo $?

– 2. 看文件是否有内容
wc -l dept_macro_1219.txt
head -50 dept_macro_1219.txt

– 3. 若仍失败,看错误信息(会在文件里)
grep -i “fail|error|ret=” dept_macro_1219.txt

老师 可以解析了。不过解析出来的这个十六进制ob 一般用啥方法转成中文呢
------------------------------{Total Rows[4]}------------------------------
[{“INT”:10}][{“BIGINT”:-1766761156944929260}][{“BIGINT”:0}][{len: 9, flag: 0, null: 0, hex: E8B4A2E58AA1E983A8}][{len: 6, flag: 0, null: 0, hex: E58C97E4BAAC}]
[{“INT”:20}][{“BIGINT”:-1766761156944929260}][{“BIGINT”:0}][{len: 9, flag: 0, null: 0, hex: E7A094E58F91E983A8}][{len: 6, flag: 0, null: 0, hex: E4B88AE6B5B7}]
[{“INT”:30}][{“BIGINT”:-1766761156944929260}][{“BIGINT”:0}][{len: 9, flag: 0, null: 0, hex: E99480E594AEE983A8}][{len: 6, flag: 0, null: 0, hex: E5B9BFE5B79E}]
[{“INT”:40}][{“BIGINT”:-1766761156944929260}][{“BIGINT”:0}][{len: 9, flag: 0, null: 0, hex: E4BABAE4BA8BE983A8}][{len: 6, flag: 0, null: 0, hex: E6B7B1E59CB3}]

obclient(root@ldf)[test]> select * from dept;
±-------±----------±-------+
| deptno | dname | loc |
±-------±----------±-------+
| 10 | 财务部 | 北京 |
| 20 | 研发部 | 上海 |
| 30 | 销售部 | 广州 |
| 40 | 人事部 | 深圳 |
±-------±----------±-------+
4 rows in set (0.003 sec)

可以使用python转译一下
python3 <<‘PY’
import re
text = open(‘dept_macro_1219.txt’).read()
for m in re.finditer(r’hex: ([0-9A-Fa-f]+)’, text):
print(bytes.fromhex(m.group(1)).decode(‘utf-8’))
PY

或者linux上执行
echo “E8B4A2E58AA1E983A8” | xxd -r -p