<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Hbase基本使用]]></title><description><![CDATA[<p dir="auto">默认管理后台<br />
<a href="http://localhost:16010/" rel="nofollow ugc">http://localhost:16010/</a></p>
<pre><code>连接
$ ./bin/hbase shell
hbase(main):001:0&gt;
</code></pre>
<p dir="auto">创建表</p>
<pre><code>hbase(main):001:0&gt; create 'test', 'cf'
0 row(s) in 0.4170 seconds

=&gt; Hbase::Table - test
</code></pre>
<p dir="auto">查看表</p>
<pre><code>hbase(main):002:0&gt; list 'test'
TABLE
test
1 row(s) in 0.0180 seconds

=&gt; ["test"]
</code></pre>
<pre><code>hbase(main):003:0&gt; describe 'test'
Table test is ENABLED
test
COLUMN FAMILIES DESCRIPTION
{NAME =&gt; 'cf', VERSIONS =&gt; '1', EVICT_BLOCKS_ON_CLOSE =&gt; 'false', NEW_VERSION_BEHAVIOR =&gt; 'false', KEEP_DELETED_CELLS =&gt; 'FALSE', CACHE_DATA_ON_WRITE =&gt;
'false', DATA_BLOCK_ENCODING =&gt; 'NONE', TTL =&gt; 'FOREVER', MIN_VERSIONS =&gt; '0', REPLICATION_SCOPE =&gt; '0', BLOOMFILTER =&gt; 'ROW', CACHE_INDEX_ON_WRITE =&gt; 'f
alse', IN_MEMORY =&gt; 'false', CACHE_BLOOMS_ON_WRITE =&gt; 'false', PREFETCH_BLOCKS_ON_OPEN =&gt; 'false', COMPRESSION =&gt; 'NONE', BLOCKCACHE =&gt; 'true', BLOCKSIZE
 =&gt; '65536'}
1 row(s)
Took 0.9998 seconds
</code></pre>
<p dir="auto">添加值</p>
<pre><code>hbase(main):003:0&gt; put 'test', 'row1', 'cf:a', 'value1'
0 row(s) in 0.0850 seconds

hbase(main):004:0&gt; put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0110 seconds

hbase(main):005:0&gt; put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0100 seconds
</code></pre>
<p dir="auto">浏览所有数据</p>
<pre><code>hbase(main):006:0&gt; scan 'test'
ROW                                      COLUMN+CELL
 row1                                    column=cf:a, timestamp=1421762485768, value=value1
 row2                                    column=cf:b, timestamp=1421762491785, value=value2
 row3                                    column=cf:c, timestamp=1421762496210, value=value3
3 row(s) in 0.0230 seconds
</code></pre>
<p dir="auto">获取单行数据</p>
<pre><code>hbase(main):007:0&gt; get 'test', 'row1'
COLUMN                                   CELL
 cf:a                                    timestamp=1421762485768, value=value1
1 row(s) in 0.0350 seconds
</code></pre>
<p dir="auto">使能和禁用表</p>
<pre><code>hbase(main):008:0&gt; disable 'test'
0 row(s) in 1.1820 seconds

hbase(main):009:0&gt; enable 'test'
0 row(s) in 0.1770 seconds
</code></pre>
<p dir="auto">删除表</p>
<pre><code>hbase(main):011:0&gt; drop 'test'
0 row(s) in 0.1370 seconds
</code></pre>
<p dir="auto">退出shell<br />
quit</p>
<p dir="auto">停止</p>
<pre><code>$ ./bin/stop-hbase.sh
stopping hbase....................
$
</code></pre>
]]></description><link>http://an.forum.genostack.com/topic/214/hbase基本使用</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 12:34:59 GMT</lastBuildDate><atom:link href="http://an.forum.genostack.com/topic/214.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Feb 2021 12:22:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hbase基本使用 on Tue, 30 Mar 2021 06:00:38 GMT]]></title><description><![CDATA[<p dir="auto">You may have to modify properties of the existing table to add more column families or to modify the table attributes. HBase has ‘alter’ command’. In this article, we will check alter HBase table using shell command with some common examples to alter HBase table.</p>
<p dir="auto">Alter HBase Table using shell command</p>
<p dir="auto">Alter HBase Table using shell command<br />
This command alters the column family schema. You can use the HBase Alter shell command used to make changes to an existing table. Using this command, you can change the table properties or attributes such as set version, set and delete table scope operators, and delete a column family from an existing table.</p>
<p dir="auto">HBase Alter Table Syntax<br />
Below is the HBase alter table syntax:</p>
<p dir="auto">alter &lt;tablename&gt;, NAME=&gt;’&lt;column familyname&gt;’, VERSIONS=&gt;&lt;new version no&gt;<br />
You can add or remove column from the HBase table. You can also modify the table properties.</p>
<p dir="auto">HBase Alter Table Examples<br />
Below are some of the common examples of HBase alter table command.</p>
<p dir="auto">HBase Alter Table add column family<br />
Let’s say you have created the table with column family name colFam1 and want to add one more column family. Below is the example:</p>
<pre><code>hbase(main):005:0&gt; alter 'test_table', {NAME=&gt; 'colFam2'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
</code></pre>
<p dir="auto">0 row(s) in 2.5210 seconds<br />
HBase Alter Table drop column family<br />
Below is the example to drop column family from HBase table:</p>
<pre><code>hbase(main):011:0&gt; alter 'test_table', {NAME =&gt; 'colFam2', METHOD =&gt; 'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
</code></pre>
<p dir="auto">0 row(s) in 2.7310 seconds<br />
You can use the other method to delete column from HBase table</p>
<pre><code>hbase(main):013:0&gt; alter 'test_table', 'delete'=&gt; 'colFam2'
Updating all regions with the new schema...
1/1 regions updated.
Done.
</code></pre>
<p dir="auto">0 row(s) in 2.4470 seconds<br />
Alter HBase Table to add versions<br />
Below is the example to add versions to existing table:</p>
<pre><code>hbase(main):015:0&gt; alter 'test_table', {NAME=&gt; 'colFam1',VERSIONS =&gt; 2}
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.
</code></pre>
<p dir="auto">0 row(s) in 3.2200 seconds<br />
Alter HBase Table to add Time TO Live (TTL)<br />
Below is the example to add Time TO Live (TTL) to existing table:</p>
<pre><code>hbase(main):016:0&gt; alter 'test_table', {NAME=&gt; 'colFam1',TTL =&gt; 2000 }
Updating all regions with the new schema...
1/1 regions updated.
Done.
</code></pre>
<p dir="auto">0 row(s) in 2.2140 seconds<br />
Alter HBase Table to enable snappy Compression<br />
Below is the example to enable snappy compression on the existing HBase column family:</p>
<pre><code>hbase(main):017:0&gt; alter 'test_table', {NAME=&gt; 'colFam1',COMPRESSION=&gt;'snappy'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
</code></pre>
]]></description><link>http://an.forum.genostack.com/post/522</link><guid isPermaLink="true">http://an.forum.genostack.com/post/522</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Tue, 30 Mar 2021 06:00:38 GMT</pubDate></item></channel></rss>