I haven't seen any replies, which is probably because the master seems to
be changing rapidly at the moment. However, if anyone needs this for
hbase 0.89.20100726, here's a patch to work around the issue temporarily
until 0.90.0 (which will probably fix the problem).
/charles thayer
--- src/main/java/org/apache/hadoop/hbase/master/HMaster.java 2010-07-30
21:09:11.000000000 +0000
+++ src/main/java/org/apache/hadoop/hbase/master/HMaster.java 2010-10-11
20:51:30.821519000 +0000
@@ -1297,11 +1297,18 @@
runtime.getVmVendor() + ", vmVersion=" + runtime.getVmVersion());
LOG.info("vmInputArguments=" + runtime.getInputArguments());
}
+
+ boolean hbase_manages_zk = true;
+ if (System.getenv("HBASE_MANAGES_ZK") != null
+ && System.getenv("HBASE_MANAGES_ZK").equals("false"))
+ hbase_manages_zk = false;
+
// If 'local', defer to LocalHBaseCluster instance. Starts master
// and regionserver both in the one JVM.
if (LocalHBaseCluster.isLocal(conf)) {
final MiniZooKeeperCluster zooKeeperCluster =
new MiniZooKeeperCluster();
+ if (hbase_manages_zk) { // thayer
File zkDataPath = new
File(conf.get("hbase.zookeeper.property.dataDir"));
int zkClientPort =
conf.getInt("hbase.zookeeper.property.clientPort", 0);
if (zkClientPort == 0) {
@@ -1319,11 +1326,15 @@
}
conf.set("hbase.zookeeper.property.clientPort",
Integer.toString(clientPort));
+ } // thayer
+
// Need to have the zk cluster shutdown when master is shutdown.
// Run a subclass that does the zk cluster shutdown on its way out.
LocalHBaseCluster cluster = new LocalHBaseCluster(conf, 1,
LocalHMaster.class, HRegionServer.class);
+ if (hbase_manages_zk) {
((LocalHMaster)cluster.getMaster()).setZKCluster(zooKeeperCluster);
+ }
cluster.startup();
} else {
HMaster master = constructMaster(masterClass, conf);
On 10/11/2010 12:32 PM, Charles Thayer wrote:
We're using a pre-existing zookeeper cluster (HBASE_MANAGES_ZK=false),
and trying to port some code from 0.20 to 0.89, but hbase fails
to start with
Couldnt start ZK at requested address of 2181 [..blah..] 2182
(from ./src/main/java/org/apache/hadoop/hbase/master/HMaster.java)
Because port 2181 is already running our separate zk instance.
I commented out (and used if(false)) to work around the issue
and now "hbase shell" appears to work (see below).
Is anyone else seeing this problem? or does anyone know if it's repaired
in trunk or being worked on, before I file a ticket?
Thanks,
/charles
PS. Around line HMaster.java:1291 (0.89.20100726)
if (cmd.getArgList().contains("start")) {
try {
// Print out vm stats before starting up.
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
if (runtime != null) {
LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" +
runtime.getVmVendor() + ", vmVersion=" +
runtime.getVmVersion());
LOG.info("vmInputArguments=" + runtime.getInputArguments());
}
// If 'local', defer to LocalHBaseCluster instance. Starts master
// and regionserver both in the one JVM.
if (LocalHBaseCluster.isLocal(conf)) {
if (false) {
final MiniZooKeeperCluster zooKeeperCluster =
new MiniZooKeeperCluster();
File zkDataPath = new
File(conf.get("hbase.zookeeper.property.dataDir"));
int zkClientPort =
conf.getInt("hbase.zookeeper.property.clientPort", 0);
if (zkClientPort == 0) {
throw new IOException("No config value for
hbase.zookeeper.property.clientPort");
}
zooKeeperCluster.setTickTime(conf.getInt("hbase.zookeeper.property.tickTime",
3000));
zooKeeperCluster.setClientPort(zkClientPort);
int clientPort = zooKeeperCluster.startup(zkDataPath);
if (clientPort != zkClientPort) {
String errorMsg = "Couldnt start ZK at requested address of " +
zkClientPort + ", instead got: " + clientPort + ".
Aborting.
Why? " +
"Because clients (eg shell) wont be able to find this ZK
quorum";
System.err.println(errorMsg);
throw new IOException(errorMsg);
}
conf.set("hbase.zookeeper.property.clientPort",
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.
LocalHBaseCluster cluster = new LocalHBaseCluster(conf, 1,
LocalHMaster.class, HRegionServer.class);
//
((LocalHMaster)cluster.getMaster()).setZKCluster(zooKeeperCluster);
cluster.startup();
} else {
HMaster master = constructMaster(masterClass, conf);
if (master.shutdownRequested.get()) {
LOG.info("Won't bring the Master up as a shutdown is
requested");
return;
}
master.start();
}
} catch (Throwable t) {
LOG.error("Failed to start master", t);
System.exit(-1);
}