赞
踩
1.到Hadoop安装目录下输入命令
sbin/start-all.sh [root@localhost hadoop-2.7.1]# sbin/start-all.sh This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh Starting namenodes on [localhost] root@localhost's password: localhost: starting namenode, logging to /usr/local/hadoop-2.7.1/logs/hadoop-root-namenode-localhost.localdomain.out root@localhost's password: localhost: starting datanode, logging to /usr/local/hadoop-2.7.1/logs/hadoop-root-datanode-localhost.localdomain.out Starting secondary namenodes [0.0.0.0] root@0.0.0.0's password: 0.0.0.0: starting secondarynamenode, logging to /usr/local/hadoop-2.7.1/logs/hadoop-root-secondarynamenode-localhost.localdomain.out starting yarn daemons starting resourcemanager, logging to /usr/local/hadoop-2.7.1/logs/yarn-root-resourcemanager-localhost.localdomain.out root@localhost's password: localhost: starting nodemanager, logging to /usr/local/hadoop-2.7.1/logs/yarn-root-nodemanager-localhost.localdomain.out
2.jps查看,在此过程中需要四次输入password
[root@localhost hadoop-2.7.1]# jps
7493 NameNode
8261 ResourceManager
8022 SecondaryNameNode
8809 Jps
8620 NodeManager
7726 DataNode
bin/start-hbase.sh
[root@localhost opt]# cd hbase-2.1.0/
[root@localhost hbase-2.1.0]# bin/start-hbase.sh
root@localhost's password:
localhost: running zookeeper, logging to /opt/hbase-2.1.0/bin/../logs/hbase-root-zookeeper-localhost.localdomain.out
running master, logging to /opt/hbase-2.1.0/logs/hbase-root-master-localhost.localdomain.out
: running regionserver, logging to /opt/hbase-2.1.0/logs/hbase-root-regionserver-localhost.localdomain.out
2.jps查看
[root@localhost hbase-2.1.0]# jps
11714 Jps
7493 NameNode
8261 ResourceManager
11397 HQuorumPeer
8022 SecondaryNameNode
11494 HMaster
8620 NodeManager
11596 HRegionServer
7726 DataNode
hbase shell
help
status
version
list
create 'Student','baseInfo','schoolInfo'
desc 'Student'
#禁用表
disable 'Student'
#检查表是否被禁用
is_disabled 'Student'
#启动表
enable 'Student'
#检查表是否被禁用
is_enable 'Student'
exists 'Student'
#删除表前需要禁用表
disable 'Student’
#删除表
drop ‘Student’
alter 'Student','teacherInfo'
alter 'Student',{NAME =>'teacherInfo',METHOD=>'delete'}
alter 'Student','delete'=>'teacherInfo'
alter 'Student',{NAME=>'baseInfo',VERSION=>3}
put 'Student', 'rowkey1','baseInfo:name','tom' put 'Student', 'rowkey1','baseInfo:birthday','1990-01-09' put 'Student', 'rowkey1','baseInfo:age','29' put 'Student', 'rowkey1','schoolInfo:name','Havard' put 'Student', 'rowkey1','schoolInfo:localtion','Boston' put 'Student', 'rowkey2','baseInfo:name','jack' put 'Student', 'rowkey2','baseInfo:birthday','1998-08-22' put 'Student', 'rowkey2','baseInfo:age','21' put 'Student', 'rowkey2','schoolInfo:name','yale' put 'Student', 'rowkey2','schoolInfo:localtion','New Haven' put 'Student', 'rowkey3','baseInfo:name','maike' put 'Student', 'rowkey3','baseInfo:birthday','1995-01-22 put 'Student', 'rowkey3','baseInfo:age','24' put 'Student', 'rowkey3','schoolInfo:name','yale' put 'Student', 'rowkey3','schoolInfo:localtion','New Haven'
#获取指定行中的所有列的数据信息
get 'Student','rowkey3'
#获取指定行中的所有列族下所有列的数据信息
get 'Student','rowkey3','baseInfo'
#获取指定行中指定列的数据信息
get 'Student','rowkey3','baseInfo:name'
#删除指定行
deleteall 'Student','rowkeys'
#删除指定行中指定列的数据
delete 'Student','rowkey3','baseInfo:name'
hbase中访问数据的两个基本方式:
scan可以设置begin和end参数来访问一个范围内的所有数据。get本质上就是begin和end相等的特殊情况的scan
#获取指定行中所有列的数据信息
get 'Student','rowkey1'
#获取指定行中指定列族的所有列信息
get 'Student','rowkey1','baseInfo'
#获取指定行的指定列的数据信息
get 'Student','rowkey1','baseInfo:name'
#获取指定行
get 'Student','rowkey1',{COLUMN=>'baseInfo:name',VERSION=>3}
scan 'Student'
scan 'Student',{COLUMN=>'baseInfo'}
#查询指定列的数据
scan ‘Student',{COLUMN=>'baseInfo:birthday'}
HBase 还支持 Limit(限制查询结果行数),STARTROW(ROWKEY 起始行,会先根据这个 key 定位到 region,再向后扫描)、STOPROW(结束行 不包含此行)、TIMERANGE(限定时间戳范围)、VERSIONS(版本数)、和 FILTER(按条件过滤行)等。
如下代表从 rowkey2 这个 rowkey 开始,查找下两个行的最新 3 个版本的 name 列的数据
scan 'Student', {COLUMNS=> 'baseInfo:name',STARTROW => 'rowkey2',STOPROW =>
'rowkey4',LIMIT=>2, VERSIONS=>3}
scan 'Student', FILTER=>"ValueFilter(=,'binary:24')"
scan 'Student', FILTER=>"ValueFilter(=,'substring:yale')"
scan 'Student', FILTER=>"ColumnPrefixFilter('birth')"
FILTER 中支持多个过滤条件通过括号、AND 和 OR 进行组合
scan 'Student', FILTER=>"ColumnPrefixFilter('birth') AND ValueFilter
ValueFilter(=,'substring:1998')"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。