http://archive.cloudera.com/cdh5/cdh/5/hbase-1.2.0-cdh5.7.5.tar.gz
2.解压
tar -zxvf hbase-1.2.0-cdh5.7.5.tar.gz
3.修改$HBASE_HOME/conf/hbase-env.sh
export JAVA_HOME=/opt/soft/jdk1.8.0_40
export HBASE_CLASSPATH=/opt/soft/hadoop-2.6.0-cdh5.7.0/etc/hadoop
export HBASE_PID_DIR=/opt/soft/hbase-1.2.0-cdh5.7.5/hbase/pids
export HBASE_MANAGES_ZK=true
4.修改$HBASE_HOME/conf/hbase-site.xml
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop01:8020/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>/opt/soft/hbase-1.2.0-cdh5.7.5/hbase/tmp</value>
</property>
5.修改regionservers(将主机名添加进去,每行一个)
hadoop01
6.修改环境变量(添加HBASE_HOME和PATH)
export HBASE_HOME=/opt/soft/hbase-1.2.0-cdh5.7.5
export PATH=$HBASE_HOME/bin:$PATH
7.启动hbase(打开hbaseUI界面进行查看,默认端口号是60010)
在启动hbase之前,首先启动hdfs的进程,因为hbase的底层存储依赖hdfs
# bin/start-hbase.sh
8.停止hbase
# bin/stop-hbase.sh
9.hbase基本的命令使用:
# cd bin/
# ./hbase
Usage: hbase [<options>] <command> [<args>]
Options:
--config DIR Configuration direction to use. Default: ./conf
--hosts HOSTS Override the list in 'regionservers' file
--auth-as-server Authenticate to ZooKeeper using servers configuration
Commands:
Some commands take arguments. Pass no args or -h for usage.
shell Run the HBase shell
hbck Run the hbase 'fsck' tool
snapshot Create a new snapshot of a table
snapshotinfo Tool for dumping snapshot information
wal Write-ahead-log analyzer
hfile Store file analyzer
zkcli Run the ZooKeeper shell
upgrade Upgrade hbase
master Run an HBase HMaster node
regionserver Run an HBase HRegionServer node
zookeeper Run a Zookeeper server
rest Run an HBase REST server
thrift Run the HBase Thrift server
thrift2 Run the HBase Thrift2 server
clean Run the HBase clean up script
classpath Dump hbase CLASSPATH
mapredcp Dump CLASSPATH entries required by mapreduce
pe Run PerformanceEvaluation
ltt Run LoadTestTool
version Print the version
CLASSNAME Run the class named CLASSNAME
简单使用一下命令:# ./hbase shell
hbase(main):004:0> help
HBase Shell, version 1.2.0-cdh5.7.5, rUnknown, Wed Nov 2 12:02:54 PDT 2016
Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command.
Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group.
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_mob, compact_rs, flush, major_compact, major_compact_mob, 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
SHELL USAGE:
Quote all names in HBase Shell such as table and column names. Commas delimit
command parameters. Type <RETURN> after entering a command to run it.
Dictionaries of configuration used in the creation and alteration of tables are
Ruby Hashes. They look like this:
{'key1' => 'value1', 'key2' => 'value2', ...}
and are opened and closed with curley-braces. Key/values are delimited by the
'=>' character combination. Usually keys are predefined constants such as
NAME, VERSIONS, COMPRESSION, etc. Constants do not need to be quoted. Type
'Object.constants' to see a (messy) list of all constants in the environment.
If you are using binary keys or values and need to enter them in the shell, use
double-quote'd hexadecimal representation. For example:
hbase> get 't1', "key\x03\x3f\xcd"
hbase> get 't1', "key\003\023\011"
hbase> put 't1', "test\xef\xff", 'f1:', "\x01\x33\x40"
The HBase shell is the (J)Ruby IRB with the above HBase-specific commands added.
For more on the HBase Shell, see http://hbase.apache.org/book.html
创建一张表:
create 'user','info'
查看有多少张表:
list
描述表:
describe 'user'
插入数据:
put 'user','10001','info:name','zhangsan'
put 'user','10001','info:age','25'
数据查询的方式:
* 依据rowkey查询,最快的(查询结果按照rowkey排序)
get 'user','10001'
* 范围查询
scan range
scan 'user',{COLUMNS=>['info:name','info:age']} -->过滤数据
* 全表扫描
scan 'user'
删除数据:
delete 'user','10001','info:name'
删除所有数据:
deleteall 'user','10001'