zoukankan      html  css  js  c++  java
  • HBase(3)-安装与Shell操作

    一. 安装

    1. 启动Zookeeper集群

    2. 启动Hadoop集群

    3. 上传并解压HBase

    tar -zxvf hbase-1.3.1-bin.tar.gz -C /opt/module

    4. 修改配置文件

    #修改habse-env.sh
    export JAVA_HOME=/opt/module/jdk1.8.0_144
    export HBASE_MANAGES_ZK=false
    JDK1.8需要注释
    #export HBASE_MASTER_OPTS。。。。
    #export HBASE_REGIONSERVER_OPTS。。。
    #修改hbase-site.xml
    <configuration>
        <property>     
            <name>hbase.rootdir</name>     
            <value>hdfs://hadoop102:9000/hbase</value>   
        </property>
    
        <property>   
            <name>hbase.cluster.distributed</name>
            <value>true</value>
        </property>
    
       <!-- 0.98后的新变动,之前版本没有.port,默认端口为60000 -->
        <property>
            <name>hbase.master.port</name>
            <value>16000</value>
        </property>
    
        <property>   
            <name>hbase.zookeeper.quorum</name>
             <value>hadoop102:2181,hadoop103:2181,hadoop104:2181</value>
        </property>
    
        <property>   
            <name>hbase.zookeeper.property.dataDir</name>
             <value>/opt/module/zookeeper-3.4.10/zkData</value>
        </property>
    </configuration>
    #修改regionservers
    hadoop100
    hadoop101
    hadoop102
    #软连接hadoop配置文件到hbase
    ln -s /opt/module/hadoop-2.7.2/etc/hadoop/core-site.xml 
    /opt/module/hbase/conf/core-site.xml
    
    ln -s /opt/module/hadoop-2.7.2/etc/hadoop/hdfs-site.xml 
    /opt/module/hbase/conf/hdfs-site.xml

    5. 分发HBase

    xsync hbase

    6. 启动服务

    #cd到hbase目录下
    #启动
    bin/start-hbase.sh
    
    #停止
    bin/stop-hbase.sh

    7. 查看HBase页面

    http://hadoop100:16010

    二. Shell操作

    cd到hbase的目录下

    1. 基本操作

    进入客户端

    bin/hbase shell

    查看帮助命令

    help

     查看当前库中的表

    list

    2. 表操作

    -- 创建表
    hbase(main):002:0> create 'student','info'
    
    -- 插入数据到表
    hbase(main):003:0> put 'student','1001','info:sex','male'
    hbase(main):004:0> put 'student','1001','info:age','18'
    hbase(main):005:0> put 'student','1002','info:name','Janna'
    hbase(main):006:0> put 'student','1002','info:sex','female'
    hbase(main):007:0> put 'student','1002','info:age','20'
    
    -- 扫描查看表数据
    hbase(main):008:0> scan 'student'
    hbase(main):009:0> scan 'student',{STARTROW => '1001', STOPROW  => '1001'}
    hbase(main):010:0> scan 'student',{STARTROW => '1001'}
    
    -- 查看表结构
    hbase(main):011:0> describe 'student'
    
    -- 更新指定字段的数据
    hbase(main):012:0> put 'student','1001','info:name','Nick'
    hbase(main):013:0> put 'student','1001','info:age','100'
    
    -- 查看“指定行”或“指定列族:列”的数据
    hbase(main):014:0> get 'student','1001'
    hbase(main):015:0> get 'student','1001','info:name'
    
    -- 统计表数据行数
    hbase(main):021:0> count 'student'
    
    -- 删除数据
    -- 删除某rowkey的全部数据:
    hbase(main):016:0> deleteall 'student','1001'
    -- 删除某rowkey的某一列数据:
    hbase(main):017:0> delete 'student','1002','info:sex'
    
    -- 清空表数据
    hbase(main):018:0> truncate 'student'
    -- 提示:清空表的操作顺序为先disable,然后再truncate
    
    -- 删除表
    -- 首先需要先让该表为disable状态:
    hbase(main):019:0> disable 'student'
    -- 然后才能drop这个表:
    hbase(main):020:0> drop 'student'
    -- 提示:如果直接drop表,会报错:ERROR: Table student is enabled. Disable it first.
    
    -- 表更表操作
    hbase(main):022:0> alter 'student',{NAME=>'info',VERSIONS=>3}
    hbase(main):022:0> get 'student','1001',{COLUMN=>'info:name',VERSIONS=>3}
  • 相关阅读:
    7、cad图纸打印
    对账
    练习10—去掉图片文字
    6、cad里面如何快速将图纸的线条全部变成黑色
    5、cad如何快速选中图纸上所有文字
    4、如何修改cad的背景色为白色
    练习九—快速修饰面部光影
    iOS alloc&init探索
    export default / export const
    Vue2.0+组件库总结
  • 原文地址:https://www.cnblogs.com/duoduotouhenying/p/10235052.html
Copyright © 2011-2022 走看看