文章目錄
- 簡介
- 使用
- OSD相關操作
- PG相關操作
- 對象相關操作
- 總結
簡介
ceph-objectstore-tool
工具,能夠操作到ceph最底層的資料,包括pg,對象層級。它能夠對底層pg以及對象相關資料進行擷取、修改。并能夠對一些問題pg和對象進行簡單修複。是以使用該工具進行操作的時候需要謹慎(涉及到修改的操作最好備份一份資料),防止誤操作造成資料丢失。
該工具的使用主要針對
對象
和
PG
,是以這裡我們的使用主要為以下兩種
-
的相關操作PG
info #檢視pg的資訊
log #檢視pg的中繼資料資訊
remove #從目前osd移除pg
mkfs #重新初始化osd
fsck #檢查bluefs資料正确性
export #導出pg中繼資料
import #導入pg中繼資料
list #列出pg内部對象或者目前osd所有對象
fix-lost #修複pg丢失的對象
list-pgs #列出目前osd所有pg
rm-past-intervals
dump-journal #針對filestore,列印日志
dump-super #列印osd的超級塊資訊
meta-list #列印中繼資料資訊清單
get-osdmap #擷取osdmap
set-osdmap #設定osd map
get-inc-osdmap #從目前osd 擷取inc 資訊
set-inc-osdmap #将inc設定進入目前osd資訊
mark-complete #标記為complete,讓bluestore認為可以pg可以選舉出權威日志
-
的相關操作,這裡主要列出常用的對象操作對象
list-attrs #列出對象的一些屬性
list-omap #列出對象的omp資訊
remove|removeall #移除對象或者移除所有對象
dump #列印對象中繼資料資訊
使用
基本指令使用如下:
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore xxx
一般前半部分如左,指定osd路徑,指定存儲引擎(
bluestore
或者
filestore
)
OSD相關操作
-
檢查bluestore的bluefs是否檔案系統被損壞,并嘗試修複
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --op fsck
-
列出目前osd所有對象
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --op list
-
擷取目前osd的osdmap資訊,并指定對應的輸出檔案
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --op get-osdmap --file 1.txt
[root@node1 ceph]# ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --op get-osdmap --file 1.txt
osdmap#1457 exported.
-
導入一個osdmap資訊到目前osd
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --op set-osdmap --file 1.txt
[root@node1 ceph]# ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --op set-osdmap --file 1.txt
Wrote osdmap.145
-
擷取目前osd的超級塊資訊
輸出如下:ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --op dump-super
{
"cluster_fsid": "fa27f041-0ce9-4df1-a4bd-5e37678834bd",
"osd_fsid": "c03c2fdb-cfd4-42bd-8e32-61e359281078",
"whoami": 8,
"current_epoch": 1457,
"oldest_map": 784,
"newest_map": 1457,
"weight": 0.000000,
"compat": {
"compat": {},
"ro_compat": {},
"incompat": {
"feature_1": "initial feature set(~v.18)",
"feature_2": "pginfo object",
"feature_3": "object locator",
"feature_4": "last_epoch_clean",
"feature_5": "categories",
"feature_6": "hobjectpool",
"feature_7": "biginfo",
"feature_8": "leveldbinfo",
"feature_9": "leveldblog",
"feature_10": "snapmapper",
"feature_11": "sharded objects",
"feature_12": "transaction hints",
"feature_13": "pg meta object",
"feature_14": "explicit missing set",
"feature_15": "fastinfo pg attr",
"feature_16": "deletes in missing set"
}
},
"clean_thru": 1457,
"last_epoch_mounted": 1456
}
-
擷取目前osd的所有pg
其中ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --op list-pgs
表示對目前osd或者目前pg的操作--op
17.es1
17.as0
17.8s1
17.4s2
17.3s1
17.3fs0
17.3ds0
17.3cs2
17.23s2
17.2es0
PG相關操作
-
針對單個pg,列出目前pg的基本資訊
輸出如下ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --pgid 17.es1 --op info
"pgid": "17.es1",
"last_update": "1380'5116",
"last_complete": "1380'5116",
"log_tail": "1376'4854",
"last_user_version": 5118,
"last_backfill": "MAX",
"last_backfill_bitwise": 0,
"purged_snaps": [],
"history": {
"epoch_created": 1290,
"epoch_pool_created": 1290,
"last_epoch_started": 1457,
"last_interval_started": 1456,
"last_epoch_clean": 1350,
"last_interval_clean": 1349,
"last_epoch_split": 0,
"last_epoch_marked_full": 0,
"same_up_since": 1456,
"same_interval_since": 1456,
"same_primary_since": 1290,
"last_scrub": "0'0",
"last_scrub_stamp": "2019-08-12 11:14:04.515869",
"last_deep_scrub": "0'0",
"last_deep_scrub_stamp": "2019-08-12 11:14:04.515869",
"last_clean_scrub_stamp": "2019-08-12 11:14:04.515869"
...
-
針對單個pg,列出目前pg中繼資料資訊
該指令的輸出主要包括pg的曆史版本資訊,記錄着每個對象的相關操作,以及當時ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --pgid 17.es1 --op log
和對應的pg小版本pg epoch
"pg_log_t": {
"head": "1380'5116",
"tail": "1376'4854",
"log": [
{
"op": "modify",
"object": "17:713bbf48:::rbd_data.18.cf83c74b0dc51.0000000000023ba0:head",
"version": "1376'4855",
"prior_version": "0'0",
"reqid": "client.852676.0:164001",
"extra_reqids": [],
"mtime": "2019-08-12 14:40:08.571459",
"return_code": 0,
"mod_desc": {
"object_mod_desc": {
"can_local_rollback": true,
"rollback_info_completed": true,
"ops": [
{
"code": "CREATE"
}
]
}
}
},
...
列印pg中對象的中繼資料
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --pgid 17.es1 --op meta-list
["meta",{"oid":"osdmap.1372","key":"","snapid":0,"hash":168878088,"max":0,"pool":-1,"namespace":"","max":0}]
["meta",{"oid":"osdmap.1053","key":"","snapid":0,"hash":168945672,"max":0,"pool":-1,"namespace":"","max":0}]
["meta",{"oid":"osdmap.1266","key":"","snapid":0,"hash":168892424,"max":0,"pool":-1,"namespace":"","max":0}]
["meta",{"oid":"osdmap.1101","key":"","snapid":0,"hash":168920072,"max":0,"pool":-1,"namespace":"","max":0}]
...
-
将pg的中繼資料導出到指定檔案,一般用作 備份
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --pgid 17.es1 --op export --file /mnt/test.obj
-
将指定的pg中繼資料導入到目前pg
這裡導入前需要先移除目前pg(remove之前請先export備份一下pg資料)
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --pgid 17.es1 --op remove
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --pgid 17.es1 --op import --file /mnt/test.obj
- 将叢集中
的pg标記為incomplete
complete
,這裡需要根據叢集的副本數将相關的所有osd上的pg進行标記
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --pgid 17.es1 --op mark-complete
對象相關操作
-
列出目前pg的所有對象
輸出如下:ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --pgid 17.es1 --op list
["17.es1",{"oid":"rbd_data.18.cf83c74b0dc51.000000000001bda5","key":"","snapid":-2,"hash":1725693966,"max":0,"pool":17,"namespace":"","shard_id":1,"max":0}]
["17.es1",{"oid":"rbd_data.18.cf83c74b0dc51.0000000000033137","key":"","snapid":-2,"hash":1782448142,"max":0,"pool":17,"namespace":"","shard_id":1,"max":0}]
["17.es1",{"oid":"rbd_data.18.cf83c74b0dc51.000000000003f128","key":"","snapid":-2,"hash":1246789646,"max":0,"pool":17,"namespace":"","shard_id":1,"max":0
...
...
從以上擷取的對象中取一個,列印對象的中繼資料資訊
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore rbd_data.18.cf83c74b0dc51.000000000003925a dump
{
"id": {
"oid": "rbd_data.18.cf83c74b0dc51.000000000003925a",
"key": "",
"snapid": -2,
"hash": 1962672078,
"max": 0,
"pool": 17,
"namespace": "",
"shard_id": 1,
"max": 0
},
"info": {
"oid": {
"oid": "rbd_data.18.cf83c74b0dc51.000000000003925a",
"key": "",
"snapid": -2,
"hash": 1962672078,
"max": 0,
"pool": 17,
"namespace": ""
},
...
-
擷取對象的屬性資訊
ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore
[root@node1 ceph]# ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore rbd_data.18.cf83c74b0dc51.000000000003925a list-attrs
_
hinfo_key
snapset
-
删除對象
請慎重測試,如有pg備份,則可以進行測試ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore rbd_data.18.cf83c74b0dc51.000000000003925a remove
[root@node1 ceph]# ceph-objectstore-tool-bak --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore rbd_data.18.cf83c74b0dc51.000000000003925a remove
remove 1#17:73ffdf2e:::rbd_data.18.cf83c74b0dc51.000000000003925a:head#
-
檢視pg中是否還有該對象
并無輸出ceph-objectstore-tool-bak --data-path /var/lib/ceph/osd/ceph-8/ --type bluestore --pgid 17.es1 --op list|grep rbd_data.18.cf83c74b0dc51.000000000003925a