mirror of https://github.com/dunwu/db-tutorial.git
106 lines
56 KiB
HTML
106 lines
56 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
<html lang="en-US">
|
|||
|
<head>
|
|||
|
<meta charset="utf-8">
|
|||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|||
|
<title>HBase 快速入门 | DB-TUTORIAL</title>
|
|||
|
<meta name="generator" content="VuePress 1.9.9">
|
|||
|
<link rel="icon" href="/db-tutorial/img/favicon.ico">
|
|||
|
<script src="https://cdn.wwads.cn/js/makemoney.js" type="text/javascript"></script>
|
|||
|
<meta name="description" content="☕ db-tutorial 是一个数据库教程。">
|
|||
|
<meta name="keywords" content="vuepress,theme,blog,vdoing">
|
|||
|
<meta name="theme-color" content="#11a8cd">
|
|||
|
<meta name="wwads-cn-verify" content="mxqWx62nfQQ9ocT4e5DzISHzOWyF4s">
|
|||
|
|
|||
|
<link rel="preload" href="/db-tutorial/assets/css/0.styles.51390d19.css" as="style"><link rel="preload" href="/db-tutorial/assets/js/app.be3f2e92.js" as="script"><link rel="preload" href="/db-tutorial/assets/js/2.aded268b.js" as="script"><link rel="preload" href="/db-tutorial/assets/js/54.340ab690.js" as="script"><link rel="prefetch" href="/db-tutorial/assets/js/10.551ab278.js"><link rel="prefetch" href="/db-tutorial/assets/js/11.c049b6a2.js"><link rel="prefetch" href="/db-tutorial/assets/js/12.92d587d6.js"><link rel="prefetch" href="/db-tutorial/assets/js/13.a7b35fa5.js"><link rel="prefetch" href="/db-tutorial/assets/js/14.9ec959b5.js"><link rel="prefetch" href="/db-tutorial/assets/js/15.e7943372.js"><link rel="prefetch" href="/db-tutorial/assets/js/16.c6ad7b26.js"><link rel="prefetch" href="/db-tutorial/assets/js/17.39500ebd.js"><link rel="prefetch" href="/db-tutorial/assets/js/18.29949979.js"><link rel="prefetch" href="/db-tutorial/assets/js/19.78f879b8.js"><link rel="prefetch" href="/db-tutorial/assets/js/20.3ce14df7.js"><link rel="prefetch" href="/db-tutorial/assets/js/21.9d311c7c.js"><link rel="prefetch" href="/db-tutorial/assets/js/22.90234550.js"><link rel="prefetch" href="/db-tutorial/assets/js/23.12cf9e2d.js"><link rel="prefetch" href="/db-tutorial/assets/js/24.5b436e46.js"><link rel="prefetch" href="/db-tutorial/assets/js/25.8f2dc7d9.js"><link rel="prefetch" href="/db-tutorial/assets/js/26.61665ff4.js"><link rel="prefetch" href="/db-tutorial/assets/js/27.dfc7cc88.js"><link rel="prefetch" href="/db-tutorial/assets/js/28.a6286a66.js"><link rel="prefetch" href="/db-tutorial/assets/js/29.bfa8c106.js"><link rel="prefetch" href="/db-tutorial/assets/js/3.82108019.js"><link rel="prefetch" href="/db-tutorial/assets/js/30.c93b7a2e.js"><link rel="prefetch" href="/db-tutorial/assets/js/31.d48aab81.js"><link rel="prefetch" href="/db-tutorial/assets/js/32.33f8bb7c.js"><link rel="prefetch" href="/db-tutorial/assets/js/33.eb3b622d.js"><link rel="prefetch" href="/db-tutorial/assets/js/34.1ba1a06c.js"><link rel="prefetch" href="/db-tutorial/assets/js/35.24e4fee8.js"><link rel="prefetch" href="/db-tutorial/assets/js/36.dc61504e.js"><link rel="prefetch" href="/db-tutorial/assets/js/37.f1c9c729.js"><link rel="prefetch" href="/db-tutorial/assets/js/38.5024023f.js"><link rel="prefetch" href="/db-tutorial/assets/js/39.30ed016e.js"><link rel="prefetch" href="/db-tutorial/assets/js/4.884deeca.js"><link rel="prefetch" href="/db-tutorial/assets/js/40.6a6327f0.js"><link rel="prefetch" href="/db-tutorial/assets/js/41.3767f4d8.js"><link rel="prefetch" href="/db-tutorial/assets/js/42.14a20b0f.js"><link rel="prefetch" href="/db-tutorial/assets/js/43.b059081c.js"><link rel="prefetch" href="/db-tutorial/assets/js/44.73f724d9.js"><link rel="prefetch" href="/db-tutorial/assets/js/45.68f2ab27.js"><link rel="prefetch" href="/db-tutorial/assets/js/46.aed8a61f.js"><link rel="prefetch" href="/db-tutorial/assets/js/47.3bbf2366.js"><link rel="prefetch" href="/db-tutorial/assets/js/48.81688356.js"><link rel="prefetch" href="/db-tutorial/assets/js/49.1d366c93.js"><link rel="prefetch" href="/db-tutorial/assets/js/5.42f2cdb7.js"><link rel="prefetch" href="/db-tutorial/assets/js/50.ee6f08b7.js"><link rel="prefetch" href="/db-tutorial/assets/js/51.47835d9d.js"><link rel="prefetch" href="/db-tutorial/assets/js/52.b0cab79c.js"><link rel="prefetch" href="/db-tutorial/assets/js/53.106440a2.js"><link rel="prefetch" href="/db-tutorial/assets/js/55.00623de9.js"><link rel="prefetch" href="/db-tutorial/assets/js/56.9f086601.js"><link rel="prefetch" href="/db-tutorial/assets/js/57.f5ad5f3f.js"><link rel="prefetch" href="/db-tutorial/assets/js/58.14827368.js"><link rel="prefetch" href="/db-tutorial/assets/js/59.c41f57d6.js"><link rel="prefetch" href="/db-tutorial/assets/js/6.5a5b4e54.js"><link rel="prefetch" href="/db-tutorial/assets/js/60.314534c0.js"><link rel="prefetch" href="/db-tutorial/assets/js/61.1ea5e4b7.js"><link rel="prefetch" href="/db-tutorial/assets/js/62.8b52e8fc.js"><link rel="prefetch" href="/db-tutorial/assets/js/63.d2fa8325.js"><link rel="prefetc
|
|||
|
<link rel="stylesheet" href="/db-tutorial/assets/css/0.styles.51390d19.css">
|
|||
|
</head>
|
|||
|
<body class="theme-mode-light">
|
|||
|
<div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/db-tutorial/" class="home-link router-link-active"><img src="https://raw.githubusercontent.com/dunwu/images/master/common/dunwu-logo.png" alt="DB-TUTORIAL" class="logo"> <span class="site-name can-hide">DB-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/db-tutorial/12.数据库/01.数据库综合/" class="nav-link">数据库综合</a></div><div class="nav-item"><a href="/db-tutorial/12.数据库/02.数据库中间件/" class="nav-link">数据库中间件</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="关系型数据库" class="dropdown-title"><a href="/db-tutorial/12.数据库/03.关系型数据库/" class="link-title">关系型数据库</a> <span class="title" style="display:none;">关系型数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/03.关系型数据库/01.综合/" class="nav-link">综合</a></li><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/03.关系型数据库/02.Mysql/" class="nav-link">Mysql</a></li><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/03.关系型数据库/99.其他/" class="nav-link">其他</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="文档数据库" class="dropdown-title"><!----> <span class="title" style="display:;">文档数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/04.文档数据库/01.MongoDB/" class="nav-link">MongoDB</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="KV数据库" class="dropdown-title"><!----> <span class="title" style="display:;">KV数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/05.KV数据库/01.Redis/" class="nav-link">Redis</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="搜索引擎数据库" class="dropdown-title"><!----> <span class="title" style="display:;">搜索引擎数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/07.搜索引擎数据库/01.Elasticsearch/" class="nav-link">Elasticsearch</a></li><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/07.搜索引擎数据库/02.Elastic/" class="nav-link">Elastic技术栈</a></li></ul></div></div> <a href="https://github.com/dunwu/db-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
|||
|
GitHub
|
|||
|
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/db-tutorial/12.数据库/01.数据库综合/" class="nav-link">数据库综合</a></div><div class="nav-item"><a href="/db-tutorial/12.数据库/02.数据库中间件/" class="nav-link">数据库中间件</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="关系型数据库" class="dropdown-title"><a href="/db-tutorial/12.数据库/03.关系型数据库/" class="link-title">关系型数据库</a> <span class="title" style="display:none;">关系型数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/03.关系型数据库/01.综合/" class="nav-link">综合</a></li><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/03.关系型数据库/02.Mysql/" class="nav-link">Mysql</a></li><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/03.关系型数据库/99.其他/" class="nav-link">其他</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="文档数据库" class="dropdown-title"><!----> <span class="title" style="display:;">文档数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/04.文档数据库/01.MongoDB/" class="nav-link">MongoDB</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="KV数据库" class="dropdown-title"><!----> <span class="title" style="display:;">KV数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/05.KV数据库/01.Redis/" class="nav-link">Redis</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="搜索引擎数据库" class="dropdown-title"><!----> <span class="title" style="display:;">搜索引擎数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/07.搜索引擎数据库/01.Elasticsearch/" class="nav-link">Elasticsearch</a></li><li class="dropdown-item"><!----> <a href="/db-tutorial/12.数据库/07.搜索引擎数据库/02.Elastic/" class="nav-link">Elastic技术栈</a></li></ul></div></div> <a href="https://github.com/dunwu/db-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
|||
|
GitHub
|
|||
|
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>数据库综合</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>数据库中间件</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>关系型数据库</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>文档数据库</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>KV数据库</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>列式数据库</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading open"><span>HBase</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/db-tutorial/pages/7ab03c/" aria-current="page" class="active sidebar-link">HBase 快速入门</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/db-tutorial/pages/7ab03c/#hbase-简介" class="sidebar-link">HBase 简介</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/db-tutorial/pages/7ab03c/#为什么需要-hbase" class="sidebar-link">为什么需要 HBase</a></li><li class="sidebar-sub-header level3"><a href="/db-tutorial/pages/7ab03c/#什么是-hbase" class="sidebar-link">什么是 HBase</a></li><li class="sidebar-sub-header level3"><a href="/db-tutorial/pages/7ab03c/#什么时候使用-hbase" class="sidebar-link">什么时候使用 HBase</a></li><li class="sidebar-sub-header level3"><a href="/db-tutorial/pages/7ab03c/#hbase-数据模型简介" class="sidebar-link">HBase 数据模型简介</a></li><li class="sidebar-sub-header level3"><a href="/db-tutorial/pages/7ab03c/#特性比较" class="sidebar-link">特性比较</a></li><li class="sidebar-sub-header level4"><a href="/db-tutorial/pages/7ab03c/#hbase-vs-rdbms" class="sidebar-link">HBase vs. RDBMS</a></li><li class="sidebar-sub-header level4"><a href="/db-tutorial/pages/7ab03c/#hbase-vs-hdfs" class="sidebar-link">HBase vs. HDFS</a></li><li class="sidebar-sub-header level4"><a href="/db-tutorial/pages/7ab03c/#行式数据库-vs-列式数据库" class="sidebar-link">行式数据库 vs. 列式数据库</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/db-tutorial/pages/7ab03c/#hbase-安装" class="sidebar-link">HBase 安装</a></li><li class="sidebar-sub-header level2"><a href="/db-tutorial/pages/7ab03c/#hbase-hello-world-示例" class="sidebar-link">HBase Hello World 示例</a></li><li class="sidebar-sub-header level2"><a href="/db-tutorial/pages/7ab03c/#参考资料" class="sidebar-link">参考资料</a></li></ul></li><li><a href="/db-tutorial/pages/c8cfeb/" class="sidebar-link">HBase 数据模型</a></li><li><a href="/db-tutorial/pages/a69528/" class="sidebar-link">HBase Schema 设计</a></li><li><a href="/db-tutorial/pages/62f8d9/" class="sidebar-link">HBase 架构</a></li><li><a href="/db-tutorial/pages/a8cad3/" class="sidebar-link">HBase Java API 基础特性</a></li><li><a href="/db
|
|||
|
hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:001:<span class="token operator"><span class="token file-descriptor important">0</span>></span>
|
|||
|
</code></pre></div></li> <li><p>输入 <code>help</code> 可以查看 HBase Shell 命令。</p></li> <li><p>创建表</p> <p>可以使用 <code>create</code> 命令创建一张新表。必须要指定表名和 Column Family。</p> <div class="language-shell extra-class"><pre class="language-shell"><code>hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:001:<span class="token operator"><span class="token file-descriptor important">0</span>></span> create <span class="token string">'test'</span>, <span class="token string">'cf'</span>
|
|||
|
<span class="token number">0</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">0.4170</span> seconds
|
|||
|
|
|||
|
<span class="token operator">=</span><span class="token operator">></span> Hbase::Table - <span class="token builtin class-name">test</span>
|
|||
|
</code></pre></div></li> <li><p>列出表信息</p> <p>使用 <code>list</code> 命令来确认新建的表已存在。</p> <div class="language-shell extra-class"><pre class="language-shell"><code>hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:002:<span class="token operator"><span class="token file-descriptor important">0</span>></span> list <span class="token string">'test'</span>
|
|||
|
TABLE
|
|||
|
<span class="token builtin class-name">test</span>
|
|||
|
<span class="token number">1</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">0.0180</span> seconds
|
|||
|
|
|||
|
<span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">[</span><span class="token string">"test"</span><span class="token punctuation">]</span>
|
|||
|
</code></pre></div><p>可以使用 <code>describe</code> 命令可以查看表的细节信息,包括配置信息</p> <div class="language-shell extra-class"><pre class="language-shell"><code>hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:003:<span class="token operator"><span class="token file-descriptor important">0</span>></span> describe <span class="token string">'test'</span>
|
|||
|
Table <span class="token builtin class-name">test</span> is ENABLED
|
|||
|
<span class="token builtin class-name">test</span>
|
|||
|
COLUMN FAMILIES DESCRIPTION
|
|||
|
<span class="token punctuation">{</span>NAME <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'cf'</span>, VERSIONS <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'1'</span>, EVICT_BLOCKS_ON_CLOSE <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'false'</span>, NEW_VERSION_BEHAVIOR <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'false'</span>, KEEP_DELETED_CELLS <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'FALSE'</span>, CACHE_DATA_ON_WRITE <span class="token operator">=</span><span class="token operator">></span>
|
|||
|
<span class="token string">'false'</span>, DATA_BLOCK_ENCODING <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'NONE'</span>, TTL <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'FOREVER'</span>, MIN_VERSIONS <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'0'</span>, REPLICATION_SCOPE <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'0'</span>, BLOOMFILTER <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'ROW'</span>, CACHE_INDEX_ON_WRITE <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'f
|
|||
|
alse'</span>, IN_MEMORY <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'false'</span>, CACHE_BLOOMS_ON_WRITE <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'false'</span>, PREFETCH_BLOCKS_ON_OPEN <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'false'</span>, COMPRESSION <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'NONE'</span>, BLOCKCACHE <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'true'</span>, BLOCKSIZE
|
|||
|
<span class="token operator">=</span><span class="token operator">></span> <span class="token string">'65536'</span><span class="token punctuation">}</span>
|
|||
|
<span class="token number">1</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
|
|||
|
Took <span class="token number">0.9998</span> seconds
|
|||
|
</code></pre></div></li> <li><p>向表中写数据</p> <p>可以使用 <code>put</code> 命令向 HBase 表中写数据。</p> <div class="language-shell extra-class"><pre class="language-shell"><code>hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:003:<span class="token operator"><span class="token file-descriptor important">0</span>></span> put <span class="token string">'test'</span>, <span class="token string">'row1'</span>, <span class="token string">'cf:a'</span>, <span class="token string">'value1'</span>
|
|||
|
<span class="token number">0</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">0.0850</span> seconds
|
|||
|
|
|||
|
hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:004:<span class="token operator"><span class="token file-descriptor important">0</span>></span> put <span class="token string">'test'</span>, <span class="token string">'row2'</span>, <span class="token string">'cf:b'</span>, <span class="token string">'value2'</span>
|
|||
|
<span class="token number">0</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">0.0110</span> seconds
|
|||
|
|
|||
|
hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:005:<span class="token operator"><span class="token file-descriptor important">0</span>></span> put <span class="token string">'test'</span>, <span class="token string">'row3'</span>, <span class="token string">'cf:c'</span>, <span class="token string">'value3'</span>
|
|||
|
<span class="token number">0</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">0.0100</span> seconds
|
|||
|
</code></pre></div></li> <li><p>一次性扫描表的所有数据</p> <p>使用 <code>scan</code> 命令来扫描表数据。</p> <div class="language-shell extra-class"><pre class="language-shell"><code>hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:006:<span class="token operator"><span class="token file-descriptor important">0</span>></span> scan <span class="token string">'test'</span>
|
|||
|
ROW COLUMN+CELL
|
|||
|
row1 <span class="token assign-left variable">column</span><span class="token operator">=</span>cf:a, <span class="token assign-left variable">timestamp</span><span class="token operator">=</span><span class="token number">1421762485768</span>, <span class="token assign-left variable">value</span><span class="token operator">=</span>value1
|
|||
|
row2 <span class="token assign-left variable">column</span><span class="token operator">=</span>cf:b, <span class="token assign-left variable">timestamp</span><span class="token operator">=</span><span class="token number">1421762491785</span>, <span class="token assign-left variable">value</span><span class="token operator">=</span>value2
|
|||
|
row3 <span class="token assign-left variable">column</span><span class="token operator">=</span>cf:c, <span class="token assign-left variable">timestamp</span><span class="token operator">=</span><span class="token number">1421762496210</span>, <span class="token assign-left variable">value</span><span class="token operator">=</span>value3
|
|||
|
<span class="token number">3</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">0.0230</span> seconds
|
|||
|
</code></pre></div></li> <li><p>查看一行数据</p> <p>使用 <code>get</code> 命令可以查看一行表数据。</p> <div class="language-shell extra-class"><pre class="language-shell"><code>hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:007:<span class="token operator"><span class="token file-descriptor important">0</span>></span> get <span class="token string">'test'</span>, <span class="token string">'row1'</span>
|
|||
|
COLUMN CELL
|
|||
|
cf:a <span class="token assign-left variable">timestamp</span><span class="token operator">=</span><span class="token number">1421762485768</span>, <span class="token assign-left variable">value</span><span class="token operator">=</span>value1
|
|||
|
<span class="token number">1</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">0.0350</span> seconds
|
|||
|
</code></pre></div></li> <li><p>禁用表</p> <p>如果想要删除表或修改表设置,必须先使用 <code>disable</code> 命令禁用表。如果想再次启用表,可以使用 <code>enable</code> 命令。</p> <div class="language-shell extra-class"><pre class="language-shell"><code>hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:008:<span class="token operator"><span class="token file-descriptor important">0</span>></span> disable <span class="token string">'test'</span>
|
|||
|
<span class="token number">0</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">1.1820</span> seconds
|
|||
|
|
|||
|
hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:009:<span class="token operator"><span class="token file-descriptor important">0</span>></span> <span class="token builtin class-name">enable</span> <span class="token string">'test'</span>
|
|||
|
<span class="token number">0</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">0.1770</span> seconds
|
|||
|
</code></pre></div></li> <li><p>删除表</p> <p>使用 <code>drop</code> 命令可以删除表。</p> <div class="language-shell extra-class"><pre class="language-shell"><code>hbase<span class="token punctuation">(</span>main<span class="token punctuation">)</span>:011:<span class="token operator"><span class="token file-descriptor important">0</span>></span> drop <span class="token string">'test'</span>
|
|||
|
<span class="token number">0</span> row<span class="token punctuation">(</span>s<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token number">0.1370</span> seconds
|
|||
|
</code></pre></div></li> <li><p>退出 HBase Shell</p> <p>使用 <code>quit</code> 命令,就能退出 HBase Shell 控制台。</p></li></ol> <h2 id="参考资料"><a href="#参考资料" class="header-anchor">#</a> 参考资料</h2> <ul><li><strong>官方</strong> <ul><li><a href="http://hbase.apache.org/" target="_blank" rel="noopener noreferrer">HBase 官网<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://hbase.apache.org/book.html" target="_blank" rel="noopener noreferrer">HBase 官方文档<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="http://abloz.com/hbase/book.html" target="_blank" rel="noopener noreferrer">HBase 官方文档中文版<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li> <li><strong>书籍</strong> <ul><li><a href="https://book.douban.com/subject/27600204/" target="_blank" rel="noopener noreferrer">Hadoop 权威指南<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li> <li><strong>文章</strong> <ul><li><a href="https://static.googleusercontent.com/media/research.google.com/zh-CN//archive/bigtable-osdi06.pdf" target="_blank" rel="noopener noreferrer">Bigtable: A Distributed Storage System for Structured Data<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://mapr.com/blog/in-depth-look-hbase-architecture" target="_blank" rel="noopener noreferrer">An In-Depth Look at the HBase Architecture<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.
|
|||
|
←
|
|||
|
<a href="/db-tutorial/pages/537098/" class="prev">Redis 运维</a></span> <span class="next"><a href="/db-tutorial/pages/c8cfeb/">HBase 数据模型</a>→
|
|||
|
</span></p></div></div></div> <div class="article-list"><div class="article-title"><a href="/db-tutorial/archives/" class="iconfont icon-bi">最近更新</a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><a href="/db-tutorial/pages/b59ba2/"><div>
|
|||
|
HBase Java API 管理功能
|
|||
|
<!----></div></a> <span class="date">04-13</span></dt></dl><dl><dd>02</dd> <dt><a href="/db-tutorial/pages/ce5ca0/"><div>
|
|||
|
HBase Java API 其他高级特性
|
|||
|
<!----></div></a> <span class="date">03-31</span></dt></dl><dl><dd>03</dd> <dt><a href="/db-tutorial/pages/c8cfeb/"><div>
|
|||
|
HBase 数据模型
|
|||
|
<!----></div></a> <span class="date">03-16</span></dt></dl> <dl><dd></dd> <dt><a href="/db-tutorial/archives/" class="more">更多文章></a></dt></dl></div></div></main></div> <div class="footer"><div class="icons"><a href="mailto:forbreak@163.com" title="发邮件" target="_blank" class="iconfont icon-youjian"></a><a href="https://github.com/dunwu" title="GitHub" target="_blank" class="iconfont icon-github"></a></div>
|
|||
|
Theme by
|
|||
|
<a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a>
|
|||
|
| Copyright © 2019-2024
|
|||
|
<span>钝悟(dunwu) | CC-BY-SA-4.0</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
|
|||
|
跟随系统
|
|||
|
</li><li class="iconfont icon-rijianmoshi">
|
|||
|
浅色模式
|
|||
|
</li><li class="iconfont icon-yejianmoshi">
|
|||
|
深色模式
|
|||
|
</li><li class="iconfont icon-yuedu">
|
|||
|
阅读模式
|
|||
|
</li></ul></div></div> <!----> <!----> <div class="custom-html-window custom-html-window-rb" style="display:;"><div class="custom-wrapper"><span class="close-but">×</span> <div>
|
|||
|
<div class="wwads-cn wwads-vertical windowRB" data-id="261" style="max-width:160px;
|
|||
|
min-width: auto;min-height:auto;"></div>
|
|||
|
<style>
|
|||
|
.windowRB{ padding: 0;}
|
|||
|
.windowRB .wwads-img{margin-top: 10px;}
|
|||
|
.windowRB .wwads-content{margin: 0 10px 40px 10px;}
|
|||
|
.custom-html-window-rb .close-but{
|
|||
|
display: none;
|
|||
|
}
|
|||
|
</style>
|
|||
|
</div></div></div></div><div class="global-ui"><div></div></div></div>
|
|||
|
<script src="/db-tutorial/assets/js/app.be3f2e92.js" defer></script><script src="/db-tutorial/assets/js/2.aded268b.js" defer></script><script src="/db-tutorial/assets/js/54.340ab690.js" defer></script>
|
|||
|
</body>
|
|||
|
</html>
|