Create table in hbase

拜拜、爱过 提交于 2019-12-21 20:43:45

问题


I am new to hbase and hadoop. Anyhow I have succeeded in setting up a hadoop cluster which consists of 3 machines. Now I need some help on building up the database.

I have a table "comments" contains fields:

  1. user id
  2. comments
  3. comments on comments (which can be more than one) and a status field to the same say,

Could any one help me out to build the same using hbase/shell?


回答1:


Here's some helpful HBase shell commands for you. Get help on format for creating a table in the shell.

help 'create'
create 'comments', {NAME=>'user_info'}, {NAME=>'comment_data'}

Note that column families need to be explicit, but actual columns themselves have no requirements and can be added post-create just by doing a Put. 1 File per Column Family, all columns for a row in the family are adjacent to each other in the file. In this case, I made a 'user_info' family that you could put 'user_id' and 'status' columns into. Ditto for 'comment_data'.

If you need to alter the table (for example, you might only create one column family on the first try), you need to disable the table then alter it

disable 'tableName'
help 'alter'
enable 'tableName' # when done altering

Note that you also need to disable a table to delete it.




回答2:


The below link is a good resource for the HBase shell, including how to create a table.
http://wiki.apache.org/hadoop/Hbase/Shell

Update
New URL is http://hbase.apache.org/book.html#shell




回答3:


If you are new to HBase, then you probably best to try a GUI for HBase administration - HAdmin. Click to the "Tables" link on the sidebar, you will see all already existed tables and "Create table" button. Click to it and in the "Create table" page you can add your new table with all settings and column families you need.



来源:https://stackoverflow.com/questions/5077577/create-table-in-hbase

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!