进入hbase下载页面,选择与hadoop版本相兼容的hbase版本。在这个页面使用ctrl+f搜索"S", 而后下面有一个表就是hbase与hadoop版本对应关系:html
我这里使用的hadoop版本是2.8.5,使用的hbase版本是2.1.1。java
新建一个/usr/hbase目录,而后下载hbase。node
使用tar xzvf hbase-XXX
命令解压hbase的包。解压完后,进入到解压好的hbase目录中,编辑conf/hbase-site.xml
,该文件时主要的hbase配置文件,配置hbase的数据存储目录,这个配置文件中,在官方文档说起到linux
You do not need to create the HBase data directory. HBase will do this for you. If you create the directory, HBase will attempt to do a migration, which is not what you want.shell
大概意思是,咱们不须要去建立hbase的数据目录,hbase会本身建一个目录来保存数据,若是咱们自定义了目录,那么hbase把数据进行迁移过来,这会致使性能以及时间上的一些损耗。apache
首先找到java的安装路径。而后使用vim /etc/profile
命令打开profile文件,而后指定JAVA_HOME:vim
由于我以前已经安装了hadoop,已经有hdfs了,因此,这里的hbase.rootdir
配置就要指向个人hadoop的hdfs目录,我是配置的core-site.xml中fs.defaultFS
配置:oop
个人hbase-site.xml配置以下:性能
<configuration> <property> <name>hbase.rootdir</name> <value>hdfs://localhost:9000/hbase</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/usr/hadoop/hbase/zookeeper</value> </property> <property> <name>hbase.unsafe.stream.capability.enforce</name> <value>false</value> <description> Controls whether HBase will check for stream capabilities (hflush/hsync). Disable this if you intend to run on LocalFileSystem, denoted by a rootdir with the 'file://' scheme, but be mindful of the NOTE below. WARNING: Setting this to false blinds you to potential data loss and inconsistent system state in the event of process and/or node failures. If HBase is complaining of an inability to use hsync or hflush it's most likely not a false positive. </description> </property> </configuration>
hbase.rootdir
指定hbase数据存储的地方hbase.zookeeper.property.dataDir
zookeeper也须要存储一些文件,该地方是指定zookeeper存储数据的地方运行bin/start-hbase.sh
,若是运行成功,使用jps命令可看到HMaster
进程启动成功:测试
另外访问<yourip>
:16010能看到HBase的管理页面:
进入到hbase的安装目录下,使用bin/hbase shell
启动hbase:
看到:
hbase(main):001:0>
表示hbase已经启动成功,能够直接使用hbase命令操做了。
create <table> <column family>
命令create 'test', 'cf'
表示建立一张test
的表,column family为cf
,建立表的时候table和column family缺一不可。
list <table>
确认某个表是否存在describe <table>
查看表的详细信息,包括默认值。put <table> <row> <column family> <value>
put值到某个表中由于HBase使用table/row/column family来肯定值的惟一性,因此在put值时,这些信息也是缺一不可的。
scan <table>
查看某个表中的数据get <table> <row>
获取某个表某行的数据disable <table>
禁用表若是须要删除表或更改表的设置,须要先使用该命令禁用表,禁用后也可使用enable <table>
来启用表。
enable <table>
启用表drop <table>
删除表最后退出HBase Shell: quit