You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/05/12 10:57:03 UTC

[GitHub] [hbase-operator-tools] petersomogyi commented on a change in pull request #86: HBASE-25874 [hbase-operator-tools]Add tool for identifying 'unknown s…

petersomogyi commented on a change in pull request #86:
URL: https://github.com/apache/hbase-operator-tools/pull/86#discussion_r630936363



##########
File path: hbase-tools/src/main/java/org/apache/hbase/RegionsOnUnknownServersRecoverer.java
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hbase;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Tool for identifying Unknown Servers from master logs and schedule SCPs for each of those using
+ * HBCK2 'scheduleRecoveries' option. This is useful for clusters running hbase versions lower than
+ * 2.2.7, 2.3.5 and 2.4.7. For any of these versions or higher, use HBCK2 'recoverUnknown' option.
+ */
+public class RegionsOnUnknownServersRecoverer extends Configured implements Tool {
+
+  private static final Logger LOG =
+    LoggerFactory.getLogger(RegionsOnUnknownServersRecoverer.class.getName());
+
+  private static final String CATALOG_JANITOR = "CatalogJanitor: hole=";
+
+  private static final String UNKNOWN_SERVER = "unknown_server=";
+
+  private Configuration conf;
+
+  private Set<String> unknownServers = new HashSet<>();
+
+  private boolean dryRun = false;
+
+  public RegionsOnUnknownServersRecoverer(Configuration conf){
+    this.conf = conf;
+  }
+
+  @Override
+  public int run(String[] args) throws Exception {
+    String logPath = null;
+    if(args.length>=1 && args.length<3) {
+      logPath = args[0];
+      if(args.length==2) {
+        dryRun = Boolean.parseBoolean(args[1]);
+      }
+    } else {
+      LOG.error("Wrong number of arguments. "
+        + "Arguments are: <PATH_TO_MASTER_LOGS> [dryRun]");

Review comment:
       From the usage message it is not obvious that the `[dryRun]` parameter should be `true`.

##########
File path: hbase-tools/README.md
##########
@@ -138,4 +138,31 @@ the affected regions, it copies the entire region dir to a
 region hfiles to a `HBASE_ROOT_DIR/.missing_dirs_repair/TS/TBL_NAME/bulkload` dir, renaming these
 files with the pattern `REGION_NAME-FILENAME`. For a given table, all affected regions would then
 have all its files under same directory for bulkload. _MissingRegionDirsRepairTool_ then uses
-_LoadIncrementalHFiles_ to load all files for a given table at once.
\ No newline at end of file
+_LoadIncrementalHFiles_ to load all files for a given table at once.
+
+## RegionsOnUnknownServersRecoverer - Tool for recovering regions on "unknown servers."
+
+_RegionsOnUnknownServersRecoverer_ parses the master log to identify `unknown servers`
+holding regions. This condition may happen in the event of recovering previously destroyed clusters,
+where new Master/RS names completely differ from the previous ones currently
+stored in meta table (see HBASE-24286).
+
+```
+NOTE: This tool is useful for clusters runing hbase versions lower than 2.2.7, 2.3.5 and 2.4.7.
+For any of these versions or higher, HBCK2 'recoverUnknown' option can be used as a much simpler solution.
+```
+
+### Usage
+
+This tool requires the master logs path as parameter. Assuming classpath is properly set, can be run as follows:
+
+```
+$ hbase org.apache.hbase.RegionsOnUnknownServersRecoverer PATH_TO_MASTER_LOGS

Review comment:
       The dry-run option is not mentioned here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org