HBase_在Linux上安装以及运用

1.上传解压文件

文件:hbase-1.0.1.1-bin.tar

2.更改配置文件

   在hbase-env.sh中,

      export JAVA_HOME=/home/lang/software/jdk1.8.0_121

      export HBASE_MANAGES_ZK=true

   

   在hbase-site.xml中

     <configuration>

        <property>

           <name>hbase.rootdir</name>

           <value>file:///home/lang/software/hbase</value>

        </property>

        <property>

           <name>hbase.zookeeper.property.dataDir</name>

           <value>/home/lang/software/zookeeper</value>

        </property>

     </configuration>

3.启动hbase

   $HBASE_HOME/bin/start-hbase.sh

打开jps如下图所示:

4.关闭hbase

   $HBASE_HOME/bin/stop-hbase.sh

5.进入HBase shell

5.0 $HBASE_HOME/bin/hbase shell

5.1创建表students,两个列族:info ,address

5.2 添加数据

put 'students','zhangsan','info:sno','001'

put 'students','zhangsan','info:sname','张三'

put 'students','zhangsan','address','天津'

5.3查询数据

get 'students','zhangsan'

5.4 更新数据

5.5 删除数据

delete 'students','zhangsan','address'

5.6 统计表的行数

count 'students'

5.7 清空表

truncate  'students

5.8 删除表

disable  'students'

drop  'students'

6.列族的数量是固定的,列的数量是添加数据时写

7.伪分布式安装将数据文件存储到HDFS上

修改hbase-site.xml文件:

 

    <configuration>

        <property>

           <name>hbase.cluster.distributed</name>

           <value>true</value>

        </property>

 

        <property>

           <name>hbase.rootdir</name>

           <value>hdfs://localhost:9000/hbase</value>

        </property>

        <property>

           <name>hbase.zookeeper.property.dataDir</name>

           <value>/home/lang/software/zookeeper</value>

        </property>

     </configuration>

在hdfs上建立hbase文件夹

 

posted @ 2017-04-05 13:09  calmLang  阅读(8623)  评论(0编辑  收藏  举报