首先上传解压:
tar -zxvf
配置环境变量:
1.[[email protected] conf]# vi hbase-site.xml
添加:export JAVA_HOME=/root/soft/jdk1.8.0_191
2.在HBASE-site.xml里添加:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///home/testuser/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/testuser/zookeeper</value>
</property>
</configuration>
3。配置环境变量
export HBASE_HOME=/root/soft/hbase-0.98.12.1-hadoop2
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ZOOKEEPER_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin
完成之后需要执行:
source /etc/profile
启动:start-hbase.sh
能访问到这个界面就说明成功了。
注意:第一法访问的时候会有一个bug,大概意思是和zookeeper端口号占用了,所以jps一下,将2181端口号先杀死
进入HBASE的建表状态,使用命令:
HBASE shell
hbase创建表:
[[email protected] ~]# hbase shell
2019-01-12 21:23:31,717 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.l
ib.availableHBase Shell; enter \'help<RETURN>\' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.98.12.1-hadoop2, rb00ec5da604d64a0bdc7d92452b1e0559f0f5d73, Sun May 17 12:55:03 PDT 2015
hbase(main):001:0> create \'test\',\'cf\'
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/soft/hbase-0.98.12.1-hadoop2/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLo
ggerBinder.class]SLF4J: Found binding in [jar:file:/root/soft/hadoop/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf
4j/impl/StaticLoggerBinder.class]SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
0 row(s) in 2.3730 seconds
=> Hbase::Table - test
hbase(main):002:0>
HBASE中插入数据用put
如果不知道怎么使用,可以help,或者输入一半,等待程序会提示的。
在HBASE的终端页面,是不能正常删除的,需要将光标移动到前边,倒着删除,或者按住Ctrl键删除
HBASE中插入数据,获取数据的命令:
hbase(main):002:0> put
ERROR: wrong number of arguments (0 for 4)
Here is some help for this command:
Put a cell \'value\' at specified table/row/column and optionally
timestamp coordinates. To put a cell value into table \'ns1:t1\' or \'t1\'
at row \'r1\' under column \'c1\' marked with the time \'ts1\', do:
hbase> put \'ns1:t1\', \'r1\', \'c1\', \'value\'
hbase> put \'t1\', \'r1\', \'c1\', \'value\'
hbase> put \'t1\', \'r1\', \'c1\', \'value\', ts1
hbase> put \'t1\', \'r1\', \'c1\', \'value\', {ATTRIBUTES=>{\'mykey\'=>\'myvalue\'}}
hbase> put \'t1\', \'r1\', \'c1\', \'value\', ts1, {ATTRIBUTES=>{\'mykey\'=>\'myvalue\'}}
hbase> put \'t1\', \'r1\', \'c1\', \'value\', ts1, {VISIBILITY=>\'PRIVATE|SECRET\'}
The same commands also can be run on a table reference. Suppose you had a reference
t to table \'t1\', the corresponding command would be:
hbase> t.put \'r1\', \'c1\', \'value\', ts1, {ATTRIBUTES=>{\'mykey\'=>\'myvalue\'}}
hbase(main):003:0> put \'test\',\'1111\',\'cf:age\',\'11\'
0 row(s) in 0.3450 seconds
hbase(main):004:0> put \'test\',\'1111\',\'cf:age\',\'12\'
0 row(s) in 0.0100 seconds
hbase(main):005:0> get \'test\',\'1111\'
COLUMN CELL
cf:age timestamp=1547299833051, value=12
1 row(s) in 0.0500 seconds
hbase(main):006:0> scan \'test\'
ROW COLUMN+CELL
1111 column=cf:age, timestamp=1547299833051, value=12
1 row(s) in 0.0670 seconds
hbase(main):007:0>
HBASE中scan和get的区别