as some distribute systems ,a spare/second master is always supplied to guarantee high availablity.
like hbase,u can run some backup masters against with master,when the real master is failure,then the backup ones will compete to manage to znode set in zookeeper,and all others will stay in backup state sparely.
flow chart
Add backup master(s)
1.add some hosts to backup-masters under dir conf(but this hosts should NOT run master simutaneously)
also,if u want to run certain backups on the same node with master,u can do this:
local-master-backup.sh start offset1 offset2 ...
the offsets are used to specify the increasement ports to be added to base line:60000 for master port,60010 for master.info.port
2.run 'start-hbase.sh' to start up backups.then the backups will only stay in standby mode to loop and check whether the current master have been failure.
/** * Try becoming active master. * @param startupStatus * @return True if we could successfully become the active master. * @throws InterruptedException */ private boolean becomeActiveMaster(MonitoredTask startupStatus) throws InterruptedException { // TODO: This is wrong!!!! Should have new servername if we restart ourselves, // if we come back to life. this.activeMasterManager = new ActiveMasterManager(zooKeeper, this.serverName, this); this.zooKeeper.registerListener(activeMasterManager); stallIfBackupMaster(this.conf, this.activeMasterManager); //for backup master only // The ClusterStatusTracker is setup before the other // ZKBasedSystemTrackers because it's needed by the activeMasterManager // to check if the cluster should be shutdown. this.clusterStatusTracker = new ClusterStatusTracker(getZooKeeper(), this); this.clusterStatusTracker.start(); return this.activeMasterManager.blockUntilBecomingActiveMaster(startupStatus, this.clusterStatusTracker); }
/** * Block until becoming the active master. * * Method blocks until there is not another active master and our attempt * to become the new active master is successful. * * This also makes sure that we are watching the master znode so will be * notified if another master dies. * @param startupStatus * @return True if no issue becoming active master else false if another * master was running or if some other problem (zookeeper, stop flag has been * set on this Master) */ boolean blockUntilBecomingActiveMaster(MonitoredTask startupStatus, ClusterStatusTracker clusterStatusTracker) { while (true) { startupStatus.setStatus("Trying to register in ZK as active master"); // Try to become the active master, watch if there is another master. // Write out our ServerName as versioned bytes. try { String backupZNode = ZKUtil.joinZNode( this.watcher.backupMasterAddressesZNode, this.sn.toString()); if (ZKUtil.createEphemeralNodeAndWatch(this.watcher, this.watcher.masterAddressZNode, this.sn.getVersionedBytes())) { //要在-本次-调用中直接建立master node成功,成为active // If we were a backup master before, delete our ZNode from the backup // master directory since we are the active now LOG.info("Deleting ZNode for " + backupZNode + " from backup master directory"); ZKUtil.deleteNodeFailSilent(this.watcher, backupZNode); //不一定存在backup node // We are the master, return startupStatus.setStatus("Successfully registered as active master."); this.clusterHasActiveMaster.set(true); LOG.info("Master=" + this.sn); return true; } // There is another active master running elsewhere or this is a restart // and the master ephemeral node has not expired yet. this.clusterHasActiveMaster.set(true); /* * Add a ZNode for ourselves in the backup master directory since we are * not the active master. * * If we become the active master later, ActiveMasterManager will delete * this node explicitly. If we crash before then, ZooKeeper will delete * this node for us since it is ephemeral. */ LOG.info("Adding ZNode for " + backupZNode + " in backup master directory"); ZKUtil.createEphemeralNodeAndWatch(this.watcher, backupZNode, this.sn.getVersionedBytes()); String msg; byte [] bytes = ZKUtil.getDataAndWatch(this.watcher, this.watcher.masterAddressZNode); if (bytes == null) { msg = ("A master was detected, but went down before its address " + "could be read. Attempting to become the next active master"); } else { ServerName currentMaster = ServerName.parseVersionedServerName(bytes); if (ServerName.isSameHostnameAndPort(currentMaster, this.sn)) { msg = ("Current master has this master's address, " + currentMaster + "; master was restarted? Deleting node."); // Hurry along the expiration of the znode. ZKUtil.deleteNode(this.watcher, this.watcher.masterAddressZNode); } else { msg = "Another master is the active master, " + currentMaster + "; waiting to become the next active master"; } } LOG.info(msg); startupStatus.setStatus(msg); } catch (KeeperException ke) { master.abort("Received an unexpected KeeperException, aborting", ke); return false; } synchronized (this.clusterHasActiveMaster) { //interact with zk events in this class while (this.clusterHasActiveMaster.get() && !this.master.isStopped()) { try { //已经有另一atcive master,wait to become new active one NOTE this.clusterHasActiveMaster.wait(); //notified by this.handleMasterNodeChange() } catch (InterruptedException e) { // We expect to be interrupted when a master dies, will fall out if so LOG.debug("Interrupted waiting for master to die", e); } } if (!clusterStatusTracker.isClusterUp()) { this.master.stop("Cluster went down before this master became active"); } if (this.master.isStopped()) { return false; } // Try to become active master again now that there is no active master } } }
simulate the failure of master
1.kill the master
2.after a while,one the backup masters will takes over the failure master,and the others will keep in their original state.
one backup enter the new master state
// We are either the active master or we were asked to shutdown if (!this.stopped) { finishInitialization(startupStatus, false); loop(); //stick this thread like daemon,so this process is in background }
相关推荐
hbase-daemon.sh start master ``` 以上步骤涵盖了HBase的基本安装与配置流程。需要注意的是,在实际操作过程中还需根据具体的环境进行相应的调整。此外,为了保证系统的稳定性和高效性,建议定期检查和优化配置...
配置文件包括hdfs-site.xml、hbase-env.sh、hbase-site.xml、regionservers和backup-master等。例如,在hbase-env.sh中,需设置JAVA_HOME、HADOOP_HOME等环境变量,并在hbase-site.xml中配置HBase的数据目录、...
为了成功地执行备份操作,文档强调了必须正确配置一系列的参数,包括设置hbase.backup.enable为true,以及为hbase.master.logcleaner.plugins、hbase.procedure.master.classes和hbase.procedure.regionserver....
如何添加backup的master 为了提高系统的可用性,可以在HBase集群中添加一个或多个备份Master。这可以通过修改`hbase-site.xml`文件中的`hbase.master.info.port`和`hbase.master.info.address`属性来实现,指定多...
class org.apache.hadoop.hbase.backup.HFileArchiver$FileablePath, file:hdfs://nameservice1/hbase/data/default/RASTER/92ceb2d86662ad6d959f4cc384229e0f/i, class org.apache.hadoop.hbase.backup....
- 在此之前,检查配置项`hbase.master.backup`,确认当前Master是否为备份Master。如果是,则直接阻塞。 以上是对HBase源码中Master启动过程的部分解析,这些步骤有助于理解HBase在启动时如何初始化Master组件,并...
- **HMaster**(Master):负责管理和协调整个集群中的HRegionServer。 - 分配Region至HRegionServer。 - 维护集群的负载均衡。 - 监控HRegionServer的状态。 - 处理失效Region的重新分配。 - **HRegionServer**...
14.7. HBase Backup 14.8. Capacity Planning 15. 创建和开发 HBase 15.1. HBase 仓库 15.2. IDEs 15.3. 创建 HBase 12-5-30 HBase 官方文档 3/81 abloz.com/hbase/book.htm 15.4. Publishing a new version of ...
### HBase源码分析——关键知识点详解 #### 一、HBase性能测试总结与环境配置 ... - 检查配置项“hbase.master.backup”,确定自身是否为备份Master,如果是,则Block直到检测到系统中存在Active Master。
【标题】"Backup-Repo:Astro(HBase上的Spark SQL)的发行版本已移至" 指的是一个关于 Astro 项目的更新,这个项目是基于 HBase 的 Spark SQL 实现,用于提供在 HBase 数据库上执行 SQL 查询的能力。 Astro 的最新...
1. 在master1、master2和slave1上安装并配置HBase。 2. 安装OpenTSDB,并确保其依赖于HBase。 3. 配置Flink将处理后的数据写入OpenTSDB。 #### 六、数据可视化 最后,使用Grafana搭建数据可视化平台,将从OpenTSDB...
HBase 为用户提供了一个非常方便的命令行使用方式——HBase Shell。 HBase Shell 提供了大多数的 HBase 命令...1 active master,0 backup masters, 1 servers,0 dead,4.0000 average load 2. 查询版本号 hbase(main):
- **组件安装**:在master1、master2和slave1上分别安装Flume、Kafka、Flink、HBase和OpenTSDB。 #### yum源配置 - **更改yum源**:为了提高软件包的下载速度,项目将默认的yum源更改为网易的yum源。 - 备份原有的...
- **60000** (hbase.master.port):用于IPC通信。 - **60010** (hbase.master.info.port):用于HTTP访问。 - **HRegionServer** - **60020** (hbase.regionserver.port):用于IPC通信。 - **60030** (hbase....
Cloudera Impala 是一款用于查询存储在 Hadoop 分布式文件系统 (HDFS) 和 HBase 中的数据的高性能 MPP (Massively Parallel Processing) SQL 引擎。它能够提供与传统商业数据仓库相当的性能,同时具备 Hadoop 的扩展...
- 提供与Hadoop兼容的文件系统,可用于HDFS、Hadoop、Spark、Flink、Presto、HBase等大数据处理工具。 7. **APIs**: - 提供丰富的API接口,方便与其他系统集成。 8. **Replication and Backup**: - 集成了...
4. NoSQL 产品如 Cassandra、HBase,适用于实时分析、分布式存储。 5. SQL 语句分为 DDL(定义)、DML(操作)、DCL(控制)、TCL(事务),关键字如 CREATE、INSERT、GRANT、COMMIT。 6. char(4)固定长度,varchar...
2. **列存储数据库**:这类数据库以列簇形式存储数据,代表产品包括Cassandra、HBase、Riak等。适合应用于分布式的文件系统。优点是查找速度快,易于分布式扩展,但功能相对有限。 3. **文档型数据库**:这类...