@InterfaceAudience.LimitedPrivate(value="Tools") @InterfaceStability.Evolving public class HBaseFsck extends org.apache.hadoop.conf.Configured implements Closeable
Region consistency checks verify that hbase:meta, region deployment on region servers and the state of data in HDFS (.regioninfo files) all are in accordance.
Table integrity checks verify that all possible row keys resolve to exactly one region of a table. This means there are no individual degenerate or backwards regions; no holes between regions; and that there are no overlapping regions.
The general repair strategy works in two phases:
For table integrity repairs, the tables' region directories are scanned for .regioninfo files. Each table's integrity is then verified. If there are any orphan regions (regions with no .regioninfo files) or holes, new regions are fabricated. Backwards regions are sidelined as well as empty degenerate (endkey==startkey) regions. If there are any overlapping regions, a new region is created and all data is merged into the new region.
Table integrity repairs deal solely with HDFS and could potentially be done offline -- the hbase region servers or master do not need to be running. This phase can eventually be used to completely reconstruct the hbase:meta table in an offline fashion.
Region consistency requires three conditions -- 1) valid .regioninfo file present in an HDFS region dir, 2) valid row with .regioninfo data in META, and 3) a region is deployed only at the regionserver that was assigned to with proper state in the master.
Region consistency repairs require hbase to be online so that hbck can contact the HBase master and region servers. The hbck#connect() method must first be called successfully. Much of the region consistency information is transient and less risky to repair.
If hbck is run from the command line, there are a handful of arguments that
can be used to limit the kinds of repairs hbck will do. See the code in
printUsageAndExit()
for more details.
Modifier and Type | Class and Description |
---|---|
static interface |
HBaseFsck.ErrorReporter |
static class |
HBaseFsck.HbckInfo
Maintain information about a particular region.
|
static class |
HBaseFsck.RegionRepairException
Exception thrown when a integrity repair operation fails in an
unresolvable way.
|
class |
HBaseFsck.TableInfo
Maintain information about a particular table.
|
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_SLEEP_BEFORE_RERUN |
static long |
DEFAULT_TIME_LAG |
protected ExecutorService |
executor |
static String |
HBCK_LOCK_FILE
Here is where hbase-1.x used to default the lock for hbck1.
|
Constructor and Description |
---|
HBaseFsck(org.apache.hadoop.conf.Configuration conf)
Constructor
|
HBaseFsck(org.apache.hadoop.conf.Configuration conf,
ExecutorService exec)
Constructor
|
Modifier and Type | Method and Description |
---|---|
static Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.FSDataOutputStream> |
checkAndMarkRunningHbck(org.apache.hadoop.conf.Configuration conf,
RetryCounter retryCounter)
This method maintains a lock using a file.
|
void |
checkRegionBoundaries() |
void |
cleanReplicationBarrier() |
void |
close() |
void |
connect()
To repair region consistency, one must call connect() in order to repair
online state.
|
protected HFileCorruptionChecker |
createHFileCorruptionChecker(boolean sidelineCorruptHFiles) |
static RetryCounterFactory |
createLockRetryCounterFactory(org.apache.hadoop.conf.Configuration conf) |
static void |
debugLsr(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.Path p)
ls -r for debugging purposes
|
static void |
debugLsr(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.Path p,
HBaseFsck.ErrorReporter errors)
ls -r for debugging purposes
|
void |
dumpOverlapProblems(org.apache.hbase.thirdparty.com.google.common.collect.Multimap<byte[],HBaseFsck.HbckInfo> regions) |
void |
dumpSidelinedRegions(Map<org.apache.hadoop.fs.Path,HBaseFsck.HbckInfo> regions) |
HBaseFsck |
exec(ExecutorService exec,
String[] args) |
void |
fixEmptyMetaCells()
To fix the empty REGIONINFO_QUALIFIER rows from hbase:meta
|
void |
fixOrphanTables()
To fix orphan table by creating a .tableinfo file under tableDir
1. |
HBaseFsck.ErrorReporter |
getErrors() |
HFileCorruptionChecker |
getHFilecorruptionChecker() |
int |
getMaxMerge() |
int |
getMaxOverlapsToSideline() |
org.apache.hbase.thirdparty.com.google.common.collect.Multimap<byte[],HBaseFsck.HbckInfo> |
getOverlapGroups(TableName table) |
int |
getRetCode() |
static org.apache.hadoop.fs.Path |
getTmpDir(org.apache.hadoop.conf.Configuration conf) |
void |
includeTable(TableName table) |
boolean |
isExclusive()
Only one instance of hbck can modify HBase at a time.
|
static byte[] |
keyOnly(byte[] b) |
void |
loadHdfsRegionDirs()
Scan HDFS for all regions, recording their information into
regionInfoMap
|
static void |
main(String[] args)
Main program
|
int |
mergeRegionDirs(org.apache.hadoop.fs.Path targetRegionDir,
HBaseFsck.HbckInfo contained)
Merge hdfs data by moving from contained HbckInfo into targetRegionDir.
|
void |
offlineHdfsIntegrityRepair()
This repair method analyzes hbase data in hdfs and repairs it to satisfy
the table integrity rules.
|
int |
onlineConsistencyRepair()
This repair method requires the cluster to be online since it contacts
region servers and the masters.
|
int |
onlineHbck()
Contacts the master and prints out cluster-wide information
|
protected HBaseFsck |
printUsageAndExit() |
void |
setCheckHdfs(boolean checking) |
void |
setCleanReplicationBarrier(boolean shouldClean) |
void |
setCleanReplicationBarrierTable(String cleanReplicationBarrierTable) |
static void |
setDisplayFullReport()
Display the full report from fsck.
|
void |
setFixAssignments(boolean shouldFix)
Fix inconsistencies found by fsck.
|
void |
setFixEmptyMetaCells(boolean shouldFix) |
void |
setFixHdfsHoles(boolean shouldFix) |
void |
setFixHdfsOrphans(boolean shouldFix) |
void |
setFixHdfsOverlaps(boolean shouldFix) |
void |
setFixHFileLinks(boolean shouldFix) |
void |
setFixMeta(boolean shouldFix) |
void |
setFixReferenceFiles(boolean shouldFix) |
void |
setFixReplication(boolean shouldFix)
Set replication fix mode.
|
void |
setFixSplitParents(boolean shouldFix) |
void |
setFixTableOrphans(boolean shouldFix) |
void |
setFixVersionFile(boolean shouldFix) |
static void |
setForceExclusive()
Set exclusive mode.
|
void |
setHFileCorruptionChecker(HFileCorruptionChecker hfcc) |
void |
setIgnorePreCheckPermission(boolean ignorePreCheckPermission) |
void |
setMaxMerge(int mm) |
void |
setMaxOverlapsToSideline(int mo) |
void |
setRemoveParents(boolean shouldFix) |
void |
setRetCode(int code) |
void |
setSidelineBigOverlaps(boolean sbo) |
void |
setSidelineDir(String sidelineDir) |
void |
setTimeLag(long seconds)
We are interested in only those tables that have not changed their state in
hbase:meta during the last few seconds specified by hbase.admin.fsck.timelag
|
boolean |
shouldFixVersionFile() |
boolean |
shouldIgnorePreCheckPermission() |
boolean |
shouldRerun() |
boolean |
shouldSidelineBigOverlaps() |
public static final long DEFAULT_TIME_LAG
public static final long DEFAULT_SLEEP_BEFORE_RERUN
public static final String HBCK_LOCK_FILE
protected ExecutorService executor
public HBaseFsck(org.apache.hadoop.conf.Configuration conf) throws IOException, ClassNotFoundException
conf
- Configuration objectMasterNotRunningException
- if the master is not runningZooKeeperConnectionException
- if unable to connect to ZooKeeperIOException
ClassNotFoundException
public HBaseFsck(org.apache.hadoop.conf.Configuration conf, ExecutorService exec) throws MasterNotRunningException, ZooKeeperConnectionException, IOException, ClassNotFoundException
conf
- Configuration objectMasterNotRunningException
- if the master is not runningZooKeeperConnectionException
- if unable to connect to ZooKeeperIOException
ClassNotFoundException
public static RetryCounterFactory createLockRetryCounterFactory(org.apache.hadoop.conf.Configuration conf)
public static org.apache.hadoop.fs.Path getTmpDir(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public static Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.FSDataOutputStream> checkAndMarkRunningHbck(org.apache.hadoop.conf.Configuration conf, RetryCounter retryCounter) throws IOException
IOException
- if IO failure occurspublic void connect() throws IOException
IOException
public void offlineHdfsIntegrityRepair() throws IOException, InterruptedException
IOException
InterruptedException
public int onlineConsistencyRepair() throws IOException, org.apache.zookeeper.KeeperException, InterruptedException
IOException
org.apache.zookeeper.KeeperException
InterruptedException
public int onlineHbck() throws IOException, org.apache.zookeeper.KeeperException, InterruptedException, ReplicationException
IOException
org.apache.zookeeper.KeeperException
InterruptedException
ReplicationException
public static byte[] keyOnly(byte[] b)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void checkRegionBoundaries()
public HBaseFsck.ErrorReporter getErrors()
public void fixEmptyMetaCells() throws IOException
IOException
public void fixOrphanTables() throws IOException
TableDescriptor
and ColumnFamilyDescriptor
IOException
public void loadHdfsRegionDirs() throws IOException, InterruptedException
IOException
InterruptedException
public int mergeRegionDirs(org.apache.hadoop.fs.Path targetRegionDir, HBaseFsck.HbckInfo contained) throws IOException
IOException
public void dumpOverlapProblems(org.apache.hbase.thirdparty.com.google.common.collect.Multimap<byte[],HBaseFsck.HbckInfo> regions)
public void dumpSidelinedRegions(Map<org.apache.hadoop.fs.Path,HBaseFsck.HbckInfo> regions)
public org.apache.hbase.thirdparty.com.google.common.collect.Multimap<byte[],HBaseFsck.HbckInfo> getOverlapGroups(TableName table)
public static void setDisplayFullReport()
public static void setForceExclusive()
public boolean isExclusive()
public void setFixReplication(boolean shouldFix)
public void setCleanReplicationBarrier(boolean shouldClean)
public boolean shouldRerun()
public void setFixAssignments(boolean shouldFix)
public void setFixMeta(boolean shouldFix)
public void setFixEmptyMetaCells(boolean shouldFix)
public void setCheckHdfs(boolean checking)
public void setFixHdfsHoles(boolean shouldFix)
public void setFixTableOrphans(boolean shouldFix)
public void setFixHdfsOverlaps(boolean shouldFix)
public void setFixHdfsOrphans(boolean shouldFix)
public void setFixVersionFile(boolean shouldFix)
public boolean shouldFixVersionFile()
public void setSidelineBigOverlaps(boolean sbo)
public boolean shouldSidelineBigOverlaps()
public void setFixSplitParents(boolean shouldFix)
public void setRemoveParents(boolean shouldFix)
public void setFixReferenceFiles(boolean shouldFix)
public void setFixHFileLinks(boolean shouldFix)
public boolean shouldIgnorePreCheckPermission()
public void setIgnorePreCheckPermission(boolean ignorePreCheckPermission)
public void setMaxMerge(int mm)
mm
- maximum number of regions to merge into a single region.public int getMaxMerge()
public void setMaxOverlapsToSideline(int mo)
public int getMaxOverlapsToSideline()
public void includeTable(TableName table)
public void setTimeLag(long seconds)
seconds
- - the time in secondspublic void setSidelineDir(String sidelineDir)
sidelineDir
- - HDFS path to sideline dataprotected HFileCorruptionChecker createHFileCorruptionChecker(boolean sidelineCorruptHFiles) throws IOException
IOException
public HFileCorruptionChecker getHFilecorruptionChecker()
public void setHFileCorruptionChecker(HFileCorruptionChecker hfcc)
public void setRetCode(int code)
public int getRetCode()
protected HBaseFsck printUsageAndExit()
public static void main(String[] args) throws Exception
args
- Exception
public HBaseFsck exec(ExecutorService exec, String[] args) throws org.apache.zookeeper.KeeperException, IOException, InterruptedException, ReplicationException
org.apache.zookeeper.KeeperException
IOException
InterruptedException
ReplicationException
public void setCleanReplicationBarrierTable(String cleanReplicationBarrierTable)
public void cleanReplicationBarrier() throws IOException
IOException
public static void debugLsr(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path p) throws IOException
IOException
public static void debugLsr(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path p, HBaseFsck.ErrorReporter errors) throws IOException
IOException
Copyright © 2007–2019 Cloudera. All rights reserved.