安装全分布式hbase前需先安装 zookeeper
-- 配置zoo.cfg文件如下
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/local/zookeeper-3.4.6/data # import!
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.0=master:2888:3888
server.1=slave1:2888:3888
server.2=slave2:2888:3888
在/usr/local/zookeeper-3.4.6/data 目录下,新建 myid 文件, 内容为 0
将zookeeper的安装文件copy到slave1 和slave2节点。
sudo scp -r /usr/local/zookeeper-3.4 root@slave1:/usr/local/
相应的,需要把这两个节点的myid文件的内容该为1 和 2.
./bin/zkServer start 依次开启三个节点的zookeeper
./bin/zkServer status 查看节点的状态
在全分布式的hbase中, hbase-site.xml的文件内容
<configuration>
<property>
<name>hbase.cluster.distributed</name> <!-- 全分布式中必须配置-->
<value>true</value>
</property>
<property>
<name>hbase.rootdir</name> <!--可以配置为本地/home/.. hdfs下的hbase文件夹会自动创建 -->
<value>hdfs://master:9000/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name> <!--需要配置成与 zoo.cfg中的 dataDir中相同 -->
<value>/usr/local/zookeeper-3.4.6/data</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name> <!--开启zookeeper的节点 -->
<value>master,slave1,slave2</value>
</property>
</configuration>
开启regionserver 的节点放在 regionservers文件中 one per line
开启backup-master的节点 backup-masters文件中 one per line
-- 启动命令
[hadoop@master local]$ hbase-0.98.9-hadoop2/bin/start-hbase.sh
master: starting zookeeper, logging to /usr/local/hbase-0.98.9-hadoop2/bin/../logs/hbase-hadoop-zookeeper-master.out
slave2: starting zookeeper, logging to /usr/local/hbase-0.98.9-hadoop2/bin/../logs/hbase-hadoop-zookeeper-slave2.out
slave1: starting zookeeper, logging to /usr/local/hbase-0.98.9-hadoop2/bin/../logs/hbase-hadoop-zookeeper-slave1.out
slave1: starting regionserver, logging to /usr/local/hbase-0.98.9-hadoop2/bin/../logs/hbase-hadoop-regionserver-slave1.out
slave2: starting regionserver, logging to /usr/local/hbase-0.98.9-hadoop2/bin/../logs/hbase-hadoop-regionserver-slave2.out
slave1: starting master, logging to /usr/local/hbase-0.98.9-hadoop2/bin/../logs/hbase-hadoop-master-slave1.out
启动的顺序为 ,zk -> masterserver -> regionserver -> backup-masterserver