help命令帮助
COMMAND GROUPS:
Group name: general
Commands: status, table_help, version, whoami
Group name: ddl
Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, locate_region, show_filters
Group name: namespace
Commands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables
Group name: dml
Commands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve
Group name: tools
Commands: assign, balance_switch, balancer, balancer_enabled, catalogjanitor_enabled, catalogjanitor_run, catalogjanitor_switch, close_region, compact, compact_rs, flush, major_compact, merge_region, move, normalize, normalizer_enabled, normalizer_switch, split, trace, unassign, wal_roll, zk_dump
Group name: replication
Commands: add_peer, append_peer_tableCFs, disable_peer, disable_table_replication, enable_peer, enable_table_replication, list_peers, list_replicated_tables, remove_peer, remove_peer_tableCFs, set_peer_tableCFs, show_peer_tableCFs
Group name: snapshots
Commands: clone_snapshot, delete_all_snapshot, delete_snapshot, list_snapshots, restore_snapshot, snapshot
Group name: configuration
Commands: update_all_config, update_config
Group name: quotas
Commands: list_quotas, set_quota
Group name: security
Commands: grant, list_security_capabilities, revoke, user_permission
Group name: procedures
Commands: abort_procedure, list_procedures
Group name: visibility labels
Commands: add_labels, clear_auths, get_auths, list_labels, set_auths, set_visibility
基础命令
#habase命令 帮助
help
#查询集群的状态:
status
#查询HBase有那些表
list
#创建命令帮助查看
help "create"
#如何创建一张表
格式: create ‘表名’,‘列族名称1‘, '列族名称2‘ ...
create 'table01','colm01','colm02'
#查看表信息
describe "table01"
#禁用表信息/启用表信息
disable "table01" / enable "table01"
#删除表
drop "table01"
#新增数据
put "table01" ,"rk001","colm1:name","lixiuyang"
put "table01" ,"rk001","colm1:sex","男"
put "table01" ,"rk001","colm2:address","hn"
put "table01" ,"rk001","colm2:phone","110"
put "table01" ,"rk002","colm1:name","liyutong"
put "table01" ,"rk002","colm1:sex","女"
put "table01" ,"rk002","colm2:address","hb"
put "table01" ,"rk002","colm2:phone","120"
#查询数据某一个rowkey的数据
get '表名','rowkey',['列族1','列族2' ...],['列族1:列名'],['列族1','列族2:列名' ...]
get "table01" ,"rk001","colm01"
#扫描查询
scan '表名',[{COLUMNS =>['列族1','列族2']} | {COLUMNS =>['列族1:列名','列族2'],VERSIONS=>N} ] [{LIMIT =>N}]
范围查询的格式: scan '表名', {COLUNMS=>['列族1','列族2']} | {COLUMNS =>['列族1:列名','列族2'], STARTROW =>'起始rowkey
的值', NEDROW=>'结束rowkey'}
注意: 包头不包尾
说明:
{FORMATTER =>'toString'} : 用于显示中文
{LIMIT =>N} : 显示前 N条数据
scan "table01"
scan "table01" , {COLUMN=>'colm01'}
#全扫 指定条件
scan "table01" ,{STARTROW=>'rk001',STOPROW=>'rk002'}
#查看所有记录
scan "table01",{RAW=>true,VERSIONS=>10}
#指定时间戳
put "table01" ,'rk001','colm1:name','wangwu', 16540856328432
#修改数据
修改与添加数据的操作 是一致的, 只需要保证 rowkey相同 就是 修改操作
put "table01" ,'rk001',"colm01:name","yutian"
#删除数据
delete '表名','rowkey','列族:列名'
delete "table01","rk002","colm01:name"
#删除整行数据
deleteall 'table01','rk004'
#清空表
truncate "table01"
#统计表数据
count 'table01'
#查看明明空间
list_namespace
list_namespace_tables 'weibo'
#修改列族版本信息
alter 'student',{NAME=>'info',VERSIONS=>3}
删除 是删除所有版本
type=DeleteColumn
type=DeleteFamily
deleteall=删除所有列族
删除最近的一个版本
Delete: addColumn
addColumns
scan:只返回最大时间戳版本数据
sacn 'stu2',{RAW=>TRUE,VERSIONS=>5}
搭建HBase
第一步:配置 hbase-site.xml
第二步:配置 regionservers
第三步:配置 HBase配置环境变量
第四步:启动 start-hbase.sh
bin目录下可执行脚本:
主要有:
sh hbase-daemon.sh start master
sh stop-hbase.sh
sh start-hbase.sh
-rwxr-xr-x 1 root root 5805 1月 29 2016 graceful_stop.sh
-rwxr-xr-x 1 root root 4541 12月 27 2015 hbase-cleanup.sh
-rwxr-xr-x 1 root root 1537 12月 27 2015 hbase-common.sh
-rwxr-xr-x 1 root root 4724 1月 29 2016 hbase-config.sh
-rwxr-xr-x 1 root root 9450 12月 31 2015 hbase-daemon.sh
-rwxr-xr-x 1 root root 1605 12月 27 2015 hbase-daemons.sh
-rwxr-xr-x 1 root root 1912 1月 29 2016 local-master-backup.sh
-rwxr-xr-x 1 root root 1858 12月 27 2015 local-regionservers.sh
-rwxr-xr-x 1 root root 2271 12月 27 2015 master-backup.sh
-rwxr-xr-x 1 root root 2527 12月 27 2015 regionservers.sh
-rwxr-xr-x 1 root root 5711 1月 29 2016 rolling-restart.sh
-rwxr-xr-x 1 root root 1986 12月 27 2015 start-hbase.sh
-rwxr-xr-x 1 root root 2236 12月 27 2015 stop-hbase.sh
-rwxr-xr-x 1 root root 1870 12月 27 2015 zookeepers.sh
Hive集成Hbase:
1.在hive创建后,hbase会自动创建映射表
2.原有的hive数据存储目录不在存储数据,hbase将会接收存储数据
3.hbase已经存在表,hive关联只能用外部表创建
4.hbase高可用基于选举机制
5.master节点挂掉,会影响表的创建,但不会影响数据的新增,查询
6.hive和hbase版本管理可以使用cdh
高可用
在 HBase中HMaster 负责监控 HRegionServer的生命周期,均衡RegionServer 的负载,
如果 HMaster 挂掉了,那么整个HBase集群将陷入不健康的状态,并且此时的工作状态并
不会维持太久。所以 HBase 支持对
1.关闭Bbase集群 bin/stop-hbase.sh
2.在conf目录下创建backup-masters文件
例如:100节点
echo hadoop101> conf/backup-masters
3.分发配置到其它节点
scp -r conf/ hadoop101:hbase_home/
scp -r conf/ hadoop102:hbase_home/
解决版本兼容问题
编译源码-替换jar包(hive-hbase-handler-1.2.1.jar)
jar位置:hive_home/lib