sstablemetadata — SSTable 메타데이터 출력
sstablemetadata — SSTable 메타데이터 출력
sstablemetadata는 SSTable 관련 Statistics.db와 Summary.db 파일로부터 해당 SSTable에 대한 정보를 표준 출력으로 출력해 주는 도구예요. SSTable의 파티셔너, 압축 정보, 타임스탬프 범위, 툼스톤(tombstone) 비율, 카디널리티 등 데이터 저장 상태를 상세히 파악할 때 유용하답니다.
관련 문서: CASSANDRA-7159, CASSANDRA-10838
이 도구 실행 전에 Cassandra를 반드시 중지해야 해요. 그렇지 않으면 예상치 못한 결과가 발생할 수 있으며, 스크립트는 Cassandra가 정지되었는지 검증하지 않습니다.
본문
기본 사용법은 다음과 같습니다.
sstablemetadata <options> <sstable filename(s)>
지원하는 옵션은 다음과 같습니다.
| 옵션 | 설명 |
|---|---|
| --colors | ANSI 색상 시퀀스 사용 |
--gc_grace_seconds <arg> |
계산에 사용할 gc_grace_seconds |
| --help | 도움말 |
| --scan | 추가 상세 정보를 위한 전체 SSTable 스캔. 3.0+ SSTable에서만 사용 가능. 기본값: false |
--timestamp_unit <arg> |
셀 타임스탬프가 기록되는 시간 단위 |
| --unicode | 히스토그램과 진행 바를 그리는 데 unicode 사용(droppable tombstones) |
모든 메타데이터 출력
테이블과 관련된 *Data.db 파일에 대해 sstablemetadata를 실행하세요. 필요하면 sstableutil로 *Data.db 파일을 찾으면 됩니다.
예시:
$ sstableutil keyspace1 standard1 | grep Data
/var/lib/cassandra/data/keyspace1/standard1-f6845640a6cb11e8b6836d2c86545d91/mc-1-big-Data.db
$ sstablemetadata /var/lib/cassandra/data/keyspace1/standard1-f6845640a6cb11e8b6836d2c86545d91/mc-1-big-Data.db
SSTable: /var/lib/cassandra/data/keyspace1/standard1-f6845640a6cb11e8b6836d2c86545d91/mc-1-big
Partitioner: org.apache.cassandra.dht.Murmur3Partitioner
Bloom Filter FP chance: 0.010000
Minimum timestamp: 07/08/2023 09:11:52 (1688800312685792)
Maximum timestamp: 07/08/2023 09:12:03 (1688800323542149)
Duration: Days: 0 Hours: 0 Minutes: 0 Seconds: 10
SSTable min local deletion time: 07/08/2023 09:11:52 (1688800312)
SSTable max local deletion time: 07/08/2023 09:12:03 (1688800323)
Compressor: org.apache.cassandra.io.compress.LZ4Compressor
Compression ratio: 0.553999337227618
TTL min: 86400
TTL max: 86400
First token: -9223004712949498654 (key=39373333373831303130)
Last token: 9222554117157811897 (key=4f3438394e39374d3730)
Covered clusterings: ALL
Estimated droppable tombstones: 0.9188263888888889
SSTable Level: 0
Repaired at: 0
Originating host id: badfcb83-a283-402b-818e-78ede00aa3c4
Pending repair: --
Replay positions covered: {CommitLogPosition(segmentId=1535025390651, position=226400)=CommitLogPosition(segmentId=1535025390651, position=6849139)}
Total Column Cells: 72918
Total Rows: 24306
Estimated tombstone drop times:
1535039100: 80390
1535039160: 5645
1535039220: 13965
Count Row Size Cell Count
1 0 0
2 0 0
3 0 0
4 0 0
5 0 20000
6 0 0
7 0 0
8 0 0
10 0 0
12 0 0
14 0 0
17 0 0
20 0 0
24 0 0
29 0 0
35 0 0
42 0 0
50 0 0
60 0 0
72 0 0
86 0 0
103 0 0
124 0 0
149 0 0
179 0 0
215 0 0
258 20000 0
310 0 0
372 0 0
446 0 0
535 0 0
642 0 0
770 0 0
924 0 0
1109 0 0
1331 0 0
1597 0 0
1916 0 0
2299 0 0
2759 0 0
3311 0 0
3973 0 0
4768 0 0
5722 0 0
6866 0 0
8239 0 0
9887 0 0
11864 0 0
14237 0 0
17084 0 0
20501 0 0
24601 0 0
29521 0 0
35425 0 0
42510 0 0
51012 0 0
61214 0 0
73457 0 0
88148 0 0
105778 0 0
126934 0 0
152321 0 0
182785 0 0
219342 0 0
263210 0 0
315852 0 0
379022 0 0
454826 0 0
545791 0 0
654949 0 0
785939 0 0
943127 0 0
1131752 0 0
1358102 0 0
1629722 0 0
1955666 0 0
2346799 0 0
2816159 0 0
3379391 0 0
4055269 0 0
4866323 0 0
5839588 0 0
7007506 0 0
8409007 0 0
10090808 0 0
12108970 0 0
14530764 0 0
17436917 0 0
20924300 0 0
25109160 0 0
30130992 0 0
36157190 0 0
43388628 0 0
52066354 0 0
62479625 0 0
74975550 0 0
89970660 0 0
107964792 0 0
129557750 0 0
155469300 0 0
186563160 0 0
223875792 0 0
268650950 0 0
322381140 0 0
386857368 0 0
464228842 0 0
557074610 0 0
668489532 0 0
802187438 0 0
962624926 0 0
1155149911 0 0
1386179893 0 0
1663415872 0 0
1996099046 0 0
2395318855 0 0
2874382626 0
3449259151 0
4139110981 0
4966933177 0
5960319812 0
7152383774 0
8582860529 0
10299432635 0
12359319162 0
14831182994 0
17797419593 0
21356903512 0
25628284214 0
30753941057 0
36904729268 0
44285675122 0
53142810146 0
63771372175 0
76525646610 0
91830775932 0
110196931118 0
132236317342 0
158683580810 0
190420296972 0
228504356366 0
274205227639 0
329046273167 0
394855527800 0
473826633360 0
568591960032 0
682310352038 0
818772422446 0
982526906935 0
1179032288322 0
1414838745986 0
Estimated cardinality: 20196
EncodingStats minTTL: 0
EncodingStats minLocalDeletionTime: 1442880000
EncodingStats minTimestamp: 1535025565275000
KeyType: org.apache.cassandra.db.marshal.BytesType
ClusteringTypes: [org.apache.cassandra.db.marshal.UTF8Type]
StaticColumns: {C3:org.apache.cassandra.db.marshal.BytesType, C4:org.apache.cassandra.db.marshal.BytesType, C0:org.apache.cassandra.db.marshal.BytesType, C1:org.apache.cassandra.db.marshal.BytesType, C2:org.apache.cassandra.db.marshal.BytesType}
RegularColumns: {}
IsTransient: false
gc grace seconds 지정
설정된 gc grace seconds 기준으로 droppable tombstone 비율을 보려면 gc_grace_seconds 옵션을 사용하세요. sstablemetadata 도구는 스키마에 직접 접근하지 않기 때문에, 이 옵션으로 droppable tombstone을 더 정확하게 추정할 수 있어요 — 예를 들어 스키마에 설정된 값과 일치하는 gc_grace_seconds를 넘겨주는 방식입니다. 제공된 gc_grace_seconds 값은 현재 머신 시간(초 단위)에서 차감됩니다.
관련 문서: CASSANDRA-12208
예시:
$ sstablemetadata /var/lib/cassandra/data/keyspace1/standard1-41b52700b4ed11e896476d2c86545d91/mc-12-big-Data.db | grep "Estimated tombstone drop times" -A4
Estimated tombstone drop times:
1536599100: 1
1536599640: 1
1536599700: 2
$ echo $(date +%s)
1536602005
# if gc_grace_seconds was configured at 100, all of the tombstones would be currently droppable
$ sstablemetadata --gc_grace_seconds 100 /var/lib/cassandra/data/keyspace1/standard1-41b52700b4ed11e896476d2c86545d91/mc-12-big-Data.db | grep "Estimated droppable tombstones"
Estimated droppable tombstones: 4.0E-5
# if gc_grace_seconds was configured at 4700, some of the tombstones would be currently droppable
$ sstablemetadata --gc_grace_seconds 4700 /var/lib/cassandra/data/keyspace1/standard1-41b52700b4ed11e896476d2c86545d91/mc-12-big-Data.db | grep "Estimated droppable tombstones"
Estimated droppable tombstones: 9.61111111111111E-6
# if gc_grace_seconds was configured at 100, none of the tombstones would be currently droppable
$ sstablemetadata --gc_grace_seconds 5000 /var/lib/cassandra/data/keyspace1/standard1-41b52700b4ed11e896476d2c86545d91/mc-12-big-Data.db | grep "Estimated droppable tombstones"
Estimated droppable tombstones: 0.0
테이블 스캔
--scan 옵션을 지정하면 테이블에 대한 추가 통계를 얻을 수 있어요. 다소 시간이 걸릴 수 있습니다.
예시:
sstablemetadata -s /var/lib/cassandra/data/data/ks/tb-dbead8501c9511ee805bb3deafc4499b/oa-1-big-Data.db
이렇게 하면 다음과 같은 통계를 얻을 수 있어요.
Size: 120
Partitions: 2
Rows: 5
Tombstones: 0
Cells: 5
Widest Partitions:
[2] 3
[1] 2
Largest Partitions:
[2] 147 (147 B)
[1] 98 (98 B)
위에 출력된 각 값의 설명
| 값 | 설명 |
|---|---|
| SSTable | 이 sstable과 관련된 sstable 파일 이름의 접두어 |
| Partitioner | 노드 간 데이터 분산에 사용되는 파티셔너 타입; cassandra.yaml에 정의 |
| Bloom Filter FP | 읽기 시 사용되는 Bloom filter의 정밀도; 테이블 정의에 정의 |
| Minimum timestamp | 이 sstable에 있는 모든 항목의 최소 타임스탬프(epoch 마이크로초) |
| Maximum timestamp | 이 sstable에 있는 모든 항목의 최대 타임스탬프(epoch 마이크로초) |
| Duration | Maximum timestamp와 Minimum timestamp의 차이 |
| SSTable min local deletion time | TTL 기반 삭제 날짜의 최소 타임스탬프(epoch 초) |
| SSTable max local deletion time | TTL 기반 삭제 날짜의 최대 타임스탬프(epoch 초) |
| Compressor | 기본적으로 빈칸(-); 비어 있지 않으면 테이블에서 활성화된 압축 유형을 나타냄 |
| TTL min | 초 단위의 time-to-live; 테이블 정의에 없으면 기본 0 |
| TTL max | 초 단위의 time-to-live; 테이블 정의에 없으면 기본 0 |
| First token | sstable 요약(summary)에서 발견된 가장 낮은 토큰과 관련 키 |
| Last token | sstable 요약(summary)에서 발견된 가장 높은 토큰과 관련 키 |
| Estimated droppable tombstones | 관련 시점에 설정된 gc grace seconds를 사용한 tombstone 대비 column 비율 |
| SSTable level | leveled compaction(LCS) 사용 시 이 sstable의 컴팩션 레벨 |
| Repaired at | sstablerepairedset로 이 sstable이 리페어됨으로 표시된 타임스탬프(epoch 밀리초) |
| Replay positions covered | 이 sstable과 관련된 시간 구간 및 commitlog 위치 |
| totalColumnsSet | 테이블의 셀(cell) 수 |
| totalRows | 테이블의 행(row) 수 |
| Estimated tombstone drop times | 만료될 것으로 예상되는 행의 대략적인 수(epoch 초 순서) |
| Count Row Size Cell Count | 두 컬럼의 두 히스토그램; 하나는 Row Size 분포, 다른 하나는 Cell Count 분포를 나타냄 |
| Estimated cardinality | 컴팩션에 사용되는 고유값의 추정치 |
| EncodingStats* minTTL | epoch 밀리초 |
| EncodingStats* minLocalDeletionTime | epoch 초 |
| EncodingStats* minTimestamp | epoch 마이크로초 |
| KeyType | 파티션 키의 타입; 스토리지에서 데이터를 읽고 쓸 때 유용하며 테이블 정의에 정의 |
| ClusteringTypes | 클러스터링 키의 타입; 스토리지에서 데이터를 읽고 쓸 때 유용하며 테이블 정의에 정의 |
| StaticColumns | 테이블의 공유 정적 컬럼 목록 |
| RegularColumns | 테이블의 일반 컬럼 목록 |
* 인코딩 통계 값의 경우, 데이터를 가장 최적의 방식으로 인코딩해 저장할 때 이 값과 현재 epoch 시간의 차이(delta)가 사용됩니다.