HBASE-6236 Offline meta repair fails if the HBase base mount point is on a different cluster/volume than its parent in a ViewFS or similar FS (Aditya)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1353008 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
270f2f01b4
commit
8645a42880
|
@ -150,6 +150,9 @@ public class HBaseFsck {
|
||||||
private static final int DEFAULT_OVERLAPS_TO_SIDELINE = 2;
|
private static final int DEFAULT_OVERLAPS_TO_SIDELINE = 2;
|
||||||
private static final int DEFAULT_MAX_MERGE = 5;
|
private static final int DEFAULT_MAX_MERGE = 5;
|
||||||
|
|
||||||
|
private static final String DEFAULT_SIDELINE_DIR = ".hbcktmp-" +
|
||||||
|
System.currentTimeMillis();
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* Internal resources
|
* Internal resources
|
||||||
**********************/
|
**********************/
|
||||||
|
@ -160,7 +163,6 @@ public class HBaseFsck {
|
||||||
private HBaseAdmin admin;
|
private HBaseAdmin admin;
|
||||||
private HTable meta;
|
private HTable meta;
|
||||||
private ScheduledThreadPoolExecutor executor; // threads to retrieve data from regionservers
|
private ScheduledThreadPoolExecutor executor; // threads to retrieve data from regionservers
|
||||||
private long startMillis = System.currentTimeMillis();
|
|
||||||
|
|
||||||
/***********
|
/***********
|
||||||
* Options
|
* Options
|
||||||
|
@ -181,6 +183,7 @@ public class HBaseFsck {
|
||||||
private int maxMerge = DEFAULT_MAX_MERGE; // maximum number of overlapping regions to merge
|
private int maxMerge = DEFAULT_MAX_MERGE; // maximum number of overlapping regions to merge
|
||||||
private int maxOverlapsToSideline = DEFAULT_OVERLAPS_TO_SIDELINE; // maximum number of overlapping regions to sideline
|
private int maxOverlapsToSideline = DEFAULT_OVERLAPS_TO_SIDELINE; // maximum number of overlapping regions to sideline
|
||||||
private boolean sidelineBigOverlaps = false; // sideline overlaps with >maxMerge regions
|
private boolean sidelineBigOverlaps = false; // sideline overlaps with >maxMerge regions
|
||||||
|
private Path sidelineDir = null;
|
||||||
|
|
||||||
private boolean rerun = false; // if we tried to fix something, rerun hbck
|
private boolean rerun = false; // if we tried to fix something, rerun hbck
|
||||||
private static boolean summary = false; // if we want to print less output
|
private static boolean summary = false; // if we want to print less output
|
||||||
|
@ -817,7 +820,7 @@ public class HBaseFsck {
|
||||||
|
|
||||||
// we can rebuild, move old root and meta out of the way and start
|
// we can rebuild, move old root and meta out of the way and start
|
||||||
LOG.info("HDFS regioninfo's seems good. Sidelining old .META.");
|
LOG.info("HDFS regioninfo's seems good. Sidelining old .META.");
|
||||||
sidelineOldRootAndMeta();
|
Path backupDir = sidelineOldRootAndMeta();
|
||||||
|
|
||||||
LOG.info("Creating new .META.");
|
LOG.info("Creating new .META.");
|
||||||
HRegion meta = createNewRootAndMeta();
|
HRegion meta = createNewRootAndMeta();
|
||||||
|
@ -832,6 +835,7 @@ public class HBaseFsck {
|
||||||
meta.put(puts.toArray(new Put[0]));
|
meta.put(puts.toArray(new Put[0]));
|
||||||
HRegion.closeHRegion(meta);
|
HRegion.closeHRegion(meta);
|
||||||
LOG.info("Success! .META. table rebuilt.");
|
LOG.info("Success! .META. table rebuilt.");
|
||||||
|
LOG.info("Old -ROOT- and .META. are moved into " + backupDir);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,11 +859,11 @@ public class HBaseFsck {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path getSidelineDir() throws IOException {
|
private Path getSidelineDir() throws IOException {
|
||||||
Path hbaseDir = FSUtils.getRootDir(conf);
|
if (sidelineDir == null) {
|
||||||
Path hbckDir = new Path(hbaseDir.getParent(), "hbck");
|
Path hbaseDir = FSUtils.getRootDir(conf);
|
||||||
Path backupDir = new Path(hbckDir, hbaseDir.getName() + "-"
|
sidelineDir = new Path(hbaseDir, DEFAULT_SIDELINE_DIR);
|
||||||
+ startMillis);
|
}
|
||||||
return backupDir;
|
return sidelineDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -957,8 +961,7 @@ public class HBaseFsck {
|
||||||
// put current -ROOT- and .META. aside.
|
// put current -ROOT- and .META. aside.
|
||||||
Path hbaseDir = new Path(conf.get(HConstants.HBASE_DIR));
|
Path hbaseDir = new Path(conf.get(HConstants.HBASE_DIR));
|
||||||
FileSystem fs = hbaseDir.getFileSystem(conf);
|
FileSystem fs = hbaseDir.getFileSystem(conf);
|
||||||
Path backupDir = new Path(hbaseDir.getParent(), hbaseDir.getName() + "-"
|
Path backupDir = getSidelineDir();
|
||||||
+ startMillis);
|
|
||||||
fs.mkdirs(backupDir);
|
fs.mkdirs(backupDir);
|
||||||
|
|
||||||
sidelineTable(fs, HConstants.ROOT_TABLE_NAME, hbaseDir, backupDir);
|
sidelineTable(fs, HConstants.ROOT_TABLE_NAME, hbaseDir, backupDir);
|
||||||
|
@ -2986,6 +2989,14 @@ public class HBaseFsck {
|
||||||
timelag = seconds * 1000; // convert to milliseconds
|
timelag = seconds * 1000; // convert to milliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sidelineDir - HDFS path to sideline data
|
||||||
|
*/
|
||||||
|
public void setSidelineDir(String sidelineDir) {
|
||||||
|
this.sidelineDir = new Path(sidelineDir);
|
||||||
|
}
|
||||||
|
|
||||||
protected static void printUsageAndExit() {
|
protected static void printUsageAndExit() {
|
||||||
System.err.println("Usage: fsck [opts] {only tables}");
|
System.err.println("Usage: fsck [opts] {only tables}");
|
||||||
System.err.println(" where [opts] are:");
|
System.err.println(" where [opts] are:");
|
||||||
|
|
|
@ -51,6 +51,8 @@ public class OfflineMetaRepair {
|
||||||
System.err
|
System.err
|
||||||
.println(" -details Display full report of all regions.");
|
.println(" -details Display full report of all regions.");
|
||||||
System.err.println(" -base <hdfs://> Base Hbase Data directory");
|
System.err.println(" -base <hdfs://> Base Hbase Data directory");
|
||||||
|
System.err
|
||||||
|
.println(" -sidelineDir <hdfs://> HDFS path to backup existing meta and root.");
|
||||||
System.err.println(" -fix Auto fix as many problems as possible");
|
System.err.println(" -fix Auto fix as many problems as possible");
|
||||||
System.err.println(" -fixHoles Auto fix as region holes");
|
System.err.println(" -fixHoles Auto fix as region holes");
|
||||||
Runtime.getRuntime().exit(-2);
|
Runtime.getRuntime().exit(-2);
|
||||||
|
@ -85,6 +87,9 @@ public class OfflineMetaRepair {
|
||||||
conf.set(HConstants.HBASE_DIR, path);
|
conf.set(HConstants.HBASE_DIR, path);
|
||||||
conf.set("fs.defaultFS", conf.get(HConstants.HBASE_DIR));
|
conf.set("fs.defaultFS", conf.get(HConstants.HBASE_DIR));
|
||||||
conf.set("fs.default.name", conf.get(HConstants.HBASE_DIR));
|
conf.set("fs.default.name", conf.get(HConstants.HBASE_DIR));
|
||||||
|
} else if (cmd.equals("-sidelineDir")) {
|
||||||
|
i++;
|
||||||
|
fsck.setSidelineDir(args[i]);
|
||||||
} else if (cmd.equals("-fixHoles")) {
|
} else if (cmd.equals("-fixHoles")) {
|
||||||
fixHoles = true;
|
fixHoles = true;
|
||||||
} else if (cmd.equals("-fix")) {
|
} else if (cmd.equals("-fix")) {
|
||||||
|
|
Loading…
Reference in New Issue