hbase1.1.3 启动一

原创 2016年06月01日 19:18:22

1. HMaster中有个main方法,这是HMaster启动的开始的地方

  /**
   * @see org.apache.hadoop.hbase.master.HMasterCommandLine
   */
  public static void main(String [] args) {
    VersionInfo.logVersion();
    new HMasterCommandLine(HMaster.class).doMain(args);
  }
  
2. 接下来我们来看看HMasterCommandLine的doMain方法所进行的工作

  /**
   * Parse and run the given command line. This may exit the JVM if
   * a nonzero exit code is returned from <code>run()</code>.
   */
  public void doMain(String args[]) {
    try {
      int ret = ToolRunner.run(HBaseConfiguration.create(), this, args);
      if (ret != 0) {
        System.exit(ret);
      }
    } catch (Exception e) {
      LOG.error("Failed to run", e);
      System.exit(-1);
    }
  }
}


  public static int run(Configuration conf, Tool tool, String[] args) 
    throws Exception{
    if(conf == null) {
      conf = new Configuration();
    }
    GenericOptionsParser parser = new GenericOptionsParser(conf, args);
    //set the configuration back, so that Tool can configure itself
    tool.setConf(conf);
    
    //get the args w/o generic hadoop args
    String[] toolArgs = parser.getRemainingArgs();
    return tool.run(toolArgs);
  }

上面run方法的tool参数为HMasterCommandLine实例,调用了HMasterCommandLine的run来启动hbase.
String command = remainingArgs.get(0);
 
if ("start".equals(command)) {
    return startMaster();
} else if ("stop".equals(command)) {
    return stopMaster();
} else if ("clear".equals(command)) {
    return (ZNodeClearer.clear(getConf()) ? 0 : 1);
} else {
    usage("Invalid command: " + command);
    return 1;
}

--具体启动的函数HMasterCommandLine.startMaster
  private int startMaster() {
    Configuration conf = getConf();
    try {
      // If 'local', defer to LocalHBaseCluster instance.  Starts master
      // and regionserver both in the one JVM.
      if (LocalHBaseCluster.isLocal(conf)) {
        DefaultMetricsSystem.setMiniClusterMode(true);
        final MiniZooKeeperCluster zooKeeperCluster = new MiniZooKeeperCluster(conf);
        File zkDataPath = new File(conf.get(HConstants.ZOOKEEPER_DATA_DIR));


        // find out the default client port
        int zkClientPort = 0;


        // If the zookeeper client port is specified in server quorum, use it.
        String zkserver = conf.get(HConstants.ZOOKEEPER_QUORUM);
        if (zkserver != null) {
          String[] zkservers = zkserver.split(",");


          if (zkservers.length > 1) {
            // In local mode deployment, we have the master + a region server and zookeeper server
            // started in the same process. Therefore, we only support one zookeeper server.
            String errorMsg = "Could not start ZK with " + zkservers.length +
                " ZK servers in local mode deployment. Aborting as clients (e.g. shell) will not "
                + "be able to find this ZK quorum.";
              System.err.println(errorMsg);
              throw new IOException(errorMsg);
          }


          String[] parts = zkservers[0].split(":");


          if (parts.length == 2) {
            // the second part is the client port
            zkClientPort = Integer.parseInt(parts [1]);
          }
        }
        // If the client port could not be find in server quorum conf, try another conf
        if (zkClientPort == 0) {
          zkClientPort = conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, 0);
          // The client port has to be set by now; if not, throw exception.
          if (zkClientPort == 0) {
            throw new IOException("No config value for " + HConstants.ZOOKEEPER_CLIENT_PORT);
          }
        }
        zooKeeperCluster.setDefaultClientPort(zkClientPort);
        // set the ZK tick time if specified
        int zkTickTime = conf.getInt(HConstants.ZOOKEEPER_TICK_TIME, 0);
        if (zkTickTime > 0) {
          zooKeeperCluster.setTickTime(zkTickTime);
        }


        // login the zookeeper server principal (if using security)
        ZKUtil.loginServer(conf, HConstants.ZK_SERVER_KEYTAB_FILE,
          HConstants.ZK_SERVER_KERBEROS_PRINCIPAL, null);
        int localZKClusterSessionTimeout =
          conf.getInt(HConstants.ZK_SESSION_TIMEOUT + ".localHBaseCluster", 10*1000);
        conf.setInt(HConstants.ZK_SESSION_TIMEOUT, localZKClusterSessionTimeout);
        LOG.info("Starting a zookeeper cluster");
        int clientPort = zooKeeperCluster.startup(zkDataPath);
        if (clientPort != zkClientPort) {
          String errorMsg = "Could not start ZK at requested port of " +
            zkClientPort + ".  ZK was started at port: " + clientPort +
            ".  Aborting as clients (e.g. shell) will not be able to find " +
            "this ZK quorum.";
          System.err.println(errorMsg);
          throw new IOException(errorMsg);
        }
        conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(clientPort));


        // Need to have the zk cluster shutdown when master is shutdown.
        // Run a subclass that does the zk cluster shutdown on its way out.
        int mastersCount = conf.getInt("hbase.masters", 1);
        int regionServersCount = conf.getInt("hbase.regionservers", 1);
        LOG.info("Starting up instance of localHBaseCluster; master=" + mastersCount +
          ", regionserversCount=" + regionServersCount);
        LocalHBaseCluster cluster = new LocalHBaseCluster(conf, mastersCount, regionServersCount,
          LocalHMaster.class, HRegionServer.class);
        ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
        cluster.startup();
        waitOnMasterThreads(cluster);
      } else {
        logProcessInfo(getConf());
        CoordinatedStateManager csm =
          CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
        HMaster master = HMaster.constructMaster(masterClass, conf, csm);
        if (master.isStopped()) {
          LOG.info("Won't bring the Master up as a shutdown is requested");
          return 1;
        }
        master.start();
        master.join();
        if(master.isAborted())
          throw new RuntimeException("HMaster Aborted");
      }
    } catch (Throwable t) {
      LOG.error("Master exiting", t);
      return 1;
    }
    return 0;
  }





  
  

