Create table in hbase
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:
- user id
- comments
- 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?
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.
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
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.
精彩评论