在hbase中创建表 [英] Create table in hbase

查看:362
本文介绍了在hbase中创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是hbase和hadoop的新手.无论如何,我成功地建立了由3台机器组成的hadoop集群.现在,我需要一些有关建立数据库的帮助.

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.

我有一个表"comments",其中包含字段:

I have a table "comments" contains fields:

  1. 用户ID
  2. 评论
  3. 对评论的评论(可以不止一个)和状态字段相同的说法,

有人可以帮助我使用hbase/shell构建相同的文件吗?

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

推荐答案

以下是一些对您有用的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'}

请注意,列族需要明确,但是实际的列本身没有要求,可以通过创建Put来在创建后添加.每个列族1个文件,该族中一行的所有列在文件中彼此相邻.在这种情况下,我创建了一个"user_info"族,您可以将"user_id"和"status"列放入其中.同上"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.

这篇关于在hbase中创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