Ubuntu 9.0 下之HBase 0.90.4 的安装和使用

来源:互联网 发布:axure的mac版怎么安装 编辑:程序博客网 时间:2024/04/28 04:18
Ubuntu 9.o 下安装 Hbase
Hbase 下载 地址 http://archive.apache.org/dist/hbase/hbase-0.90.4/
解压 tar vxf hbase-0.90.4.tar.gz

         cd hbase-0.90.4

单机版的配置

配置一个目录 

现在你已经可以启动Hbase了。但是你可能需要先编辑 conf/hbase-site.xml 去配置hbase.rootdir,来选择Hbase将数据写到哪个目录 .

<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?><configuration>  <property>    <name>hbase.rootdir</name>    <value>file:///DIRECTORY/hbase</value>  </property></configuration>

将 DIRECTORY 替换成你期望写文件的目录. 默认 hbase.rootdir 是指向 /tmp/hbase-${user.name} ,也就说你会在重启后丢失数据(重启的时候操作系统会清理/tmp目录)

我配置到 只要指定到一个目录下就可以,这个目录是用来保存创建表记录。

 <value>/home/liucheng/hbase0.90.4/hbase</value>


参看http://www.yankay.com/wp-content/hbase/book.html

然后编辑conf/hbase-env.sh,将其中的JAVA_HOME指向到你Java的安装目录。

启动 HBase

现在启动Hbase:

$ ./bin/start-hbase.shstarting Master, logging to logs/hbase-user-master-example.org.out

shell连接你的Hbase 这个时候 估计 需要 30秒左右,不要 以为死了 关闭了。

$ ./bin/hbase shellHBase Shell; enter 'help<RETURN>' for list of supported commands.Type "exit<RETURN>" to leave the HBase ShellVersion: 0.90.0, r1001068, Fri Sep 24 13:55:42 PDT 2010hbase(main):001:0> 

在创建表时 出现 

ERROR: org.apache.hadoop.hbase.ZooKeeperConnectionException: HBase is able to connect to
ZooKeeper but the connection closes immediately. This could be a sign that the server has too many
connections (30 is the default).

具体 方式:

vi /etc/security/limits.conf

在最后添加两行:

hdfs  -       nofile  32768
hbase  -       nofile  32768
 解决方案参看 http://mazd1002.blog.163.com/blog/static/6657496520111121018145/

重启下 hbase
[root@master bin]# ./stop-hbase.sh 
stopping hbase.............................
[root@master bin]# ./start-hbase.sh
(如果stop-hbase一直处于………………的状态,怎么办?我教你一个方法,先去重新start-hbase,肯定说hbase还没有停止,需要先停止,给你一个PID,哈哈,之后你就kill -9 pid,在执行start-hbase.sh)
当你结束的时候,会提示 hbase 的进程号 kill 进程号 就好
在创建表完成 后 显示表
list 'table'
只会显示 TABLE
所以 显示表 用list 就可以 把刚刚新建的表显示出来
/home/liucheng/hbase-0.90.4/
$ ./bin/start-hbase.sh
$ ./bin/stop-hbase.sh
 
九、遇到的问题  
hbase(main):001:0> create 'test','cf'
 
ERROR: org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException: org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException: Timed out (10000ms)
 
解决方法:修改/etc/hosts。把ubuntu对应的127.0.1.1改成本机的IP。OK!

参考 http://blog.csdn.net/god_wot/article/details/6829427

Hbase 的基础命令语法 可以参考 http://blog.csdn.net/scutshuxue/article/details/6988348

我们做一个测试;

注意:有些命令是没有 ; 号结束的。请注意。

第一步:新建一个学生表,只有两列,一列是name,一列是address.

             create 'stu',{name=>'name'},{name=>'address'};

            同时显示一下,list 


第二步:向学生表添加一列数据,

                put 'stu','row1','name:1','zs';


第三步:查看一下,建表语句,

              describe  'stu'


第四步:查看一下表内容 scan 'stu' 

  

第五步:通过key 获取一行数据。

               get  'stu','row1'

注:如果在一个表中,列族相同,第二个列就会覆盖第一个列。

结束,删除表。

伪分布式的配置

第一步:到hbase 的目录 conf 下修改hbase-site.xml 配置文件,内容如下。

第二步:启动 hbase  ./bin/start-hbase.sh 并进入shell 命令



在我想看一下表的时候。输放list  但报错了。
错误信息是:
ERROR: org.apache.hadoop.hbase.ZooKeeperConnectionException: HBase is able to connect to ZooKeeper but the connection closes immediately. This could be a sign that the server has too many connections (30 is the default). Consider inspecting your ZK server logs for that error and then make sure you are reusing HBaseConfiguration as often as you can. See HTable's javadoc for more information.

 按这样修改。
  1.    在/etc/hosts 下加放 本机IP  hbase

  2. 修改 hbase conf目录下的regionservers 下的loclhost 改成 hbase

  3. 把hadoop 目录下的 hadoop-0.20.2-core.jar hadoop-0.20.2-test.jar 放到hbase 的lib目录下

  4. 重新启动 hbase  ./bin/start-hbase.sh

Hbase 常用命令:

  1.   COLUMNS 与 COLUMN 的使用区别。


原创粉丝点击