1.下载解压最新版本:http://hbase.apache.org/
2.解压缩:
$ tar xfz hbase-0.95-SNAPSHOT.tar.gz
现在你已经可以启动HBase了。但是你可能需要先编辑 conf/hbase-site.xml
去配置hbase.rootdir
,来选择HBase将数据写到哪个目录 .
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://cloud001:9000/hbase</value>
</property>
</configuration>
将 DIRECTORY
替换成你期望写文件的目录. 默认 hbase.rootdir
是指向 /tmp/hbase-${user.name}
,也就说你会在重启后丢失数据(重启的时候操作系统会清理/tmp
目录),自己设置的为:hdfs://cloud001:9000/hbase
3.启动Hbase
现在启动HBase:
$ ./bin/start-hbase.sh starting Master, logging to logs/hbase-user-master-example.org.out
现在你运行的是单机模式的Hbaes。所有的服务都运行在一个JVM上,包括HBase和Zookeeper。HBase的日志放在logs
目录,当你启动出问题的时候,可以检查这个日志。
5.完全分布式模式
要想运行完全分布式模式,你要进行如下配置,先在 hbase-site.xml
, 加一个属性 hbase.cluster.distributed
设置为 true
然后把 hbase.rootdir
设置为HDFS的NameNode的位置。 例如,你的namenode运行在namenode.example.org,端口是9000 你期望的目录是 /hbase
,使用如下的配置
<configuration> ... <property> <name>hbase.rootdir</name> <value>hdfs://namenode.example.org:9000/hbase</value> <description>The directory shared by RegionServers. </description> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> <description>The mode the cluster will be in. Possible values are false: standalone and pseudo-distributed setups with managed Zookeeper true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh) </description> </property> ... </configuration>6. regionservers
完全分布式模式的还需要修改conf/regionservers
. 在 Section 2.7.1.2, “regionservers
” 列出了你希望运行的全部 HRegionServer,一行写一个host (就像Hadoop里面的 slaves
一样). 列在这里的server会随着集群的启动而启动,集群的停止而停止.