zoukankan      html  css  js  c++  java
  • Ubuntu 安装HBase

     

    下载:http://mirror.bit.edu.cn/apache/hbase/stable/

    官方指南:http://abloz.com/hbase/book.html

    安装配置:

    解压:

    tar -xzvf hbase-0.96.0-hadoop1-bin.tar.gz

    进入$hbase/lib下查看相关的hadoop包,看是哪个版本的hadoop。

    此处只记录伪分布式Hbase的安装。

    配置参数,修改hbase-site.xml:

    [html] view plain copy
     
    1. <configuration>  
    2.   ...  
    3.   <property>  
    4.     <name>hbase.rootdir</name>  
    5.     <value>hdfs://localhost:9000/hbase</value>  
    6.     <description>The directory shared by RegionServers.  
    7.     </description>  
    8.   </property>  
    9.   <property>  
    10.     <name>dfs.replication</name>  
    11.     <value>1</value>  
    12.     <description>The replication count for HLog & HFile storage. Should not be greater than HDFS datanode count.  
    13.     </description>  
    14.   </property>  
    15.   ...  
    16. </configuration>  

    伪分布式启动:

    伪分布式是基于HDFS的,所以需要先启动HDFS.

    之后启动HBase

    sh start-hbase.sh

    不出意外的报错:

    dat@dat-HP:/opt/hbase-0.96/bin$ sh start-hbase.sh 
    start-hbase.sh: 79: /opt/hbase-0.96/bin/hbase-config.sh: [[: not found
    start-hbase.sh: 88: /opt/hbase-0.96/bin/hbase-config.sh: [[: not found
    start-hbase.sh: 53: [: false: unexpected operator

    localhost: zookeeper running as process 24164. Stop it first.
    starting master, logging to /opt/hbase-0.96/bin/../logs/hbase-dat-master-dat-HP.out
    Could not start ZK at requested port of 2181.  ZK was started at port: -1.  Aborting as clients (e.g. shell) will not be able to find this ZK quorum.

    看样子是2181被占用了,查看占用2181端口的进程:

     lsof -i:2181

    [plain] view plain copy
     
    1. dat@dat-HP:/opt/hbase-0.96/logs$ lsof -i:2181  
    2. COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME  
    3. java    24164  dat   87u  IPv6 2800953      0t0  TCP *:2181 (LISTEN)  

    ps -ef|grep 24164

    [plain] view plain copy
     
    1. dat@dat-HP:/opt/hbase-0.96/logs$ ps -ef|grep 24164  
    2. dat      24164 24151  0 10:09 ?        00:00:03 /opt/jdk1.7.0_25/bin/java -Dproc_zookeeper -XX:OnOutOfMemoryError=kill -9 %p -Xmx1000m -XX:+UseConcMarkSweepGC -Dhbase.log.dir=/opt/hbase-0.96/bin/../logs -Dhbase.log.file=hbase-dat-zookeeper-dat-HP.log -Dhbase.home.dir=/opt/hbase-0.96/bin/.. -Dhbase.id.str=dat -Dhbase.root.logger=INFO,RFA -Dhbase.security.logger=INFO,RFAS org.apache.hadoop.hbase.zookeeper.HQuorumPeer start  

    显示已经是hbase的zookeeper服务,杀掉pid,重试,

    [plain] view plain copy
     
    1. dat@dat-HP:/opt/hbase-0.96/bin$ ./start-hbase.sh   
    2. starting master, logging to /opt/hbase-0.96/bin/../logs/hbase-dat-master-dat-HP.out  

    正常启动,检测jps
    [plain] view plain copy
     
    1. dat@dat-HP:/opt/hbase-0.96/bin$ jps  
    2. 25644 HMaster  
    3. 23468 TaskTracker  
    4. 23199 SecondaryNameNode  
    5. 23307 JobTracker  
    6. 25849 Jps  
    7. 22827 NameNode  
    8. 23031 DataNode  

    正常。。。

    HBase Shell

    编辑/etc/profile加入hbase_home,重新生效,source /etc/profile

    [plain] view plain copy
     
    1. export PIG_INSTALL=/opt/pig-0.12.0  
    2. export PATH=$PATH:$PIG_INSTALL/bin  
    3. export PIG_CLASSPATH=/opt/hadoop-1.2.1/conf  
    4. export HIVE_HOME=/opt/hive-0.12.0  
    5. export PATH=$HIVE_HOME/bin:$HIVE_HOME/conf:$PATH  
    6. export ANT_HOME=/opt/ant  
    7. export PATH=$PATH:$ANT_HOME/bin  
    8. export HBASE_HOME=/opt/hbase-0.96  
    9. export PATH=$PATH:$HBASE_HOME/bin  
    hbase shell进入:
    [plain] view plain copy
     
    1. dat@dat-HP:/opt/hbase-0.96/bin$ hbase shell  
    2. HBase Shell; enter 'help<RETURN>' for list of supported commands.  
    3. Type "exit<RETURN>" to leave the HBase Shell  
    4. Version 0.96.0-hadoop1, r1531434, Fri Oct 11 15:11:29 PDT 2013  
    5.   
    6. hbase(main):001:0>   


    输入help,会列出hbase shell所支持的命令

    shutdown是关闭hbase集群,exit是退出hbase shell。

    HBase Shell 练习

    建表

    hbase(main):006:0> create 'test','cf'

    列出所有表

    hbase(main):007:0> list
    TABLE                                                                               
    test                                                                                
    1 row(s) in 0.0440 seconds


    => ["test"]

    插入数据

    hbase(main):008:0> put 'test','row1','cf:a','value1'
    0 row(s) in 0.0750 seconds


    hbase(main):009:0> put 'test','row2','cf:b','value2'
    0 row(s) in 0.0080 seconds


    hbase(main):010:0> put 'test','row3','cf:c','value3'
    0 row(s) in 0.0060 seconds

    检查插入情况

    hbase(main):011:0> scan 'test'
    ROW                    COLUMN+CELL                                                  
     row1                  column=cf:a, timestamp=1386389158263, value=value1           
     row2                  column=cf:b, timestamp=1386389170821, value=value2           
     row3                  column=cf:c, timestamp=1386389185954, value=value3           
    3 row(s) in 0.0450 seconds

    get一行

    hbase(main):012:0> get 'test','row2'
    COLUMN                 CELL                                                         
     cf:b                  timestamp=1386389170821, value=value2                        
    1 row(s) in 0.0140 seconds


    disable之后drop表

    hbase(main):013:0> disable 'test'
    0 row(s) in 1.4220 seconds


    hbase(main):014:0> drop 'test'
    0 row(s) in 0.2740 seconds


    hbase(main):015:0> list
    TABLE                                                                               
    0 row(s) in 0.0270 seconds


    => []

  • 相关阅读:
    CodeSmith-Select
    winform显示、隐藏任务栏及开始菜单
    WinForm水印文本框
    添加自定义字体
    判断网络地址是否是自动获取
    设置本地网络为自动获取
    获取本地连接ip 掩码 网关 DNS
    指定WinCE部署路径
    SqlCeHelper
    docker netcore
  • 原文地址:https://www.cnblogs.com/gaochsh/p/7803295.html
Copyright © 2011-2022 走看看