{"id":2198,"date":"2022-10-07T14:46:54","date_gmt":"2022-10-07T06:46:54","guid":{"rendered":"https:\/\/cowmanchiang.me\/wp\/?p=2198"},"modified":"2023-10-31T15:41:35","modified_gmt":"2023-10-31T07:41:35","slug":"rocksdb-tool","status":"publish","type":"post","link":"https:\/\/cowmanchiang.me\/wp\/?p=2198","title":{"rendered":"RocksDB Tool"},"content":{"rendered":"<ol>\n<li>\n<p>Install rocksdb first.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">brew install rocksdb<\/pre>\n<\/li>\n<li>\n<p>Add alias in zshrc<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">alias ldb = &#039;rocksdb_ldb --db=. &#039;<\/pre>\n<\/li>\n<li>\n<p>List all column families<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\"># ldb list_column_families\nColumn families in .:\n{default, S1, User, C1, C2, U1, C3}<\/pre>\n<\/li>\n<li>\n<p>Scan command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\"># ldb --column_family=User scan\nUser_U_name : cowman\nUser_U_status : 0\nUser_U_type : 0\nUser_U_updatedTimestamp :\nUser_U_userId : U<\/pre>\n<\/li>\n<li>\n<p>Show result with hex value<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">ldb --column_family=User scan --value_hex\nUser_U_name : 0x636F776D616E\nUser_U_status : 0x30\nUser_U_type : 0x30\nUser_U_updatedTimestamp : 0x0000000000000000\nUser_U_userId : 0x55<\/pre>\n<\/li>\n<li>\n<p>Command description (Some commands are inconsistent with how they are used on linux servers)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">ldb - RocksDB Tool\n\ncommands MUST specify --db=&lt;full_path_to_db_directory&gt; when necessary\n\ncommands can optionally specify\n  --env_uri=&lt;uri_of_environment&gt; or --fs_uri=&lt;uri_of_filesystem&gt; if necessary\n  --secondary_path=&lt;secondary_path&gt; to open DB as secondary instance. Operations not supported in secondary instance will fail.\n\nThe following optional parameters control if keys\/values are input\/output as hex or as plain strings:\n  --key_hex : Keys are input\/output as hex\n  --value_hex : Values are input\/output as hex\n  --hex : Both keys and values are input\/output as hex\n\nThe following optional parameters control the database internals:\n  --column_family=&lt;string&gt; : name of the column family to operate on. default: default column family\n  --ttl with &#039;put&#039;,&#039;get&#039;,&#039;scan&#039;,&#039;dump&#039;,&#039;query&#039;,&#039;batchput&#039; : DB supports ttl and value is internally timestamp-suffixed\n  --try_load_options : Try to load option file from DB. Default to true if db is specified and not creating a new DB and not open as TTL DB. Can be set to false explicitly.\n  --disable_consistency_checks : Set options.force_consistency_checks = false.\n  --ignore_unknown_options : Ignore unknown options when loading option file.\n  --bloom_bits=&lt;int,e.g.:14&gt;\n  --fix_prefix_len=&lt;int,e.g.:14&gt;\n  --compression_type=&lt;no|snappy|zlib|bzip2|lz4|lz4hc|xpress|zstd&gt;\n  --compression_max_dict_bytes=&lt;int,e.g.:16384&gt;\n  --block_size=&lt;block_size_in_bytes&gt;\n  --auto_compaction=&lt;true|false&gt;\n  --db_write_buffer_size=&lt;int,e.g.:16777216&gt;\n  --write_buffer_size=&lt;int,e.g.:4194304&gt;\n  --file_size=&lt;int,e.g.:2097152&gt;\n  --enable_blob_files : Enable key-value separation using BlobDB\n  --min_blob_size=&lt;int,e.g.:2097152&gt;\n  --blob_file_size=&lt;int,e.g.:2097152&gt;\n  --blob_compression_type=&lt;no|snappy|zlib|bzip2|lz4|lz4hc|xpress|zstd&gt;\n  --enable_blob_garbage_collection : Enable blob garbage collection\n  --blob_garbage_collection_age_cutoff=&lt;double,e.g.:0.25&gt;\n  --blob_garbage_collection_force_threshold=&lt;double,e.g.:0.25&gt;\n  --blob_compaction_readahead_size=&lt;int,e.g.:2097152&gt;\n\n\nData Access Commands:\n  put &lt;key&gt; &lt;value&gt; [--create_if_missing] [--ttl]\n  get &lt;key&gt; [--ttl]\n  batchput &lt;key&gt; &lt;value&gt; [&lt;key&gt; &lt;value&gt;] [..] [--create_if_missing] [--ttl]\n  scan [--from] [--to]  [--ttl] [--timestamp] [--max_keys=&lt;N&gt;q]  [--start_time=&lt;N&gt;:- is inclusive] [--end_time=&lt;N&gt;:- is exclusive] [--no_value]\n  delete &lt;key&gt;\n  deleterange &lt;begin key&gt; &lt;end key&gt;\n  query [--ttl]\n    Starts a REPL shell.  Type help for list of available commands.\n  approxsize [--from] [--to]\n  checkconsistency\n  list_file_range_deletes [--max_keys=&lt;N&gt;] : print tombstones in SST files.\n\n\nAdmin Commands:\n  dump_wal --walfile=&lt;write_ahead_log_file_path&gt; [--header]  [--print_value]  [--write_committed=true|false]\n  compact [--from] [--to]\n  reduce_levels --new_levels=&lt;New number of levels&gt; [--print_old_levels]\n  change_compaction_style --old_compaction_style=&lt;Old compaction style: 0 for level compaction, 1 for universal compaction&gt; --new_compaction_style=&lt;New compaction style: 0 for level compaction, 1 for universal compaction&gt;\n  dump [--from] [--to]  [--ttl] [--max_keys=&lt;N&gt;] [--timestamp] [--count_only] [--count_delim=&lt;char&gt;] [--stats] [--bucket=&lt;N&gt;] [--start_time=&lt;N&gt;:- is inclusive] [--end_time=&lt;N&gt;:- is exclusive] [--path=&lt;path_to_a_file&gt;] [--decode_blob_index] [--dump_uncompressed_blobs]\n  load [--create_if_missing] [--disable_wal] [--bulk_load] [--compact]\n  manifest_dump [--verbose] [--json] [--path=&lt;path_to_manifest_file&gt;]\n  update_manifest [--update_temperatures]      MUST NOT be used on a live DB.\n  file_checksum_dump [--path=&lt;path_to_manifest_file&gt;]\n  get_property &lt;property_name&gt;\n  list_column_families\n  create_column_family --db=&lt;db_path&gt; &lt;new_column_family_name&gt;\n  drop_column_family --db=&lt;db_path&gt; &lt;column_family_name_to_drop&gt;\n  dump_live_files [--decode_blob_index]  [--dump_uncompressed_blobs]\n  idump [--from] [--to]  [--input_key_hex] [--max_keys=&lt;N&gt;] [--count_only] [--count_delim=&lt;char&gt;] [--stats] [--decode_blob_index]\n  list_live_files_metadata [--sort_by_filename]\n  repair [--verbose]\n  backup [--backup_env_uri | --backup_fs_uri]  [--backup_dir]  [--num_threads]  [--stderr_log_level=&lt;int (InfoLogLevel)&gt;]\n  restore [--backup_env_uri | --backup_fs_uri]  [--backup_dir]  [--num_threads]  [--stderr_log_level=&lt;int (InfoLogLevel)&gt;]\n  checkpoint [--checkpoint_dir]\n  write_extern_sst &lt;output_sst_path&gt;\n  ingest_extern_sst &lt;input_sst_path&gt; [--move_files]  [--snapshot_consistency]  [--allow_global_seqno]  [--allow_blocking_flush]  [--ingest_behind]  [--write_global_seqno]\n  unsafe_remove_sst_file &lt;SST file number        MUST NOT be used on a live DB.<\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Install rocksdb first. brew install rocksdb Add alias in zshrc alias ldb = &#039;rocksdb_ldb &#8211;db=. &#039; List all column families # ldb list_column_families Column families in .: {default, S1, User, C1, C2, U1, C3} Scan command: # ldb &#8211;column_family=User scan &hellip; <a href=\"https:\/\/cowmanchiang.me\/wp\/?p=2198\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[],"class_list":["post-2198","post","type-post","status-publish","format-standard","hentry","category-rocksdb"],"_links":{"self":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2198"}],"version-history":[{"count":1,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2198\/revisions"}],"predecessor-version":[{"id":2199,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2198\/revisions\/2199"}],"wp:attachment":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}