问题
今天主要分析一下如何记下OSD的pg_log_entry, 我们只要pg_log是存在osd的radosdb里面的那如何去反序列化解析出来
方法
1. 用ceph-kvstore-tool导出pglog条目信息
1 | # ceph-kvstore-tool rocksdb dev/osd0/current/omap/ list |
这些每一个条目对应一个pglog条目,就是所谓的pg_log_entry,我们取一个147进行解析,先导出1
ceph-kvstore-tool rocksdb dev/osd0/current/omap/ get _USER_0000000000000041_USER_ 0000000031.00000000000000000147 out /home/krunerge/0000000031.00000000000000000147
2. 查看二进制内容
1 | [root@ceph /data/ceph/ceph-aduit-log/Ceph/build]# ll /home/krunerge/0000000031.00000000000000000147 |
167个字节,二进制内容1
2
3
4
5
6
7
8
9
10
11
12
13[root@ceph /data/ceph/ceph-aduit-log/Ceph/build]# hexdump -C /home/krunerge/0000000031.00000000000000000147
00000000 9f 00 00 00 0b 04 99 00 00 00 01 00 00 00 04 03 |................|
00000010 38 00 00 00 00 00 00 00 17 00 00 00 72 62 64 5f |8...........rbd_|
00000020 68 65 61 64 65 72 2e 31 30 65 31 36 62 38 62 34 |header.10e16b8b4|
00000030 35 36 37 fe ff ff ff ff ff ff ff a8 fc 56 eb 00 |567..........V..|
00000040 00 00 00 00 03 00 00 00 00 00 00 00 93 00 00 00 |................|
00000050 00 00 00 00 1f 00 00 00 92 00 00 00 00 00 00 00 |................|
00000060 1f 00 00 00 02 02 15 00 00 00 08 0e 11 00 00 00 |................|
00000070 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 20 |............... |
00000080 35 32 60 8d aa da 29 00 00 00 00 93 00 00 00 00 |52`...).........|
00000090 00 00 00 01 01 06 00 00 00 00 00 00 00 00 00 00 |................|
000000a0 00 00 00 d5 1a b8 29 |......)|
000000a7
前面
3. dd截取
截掉开头4个字节1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17[root@ceph /data/ceph/ceph-aduit-log/Ceph/build]# dd if=/home/krunerge/0000000031.00000000000000000147 of=/home/krunerge/0000000031.00000000000000000147_tmp count=163 bs=1 skip=4
163+0 records in
163+0 records out
163 bytes (163 B) copied, 0.000279881 s, 582 kB/s
[root@ceph /data/ceph/ceph-aduit-log/Ceph/build]# hexdump -C /home/krunerge/0000000031.00000000000000000147_tmp
00000000 0b 04 99 00 00 00 01 00 00 00 04 03 38 00 00 00 |............8...|
00000010 00 00 00 00 17 00 00 00 72 62 64 5f 68 65 61 64 |........rbd_head|
00000020 65 72 2e 31 30 65 31 36 62 38 62 34 35 36 37 fe |er.10e16b8b4567.|
00000030 ff ff ff ff ff ff ff a8 fc 56 eb 00 00 00 00 00 |.........V......|
00000040 03 00 00 00 00 00 00 00 93 00 00 00 00 00 00 00 |................|
00000050 1f 00 00 00 92 00 00 00 00 00 00 00 1f 00 00 00 |................|
00000060 02 02 15 00 00 00 08 0e 11 00 00 00 00 00 00 11 |................|
00000070 00 00 00 00 00 00 00 00 00 00 00 20 35 32 60 8d |........... 52`.|
00000080 aa da 29 00 00 00 00 93 00 00 00 00 00 00 00 01 |..).............|
00000090 01 06 00 00 00 00 00 00 00 00 00 00 00 00 00 d5 |................|
000000a0 1a b8 29 |..)|
000000a3
再截掉尾部4个字节1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22[root@ceph /data/ceph/ceph-aduit-log/Ceph/build]# dd if=/home/krunerge/0000000031.00000000000000000147_tmp of=/home/krunerge/0000000031.00000000000000000147_tmp2 count=159 bs=1
159+0 records in
159+0 records out
159 bytes (159 B) copied, 0.000279745 s, 568 kB/s
[root@ceph /data/ceph/ceph-aduit-log/Ceph/build]# ./bin/ceph-dencoder type pg_log_entry_t import /home/krunerge/0000000031.00000000000000000147_tmp2 decode dump_json
{
"op": "modify",
"object": "3:153f6ad7:::rbd_header.10e16b8b4567:head",
"version": "31'147",
"prior_version": "31'146",
"reqid": "client.4366.0:17",
"extra_reqids": [],
"mtime": "2021-02-21 18:25:36.702196",
"return_code": 0,
"mod_desc": {
"object_mod_desc": {
"can_local_rollback": false,
"rollback_info_completed": false,
"ops": []
}
}
}