hbase增加backup master

原文:http://www.oratea.net/?p=1177

为了增加hbase集群的可用性,可以为hbase增加多个backup master。当master挂掉后,backup master可以自动接管整个hbase的集群。

配置backup master的方式是在hbase的conf下增加文件backup-masters,在该文件里面增加backup master的机器列表,每台机器一条记录。

如:

hadoop02

整个集群启动后,在hadoop02的机器上也会启动hmaster的进程:

4301 Jps
4175 HMaster

查看hadoop02上该master的log,可以看到如下的信息:

2012-04-10 05:53:10,120 INFO org.apache.hadoop.hbase.master.ActiveMasterManager: Another master is the active master, 
   hadoop01,60000,1334008045435; waiting to become the next active master

该信息说明,当前hbase集群有活动的master节点,该master节点为hadoop01,所以hadoop02节点开始等待,直到hadoop01上的master挂掉。hadoop02会变成新的hmaster节点。

当当前的master挂掉后,backup master会接管,进而变成新的active master

2012-04-10 06:48:52,436 DEBUG org.apache.hadoop.hbase.master.ActiveMasterManager: No master available. Notifying waiting threads
2012-04-10 06:48:52,438 INFO org.apache.hadoop.hbase.master.ActiveMasterManager: Master=hadoop02,60000,1334011638701
2012-04-10 06:48:52,443 DEBUG org.apache.hadoop.hbase.master.ActiveMasterManager: A master is now available
# 从start-hbase.sh里找到,这应该也是hbase的启动顺序?

$bin/hbase-daemons.sh --config "${HBASE_CONF_DIR}" start zookeeper
$bin/hbase-daemon.sh --config "${HBASE_CONF_DIR}" start master

$bin/hbase-daemons.sh --config "${HBASE_CONF_DIR}" --hosts "${HBASE_REGIONSERVERS}" start regionserver
$bin/hbase-daemons.sh --config "${HBASE_CONF_DIR}" --hosts "${HBASE_BACKUP_MASTERS}" start master-backup

# 手工、本地启动master?
$bin/hbase-daemon.sh --config "${HBASE_CONF_DIR}" start master
$bin/hbase-daemon.sh --config "${HBASE_CONF_DIR}" start master --backup