总结的一些Hbase shell的命令
都很简单,可以help来查看帮助
标签:opt,info,Shell,hadoop,user,常用命令,test,Hbase,hbase From: https://blog.51cto.com/u_16255870/7535841create 'user_test','info'
describe 'user_test'
disable 'user_testinfo'
drop 'user_testinfo'
put 'user_test','test-1','info:username','test1'
put 'user_test','test-1','info','1'
put 'user_test','test-2','info:creattime','20101116'
list
scan 'user_test'
#可以指定startrow,stoprow来scan多个row
scan 'user_test',{COLUMNS =>'info:username',LIMIT =>10, STARTROW => 'test',STOPROW=>'test2'}
get 'user_test','test-1'
get 'user_test','test-1',{COLUMN => 'info:username'}
#删除某行的某一列,比如username那列的值
delete 'user_test','test-1','info:username'
#删除某行所有的列
deleteall 'user_test','test-2'
count 'user_test'
status 'detailed'
=======================================
基于现有的Hadoop集群,来搭建Hbase的环境
整个过程还是比较简单的
1. 下载Hbase源码,并解压
cp hbase-0.20.6.tar.gz /opt/hadoop/
cd /opt/hadoop/
tar zxvf hbase-0.20.6.tar.gz
ln -s hbase-0.20.6 hbase2.修改hbase-env.sh,加入java环境,并修改log位置
export JAVA_HOME=/opt/java/jdk
export HBASE_LOG_DIR=/opt/log/hbase
export HBASE_MANAGES_ZK=true3. 修改hbase-site.xml,配置hbase
<property>
<name>hbase.rootdir</name>
<value>hdfs://zw-hadoop-master:9000/hbase</value>
<description>The directory shared by region servers.</description>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
<description>The mode the cluster will be in. Possible values are
false: standalone and pseudo-distributed setups with managed Zookeeper
true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh)
</description>
</property>
<property>
<name>hbase.master</name>
<value>hdfs://zw-hadoop-master:60000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>zw-hadoop-slave225,zw-hadoop-slave226,zw-hadoop-slave227</value>
<description>Comma separated list of servers in the ZooKeeper Quorum. For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com". By default this is set to localhost for local and pseudo-distributed modes of operation. For a fully-distributed setup, this should be set to a full list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh this is the list of servers which we will start/stop ZooKeeper on.
</description>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/opt/log/zookeeper</value>
<description>Property from ZooKeeper's config zoo.cfg.
The directory where the snapshot is stored.
</description>
</property>几个配置的说明:
- hbase.rootdir设置hbase在hdfs上的目录,主机名为hdfs的namenode节点所在的主机
- hbase.cluster.distributed设置为true,表明是完全分布式的hbase集群
- hbase.master设置hbase的master主机名和端口
- hbase.zookeeper.quorum设置zookeeper的主机,官方推荐设置为3,5,7比较好
4. 编辑regionservers文件,设置regionservers的服务器,和hadoop的slaves一样即可
5. 启动Hbase
/opt/sohuhadoop/hbase/bin/start-hbase.sh
/opt/sohuhadoop/hbase/bin/stop-hbase.shHbase默认只有一个Master,我们可以也启动多个Master:
/opt/sohuhadoop/hbase/bin/hbase-daemon.sh start master
不过,其它的Master并不会工作,只有当主Master down掉后
其它的Master才会选择接管Master的工作
Hbase也有一个简单的web界面,来查看其状态
http://10.10.71.1:60010/master.jsphttp://10.10.71.1:60030/regionserver.jsp
http://10.10.71.1:60010/zk.jsp