這篇文章給大家分享的是有關如何查看ceph中levelDB存儲的數據的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
這個程序用于查看ceph 中leveldb都存了些什么值 /var/lib/ceph/osd/ceph-1/current/omap ,把查詢出來的結果存入levelDBFile.txt文件中。
#include <assert.h> #include <string> #include <iostream> #include <fstream> #include "leveldb/db.h" #include "leveldb/env.h" #include "leveldb/write_batch.h" #include "leveldb/cache.h" using namespace std; int main() { leveldb::DB* db; leveldb::Options options; options.create_if_missing = true; leveldb::Status status = leveldb::DB::Open(options, "/var/lib/ceph/osd/ceph-1/current/omap", &db); assert(status.ok()); ofstream outfile; outfile.open("levelDBFile.txt",ios::out); if(!outfile) { cout <<"Cannot open file!" << endl; return 0; } leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions()); for (it->SeekToFirst(); it->Valid(); it->Next()) { outfile << it->key().ToString() << " : " << it->value().ToString() << endl << endl << endl; } outfile.close(); assert(it->status().ok()); // Check for any errors found during the scan delete it; delete db; return 0; }
編譯: g++ -I include/ leveldb.cc -lleveldb levelDB只能一個進程去操作,執行./a.out程序時先停掉ceph進程。 stop ceph-all ./a.out start ceph-all vi levelDBFile.txt :set nu :%!xxd
感謝各位的閱讀!關于“如何查看ceph中levelDB存儲的數據”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。