hbase1.2.3+zookeeper3.4.9+hadoop2.7.3完全分布式部署遇到的问题

启动start-hbase.sh 后hbase没有启动 查看日志如下: ERROR [main] master.HMasterCommandLine: Master exiting java.i...
  • kamereon
  • kamereon
  • 2017年01月17日 14:27
  • 991

HBase启动

# HBase中组件及启动流程记录   ## 1.服务组件 - Client     -包含访问HBase的接口,并维护cache来加快对HBase的访问,比如region的位置信息    ...
  • cangencong
  • cangencong
  • 2017年04月13日 16:55
  • 668

Hbase1.3.1 完全分布式搭建。

hbase的搭建是比较简单的,无论是单机模式还是分布式都相对容易。本人选择的是1.3.1的版本,按照官方的文档很快就搭建起来了,但是启动的时候出现了错误。无论是baidu还是google都没有找到答案...
  • Leafage_M
  • Leafage_M
  • 2017年07月16日 17:45
  • 2327

hbase 启动顺序

zookeeper 是独立的没有给hbase托管。 1、先启动zookeeper  bash ./bin/zkServer.sh  start zk1.cfg bash ./bin/...
  • pdw2009
  • pdw2009
  • 2014年03月18日 00:17
  • 13654

【Hadoop】Hbase分布式链接出错的问题,启动后不能连上其他节点处理问题。一直报错The node /hbase is not in ZooKeeper.不能同步的问题。

【hadoop】hbase分布式链接出错的问题,启动后不能连上其他节点处理问题。一直报错The node /hbase is not in ZooKeeper.不能同步的问题解决方案。...
  • lsttoy
  • lsttoy
  • 2016年12月09日 20:22
  • 2162

solr cloud异常与处理

启动solr cloud ,启动到一半发现抛出这样的异常:ZkController.java第1087行代码 "Could not find configName for collection ...
  • zheng0518
  • zheng0518
  • 2015年01月09日 10:55
  • 7120

zookeeper——启动zookeeper中的常见问题

原文地址:http://hi.baidu.com/luhao8415/item/23c6e7f075aa18b730c1993a 最近常有启动zookeeper出现问题的,整理下贴出来,以后也可以参考...
  • qinglu000
  • qinglu000
  • 2013年08月07日 13:46
  • 69771

Ubuntu14.0.4下Hbase1.1.3单机模式部署

学习Hbase1.1.3的初级教程,在ubuntu14.0.4下,搭建Hbase1.1.3的单机模式。
  • Veechange
  • Veechange
  • 2016年02月28日 18:28
  • 1109

hbase1.1.3+snappy 安装

hbase安装以及snappy压缩算法的配置安装
  • zychun1991
  • zychun1991
  • 2016年06月28日 23:16
  • 212

Hbase1.1.3的相关使用心得

使用hbase最关心与主要的问题就是过滤条件、排序、分页问题,下面是一些常用到的相关方法。其中做的分页不是很理想,所以就一笔带过了。 1       相关组件 1.1   Phoeni...
  • leeking888
  • leeking888
  • 2016年07月05日 15:31
  • 1092
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:hbase1.1.3 启动一
举报原因:
原因补充:

(最多只允许输入30个字)