| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <title>Pegasus | Shell</title> |
| <link rel="stylesheet" href="/assets/css/app.css"> |
| <link rel="shortcut icon" href="/assets/images/favicon.ico"> |
| <link rel="stylesheet" href="/assets/css/utilities.min.css"> |
| <link rel="stylesheet" href="/assets/css/docsearch.v3.css"> |
| <script src="/assets/js/jquery.min.js"></script> |
| <script src="/assets/js/all.min.js"></script> |
| <script src="/assets/js/docsearch.v3.js"></script> |
| <!-- Begin Jekyll SEO tag v2.8.0 --> |
| <title>Shell | Pegasus</title> |
| <meta name="generator" content="Jekyll v4.3.2" /> |
| <meta property="og:title" content="Shell" /> |
| <meta property="og:locale" content="en_US" /> |
| <meta name="description" content="Pegasus提供了Shell工具,用于查看集群相关信息,创建/删除表,操作数据等。" /> |
| <meta property="og:description" content="Pegasus提供了Shell工具,用于查看集群相关信息,创建/删除表,操作数据等。" /> |
| <meta property="og:site_name" content="Pegasus" /> |
| <meta property="og:type" content="article" /> |
| <meta property="article:published_time" content="2023-11-23T14:57:08+00:00" /> |
| <meta name="twitter:card" content="summary" /> |
| <meta property="twitter:title" content="Shell" /> |
| <script type="application/ld+json"> |
| {"@context":"https://schema.org","@type":"BlogPosting","dateModified":"2023-11-23T14:57:08+00:00","datePublished":"2023-11-23T14:57:08+00:00","description":"Pegasus提供了Shell工具,用于查看集群相关信息,创建/删除表,操作数据等。","headline":"Shell","mainEntityOfPage":{"@type":"WebPage","@id":"/docs/tools/shell/"},"url":"/docs/tools/shell/"}</script> |
| <!-- End Jekyll SEO tag --> |
| </head> |
| |
| |
| <body> |
| <div class="dashboard is-full-height"> |
| <!-- left panel --> |
| <div class="dashboard-panel is-medium is-hidden-mobile pl-0"> |
| <div class="dashboard-panel-header has-text-centered"> |
| <a href="/"> |
| <img src="/assets/images/pegasus-logo-inv.png" style="width: 80%;"> |
| </a> |
| |
| </div> |
| <div class="dashboard-panel-main is-scrollable pl-6"> |
| |
| |
| <aside class="menu"> |
| |
| <p class="menu-label">The Pegasus documentation</p> |
| <ul class="menu-list"> |
| |
| <li> |
| <a href="/docs/downloads" |
| class=""> |
| Downloads |
| </a> |
| </li> |
| |
| </ul> |
| |
| <p class="menu-label">Building Pegasus</p> |
| <ul class="menu-list"> |
| |
| <li> |
| <a href="/docs/build/compile-by-docker" |
| class=""> |
| Compile by docker (recommended) |
| </a> |
| </li> |
| |
| <li> |
| <a href="/docs/build/compile-from-source" |
| class=""> |
| Compile from source |
| </a> |
| </li> |
| |
| </ul> |
| |
| <p class="menu-label">Client Libs</p> |
| <ul class="menu-list"> |
| |
| <li> |
| <a href="/clients/java-client" |
| class=""> |
| Java Client |
| </a> |
| </li> |
| |
| <li> |
| <a href="/clients/cpp-client" |
| class=""> |
| C++ Client |
| </a> |
| </li> |
| |
| <li> |
| <a href="https://github.com/apache/incubator-pegasus/tree/master/go-client" |
| class=""> |
| Golang Client |
| </a> |
| </li> |
| |
| <li> |
| <a href="/clients/python-client" |
| class=""> |
| Python Client |
| </a> |
| </li> |
| |
| <li> |
| <a href="/clients/node-client" |
| class=""> |
| NodeJS Client |
| </a> |
| </li> |
| |
| <li> |
| <a href="/clients/scala-client" |
| class=""> |
| Scala Client |
| </a> |
| </li> |
| |
| </ul> |
| |
| <p class="menu-label">Tools</p> |
| <ul class="menu-list"> |
| |
| <li> |
| <a href="/docs/tools/shell" |
| class=""> |
| Pegasus Shell |
| </a> |
| </li> |
| |
| <li> |
| <a href="https://github.com/pegasus-kv/admin-cli" |
| class=""> |
| Admin CLI |
| </a> |
| </li> |
| |
| <li> |
| <a href="https://github.com/pegasus-kv/pegic" |
| class=""> |
| Pegasus data access CLI |
| </a> |
| </li> |
| |
| </ul> |
| |
| <p class="menu-label">API</p> |
| <ul class="menu-list"> |
| |
| <li> |
| <a href="/api/ttl" |
| class=""> |
| TTL(Time To Live) |
| </a> |
| </li> |
| |
| <li> |
| <a href="/api/single-atomic" |
| class=""> |
| Single-Atomic Operations |
| </a> |
| </li> |
| |
| <li> |
| <a href="/api/redis" |
| class=""> |
| Redis Adaption |
| </a> |
| </li> |
| |
| <li> |
| <a href="/api/geo" |
| class=""> |
| GEO Support |
| </a> |
| </li> |
| |
| <li> |
| <a href="/api/http" |
| class=""> |
| HTTP API |
| </a> |
| </li> |
| |
| </ul> |
| |
| <p class="menu-label">Admin</p> |
| <ul class="menu-list"> |
| |
| <li> |
| <a href="/administration/deployment" |
| class=""> |
| Deployment |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/config" |
| class=""> |
| Configurations |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/rebalance" |
| class=""> |
| Rebalance |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/monitoring" |
| class=""> |
| Monitoring |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/rolling-update" |
| class=""> |
| Rolling-Update |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/scale-in-out" |
| class=""> |
| Scale-in and Scale-out |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/resource-management" |
| class=""> |
| Resource Management |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/cold-backup" |
| class=""> |
| Cold Backup |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/meta-recovery" |
| class=""> |
| Metadata Recovery |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/replica-recovery" |
| class=""> |
| Replica Data Recovery |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/zk-migration" |
| class=""> |
| Zookeeper Migration |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/table-migration" |
| class=""> |
| Table Migration |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/table-soft-delete" |
| class=""> |
| Table Soft-Delete |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/table-env" |
| class=""> |
| Table Environment Variables |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/remote-commands" |
| class=""> |
| Remote Command |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/partition-split" |
| class=""> |
| Partition-Split |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/duplication" |
| class=""> |
| Duplication |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/compression" |
| class=""> |
| Data Compression |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/throttling" |
| class=""> |
| Throttling |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/experiences" |
| class=""> |
| Experiences |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/manual-compact" |
| class=""> |
| Manual Compact |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/usage-scenario" |
| class=""> |
| Usage Scenario |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/bad-disk" |
| class=""> |
| Bad Disk Repair |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/whitelist" |
| class=""> |
| Whitelist |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/backup-request" |
| class=""> |
| Backup Request |
| </a> |
| </li> |
| |
| <li> |
| <a href="/administration/hotspot-detection" |
| class=""> |
| Hotspot Detection |
| </a> |
| </li> |
| |
| </ul> |
| |
| </aside> |
| </div> |
| </div> |
| |
| <!-- main section --> |
| <div class="dashboard-main is-scrollable"> |
| <nav class="navbar is-hidden-desktop"> |
| <div class="navbar-brand"> |
| <a href="/" class="navbar-item"> |
| <!-- Pegasus Icon --> |
| <img src="/assets/images/pegasus-square.png"> |
| </a> |
| <div class="navbar-item"> |
| |
| |
| <!--A simple language switch button that only supports zh and en.--> |
| <!--IF its language is zh, then switches to en.--> |
| |
| <a class="button is-light is-outlined is-inverted" href="/zh/docs/tools/shell/"><strong>中</strong></a> |
| |
| </div> |
| <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navMenu"> |
| <!-- Appears in mobile mode only --> |
| <span aria-hidden="true"></span> |
| <span aria-hidden="true"></span> |
| <span aria-hidden="true"></span> |
| </a> |
| </div> |
| <div class="navbar-menu" id="navMenu"> |
| <div class="navbar-end"> |
| |
| <!--dropdown--> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a href="" |
| class="navbar-link "> |
| <span> |
| The Pegasus documentation |
| </span> |
| </a> |
| <div class="navbar-dropdown"> |
| |
| <a href="/docs/downloads" |
| class="navbar-item "> |
| Downloads |
| </a> |
| |
| </div> |
| </div> |
| |
| <!--dropdown--> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a href="" |
| class="navbar-link "> |
| <span> |
| Building Pegasus |
| </span> |
| </a> |
| <div class="navbar-dropdown"> |
| |
| <a href="/docs/build/compile-by-docker" |
| class="navbar-item "> |
| Compile by docker (recommended) |
| </a> |
| |
| <a href="/docs/build/compile-from-source" |
| class="navbar-item "> |
| Compile from source |
| </a> |
| |
| </div> |
| </div> |
| |
| <!--dropdown--> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a href="" |
| class="navbar-link "> |
| <span> |
| Client Libs |
| </span> |
| </a> |
| <div class="navbar-dropdown"> |
| |
| <a href="/clients/java-client" |
| class="navbar-item "> |
| Java Client |
| </a> |
| |
| <a href="/clients/cpp-client" |
| class="navbar-item "> |
| C++ Client |
| </a> |
| |
| <a href="https://github.com/apache/incubator-pegasus/tree/master/go-client" |
| class="navbar-item "> |
| Golang Client |
| </a> |
| |
| <a href="/clients/python-client" |
| class="navbar-item "> |
| Python Client |
| </a> |
| |
| <a href="/clients/node-client" |
| class="navbar-item "> |
| NodeJS Client |
| </a> |
| |
| <a href="/clients/scala-client" |
| class="navbar-item "> |
| Scala Client |
| </a> |
| |
| </div> |
| </div> |
| |
| <!--dropdown--> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a href="" |
| class="navbar-link "> |
| <span> |
| Tools |
| </span> |
| </a> |
| <div class="navbar-dropdown"> |
| |
| <a href="/docs/tools/shell" |
| class="navbar-item "> |
| Pegasus Shell |
| </a> |
| |
| <a href="https://github.com/pegasus-kv/admin-cli" |
| class="navbar-item "> |
| Admin CLI |
| </a> |
| |
| <a href="https://github.com/pegasus-kv/pegic" |
| class="navbar-item "> |
| Pegasus data access CLI |
| </a> |
| |
| </div> |
| </div> |
| |
| <!--dropdown--> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a href="" |
| class="navbar-link "> |
| <span> |
| API |
| </span> |
| </a> |
| <div class="navbar-dropdown"> |
| |
| <a href="/api/ttl" |
| class="navbar-item "> |
| TTL(Time To Live) |
| </a> |
| |
| <a href="/api/single-atomic" |
| class="navbar-item "> |
| Single-Atomic Operations |
| </a> |
| |
| <a href="/api/redis" |
| class="navbar-item "> |
| Redis Adaption |
| </a> |
| |
| <a href="/api/geo" |
| class="navbar-item "> |
| GEO Support |
| </a> |
| |
| <a href="/api/http" |
| class="navbar-item "> |
| HTTP API |
| </a> |
| |
| </div> |
| </div> |
| |
| <!--dropdown--> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a href="" |
| class="navbar-link "> |
| <span> |
| Admin |
| </span> |
| </a> |
| <div class="navbar-dropdown"> |
| |
| <a href="/administration/deployment" |
| class="navbar-item "> |
| Deployment |
| </a> |
| |
| <a href="/administration/config" |
| class="navbar-item "> |
| Configurations |
| </a> |
| |
| <a href="/administration/rebalance" |
| class="navbar-item "> |
| Rebalance |
| </a> |
| |
| <a href="/administration/monitoring" |
| class="navbar-item "> |
| Monitoring |
| </a> |
| |
| <a href="/administration/rolling-update" |
| class="navbar-item "> |
| Rolling-Update |
| </a> |
| |
| <a href="/administration/scale-in-out" |
| class="navbar-item "> |
| Scale-in and Scale-out |
| </a> |
| |
| <a href="/administration/resource-management" |
| class="navbar-item "> |
| Resource Management |
| </a> |
| |
| <a href="/administration/cold-backup" |
| class="navbar-item "> |
| Cold Backup |
| </a> |
| |
| <a href="/administration/meta-recovery" |
| class="navbar-item "> |
| Metadata Recovery |
| </a> |
| |
| <a href="/administration/replica-recovery" |
| class="navbar-item "> |
| Replica Data Recovery |
| </a> |
| |
| <a href="/administration/zk-migration" |
| class="navbar-item "> |
| Zookeeper Migration |
| </a> |
| |
| <a href="/administration/table-migration" |
| class="navbar-item "> |
| Table Migration |
| </a> |
| |
| <a href="/administration/table-soft-delete" |
| class="navbar-item "> |
| Table Soft-Delete |
| </a> |
| |
| <a href="/administration/table-env" |
| class="navbar-item "> |
| Table Environment Variables |
| </a> |
| |
| <a href="/administration/remote-commands" |
| class="navbar-item "> |
| Remote Command |
| </a> |
| |
| <a href="/administration/partition-split" |
| class="navbar-item "> |
| Partition-Split |
| </a> |
| |
| <a href="/administration/duplication" |
| class="navbar-item "> |
| Duplication |
| </a> |
| |
| <a href="/administration/compression" |
| class="navbar-item "> |
| Data Compression |
| </a> |
| |
| <a href="/administration/throttling" |
| class="navbar-item "> |
| Throttling |
| </a> |
| |
| <a href="/administration/experiences" |
| class="navbar-item "> |
| Experiences |
| </a> |
| |
| <a href="/administration/manual-compact" |
| class="navbar-item "> |
| Manual Compact |
| </a> |
| |
| <a href="/administration/usage-scenario" |
| class="navbar-item "> |
| Usage Scenario |
| </a> |
| |
| <a href="/administration/bad-disk" |
| class="navbar-item "> |
| Bad Disk Repair |
| </a> |
| |
| <a href="/administration/whitelist" |
| class="navbar-item "> |
| Whitelist |
| </a> |
| |
| <a href="/administration/backup-request" |
| class="navbar-item "> |
| Backup Request |
| </a> |
| |
| <a href="/administration/hotspot-detection" |
| class="navbar-item "> |
| Hotspot Detection |
| </a> |
| |
| </div> |
| </div> |
| |
| </div> |
| </div> |
| </nav> |
| |
| <nav class="navbar is-hidden-mobile"> |
| <div class="navbar-start w-full"> |
| <div class="navbar-item pl-0 w-full"> |
| <!--TODO(wutao): Given the limitation of docsearch that couldn't handle multiple input, |
| I make searchbox only shown in desktop. Fix this issue when docsearch.js v3 released. |
| Related issue: https://github.com/algolia/docsearch/issues/230--> |
| <div id="docsearch"></div> |
| </div> |
| </div> |
| <div class="navbar-end"> |
| <div class="navbar-item"> |
| |
| |
| <!--A simple language switch button that only supports zh and en.--> |
| <!--IF its language is zh, then switches to en.--> |
| |
| <a class="button is-light is-outlined is-inverted" href="/zh/docs/tools/shell/"><strong>中</strong></a> |
| |
| </div> |
| </div> |
| </nav> |
| |
| <section class="hero is-info lg:mr-3"> |
| <div class="hero-body"> |
| |
| <p class="title is-size-2 is-centered">Pegasus Shell</p> |
| </div> |
| </section> |
| <section class="section" style="padding-top: 2rem;"> |
| <div class="content"> |
| <p>Pegasus提供了Shell工具,用于查看集群相关信息,创建/删除表,操作数据等。</p> |
| |
| <h1 id="工具获取">工具获取</h1> |
| <p>在成功<a href="compilation">编译Pegasus</a>后,在pegasus目录下启动Shell工具:</p> |
| <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./run.sh shell |
| </code></pre></div></div> |
| |
| <p>也可以用pack工具打包Shell工具,方便在其他机器上使用:</p> |
| <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./run.sh pack_tools |
| </code></pre></div></div> |
| <p>pack成功后,会在本地文件夹下生成<code class="language-plaintext highlighter-rouge">pegasus-tools-{version}-{platform}-{buildType}.tar.gz</code>文件。将该文件拷贝到目标机器上,解压后进入该文件夹,运行<code class="language-plaintext highlighter-rouge">./run.sh shell</code>就可以使用Shell工具,可以使用<code class="language-plaintext highlighter-rouge">-h</code>选项获取帮助:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ./run.sh shell -h |
| Options for subcommand 'shell': |
| -h|--help print the help info |
| -c|--config <path> config file path, default './config-shell.ini.{PID}' |
| --cluster <str> cluster meta lists, default '127.0.0.1:34601,127.0.0.1:34602,127.0.0.1:34603' |
| </code></pre></div></div> |
| <p>譬如访问某个特定集群:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./run.sh shell --cluster 127.0.0.1:34601,127.0.0.1:34602 |
| </code></pre></div></div> |
| |
| <h1 id="工具使用">工具使用</h1> |
| |
| <p>Shell工具采用子命令模式,进入子命令模式执行<code class="language-plaintext highlighter-rouge">help</code>后会显示帮助文档。(注:根据版本不同命令会有区别,以下为1.11.3版本)。对于每个子命令,也可以通过<code class="language-plaintext highlighter-rouge">-h</code>选项获取该子命令的帮助信息。</p> |
| |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Usage: |
| help |
| version |
| cluster_info [-r|--resolve_ip] [-o|--output file_name] [-j|--json] |
| app <app_name> [-d|--detailed] [-r|--resolve_ip] [-o|--output file_name] |
| [-j|--json] |
| app_disk <app_name> [-d|--detailed] [-r|--resolve_ip] [-j|--json] |
| [-o|--output file_name] |
| ls [-a|-all] [-d|--detailed] [-j|--json] |
| [-o|--output file_name][-s|--status all|available|creating|dropping|dropped] |
| nodes [-d|--detailed] [-j|--json] [-r|--resolve_ip] |
| [-u|--resource_usage][-o|--output file_name] |
| [-s|--status all|alive|unalive] [-q|--qps] |
| create <app_name> [-p|--partition_count num] [-r|--replica_count num] |
| [-e|--envs k1=v1,k2=v2...] |
| drop <app_name> [-r|--reserve_seconds num] |
| recall <app_id> [new_app_name] |
| set_meta_level <stopped|blind|freezed|steady|lively> |
| get_meta_level |
| balance <-g|--gpid appid.pidx> <-p|--type move_pri|copy_pri|copy_sec> |
| <-f|--from from_address> <-t|--to to_address> |
| propose [-f|--force] <-g|--gpid appid.pidx> |
| <-p|--type ASSIGN_PRIMARY|ADD_SECONDARY|DOWNGRADE_TO_INACTIVE...> |
| <-t|--target node_to_exec_command> <-n|--node node_to_be_affected> |
| use [app_name] |
| cc [cluster_name] |
| escape_all [true|false] |
| timeout [time_in_ms] |
| hash <hash_key> <sort_key> |
| set <hash_key> <sort_key> <value> [ttl_in_seconds] |
| multi_set <hash_key> <sort_key> <value> [sort_key value...] |
| get <hash_key> <sort_key> |
| multi_get <hash_key> [sort_key...] |
| multi_get_range <hash_key> <start_sort_key> <stop_sort_key> |
| [-a|--start_inclusive true|false] [-b|--stop_inclusive true|false] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix] |
| [-y|--sort_key_filter_pattern str] [-n|--max_count num] |
| [-i|--no_value] [-r|--reverse] |
| multi_get_sortkeys <hash_key> |
| del <hash_key> <sort_key> |
| multi_del <hash_key> <sort_key> [sort_key...] |
| multi_del_range <hash_key> <start_sort_key> <stop_sort_key> |
| [-a|--start_inclusive true|false] [-b|--stop_inclusive true|false] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix] |
| [-y|--sort_key_filter_pattern str] [-o|--output file_name] |
| [-i|--silent] |
| incr <hash_key> <sort_key> [increment] |
| check_and_set <hash_key> [-c|--check_sort_key str] |
| [-t|--check_type not_exist|not_exist_or_empty|exist|not_empty] |
| [match_anywhere|match_prefix|match_postfix] |
| [bytes_less|bytes_less_or_equal|bytes_equal|bytes_greater_or_equal|bytes_greater] |
| [int_less|int_less_or_equal|int_equal|int_greater_or_equal|int_greater] |
| [-o|--check_operand str] [-s|--set_sort_key str] [-v|--set_value str] |
| [-l|--set_value_ttl_seconds num] [-r|--return_check_value] |
| check_and_mutate <hash_key> [-c|--check_sort_key str] |
| [-t|--check_type not_exist|not_exist_or_empty|exist|not_empty] |
| [match_anywhere|match_prefix|match_postfix] |
| [bytes_less|bytes_less_or_equal|bytes_equal|bytes_greater_or_equal|bytes_greater] |
| [int_less|int_less_or_equal|int_equal|int_greater_or_equal|int_greater] |
| [-o|--check_operand str] [-r|--return_check_value] |
| exist <hash_key> <sort_key> |
| count <hash_key> |
| ttl <hash_key> <sort_key> |
| hash_scan <hash_key> <start_sort_key> <stop_sort_key> |
| [-a|--start_inclusive true|false] [-b|--stop_inclusive true|false] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact] |
| [-z|--value_filter_pattern str] [-o|--output file_name] |
| [-n|--max_count num] [-t|--timeout_ms num] [-d|--detailed] |
| [-i|--no_value] |
| full_scan [-h|--hash_key_filter_type anywhere|prefix|postfix] |
| [-x|--hash_key_filter_pattern str] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix|exact] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact] |
| [-z|--value_filter_pattern str] [-o|--output file_name] |
| [-n|--max_count num] [-t|--timeout_ms num] [-d|--detailed] |
| [-i|--no_value] [-p|--partition num] |
| copy_data <-c|--target_cluster_name str> <-a|--target_app_name str> |
| [-p|--partition num] [-b|--max_batch_count num] [-t|--timeout_ms num] |
| [-h|--hash_key_filter_type anywhere|prefix|postfix] |
| [-x|--hash_key_filter_pattern str] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix|exact] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact] |
| [-z|--value_filter_pattern str] [-n|--no_overwrite] [-i|--no_value] |
| [-g|--geo_data] |
| clear_data [-p|--partition num] [-b|--max_batch_count num] [-t|--timeout_ms num] |
| [-h|--hash_key_filter_type anywhere|prefix|postfix] |
| [-x|--hash_key_filter_pattern str] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix|exact] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact] |
| [-z|--value_filter_pattern str] [-f|--force] |
| count_data [-p|--partition num] [-b|--max_batch_count num] [-t|--timeout_ms num] |
| [-h|--hash_key_filter_type anywhere|prefix|postfix] |
| [-x|--hash_key_filter_pattern str] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix|exact] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact] |
| [-z|--value_filter_pattern str] [-d|--diff_hash_key] [-a|--stat_size] |
| [-n|--top_count num] [-r|--run_seconds num] |
| remote_command [-t all|meta-server|replica-server] [-r|--resolve_ip] |
| [-l ip:port,ip:port...]<command> [arguments...] |
| server_info [-t all|meta-server|replica-server] [-l ip:port,ip:port...] |
| [-r|--resolve_ip] |
| server_stat [-t all|meta-server|replica-server] [-l ip:port,ip:port...] |
| [-r|--resolve_ip] |
| app_stat [-a|--app_name str] [-q|--only_qps] [-u|--only_usage] [-j|--json] |
| [-o|--output file_name] |
| flush_log [-t all|meta-server|replica-server] |
| [-l ip:port,ip:port...][-r|--resolve_ip] |
| disk_replica [-n|--node replica_server(ip:port)][-a|-app app_name][-o|--out file_name][-j|--json] |
| disk_capacity [-n|--node replica_server(ip:port)][-o|--out file_name][-j|-json][-d|--detail] |
| local_get <db_path> <hash_key> <sort_key> |
| rdb_key_str2hex <hash_key> <sort_key> |
| rdb_key_hex2str <rdb_key_in_hex> |
| rdb_value_hex2str <value_in_hex> |
| sst_dump [--command=check|scan|none|raw] <--file=data_dir_OR_sst_file> |
| [--from=user_key] [--to=user_key] [--read_num=num] [--show_properties] |
| [--pegasus_data] |
| mlog_dump <-i|--input log_dir> [-o|--output file_name] [-d|--detailed] |
| recover [-f|--node_list_file file_name] [-s|--node_list_str str] |
| [-w|--wait_seconds num] [-b|--skip_bad_nodes] |
| [-l|--skip_lost_partitions] [-o|--output file_name] |
| add_backup_policy <-p|--policy_name str> <-b|--backup_provider_type str> |
| <-a|--app_ids 1,2...> <-i|--backup_interval_seconds num> |
| <-s|--start_time hour:minute> <-c|--backup_history_cnt num> |
| ls_backup_policy |
| query_backup_policy <-p|--policy_name p1,p2...> [-b|--backup_info_cnt num] |
| modify_backup_policy <-p|--policy_name str> [-a|--add_app 1,2...] [-r|--remove_app 1,2...] |
| [-i|--backup_interval_seconds num] [-c|--backup_history_count num] |
| [-s|--start_time hour:minute] |
| disable_backup_policy <-p|--policy_name str> |
| enable_backup_policy <-p|--policy_name str> |
| restore_app <-c|--old_cluster_name str> <-p|--old_policy_name str> |
| <-a|--old_app_name str> <-i|--old_app_id id> |
| <-t|--timestamp/backup_id timestamp> <-b|--backup_provider_type str> |
| [-n|--new_app_name str] [-s|--skip_bad_partition] |
| query_restore_status <restore_app_id> [-d|--detailed] |
| get_app_envs [-j|--json] |
| set_app_envs <key> <value> [key value...] |
| del_app_envs <key> [key...] |
| clear_app_envs [-a|--all] [-p|--prefix str] |
| ddd_diagnose [-g|--gpid appid|appid.pidx] [-d|--diagnose] [-a|--auto_diagnose] |
| [-s|--skip_prompt] [-o|--output file_name] |
| exit |
| |
| </code></pre></div></div> |
| |
| <p>由于子命令很多,为了方便使用,我们根据功能不同进行分类。</p> |
| |
| <h2 id="基本命令">基本命令</h2> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>子命令</th> |
| <th>功能</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>help</td> |
| <td>获取帮助信息</td> |
| </tr> |
| <tr> |
| <td>version</td> |
| <td>获取Shell工具的版本信息</td> |
| </tr> |
| <tr> |
| <td>exit</td> |
| <td>退出shell工具,等同于输入”Ctrl-C”或者”Ctrl-D”</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h3 id="help">help</h3> |
| <p>获取帮助信息。</p> |
| |
| <h3 id="version">version</h3> |
| <p>获取Shell工具的版本信息。</p> |
| |
| <h3 id="exit">exit</h3> |
| <p>退出shell工具,等同于输入”Ctrl-C”或者”Ctrl-D”。</p> |
| |
| <h2 id="全局属性">全局属性</h2> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>子命令</th> |
| <th>功能</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>cc</td> |
| <td>change cluster,改变当前使用的集群</td> |
| </tr> |
| <tr> |
| <td>use</td> |
| <td>指定当前使用的表,有的子命令在使用前需要先指定表,譬如数据操作类命令</td> |
| </tr> |
| <tr> |
| <td>escape_all</td> |
| <td>输出字节类数据时,选择将”所有字符”转换为十六进制编码还是仅将”不可见字符”转换为十六进制编码,默认为后者</td> |
| </tr> |
| <tr> |
| <td>timeout</td> |
| <td>数据操作的默认超时时间</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h3 id="cc">cc</h3> |
| <p>change cluster,改变当前使用的集群。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: cc [cluster_name] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>指定的集群名必须在<code class="language-plaintext highlighter-rouge">src/shell/config.ini</code>配置文件的[pegasus.clusters]配置段中可以找到。</li> |
| <li>你可以在[pegasus.clusters]配置段中设置多个集群。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> cc my_cluster |
| </code></pre></div></div> |
| <h3 id="use">use</h3> |
| <p>指定当前使用的表,有的子命令在使用前需要先指定表,譬如数据操作类命令。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: use [app_name] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>表必须已经创建才能使用,默认存在temp表。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> use tmp |
| </code></pre></div></div> |
| |
| <h3 id="escape_all">escape_all</h3> |
| <p>输出字节类数据时,选择将”所有字符”转换为十六进制编码还是仅将”不可见字符”转换为十六进制编码,默认为后者。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: escape_all [true|false] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>默认为false。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> escape_all true |
| </code></pre></div></div> |
| |
| <h3 id="timeout">timeout</h3> |
| <p>设置数据操作的默认超时时间,单位ms。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: timeout [time_in_ms] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>如果不指定[time_in_ms],则输出当前的超时时间。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> timeout 1000 |
| </code></pre></div></div> |
| |
| <h2 id="节点管理">节点管理</h2> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>子命令</th> |
| <th>功能</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>cluster_info</td> |
| <td>获取集群基本信息</td> |
| </tr> |
| <tr> |
| <td>nodes</td> |
| <td>获取节点列表,可加<code class="language-plaintext highlighter-rouge">-d</code>选项获取各节点的负载情况</td> |
| </tr> |
| <tr> |
| <td>server_info</td> |
| <td>各节点的基本信息,主要是server版本、节点启动时间</td> |
| </tr> |
| <tr> |
| <td>server_stat</td> |
| <td>各节点的统计信息,包含一些关键的统计数据,譬如get和put操作的QPS和延迟、内存和存储使用情况</td> |
| </tr> |
| <tr> |
| <td>remote_command</td> |
| <td>向节点发送<strong>远程命令</strong>,以执行某些特殊操作</td> |
| </tr> |
| <tr> |
| <td>flush_log</td> |
| <td>向节点发送<strong>远程命令</strong>,将最近缓冲区中的日志数据刷出到日志文件中</td> |
| </tr> |
| <tr> |
| <td>disk_replica</td> |
| <td>各节点的副本在磁盘上的分布</td> |
| </tr> |
| <tr> |
| <td>disk_capacity</td> |
| <td>各节点的磁盘空间占用</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h3 id="cluster_info">cluster_info</h3> |
| <p>获取集群基本信息。</p> |
| |
| <p>说明:</p> |
| <ul> |
| <li>集群信息主要主要包含: |
| <ul> |
| <li>meta_server、zookeeper的节点信息。</li> |
| <li>meta_function_level:负载均衡策略。</li> |
| <li>balance_operation_count:负载均衡操作统计,包括move_pri、move_pri、copy_sec、total。负载均衡信息参见<a href="/administration/rebalance">负载均衡</a>。</li> |
| <li>primary_replica_count_stddev:负载均衡衡量指标。</li> |
| <li>total_replica_count_stddev:负载均衡衡量指标。</li> |
| </ul> |
| </li> |
| </ul> |
| |
| <h3 id="nodes">nodes</h3> |
| <p>获取replica节点列表,默认以IP地址表示各个节点,并输出基本信息。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: nodes [-d|--detailed] [-r|--resolve_ip] [-u|--resource_usage] |
| [-o|--output file_name] [-s|--status all|alive|unalive] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-d</code>选项:如果指定,输出节点的详细信息,如获取各节点的负载情况。</li> |
| <li><code class="language-plaintext highlighter-rouge">-r</code>选项:如果指定,以域名信息表示该节点,并输出基本信息,如果无法找到节点地址对应域名信息,显示UNRESOLVABLE。</li> |
| <li><code class="language-plaintext highlighter-rouge">-u</code>选项:如果指定,输出节点资源使用情况。</li> |
| <li><code class="language-plaintext highlighter-rouge">-o</code>选项:如果指定,输出基本信息到指定文件,默认为当前路径。</li> |
| <li><code class="language-plaintext highlighter-rouge">-s</code>选项:如果指定,输出某种状态的节点信息,包括all、alive、unalive。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> nodes -s alive |
| </code></pre></div></div> |
| |
| <h3 id="server_info">server_info</h3> |
| <p>各节点的基本信息,主要是节点地址、状态、server版本、启动时间等。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE:server_info [-t all|meta-server|replica-server] [-l ip:port,ip:port...] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-t</code>选项:如果指定,则选择输出服务器节点类别的信息,包含all、meta-server、replica-server。</li> |
| <li><code class="language-plaintext highlighter-rouge">-l</code>选项:如果指定,则选择输出特定IP地址节点的信息,多个节点使用<code class="language-plaintext highlighter-rouge">,</code>连接。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> server_info -t meta-server |
| </code></pre></div></div> |
| |
| <h3 id="server_stat">server_stat</h3> |
| <p>各节点的统计信息,包含一些关键的统计数据,譬如get和put操作的QPS和延迟、内存和存储使用情况。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE:server_stat [-t all|meta-server|replica-server] [-l ip:port,ip:port...] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>选项参数说明同<a href="#server_info">server_info</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> server_stat -t meta-server |
| </code></pre></div></div> |
| |
| <h3 id="remote_command">remote_command</h3> |
| <p>向节点发送远程命令,以执行某些特殊操作。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE:remote_command [-t all|meta-server|replica-server] [-l ip:port,ip:port...] <command> |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-t</code>、<code class="language-plaintext highlighter-rouge">-l</code>选项:用于选择特定目标机器,参见<a href="#server_info">server_info</a>说明。</li> |
| <li>远程命令详细信息,参见<a href="/administration/remote-commands">远程命令</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> recommand -t meta-server server-info |
| </code></pre></div></div> |
| |
| <h3 id="flush_log">flush_log</h3> |
| <p>向节点发送远程命令,将最近缓冲区中的日志数据刷出到日志文件中。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE:flush_log [-t all|meta-server|replica-server] [-l ip:port,ip:port...] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-t</code>、<code class="language-plaintext highlighter-rouge">-l</code>选项:用于选择特定目标机器,参见<a href="#server_info">server_info</a>说明。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> flush_log -t meta-server |
| </code></pre></div></div> |
| |
| <h3 id="disk_replica">disk_replica</h3> |
| <p>查询副本在replica_server节点的磁盘分布,1.12.3版本提供支持</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE:disk_replica [-n|--node replica_server(ip:port)][-a|-app app_name][-o|--out file_name][-j|--json] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-n</code>选项:用于查看特定节点磁盘上的副本分布,格式为ip:port</li> |
| <li><code class="language-plaintext highlighter-rouge">-a</code>选项:用于查看某个表的副本在节点磁盘上的分布</li> |
| <li><code class="language-plaintext highlighter-rouge">-o</code>选项:把结果输出到某个文件</li> |
| <li><code class="language-plaintext highlighter-rouge">-j</code>选项:以json格式输出查询结果</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> disk_replica -n 127.0.0.1:34608 -a temp |
| </code></pre></div></div> |
| |
| <h3 id="disk_capacity">disk_capacity</h3> |
| <p>查询replica_server节点的磁盘空间占用,1.12.3版本提供支持</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE:disk_capacity [-n|--node replica_server(ip:port)][-o|--out file_name][-j|-json][-d|--detail] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-n</code>选项:用于查看特定节点磁盘上的副本分布,格式为ip:port</li> |
| <li><code class="language-plaintext highlighter-rouge">-d</code>选项:用于查看节点上每个磁盘的空间占用信息</li> |
| <li><code class="language-plaintext highlighter-rouge">-o</code>选项:把结果输出到某个文件</li> |
| <li><code class="language-plaintext highlighter-rouge">-j</code>选项:以json格式输出查询结果</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> disk_capacity -n 127.0.0.1:34608 -d |
| </code></pre></div></div> |
| |
| <h2 id="表管理">表管理</h2> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>子命令</th> |
| <th>功能</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>ls</td> |
| <td>获取所有表的列表,可加<code class="language-plaintext highlighter-rouge">-d</code>选项获取各表的健康状况,可加<code class="language-plaintext highlighter-rouge">-a</code>选项包含已删除表的信息</td> |
| </tr> |
| <tr> |
| <td>app</td> |
| <td>获取某个表的信息,可加<code class="language-plaintext highlighter-rouge">-d</code>选项获取详细信息,包括各partition的分布情况、健康状况</td> |
| </tr> |
| <tr> |
| <td>app_stat</td> |
| <td>获取表的读写情况和存储统计信息,可加<code class="language-plaintext highlighter-rouge">-a</code>选项指定单个表,以获取该表各个partition的详细统计信息</td> |
| </tr> |
| <tr> |
| <td>app_disk</td> |
| <td>获取某个表的详细存储信息,可加<code class="language-plaintext highlighter-rouge">-d</code>选项获取各partition的详细存储信息</td> |
| </tr> |
| <tr> |
| <td>create</td> |
| <td>创建表,可加<code class="language-plaintext highlighter-rouge">-p</code>和<code class="language-plaintext highlighter-rouge">-r</code>选项指定分片数和副本数,要求分片数是2的指数倍,不指定 -r 则默认副本数为3(推荐值)</td> |
| </tr> |
| <tr> |
| <td>drop</td> |
| <td>删除表,参见<a href="/administration/table-soft-delete#使用drop命令删除表">使用drop命令删除表</a></td> |
| </tr> |
| <tr> |
| <td>recall</td> |
| <td>恢复已删除的表,参见<a href="/administration/table-soft-delete#使用recall命令恢复表">使用recall命令恢复表</a></td> |
| </tr> |
| <tr> |
| <td>get_app_envs</td> |
| <td>获取表的环境变量,参见<a href="/administration/table-env#get_app_envs">Table环境变量#get_app_envs</a></td> |
| </tr> |
| <tr> |
| <td>set_app_envs</td> |
| <td>设置表的环境变量,参见<a href="/administration/table-env#set_app_envs">Table环境变量#set_app_envs</a></td> |
| </tr> |
| <tr> |
| <td>del_app_envs</td> |
| <td>删除表的环境变量,参见<a href="/administration/table-env#del_app_envs">Table环境变量#del_app_envs</a></td> |
| </tr> |
| <tr> |
| <td>clear_app_envs</td> |
| <td>清理表的环境变量,参见<a href="/administration/table-env#clear_app_envs">Table环境变量#clear_app_envs</a></td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h3 id="ls">ls</h3> |
| <p>获取所有表的列表。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: ls [-a|-all] [-d|--detailed] [-o|--output file_name] |
| [-s|--status all|available|creating|dropping|dropped] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-a</code>选项:如果指定,则显示包括已被删除的所有表。</li> |
| <li><code class="language-plaintext highlighter-rouge">-d</code>选项:如果指定,则显示各个表的详细信息,主要是partition的健康状况。</li> |
| <li><code class="language-plaintext highlighter-rouge">-o</code>选项:如果指定,则将结果输出到参数所指定的文件中。</li> |
| <li><code class="language-plaintext highlighter-rouge">-s</code>选项:如果指定,则只显示符合参数所指定的状态的表。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> ls -d -o ls.txt |
| </code></pre></div></div> |
| |
| <h3 id="app">app</h3> |
| <p>获取某个表的基本信息。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: app <app_name> [-d|--detailed] [-o|--output file_name] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-d</code>选项:如果指定,则显示各个表的详细信息,如partition的分布和健康状况。</li> |
| <li><code class="language-plaintext highlighter-rouge">-o</code>选项:如果指定,则将结果输出到参数所指定的文件中。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> app temp |
| </code></pre></div></div> |
| |
| <h3 id="app_stat">app_stat</h3> |
| <p>获取表的读写和存储统计信息,如get、put、del等。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: app_stat [-a|--app_name str] [-q|--only_qps] [-u|--only_usage] |
| [-o|--output file_name] |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> app_stat temp |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-a</code>选项:如果指定,则按照指定表的partition分类显示详细信息。</li> |
| <li><code class="language-plaintext highlighter-rouge">-q</code>选项:如果指定,则仅显示指定表的qps信息。</li> |
| <li><code class="language-plaintext highlighter-rouge">-u</code>选项:如果指定,则仅显示指定表的usage信息。</li> |
| <li><code class="language-plaintext highlighter-rouge">-o</code>选项:如果指定,则把结果输出到指定文件中。</li> |
| </ul> |
| |
| <h3 id="app_disk">app_disk</h3> |
| <p>获取某个表的详细存储信息。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: app_disk <app_name> [-d|--detailed] [-o|--output file_name] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-d</code>选项:如果指定,则可以获取表的详细信息,如primary和secondary情况。</li> |
| <li><code class="language-plaintext highlighter-rouge">-o</code>选项:如果指定,则将结果输出到参数所指定的文件中。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> app_disk temp |
| </code></pre></div></div> |
| |
| <h3 id="create">create</h3> |
| <p>创建表</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: create <app_name> [-p|--partition_count num] [-r|--replica_count num] |
| [-e|--envs k1=v1,k2=v2...] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-p</code>选项:如果指定,则可以设置分片数,要求分片数是2的指数倍。</li> |
| <li><code class="language-plaintext highlighter-rouge">-r</code>选项:如果指定,则可以指定副本数,推荐副本数为3。</li> |
| <li><code class="language-plaintext highlighter-rouge">-e</code>选项:如果指定,则可是设置环境变量,参见<a href="/administration/table-env">Table环境变量</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> create temp |
| </code></pre></div></div> |
| |
| <h3 id="drop">drop</h3> |
| <p>删除表</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: drop <app_name> [-r|--reserve_seconds num] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-r</code>选项:如果指定,则设置数据的保留时间(删除时间开始计算,单位为秒)。如果不指定,则使用配置文件hold_seconds_for_dropped_app指定的值,默认为7天,参见<a href="/administration/table-soft-delete#使用drop命令删除表">Table软删除#使用drop命令删除表</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> drop temp |
| </code></pre></div></div> |
| |
| <h3 id="recall">recall</h3> |
| <p>恢复已经删除的表。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: recall <app_id> [new_app_name] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>注意该命令通过app_id进行表恢复。</li> |
| <li><code class="language-plaintext highlighter-rouge">new_app_name</code>参数:如果不指定新表名,则会使用原表名,否则使用指定的新表名,如果原表名已存在(删表后新建了同名表),则必须指定另外一个不同的新表名,否则会失败。</li> |
| <li>详细信息参见<a href="/administration/table-soft-delete#使用recall命令恢复表">Table软删除#使用recall命令恢复表</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> recall 19 |
| </code></pre></div></div> |
| |
| <h3 id="get_app_envs">get_app_envs</h3> |
| <p>获取表的环境变量,关于环境变量请参见<a href="/administration/table-env">Table环境变量</a>。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: get_app_envs |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>该命令输出当前表的环境变量,使用前请首先使用<code class="language-plaintext highlighter-rouge">use [app_name]</code>选定特定表,参见<a href="/administration/table-env#get_app_envs">get_app_envs</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> use temp |
| >>> get_app_envs |
| </code></pre></div></div> |
| |
| <h3 id="set_app_envs">set_app_envs</h3> |
| <p>设置表的环境变量,关于环境变量请参见<a href="/administration/table-env">Table环境变量</a>。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: set_app_envs <key> <value> [key value...] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>该命令设置当前表的环境变量,使用前请首先使用<code class="language-plaintext highlighter-rouge">use [app_name]</code>选定特定表,参见<a href="/administration/table-env#set_app_envs">set_app_envs</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> use temp |
| >>> set_app_envs rocksdb.usage_scenario bulk_load |
| </code></pre></div></div> |
| |
| <h3 id="del_app_envs">del_app_envs</h3> |
| <p>删除表的环境变量,关于环境变量请参见<a href="/administration/table-env">Table环境变量</a>。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: del_app_envs <key> [key...] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>该命令删除当前表的环境变量,使用前请首先使用<code class="language-plaintext highlighter-rouge">use [app_name]</code>选定特定表,参见<a href="/administration/table-env#del_app_envs">del_app_envs</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> use temp |
| >>> del_app_envs rocksdb.usage_scenario |
| </code></pre></div></div> |
| |
| <h3 id="clear_app_envs">clear_app_envs</h3> |
| <p>清理表的环境变量,关于环境变量请参见<a href="/administration/table-env">Table环境变量</a>。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: clear_app_envs [-a|--all] [-p|--prefix str] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>该命令删除当前表的环境变量,使用前请首先使用<code class="language-plaintext highlighter-rouge">use [app_name]</code>选定特定表,参见<a href="/administration/table-env#clear_app_envs">clear_app_envs</a>。</li> |
| <li><code class="language-plaintext highlighter-rouge">-a</code>选项:如果指定,则清理所有的环境变量。</li> |
| <li><code class="language-plaintext highlighter-rouge">-p</code>选项:如果指定,则可以清理以特定字符串为前缀的环境变量。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> use temp |
| >>> clear_app_envs -p rocksdb |
| </code></pre></div></div> |
| |
| <h2 id="数据操作">数据操作</h2> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>子命令</th> |
| <th>功能</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>set</td> |
| <td>设置单条数据</td> |
| </tr> |
| <tr> |
| <td>multi_set</td> |
| <td>设置同一HashKey下的多条数据</td> |
| </tr> |
| <tr> |
| <td>get</td> |
| <td>获取单条数据</td> |
| </tr> |
| <tr> |
| <td>multi_get</td> |
| <td>通过指定多个SortKey,获取同一HashKey下的多条数据</td> |
| </tr> |
| <tr> |
| <td>multi_get_range</td> |
| <td>通过指定SortKey的查询范围和过滤条件,获取同一HashKey下的多条数据</td> |
| </tr> |
| <tr> |
| <td>multi_get_sortkeys</td> |
| <td>获取同一HashKey下的所有SortKey</td> |
| </tr> |
| <tr> |
| <td>del</td> |
| <td>删除单条数据</td> |
| </tr> |
| <tr> |
| <td>multi_del</td> |
| <td>通过指定多个SortKey,删除同一HashKey下的多条数据</td> |
| </tr> |
| <tr> |
| <td>multi_del_range</td> |
| <td>通过指定SortKey的查询范围和过滤条件,删除同一HashKey下的多条数据</td> |
| </tr> |
| <tr> |
| <td>incr</td> |
| <td><a href="/api/single-atomic#原子增减">原子增减操作</a></td> |
| </tr> |
| <tr> |
| <td>check_and_set</td> |
| <td><a href="/api/single-atomic#cas操作">原子CAS操作</a></td> |
| </tr> |
| <tr> |
| <td>check_and_mutate</td> |
| <td><a href="/clients/java-client#checkandmutate">原子CAS扩展版本</a></td> |
| </tr> |
| <tr> |
| <td>exist</td> |
| <td>查询某条数据是否存在</td> |
| </tr> |
| <tr> |
| <td>count</td> |
| <td>获取同一HashKey下的SortKey的个数</td> |
| </tr> |
| <tr> |
| <td>ttl</td> |
| <td>查询某条数据的TTL(Time To Live)时间,返回剩余的live时间,单位为秒;返回Infinite表示没有TTL限制</td> |
| </tr> |
| <tr> |
| <td>hash</td> |
| <td>计算键值的哈希值</td> |
| </tr> |
| <tr> |
| <td>hash_scan</td> |
| <td>逐条扫描同一HashKey下的数据,可指定SortKey的查询范围和过滤条件,结果按照SortKey排序</td> |
| </tr> |
| <tr> |
| <td>full_scan</td> |
| <td>对表进行全扫描,可指定HashKey、SortKey和Value的过滤条件,同一HashKey的结果按照SortKey排序,HashKey之间无顺序保证</td> |
| </tr> |
| <tr> |
| <td>copy_data</td> |
| <td>将一个表的数据逐条插入到另外一个表,源表通过<code class="language-plaintext highlighter-rouge">use</code>命令指定,目标表通过<code class="language-plaintext highlighter-rouge">-c</code>和<code class="language-plaintext highlighter-rouge">-a</code>命令执行,目标表可以在另外一个集群,详细用法参见<a href="/administration/table-migration#copy_data迁移">Table迁移#copy_data迁移</a>,可指定HashKey、SortKey和Value的过滤条件</td> |
| </tr> |
| <tr> |
| <td>clear_data</td> |
| <td>将一个表的数据逐条删除,实际上就是先扫描数据,然后对每一条数据执行删除操作,可指定HashKey、SortKey和Value的过滤条件</td> |
| </tr> |
| <tr> |
| <td>count_data</td> |
| <td>统计一个表的数据条数,可加<code class="language-plaintext highlighter-rouge">-z</code>选项统计数据大小,可指定HashKey、SortKey和Value的过滤条件</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h3 id="set">set</h3> |
| <p>设置单条数据。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: set <hash_key> <sort_key> <value> [ttl_in_seconds] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>写入数据的格式必须为<code class="language-plaintext highlighter-rouge">hash_key</code>+<code class="language-plaintext highlighter-rouge">sort_key</code>+<code class="language-plaintext highlighter-rouge">value</code>。</li> |
| <li><code class="language-plaintext highlighter-rouge">ttl_in_seconds</code>参数:如果指定,则设置该条数据的存活时间,单位为秒。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> set xiaomi cloud 000 |
| </code></pre></div></div> |
| |
| <h3 id="multi_set">multi_set</h3> |
| <p>设置同一hash_key下的多条数据。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: multi_set <hash_key> <sort_key> <value> [sort_key value...] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>sort_key是pegasus定义的一种数据模型,详细信息参见<a href="/overview/data-model">数据模型</a>。</li> |
| <li>不同的sort_key名字必须不同,否则会输出“ERROR: duplicate sort key <sort_key>”。</sort_key></li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> multi_set xiaomi cloud0 000 cloud1 001 |
| </code></pre></div></div> |
| |
| <h3 id="get">get</h3> |
| <p>获取单条数据。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: get <hash_key> <sort_key> |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> get xiaomi cloud |
| </code></pre></div></div> |
| |
| <h3 id="multi_get">multi_get</h3> |
| <p>通过指定多个SortKey,获取同一HashKey下的多条数据。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: multi_get <hash_key> [sort_key...] |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> multi_get xiaomi cloud0 cloud1 |
| </code></pre></div></div> |
| |
| <h3 id="multi_get_range">multi_get_range</h3> |
| <p>通过指定SortKey的查询范围和过滤条件,获取同一HashKey下的多条数据。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: multi_get_range <hash_key> <start_sort_key> <stop_sort_key> |
| [-a|--start_inclusive true|false] [-b|--stop_inclusive true|false] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix] |
| [-y|--sort_key_filter_pattern str] [-n|--max_count num] |
| [-i|--no_value] [-r|--reverse] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-a|--start_inclusive</code>参数:指定是否包含StartSortKey,默认为true。</li> |
| <li><code class="language-plaintext highlighter-rouge">-b|--stop_inclusive</code>参数:指定是否包含StopSortKey,默认为false。</li> |
| <li><code class="language-plaintext highlighter-rouge">-s|--sort_key_filter_type</code>参数:指定SortKey的过滤类型,包括无过滤、任意位置匹配、前缀匹配和后缀匹配,默认无过滤。</li> |
| <li><code class="language-plaintext highlighter-rouge">-y|--sort_key_filter_pattern</code>参数:指定SortKey的过滤模式串,空串相当于无过滤。</li> |
| <li><code class="language-plaintext highlighter-rouge">-n|--max_count</code>参数:指定最多读取的数据条数。</li> |
| <li><code class="language-plaintext highlighter-rouge">-i|--no_value</code>参数:指定是否只返回HashKey和SortKey,不返回Value数据,默认为false。</li> |
| <li><code class="language-plaintext highlighter-rouge">-r|--reverse</code>参数:是否逆向扫描数据库,从后往前查找数据,但是查找得到的结果在list中还是按照SortKey从小到大顺序存放。该参数从<a href="https://github.com/apache/incubator-pegasus/releases/tag/v1.8.0">v1.8.0版本</a>开始支持。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> multi_get_range xioami cloud0 cloud5 -a true -b true -s prefix -y str -n 100 -i false -r false |
| </code></pre></div></div> |
| |
| <h3 id="multi_get_sortkeys">multi_get_sortkeys</h3> |
| <p>获取同一HashKey下的所有SortKey。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: multi_get_sortkeys <hash_key> |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> multi_get_sortkeys xiaomi |
| </code></pre></div></div> |
| |
| <h3 id="del">del</h3> |
| <p>删除单条数据。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: del <hash_key> <sort_key> |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> del xiaomi cloud0 |
| </code></pre></div></div> |
| |
| <h3 id="multi_del">multi_del</h3> |
| <p>通过指定多个SortKey,删除同一HashKey下的多条数据。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: multi_del <hash_key> <sort_key> [sort_key...] |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> multi_del del xiaomi cloud0 cloud1 |
| </code></pre></div></div> |
| |
| <h3 id="multi_del_range">multi_del_range</h3> |
| <p>通过指定SortKey的查询范围和过滤条件,删除同一HashKey下的多条数据。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: multi_del_range <hash_key> <start_sort_key> <stop_sort_key> |
| [-a|--start_inclusive true|false] [-b|--stop_inclusive true|false] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix] |
| [-y|--sort_key_filter_pattern str] [-o|--output file_name] |
| [-i|--silent] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-i|--silent</code>参数:如果为<code class="language-plaintext highlighter-rouge">true</code>表示不打印删除时的日志。</li> |
| <li>其余参数,参见<a href="#multi_get_range">multi_get_range</a>说明。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> multi_del_range xioami cloud0 cloud5 -a true -b true -s prefix -y str -n 100 -i false -r false |
| </code></pre></div></div> |
| |
| <h3 id="incr">incr</h3> |
| <p>原子增减操作。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: incr <hash_key> <sort_key> [increment] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>操作数increment可以为正数也可以为负数,所以一个incr接口就可以实现原子增或者原子减,详情参照<a href="/api/single-atomic#原子增减">原子增减</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> incr cloud0 xiaomi 1 |
| </code></pre></div></div> |
| |
| <h3 id="check_and_set">check_and_set</h3> |
| <p>原子CAS操作。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: check_and_set <hash_key> [-c|--check_sort_key str] |
| [-t|--check_type not_exist|not_exist_or_empty|exist|not_empty] |
| [match_anywhere|match_prefix|match_postfix] |
| [bytes_less|bytes_less_or_equal|bytes_equal|bytes_greater_or_equal|bytes_greater] |
| [int_less|int_less_or_equal|int_equal|int_greater_or_equal|int_greater] |
| [-o|--check_operand str] [-s|--set_sort_key str] [-v|--set_value str] |
| [-l|--set_value_ttl_seconds num] [-r|--return_check_value] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>对比交换,最初是表示一条CPU的原子指令,其作用是让CPU先进行比较两个值是否相等,然后原子地更新某个位置的值。参照<a href="/api/single-atomic#cas操作">CAS操作</a>。</li> |
| </ul> |
| |
| <p>示例: |
| 该命令检查hashKey=cloud的数据,若sortKey=90的value存在,则将sortKey=91的value设置为92,且返回sortKey=90的value值。</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> check_and_set cloud -c 90 -t exist -s 91 -v 92 -r |
| </code></pre></div></div> |
| |
| <h3 id="check_and_mutate">check_and_mutate</h3> |
| <p>原子CAS扩展版本,参见<a href="/clients/java-client#checkandmutate">原子CAS扩展版本</a>。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: check_and_mutate <hash_key> [-c|--check_sort_key str] |
| [-t|--check_type not_exist|not_exist_or_empty|exist|not_empty] |
| [match_anywhere|match_prefix|match_postfix] |
| [bytes_less|bytes_less_or_equal|bytes_equal|bytes_greater_or_equal|bytes_greater] |
| [int_less|int_less_or_equal|int_equal|int_greater_or_equal|int_greater] |
| [-o|--check_operand str] [-r|--return_check_value] |
| </code></pre></div></div> |
| |
| <h3 id="exist">exist</h3> |
| <p>查询某条数据是否存在。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: exist <hash_key> <sort_key> |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> exist xiaomi cloud0 |
| </code></pre></div></div> |
| |
| <h3 id="count">count</h3> |
| <p>获取同一HashKey下的SortKey的个数。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: count <hash_key> |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> count xiaomi |
| </code></pre></div></div> |
| |
| <h3 id="ttl">ttl</h3> |
| <p>查询某条数据的TTL(Time To Live)时间,返回剩余的live时间,单位为秒;返回Infinite表示没有TTL限制。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: ttl <hash_key> <sort_key> |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> ttl xiaomi cloud |
| </code></pre></div></div> |
| |
| <h3 id="hash">hash</h3> |
| <p>查询某条数据的hash值,返回hash值的整数形式。</p> |
| |
| <p>如果在使用该命令前通过<code class="language-plaintext highlighter-rouge">use [app_name]</code>选定了特定表,还会根据hash值计算数据所对应的partition_id,并返回当前服务该partition的primary和secondary节点信息。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: hash <hash_key> <sort_key> |
| </code></pre></div></div> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> hash xiaomi cloud |
| </code></pre></div></div> |
| |
| <h3 id="hash_scan">hash_scan</h3> |
| <p>逐条扫描同一HashKey下的数据,可指定SortKey的查询范围和过滤条件,结果按照SortKey排序。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: hash_scan <hash_key> <start_sort_key> <stop_sort_key> |
| [-a|--start_inclusive true|false] |
| [-b|--stop_inclusive true|false] |
| [-s|--sort_key_filter_type anywhere|prefix] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact |
| [-z|--value_filter_pattern str] |
| [-o|--output file_name] |
| [-n|--max_count num] |
| [-t|--timeout_ms num] |
| [-d|--detailed] |
| [-i|--no_value] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-a|--start_inclusive</code>参数:指定是否包含StartSortKey,默认为true。</li> |
| <li><code class="language-plaintext highlighter-rouge">-b|--stop_inclusive</code>参数:指定是否包含StopSortKey,默认为false。</li> |
| <li><code class="language-plaintext highlighter-rouge">-s|--sort_key_filter_type</code>参数:指定SortKey的过滤类型,包括无过滤、任意位置匹配、前缀匹配和后缀匹配,默认无过滤。</li> |
| <li><code class="language-plaintext highlighter-rouge">-y|--sort_key_filter_pattern</code>参数:指定SortKey的过滤模式串,空串相当于无过滤。</li> |
| <li><code class="language-plaintext highlighter-rouge">-v|--value_filter_type</code>参数:指定value过滤类型,包括任意位置匹配、前缀匹配、后缀匹配等。</li> |
| <li><code class="language-plaintext highlighter-rouge">-z|--value_filter_pattern str</code>参数:指定value的过滤模式串,空串相当于无过滤。</li> |
| <li><code class="language-plaintext highlighter-rouge">-o|--output file_name</code>参数:指定输出结果存入的文件名。</li> |
| <li><code class="language-plaintext highlighter-rouge">-n|--max_count num</code>参数:指定获取值的最大数量。</li> |
| <li><code class="language-plaintext highlighter-rouge">-t|--timeout_ms num</code>参数:指定获取数据的超时时间。</li> |
| <li><code class="language-plaintext highlighter-rouge">-d|--detailed</code>参数:输出数据的详细存储信息,包括app_id、partition_index、server_ip。</li> |
| <li><code class="language-plaintext highlighter-rouge">-i|--no_value</code>参数:不获取value值,仅输出hash_key和sort_key。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> hash_scan xiaomi cloud00 cloud01 |
| </code></pre></div></div> |
| |
| <h3 id="full_scan">full_scan</h3> |
| <p>对表进行全扫描,可指定HashKey、SortKey和Value的过滤条件,同一HashKey的结果按照SortKey排序,HashKey之间无顺序保证。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: full_scan [-h|--hash_key_filter_type anywhere|prefix|postfix] |
| [-x|--hash_key_filter_pattern str] |
| [-s|--sort_key_filter_type anywhere|prefix] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact |
| [-z|--value_filter_pattern str] |
| [-o|--output file_name] |
| [-n|--max_count num] |
| [-t|--timeout_ms num] |
| [-d|--detailed] |
| [-i|--no_value] |
| </code></pre></div></div> |
| <p>说明:</p> |
| <ul> |
| <li>参数说明参见<a href="#hashKey_scan">hash_scan</a>。</li> |
| </ul> |
| |
| <p>实例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> full_scan |
| </code></pre></div></div> |
| |
| <h3 id="copy_data">copy_data</h3> |
| <p>将一个表的数据逐条插入到另外一个表。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: copy_data <-c|--target_cluster_name str> <-a|--target_app_name str> |
| [-s|--max_split_count num] |
| [-p|--partition num] |
| [-b|--max_batch_count num] |
| [-t|--timeout_ms num] |
| [-h|--hash_key_filter_type anywhere|prefix|postfix] |
| [-x|--hash_key_filter_pattern str] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix|exact] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact] |
| [-z|--value_filter_pattern str] |
| [-n|--no_overwrite] [-i|--no_value] [-g|--geo_data] |
| |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li>源表通过use命令指定,目标表通过-c和-a命令执行,目标表可以在另外一个集群,详细用法参见<a href="/administration/table-migration#copy_data迁移">Table迁移#copy_data迁移</a>,可指定HashKey、SortKey和Value的过滤条件。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> copy_data -c ClusterB -a TableB -t 10000 |
| </code></pre></div></div> |
| |
| <h3 id="clear_data">clear_data</h3> |
| <p>将一个表的数据逐条删除,实际上就是先扫描数据,然后对每一条数据执行删除操作,可指定HashKey、SortKey和Value的过滤条件。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: clear_data [-p|--partition num] |
| [-b|--max_batch_count num] |
| [-t|--timeout_ms num] |
| [-h|--hash_key_filter_type anywhere|prefix|postfix] |
| [-x|--hash_key_filter_pattern str] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix|exact] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact] |
| [-z|--value_filter_pattern str] |
| [-f|--force] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-p|--partition num</code>参数:指定删除的分片。</li> |
| <li><code class="language-plaintext highlighter-rouge">-b|--max_batch_count num</code>参数:指定一次性删除的最大数量。</li> |
| <li><code class="language-plaintext highlighter-rouge">-f|--force</code>参数:如果为true,则表示删除,否则无法删除并打印再次确认信息“ERROR: be careful to clear data!!! Please specify –force if you are determined to do”。</li> |
| <li>其余参数均为过滤条件,参见<a href="#multi_get_range">multi_get_range</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> clear_data |
| </code></pre></div></div> |
| |
| <h3 id="count_data">count_data</h3> |
| <p>统计一个表的数据条数,可指定HashKey、SortKey和Value的过滤条件。</p> |
| |
| <p>用法:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>USAGE: count_data [-p|--partition num] [-b|--max_batch_count num] [-t|--timeout_ms num] |
| [-h|--hash_key_filter_type anywhere|prefix|postfix] |
| [-x|--hash_key_filter_pattern str] |
| [-s|--sort_key_filter_type anywhere|prefix|postfix|exact] |
| [-y|--sort_key_filter_pattern str] |
| [-v|--value_filter_type anywhere|prefix|postfix|exact] |
| [-z|--value_filter_pattern str] [-d|--diff_hash_key] [-a|--stat_size] |
| [-n|--top_count num] [-r|--run_seconds num] |
| </code></pre></div></div> |
| |
| <p>说明:</p> |
| <ul> |
| <li><code class="language-plaintext highlighter-rouge">-p|--partition</code>参数:指定删除的分片。</li> |
| <li><code class="language-plaintext highlighter-rouge">-b|--max_batch_count</code>参数:指定一次性删除的最大数量。</li> |
| <li><code class="language-plaintext highlighter-rouge">-d|--diff_hash_key</code>参数:统计hashKey数量。</li> |
| <li><code class="language-plaintext highlighter-rouge">-n|--top_count</code>参数:仅展示指定数量的数据。</li> |
| <li><code class="language-plaintext highlighter-rouge">-a|--stat_size</code>参数:统计当前value的大小,单位字节。</li> |
| <li><code class="language-plaintext highlighter-rouge">-r|--run_seconds num</code>参数:仅运行指定时间进行统计。</li> |
| <li>其余参数均为过滤条件,参见<a href="#multi_get_range">multi_get_range</a>。</li> |
| </ul> |
| |
| <p>示例:</p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> count_data |
| </code></pre></div></div> |
| |
| <h2 id="负载均衡">负载均衡</h2> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>子命令</th> |
| <th>功能</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>set_meta_level</td> |
| <td>设置集群的负载均衡级别,包括stopped、blind、freezed、steady、lively。集群默认为steady,表示不进行自动负载均衡;设置为lively可以开启自动负载均衡</td> |
| </tr> |
| <tr> |
| <td>get_meta_level</td> |
| <td>获取集群的负载均衡级别</td> |
| </tr> |
| <tr> |
| <td>propose</td> |
| <td>发送partition操作,包括ASSIGN_PRIMARY、ADD_SECONDARY、DOWNGRADE_TO_INACTIVE等</td> |
| </tr> |
| <tr> |
| <td>balance</td> |
| <td>发送balance操作,包括move_pri、copy_pri、copy_sec等</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <p>关于负载均衡的详细文档,请参考<a href="/administration/rebalance">负载均衡</a>。</p> |
| |
| <h2 id="数据恢复">数据恢复</h2> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>子命令</th> |
| <th>功能</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>recover</td> |
| <td>启动数据恢复流程,通过向ReplicaServer收集和学习,重新构建Zookeeper上的元数据信息,参见<a href="/administration/meta-recovery">元数据恢复</a></td> |
| </tr> |
| <tr> |
| <td>ddd_diagnose</td> |
| <td>DDD自动诊断工具,用于恢复所有备份全部不可用的partition,参见<a href="/administration/replica-recovery">Replica数据恢复</a></td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="冷备份管理">冷备份管理</h2> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>子命令</th> |
| <th>功能</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>add_backup_policy</td> |
| <td>增加冷备份策略</td> |
| </tr> |
| <tr> |
| <td>ls_backup_policy</td> |
| <td>查询冷备份策略</td> |
| </tr> |
| <tr> |
| <td>modify_backup_policy</td> |
| <td>修改冷备份策略</td> |
| </tr> |
| <tr> |
| <td>disable_backup_policy</td> |
| <td>禁用冷备份策略</td> |
| </tr> |
| <tr> |
| <td>enable_backup_policy</td> |
| <td>启用冷备份策略</td> |
| </tr> |
| <tr> |
| <td>restore_app</td> |
| <td>从冷备份中恢复表</td> |
| </tr> |
| <tr> |
| <td>query_backup_policy</td> |
| <td>查询备份策略和上次备份信息</td> |
| </tr> |
| <tr> |
| <td>query_restore_status</td> |
| <td>查询冷备份恢复进度</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <p>关于冷备份的详细文档,请参考<a href="/administration/cold-backup">冷备份</a>。</p> |
| |
| <h2 id="调试工具">调试工具</h2> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>子命令</th> |
| <th>功能</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>sst_dump</td> |
| <td>使用RocksDB的<code class="language-plaintext highlighter-rouge">sst_dump</code>工具,将rocksdb的二进制sstable数据转换为可读的文本数据</td> |
| </tr> |
| <tr> |
| <td>mlog_dump</td> |
| <td>将Pegasus的二进制commit log数据转换为可读的文本数据</td> |
| </tr> |
| <tr> |
| <td>local_get</td> |
| <td>从本地数据库获取值(原来的调试工具)</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| |
| </div> |
| </section> |
| <footer class="footer"> |
| <div class="container"> |
| <div class="content is-small has-text-centered"> |
| <div style="margin-bottom: 20px;"> |
| <a href="http://incubator.apache.org"> |
| <img src="/assets/images/egg-logo.png" |
| width="15%" |
| alt="Apache Incubator"/> |
| </a> |
| </div> |
| Copyright © 2023 <a href="http://www.apache.org">The Apache Software Foundation</a>. |
| Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version |
| 2.0</a>. |
| <br><br> |
| |
| Apache Pegasus is an effort undergoing incubation at The Apache Software Foundation (ASF), |
| sponsored by the Apache Incubator. Incubation is required of all newly accepted projects |
| until a further review indicates that the infrastructure, communications, and decision making process |
| have stabilized in a manner consistent with other successful ASF projects. While incubation status is |
| not necessarily a reflection of the completeness or stability of the code, it does indicate that the |
| project has yet to be fully endorsed by the ASF. |
| |
| <br><br> |
| Apache Pegasus, Pegasus, Apache, the Apache feather logo, and the Apache Pegasus project logo are either |
| registered trademarks or trademarks of The Apache Software Foundation in the United States and other |
| countries. |
| </div> |
| </div> |
| </footer> |
| </div> |
| |
| <!-- right panel --> |
| <div class="dashboard-panel is-small is-scrollable is-hidden-mobile"> |
| <p class="menu-label"> |
| <span class="icon"> |
| <i class="fa fa-bars" aria-hidden="true"></i> |
| </span> |
| Table of contents |
| </p> |
| <ul class="menu-list"> |
| <li><a href="#工具获取">工具获取</a></li> |
| <li><a href="#工具使用">工具使用</a> |
| <ul> |
| <li><a href="#基本命令">基本命令</a> |
| <ul> |
| <li><a href="#help">help</a></li> |
| <li><a href="#version">version</a></li> |
| <li><a href="#exit">exit</a></li> |
| </ul> |
| </li> |
| <li><a href="#全局属性">全局属性</a> |
| <ul> |
| <li><a href="#cc">cc</a></li> |
| <li><a href="#use">use</a></li> |
| <li><a href="#escape_all">escape_all</a></li> |
| <li><a href="#timeout">timeout</a></li> |
| </ul> |
| </li> |
| <li><a href="#节点管理">节点管理</a> |
| <ul> |
| <li><a href="#cluster_info">cluster_info</a></li> |
| <li><a href="#nodes">nodes</a></li> |
| <li><a href="#server_info">server_info</a></li> |
| <li><a href="#server_stat">server_stat</a></li> |
| <li><a href="#remote_command">remote_command</a></li> |
| <li><a href="#flush_log">flush_log</a></li> |
| <li><a href="#disk_replica">disk_replica</a></li> |
| <li><a href="#disk_capacity">disk_capacity</a></li> |
| </ul> |
| </li> |
| <li><a href="#表管理">表管理</a> |
| <ul> |
| <li><a href="#ls">ls</a></li> |
| <li><a href="#app">app</a></li> |
| <li><a href="#app_stat">app_stat</a></li> |
| <li><a href="#app_disk">app_disk</a></li> |
| <li><a href="#create">create</a></li> |
| <li><a href="#drop">drop</a></li> |
| <li><a href="#recall">recall</a></li> |
| <li><a href="#get_app_envs">get_app_envs</a></li> |
| <li><a href="#set_app_envs">set_app_envs</a></li> |
| <li><a href="#del_app_envs">del_app_envs</a></li> |
| <li><a href="#clear_app_envs">clear_app_envs</a></li> |
| </ul> |
| </li> |
| <li><a href="#数据操作">数据操作</a> |
| <ul> |
| <li><a href="#set">set</a></li> |
| <li><a href="#multi_set">multi_set</a></li> |
| <li><a href="#get">get</a></li> |
| <li><a href="#multi_get">multi_get</a></li> |
| <li><a href="#multi_get_range">multi_get_range</a></li> |
| <li><a href="#multi_get_sortkeys">multi_get_sortkeys</a></li> |
| <li><a href="#del">del</a></li> |
| <li><a href="#multi_del">multi_del</a></li> |
| <li><a href="#multi_del_range">multi_del_range</a></li> |
| <li><a href="#incr">incr</a></li> |
| <li><a href="#check_and_set">check_and_set</a></li> |
| <li><a href="#check_and_mutate">check_and_mutate</a></li> |
| <li><a href="#exist">exist</a></li> |
| <li><a href="#count">count</a></li> |
| <li><a href="#ttl">ttl</a></li> |
| <li><a href="#hash">hash</a></li> |
| <li><a href="#hash_scan">hash_scan</a></li> |
| <li><a href="#full_scan">full_scan</a></li> |
| <li><a href="#copy_data">copy_data</a></li> |
| <li><a href="#clear_data">clear_data</a></li> |
| <li><a href="#count_data">count_data</a></li> |
| </ul> |
| </li> |
| <li><a href="#负载均衡">负载均衡</a></li> |
| <li><a href="#数据恢复">数据恢复</a></li> |
| <li><a href="#冷备份管理">冷备份管理</a></li> |
| <li><a href="#调试工具">调试工具</a></li> |
| </ul> |
| </li> |
| </ul> |
| |
| </div> |
| </div> |
| |
| <script src="/assets/js/app.js" type="text/javascript"></script> |
| <script> |
| docsearch({ |
| container: '#docsearch', |
| appId: 'QRN30RBW0S', |
| indexName: 'pegasus-apache', |
| apiKey: 'd3a3252fa344359766707a106c4ed88f', |
| debug: true |
| }); |
| </script> |
| |
| </body> |
| |
| </html> |