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 sim
ilar FS (Aditya) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1353065 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
22ca8dc565
commit
9cfae9f15f
|
@ -229,6 +229,9 @@ public final class HConstants {
|
||||||
/** Like the previous, but for old logs that are about to be deleted */
|
/** Like the previous, but for old logs that are about to be deleted */
|
||||||
public static final String HREGION_OLDLOGDIR_NAME = ".oldlogs";
|
public static final String HREGION_OLDLOGDIR_NAME = ".oldlogs";
|
||||||
|
|
||||||
|
/** Used by HBCK to sideline backup data */
|
||||||
|
public static final String HBCK_SIDELINEDIR_NAME = ".hbck";
|
||||||
|
|
||||||
/** Used to construct the name of the compaction directory during compaction */
|
/** Used to construct the name of the compaction directory during compaction */
|
||||||
public static final String HREGION_COMPACTIONDIR_NAME = "compaction.dir";
|
public static final String HREGION_COMPACTIONDIR_NAME = "compaction.dir";
|
||||||
|
|
||||||
|
@ -594,7 +597,8 @@ public final class HConstants {
|
||||||
public static final List<String> HBASE_NON_USER_TABLE_DIRS = new ArrayList<String>(
|
public static final List<String> HBASE_NON_USER_TABLE_DIRS = new ArrayList<String>(
|
||||||
Arrays.asList(new String[]{ HREGION_LOGDIR_NAME, HREGION_OLDLOGDIR_NAME,
|
Arrays.asList(new String[]{ HREGION_LOGDIR_NAME, HREGION_OLDLOGDIR_NAME,
|
||||||
CORRUPT_DIR_NAME, Bytes.toString(META_TABLE_NAME),
|
CORRUPT_DIR_NAME, Bytes.toString(META_TABLE_NAME),
|
||||||
Bytes.toString(ROOT_TABLE_NAME), SPLIT_LOGDIR_NAME }));
|
Bytes.toString(ROOT_TABLE_NAME), SPLIT_LOGDIR_NAME,
|
||||||
|
HBCK_SIDELINEDIR_NAME }));
|
||||||
|
|
||||||
public static final Pattern CP_HTD_ATTR_KEY_PATTERN = Pattern.compile
|
public static final Pattern CP_HTD_ATTR_KEY_PATTERN = Pattern.compile
|
||||||
("^coprocessor\\$([0-9]+)$", Pattern.CASE_INSENSITIVE);
|
("^coprocessor\\$([0-9]+)$", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
|
@ -181,6 +181,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 +818,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 +833,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 +857,13 @@ 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() + "-"
|
Path hbckDir = new Path(hbaseDir, HConstants.HBCK_SIDELINEDIR_NAME);
|
||||||
+ startMillis);
|
sidelineDir = new Path(hbckDir, hbaseDir.getName() + "-"
|
||||||
return backupDir;
|
+ startMillis);
|
||||||
|
}
|
||||||
|
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,18 +2989,27 @@ 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:");
|
||||||
System.err.println(" -help Display help options (this)");
|
System.err.println(" -help Display help options (this)");
|
||||||
System.err.println(" -details Display full report of all regions.");
|
System.err.println(" -details Display full report of all regions.");
|
||||||
System.err.println(" -timelag {timeInSeconds} Process only regions that " +
|
System.err.println(" -timelag <timeInSeconds> Process only regions that " +
|
||||||
" have not experienced any metadata updates in the last " +
|
" have not experienced any metadata updates in the last " +
|
||||||
" {{timeInSeconds} seconds.");
|
" <timeInSeconds> seconds.");
|
||||||
System.err.println(" -sleepBeforeRerun {timeInSeconds} Sleep this many seconds" +
|
System.err.println(" -sleepBeforeRerun <timeInSeconds> Sleep this many seconds" +
|
||||||
" before checking if the fix worked if run with -fix");
|
" before checking if the fix worked if run with -fix");
|
||||||
System.err.println(" -summary Print only summary of the tables and status.");
|
System.err.println(" -summary Print only summary of the tables and status.");
|
||||||
System.err.println(" -metaonly Only check the state of ROOT and META tables.");
|
System.err.println(" -metaonly Only check the state of ROOT and META tables.");
|
||||||
|
System.err.println(" -sidelineDir <hdfs://> HDFS path to backup existing meta and root.");
|
||||||
|
|
||||||
System.err.println(" Repair options: (expert features, use with caution!)");
|
System.err.println(" Repair options: (expert features, use with caution!)");
|
||||||
System.err.println(" -fix Try to fix region assignments. This is for backwards compatiblity");
|
System.err.println(" -fix Try to fix region assignments. This is for backwards compatiblity");
|
||||||
|
@ -3067,6 +3079,13 @@ public class HBaseFsck {
|
||||||
printUsageAndExit();
|
printUsageAndExit();
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
} else if (cmd.equals("-sidelineDir")) {
|
||||||
|
if (i == args.length - 1) {
|
||||||
|
System.err.println("HBaseFsck: -sidelineDir needs a value.");
|
||||||
|
printUsageAndExit();
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
fsck.setSidelineDir(args[i]);
|
||||||
} else if (cmd.equals("-fix")) {
|
} else if (cmd.equals("-fix")) {
|
||||||
System.err.println("This option is deprecated, please use " +
|
System.err.println("This option is deprecated, please use " +
|
||||||
"-fixAssignments instead.");
|
"-fixAssignments instead.");
|
||||||
|
|
|
@ -46,13 +46,15 @@ public class OfflineMetaRepair {
|
||||||
private static final Log LOG = LogFactory.getLog(HBaseFsck.class.getName());
|
private static final Log LOG = LogFactory.getLog(HBaseFsck.class.getName());
|
||||||
|
|
||||||
protected static void printUsageAndExit() {
|
protected static void printUsageAndExit() {
|
||||||
System.err.println("Usage: OfflineMetaRepair [opts] ");
|
StringBuilder sb = new StringBuilder();
|
||||||
System.err.println(" where [opts] are:");
|
sb.append("Usage: OfflineMetaRepair [opts]\n").
|
||||||
System.err
|
append(" where [opts] are:\n").
|
||||||
.println(" -details Display full report of all regions.");
|
append(" -details Display full report of all regions.\n").
|
||||||
System.err.println(" -base <hdfs://> Base Hbase Data directory");
|
append(" -base <hdfs://> Base Hbase Data directory.\n").
|
||||||
System.err.println(" -fix Auto fix as many problems as possible");
|
append(" -sidelineDir <hdfs://> HDFS path to backup existing meta and root.\n").
|
||||||
System.err.println(" -fixHoles Auto fix as region holes");
|
append(" -fix Auto fix as many problems as possible.\n").
|
||||||
|
append(" -fixHoles Auto fix as region holes.");
|
||||||
|
System.err.println(sb.toString());
|
||||||
Runtime.getRuntime().exit(-2);
|
Runtime.getRuntime().exit(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,12 +81,24 @@ public class OfflineMetaRepair {
|
||||||
if (cmd.equals("-details")) {
|
if (cmd.equals("-details")) {
|
||||||
fsck.setDisplayFullReport();
|
fsck.setDisplayFullReport();
|
||||||
} else if (cmd.equals("-base")) {
|
} else if (cmd.equals("-base")) {
|
||||||
|
if (i == args.length - 1) {
|
||||||
|
System.err.println("OfflineMetaRepair: -base needs an HDFS path.");
|
||||||
|
printUsageAndExit();
|
||||||
|
}
|
||||||
// update hbase root dir to user-specified base
|
// update hbase root dir to user-specified base
|
||||||
i++;
|
i++;
|
||||||
String path = args[i];
|
String path = args[i];
|
||||||
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")) {
|
||||||
|
if (i == args.length - 1) {
|
||||||
|
System.err.println("OfflineMetaRepair: -sidelineDir needs an HDFS path.");
|
||||||
|
printUsageAndExit();
|
||||||
|
}
|
||||||
|
// set the hbck sideline dir to user-specified one
|
||||||
|
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