HBASE-23953 SimpleBalancer bug when second pass to fill up to min (#1262)
[hbase.git] / src / main / asciidoc / _chapters / ops_mgt.adoc
blob4f7734fefd7802098815eec57f1b11f56c10ba8a
1 ////
2 /**
3  *
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 ////
22 [[ops_mgt]]
23 = Apache HBase Operational Management
24 :doctype: book
25 :numbered:
26 :toc: left
27 :icons: font
28 :experimental:
30 This chapter will cover operational tools and practices required of a running Apache HBase cluster.
31 The subject of operations is related to the topics of <<trouble>>, <<performance>>, and <<configuration>> but is a distinct topic in itself.
33 [[tools]]
34 == HBase Tools and Utilities
36 HBase provides several tools for administration, analysis, and debugging of your cluster.
37 The entry-point to most of these tools is the _bin/hbase_ command, though some tools are available in the _dev-support/_ directory.
39 To see usage instructions for _bin/hbase_ command, run it with no arguments, or with the `-h` argument.
40 These are the usage instructions for HBase 0.98.x.
41 Some commands, such as `version`, `pe`, `ltt`, `clean`, are not available in previous versions.
43 ----
44 $ bin/hbase
45 Usage: hbase [<options>] <command> [<args>]
46 Options:
47   --config DIR     Configuration direction to use. Default: ./conf
48   --hosts HOSTS    Override the list in 'regionservers' file
49   --auth-as-server Authenticate to ZooKeeper using servers configuration
51 Commands:
52 Some commands take arguments. Pass no args or -h for usage.
53   shell           Run the HBase shell
54   hbck            Run the HBase 'fsck' tool. Defaults read-only hbck1.
55                   Pass '-j /path/to/HBCK2.jar' to run hbase-2.x HBCK2.
56   snapshot        Tool for managing snapshots
57   wal             Write-ahead-log analyzer
58   hfile           Store file analyzer
59   zkcli           Run the ZooKeeper shell
60   master          Run an HBase HMaster node
61   regionserver    Run an HBase HRegionServer node
62   zookeeper       Run a ZooKeeper server
63   rest            Run an HBase REST server
64   thrift          Run the HBase Thrift server
65   thrift2         Run the HBase Thrift2 server
66   clean           Run the HBase clean up script
67   classpath       Dump hbase CLASSPATH
68   mapredcp        Dump CLASSPATH entries required by mapreduce
69   pe              Run PerformanceEvaluation
70   ltt             Run LoadTestTool
71   canary          Run the Canary tool
72   version         Print the version
73   backup          Backup tables for recovery
74   restore         Restore tables from existing backup image
75   regionsplitter  Run RegionSplitter tool
76   rowcounter      Run RowCounter tool
77   cellcounter     Run CellCounter tool
78   CLASSNAME       Run the class named CLASSNAME
79 ----
81 Some of the tools and utilities below are Java classes which are passed directly to the _bin/hbase_ command, as referred to in the last line of the usage instructions.
82 Others, such as `hbase shell` (<<shell>>), `hbase upgrade` (<<upgrading>>), and `hbase thrift` (<<thrift>>), are documented elsewhere in this guide.
84 === Canary
86 The Canary tool can help users "canary-test" the HBase cluster status.
87 The default "region mode" fetches a row from every column-family of every regions.
88 In "regionserver mode", the Canary tool will fetch a row from a random
89 region on each of the cluster's RegionServers. In "zookeeper mode", the
90 Canary will read the root znode on each member of the zookeeper ensemble.
92 To see usage, pass the `-help` parameter (if you pass no
93 parameters, the Canary tool starts executing in the default
94 region "mode" fetching a row from every region in the cluster).
96 ----
97 2018-10-16 13:11:27,037 INFO  [main] tool.Canary: Execution thread count=16
98 Usage: canary [OPTIONS] [<TABLE1> [<TABLE2]...] | [<REGIONSERVER1> [<REGIONSERVER2]..]
99 Where [OPTIONS] are:
100  -h,-help        show this help and exit.
101  -regionserver   set 'regionserver mode'; gets row from random region on server
102  -allRegions     get from ALL regions when 'regionserver mode', not just random one.
103  -zookeeper      set 'zookeeper mode'; grab zookeeper.znode.parent on each ensemble member
104  -daemon         continuous check at defined intervals.
105  -interval <N>   interval between checks in seconds
106  -e              consider table/regionserver argument as regular expression
107  -f <B>          exit on first error; default=true
108  -failureAsError treat read/write failure as error
109  -t <N>          timeout for canary-test run; default=600000ms
110  -writeSniffing  enable write sniffing
111  -writeTable     the table used for write sniffing; default=hbase:canary
112  -writeTableTimeout <N>  timeout for writeTable; default=600000ms
113  -readTableTimeouts <tableName>=<read timeout>,<tableName>=<read timeout>,...
114                 comma-separated list of table read timeouts (no spaces);
115                 logs 'ERROR' if takes longer. default=600000ms
116  -permittedZookeeperFailures <N>  Ignore first N failures attempting to
117                 connect to individual zookeeper nodes in ensemble
119  -D<configProperty>=<value> to assign or override configuration params
120  -Dhbase.canary.read.raw.enabled=<true/false> Set to enable/disable raw scan; default=false
122 Canary runs in one of three modes: region (default), regionserver, or zookeeper.
123 To sniff/probe all regions, pass no arguments.
124 To sniff/probe all regions of a table, pass tablename.
125 To sniff/probe regionservers, pass -regionserver, etc.
126 See http://hbase.apache.org/book.html#_canary for Canary documentation.
127 ----
129 [NOTE]
130 The `Sink` class is instantiated using the `hbase.canary.sink.class` configuration property.
132 This tool will return non zero error codes to user for collaborating with other monitoring tools,
133 such as Nagios.  The error code definitions are:
135 [source,java]
136 ----
137 private static final int USAGE_EXIT_CODE = 1;
138 private static final int INIT_ERROR_EXIT_CODE = 2;
139 private static final int TIMEOUT_ERROR_EXIT_CODE = 3;
140 private static final int ERROR_EXIT_CODE = 4;
141 private static final int FAILURE_EXIT_CODE = 5;
142 ----
144 Here are some examples based on the following given case: given two Table objects called test-01
145 and test-02 each with two column family cf1 and cf2 respectively, deployed on 3 RegionServers.
146 See the following table.
148 [cols="1,1,1", options="header"]
149 |===
150 | RegionServer
151 | test-01
152 | test-02
153 | rs1 | r1 | r2
154 | rs2 | r2 |
155 | rs3 | r2 | r1
156 |===
158 Following are some example outputs based on the previous given case.
160 ==== Canary test for every column family (store) of every region of every table
162 ----
163 $ ${HBASE_HOME}/bin/hbase canary
165 3/12/09 03:26:32 INFO tool.Canary: read from region test-01,,1386230156732.0e3c7d77ffb6361ea1b996ac1042ca9a. column family cf1 in 2ms
166 13/12/09 03:26:32 INFO tool.Canary: read from region test-01,,1386230156732.0e3c7d77ffb6361ea1b996ac1042ca9a. column family cf2 in 2ms
167 13/12/09 03:26:32 INFO tool.Canary: read from region test-01,0004883,1386230156732.87b55e03dfeade00f441125159f8ca87. column family cf1 in 4ms
168 13/12/09 03:26:32 INFO tool.Canary: read from region test-01,0004883,1386230156732.87b55e03dfeade00f441125159f8ca87. column family cf2 in 1ms
170 13/12/09 03:26:32 INFO tool.Canary: read from region test-02,,1386559511167.aa2951a86289281beee480f107bb36ee. column family cf1 in 5ms
171 13/12/09 03:26:32 INFO tool.Canary: read from region test-02,,1386559511167.aa2951a86289281beee480f107bb36ee. column family cf2 in 3ms
172 13/12/09 03:26:32 INFO tool.Canary: read from region test-02,0004883,1386559511167.cbda32d5e2e276520712d84eaaa29d84. column family cf1 in 31ms
173 13/12/09 03:26:32 INFO tool.Canary: read from region test-02,0004883,1386559511167.cbda32d5e2e276520712d84eaaa29d84. column family cf2 in 8ms
174 ----
176 So you can see, table test-01 has two regions and two column families, so the Canary tool in the
177 default "region mode" will pick 4 small piece of data from 4 (2 region * 2 store) different stores.
178 This is a default behavior.
180 ==== Canary test for every column family (store) of every region of a specific table(s)
182 You can also test one or more specific tables by passing table names.
184 ----
185 $ ${HBASE_HOME}/bin/hbase canary test-01 test-02
186 ----
188 ==== Canary test with RegionServer granularity
190 In "regionserver mode", the Canary tool will pick one small piece of data
191 from each RegionServer (You can also pass one or more RegionServer names as arguments
192 to the canary-test when in "regionserver mode").
194 ----
195 $ ${HBASE_HOME}/bin/hbase canary -regionserver
197 13/12/09 06:05:17 INFO tool.Canary: Read from table:test-01 on region server:rs2 in 72ms
198 13/12/09 06:05:17 INFO tool.Canary: Read from table:test-02 on region server:rs3 in 34ms
199 13/12/09 06:05:17 INFO tool.Canary: Read from table:test-01 on region server:rs1 in 56ms
200 ----
202 ==== Canary test with regular expression pattern
204 You can pass regexes for table names when in "region mode" or for servernames when
205 in "regionserver mode". The below will test both table test-01 and test-02.
207 ----
208 $ ${HBASE_HOME}/bin/hbase canary -e test-0[1-2]
209 ----
211 ==== Run canary test as a "daemon"
213 Run repeatedly with an interval defined via the option `-interval` (default value is 60 seconds).
214 This daemon will stop itself and return non-zero error code if any error occur. To have
215 the daemon keep running across errors, pass the -f flag with its value set to false
216 (see usage above).
218 ----
219 $ ${HBASE_HOME}/bin/hbase canary -daemon
220 ----
222 To run repeatedly with 5 second intervals and not stop on errors, do the following.
224 ----
225 $ ${HBASE_HOME}/bin/hbase canary -daemon -interval 5 -f false
226 ----
228 ==== Force timeout if canary test stuck
230 In some cases the request is stuck and no response is sent back to the client. This
231 can happen with dead RegionServers which the master has not yet noticed.
232 Because of this we provide a timeout option to kill the canary test and return a
233 non-zero error code. The below sets the timeout value to 60 seconds (the default value
234 is 600 seconds).
236 ----
237 $ ${HBASE_HOME}/bin/hbase canary -t 60000
238 ----
240 ==== Enable write sniffing in canary
242 By default, the canary tool only checks read operations. To enable the write sniffing,
243 you can run the canary with the `-writeSniffing` option set.  When write sniffing is
244 enabled, the canary tool will create an hbase table and make sure the
245 regions of the table are distributed to all region servers. In each sniffing period,
246 the canary will try to put data to these regions to check the write availability of
247 each region server.
248 ----
249 $ ${HBASE_HOME}/bin/hbase canary -writeSniffing
250 ----
252 The default write table is `hbase:canary` and can be specified with the option `-writeTable`.
253 ----
254 $ ${HBASE_HOME}/bin/hbase canary -writeSniffing -writeTable ns:canary
255 ----
257 The default value size of each put is 10 bytes. You can set it via the config key:
258 `hbase.canary.write.value.size`.
260 ==== Treat read / write failure as error
262 By default, the canary tool only logs read failures -- due to e.g. RetriesExhaustedException, etc. --
263 and will return the 'normal' exit code. To treat read/write failure as errors, you can run canary
264 with the `-treatFailureAsError` option. When enabled, read/write failures will result in an
265 error exit code.
266 ----
267 $ ${HBASE_HOME}/bin/hbase canary -treatFailureAsError
268 ----
270 ==== Running Canary in a Kerberos-enabled Cluster
272 To run the Canary in a Kerberos-enabled cluster, configure the following two properties in _hbase-site.xml_:
274 * `hbase.client.keytab.file`
275 * `hbase.client.kerberos.principal`
277 Kerberos credentials are refreshed every 30 seconds when Canary runs in daemon mode.
279 To configure the DNS interface for the client, configure the following optional properties in _hbase-site.xml_.
281 * `hbase.client.dns.interface`
282 * `hbase.client.dns.nameserver`
284 .Canary in a Kerberos-Enabled Cluster
285 ====
286 This example shows each of the properties with valid values.
288 [source,xml]
289 ----
290 <property>
291   <name>hbase.client.kerberos.principal</name>
292   <value>hbase/_HOST@YOUR-REALM.COM</value>
293 </property>
294 <property>
295   <name>hbase.client.keytab.file</name>
296   <value>/etc/hbase/conf/keytab.krb5</value>
297 </property>
298 <!-- optional params -->
299 <property>
300   <name>hbase.client.dns.interface</name>
301   <value>default</value>
302 </property>
303 <property>
304   <name>hbase.client.dns.nameserver</name>
305   <value>default</value>
306 </property>
307 ----
308 ====
310 === RegionSplitter
312 ----
313 usage: bin/hbase regionsplitter <TABLE> <SPLITALGORITHM>
314 SPLITALGORITHM is the java class name of a class implementing
315                       SplitAlgorithm, or one of the special strings
316                       HexStringSplit or DecimalStringSplit or
317                       UniformSplit, which are built-in split algorithms.
318                       HexStringSplit treats keys as hexadecimal ASCII, and
319                       DecimalStringSplit treats keys as decimal ASCII, and
320                       UniformSplit treats keys as arbitrary bytes.
321  -c <region count>        Create a new table with a pre-split number of
322                           regions
323  -D <property=value>      Override HBase Configuration Settings
324  -f <family:family:...>   Column Families to create with new table.
325                           Required with -c
326     --firstrow <arg>      First Row in Table for Split Algorithm
327  -h                       Print this usage help
328     --lastrow <arg>       Last Row in Table for Split Algorithm
329  -o <count>               Max outstanding splits that have unfinished
330                           major compactions
331  -r                       Perform a rolling split of an existing region
332     --risky               Skip verification steps to complete
333                           quickly. STRONGLY DISCOURAGED for production
334                           systems.
335 ----
337 For additional detail, see <<manual_region_splitting_decisions>>.
339 [[health.check]]
340 === Health Checker
342 You can configure HBase to run a script periodically and if it fails N times (configurable), have the server exit.
343 See _HBASE-7351 Periodic health check script_ for configurations and detail.
345 === Driver
347 Several frequently-accessed utilities are provided as `Driver` classes, and executed by the _bin/hbase_ command.
348 These utilities represent MapReduce jobs which run on your cluster.
349 They are run in the following way, replacing _UtilityName_ with the utility you want to run.
350 This command assumes you have set the environment variable `HBASE_HOME` to the directory where HBase is unpacked on your server.
352 ----
354 ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.mapreduce.UtilityName
355 ----
357 The following utilities are available:
359 `LoadIncrementalHFiles`::
360   Complete a bulk data load.
362 `CopyTable`::
363   Export a table from the local cluster to a peer cluster.
365 `Export`::
366   Write table data to HDFS.
368 `Import`::
369   Import data written by a previous `Export` operation.
371 `ImportTsv`::
372   Import data in TSV format.
374 `RowCounter`::
375   Count rows in an HBase table.
377 `CellCounter`::
378   Count cells in an HBase table.
380 `replication.VerifyReplication`::
381   Compare the data from tables in two different clusters.
382   WARNING: It doesn't work for incrementColumnValues'd cells since the timestamp is changed.
383   Note that this command is in a different package than the others.
385 Each command except `RowCounter` and `CellCounter` accept a single `--help` argument to print usage instructions.
387 [[hbck]]
388 === HBase `hbck`
390 The `hbck` tool that shipped with hbase-1.x has been made read-only in hbase-2.x. It is not able to repair
391 hbase-2.x clusters as hbase internals have changed. Nor should its assessments in read-only mode be
392 trusted as it does not understand hbase-2.x operation.
394 A new tool, <<HBCK2>>, described in the next section, replaces `hbck`.
396 [[HBCK2]]
397 === HBase `HBCK2`
399 `HBCK2` is the successor to <<hbck>>, the hbase-1.x fix tool (A.K.A `hbck1`). Use it in place of `hbck1`
400 making repairs against hbase-2.x installs.
402 `HBCK2` does not ship as part of hbase. It can be found as a subproject of the companion
403 link:https://github.com/apache/hbase-operator-tools[hbase-operator-tools] repository at
404 link:https://github.com/apache/hbase-operator-tools/tree/master/hbase-hbck2[Apache HBase HBCK2 Tool].
405 `HBCK2` was moved out of hbase so it could evolve at a cadence apart from that of hbase core.
407 See the [https://github.com/apache/hbase-operator-tools/tree/master/hbase-hbck2](HBCK2) Home Page
408 for how `HBCK2` differs from `hbck1`, and for how to build and use it.
410 Once built, you can run `HBCK2` as follows:
413 $ hbase hbck -j /path/to/HBCK2.jar
416 This will generate `HBCK2` usage describing commands and options.
418 [[hfile_tool2]]
419 === HFile Tool
421 See <<hfile_tool>>.
423 === WAL Tools
424 For bulk replaying WAL files or _recovered.edits_ files, see
425 <<walplayer>>. For reading/verifying individual files, read on.
427 [[hlog_tool]]
428 ==== FSHLog tool
430 The main method on `FSHLog` offers manual split and dump facilities.
431 Pass it WALs or the product of a split, the content of the _recovered.edits_.
432 directory.
434 You can get a textual dump of a WAL file content by doing the following:
436 ----
437  $ ./bin/hbase org.apache.hadoop.hbase.regionserver.wal.FSHLog --dump hdfs://example.org:8020/hbase/WALs/example.org,60020,1283516293161/10.10.21.10%3A60020.1283973724012
438 ----
440 The return code will be non-zero if there are any issues with the file so you can test wholesomeness of file by redirecting `STDOUT` to `/dev/null` and testing the program return.
442 Similarly you can force a split of a log file directory by doing:
444 ----
445  $ ./bin/hbase org.apache.hadoop.hbase.regionserver.wal.FSHLog --split hdfs://example.org:8020/hbase/WALs/example.org,60020,1283516293161/
446 ----
448 [[hlog_tool.prettyprint]]
449 ===== WALPrettyPrinter
451 The `WALPrettyPrinter` is a tool with configurable options to print the contents of a WAL.
452 You can invoke it via the HBase cli with the 'wal' command.
454 ----
455  $ ./bin/hbase wal hdfs://example.org:8020/hbase/WALs/example.org,60020,1283516293161/10.10.21.10%3A60020.1283973724012
456 ----
458 .WAL Printing in older versions of HBase
459 [NOTE]
460 ====
461 Prior to version 2.0, the `WALPrettyPrinter` was called the `HLogPrettyPrinter`, after an internal name for HBase's write ahead log.
462 In those versions, you can print the contents of a WAL using the same configuration as above, but with the 'hlog' command.
464 ----
465  $ ./bin/hbase hlog hdfs://example.org:8020/hbase/.logs/example.org,60020,1283516293161/10.10.21.10%3A60020.1283973724012
466 ----
467 ====
469 [[compression.tool]]
470 === Compression Tool
472 See <<compression.test,compression.test>>.
474 [[copy.table]]
475 === CopyTable
477 CopyTable is a utility that can copy part or of all of a table, either to the same cluster or another cluster.
478 The target table must first exist.
479 The usage is as follows:
481 ----
483 $ ./bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --help
484 /bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --help
485 Usage: CopyTable [general options] [--starttime=X] [--endtime=Y] [--new.name=NEW] [--peer.adr=ADR] <tablename>
487 Options:
488  rs.class     hbase.regionserver.class of the peer cluster,
489               specify if different from current cluster
490  rs.impl      hbase.regionserver.impl of the peer cluster,
491  startrow     the start row
492  stoprow      the stop row
493  starttime    beginning of the time range (unixtime in millis)
494               without endtime means from starttime to forever
495  endtime      end of the time range.  Ignored if no starttime specified.
496  versions     number of cell versions to copy
497  new.name     new table's name
498  peer.adr     Address of the peer cluster given in the format
499               hbase.zookeeer.quorum:hbase.zookeeper.client.port:zookeeper.znode.parent
500  families     comma-separated list of families to copy
501               To copy from cf1 to cf2, give sourceCfName:destCfName.
502               To keep the same name, just give "cfName"
503  all.cells    also copy delete markers and deleted cells
505 Args:
506  tablename    Name of the table to copy
508 Examples:
509  To copy 'TestTable' to a cluster that uses replication for a 1 hour window:
510  $ bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --starttime=1265875194289 --endtime=1265878794289 --peer.adr=server1,server2,server3:2181:/hbase --families=myOldCf:myNewCf,cf2,cf3 TestTable
512 For performance consider the following general options:
513   It is recommended that you set the following to >=100. A higher value uses more memory but
514   decreases the round trip time to the server and may increase performance.
515     -Dhbase.client.scanner.caching=100
516   The following should always be set to false, to prevent writing data twice, which may produce
517   inaccurate results.
518     -Dmapred.map.tasks.speculative.execution=false
519 ----
521 .Scanner Caching
522 [NOTE]
523 ====
524 Caching for the input Scan is configured via `hbase.client.scanner.caching`          in the job configuration.
525 ====
527 .Versions
528 [NOTE]
529 ====
530 By default, CopyTable utility only copies the latest version of row cells unless `--versions=n` is explicitly specified in the command.
531 ====
533 .Data Load
534 [NOTE]
535 ====
536 CopyTable does not perform a diff, it copies all Cells in between the specified startrow/stoprow starttime/endtime range.
537 This means that already existing cells with same values will still be copied.
538 ====
540 See Jonathan Hsieh's link:https://blog.cloudera.com/blog/2012/06/online-hbase-backups-with-copytable-2/[Online
541           HBase Backups with CopyTable] blog post for more on `CopyTable`.
543 [[hashtable.synctable]]
544 === HashTable/SyncTable
546 HashTable/SyncTable is a two steps tool for synchronizing table data, where each of the steps are implemented as MapReduce jobs.
547 Similarly to CopyTable, it can be used for partial or entire table data syncing, under same or remote cluster.
548 However, it performs the sync in a more efficient way than CopyTable. Instead of copying all cells
549 in specified row key/time period range, HashTable (the first step) creates hashed indexes for batch of cells on source table and output those as results.
550 On the next stage, SyncTable scans the source table and now calculates hash indexes for table cells,
551 compares these hashes with the outputs of HashTable, then it just scans (and compares) cells for diverging hashes, only updating
552 mismatching cells. This results in less network traffic/data transfers, which can be impacting when syncing large tables on remote clusters.
554 ==== Step 1, HashTable
556 First, run HashTable on the source table cluster (this is the table whose state will be copied to its counterpart).
558 Usage:
560 ----
561 $ ./bin/hbase org.apache.hadoop.hbase.mapreduce.HashTable --help
562 Usage: HashTable [options] <tablename> <outputpath>
564 Options:
565  batchsize     the target amount of bytes to hash in each batch
566                rows are added to the batch until this size is reached
567                (defaults to 8000 bytes)
568  numhashfiles  the number of hash files to create
569                if set to fewer than number of regions then
570                the job will create this number of reducers
571                (defaults to 1/100 of regions -- at least 1)
572  startrow      the start row
573  stoprow       the stop row
574  starttime     beginning of the time range (unixtime in millis)
575                without endtime means from starttime to forever
576  endtime       end of the time range.  Ignored if no starttime specified.
577  scanbatch     scanner batch size to support intra row scans
578  versions      number of cell versions to include
579  families      comma-separated list of families to include
581 Args:
582  tablename     Name of the table to hash
583  outputpath    Filesystem path to put the output data
585 Examples:
586  To hash 'TestTable' in 32kB batches for a 1 hour window into 50 files:
587  $ bin/hbase org.apache.hadoop.hbase.mapreduce.HashTable --batchsize=32000 --numhashfiles=50 --starttime=1265875194289 --endtime=1265878794289 --families=cf2,cf3 TestTable /hashes/testTable
588 ----
590 The *batchsize* property defines how much cell data for a given region will be hashed together in a single hash value.
591 Sizing this properly has a direct impact on the sync efficiency, as it may lead to less scans executed by mapper tasks
592 of SyncTable (the next step in the process). The rule of thumb is that, the smaller the number of cells out of sync
593 (lower probability of finding a diff), larger batch size values can be determined.
595 ==== Step 2, SyncTable
597 Once HashTable has completed on source cluster, SyncTable can be ran on target cluster.
598 Just like replication and other synchronization jobs, it requires that all RegionServers/DataNodes
599 on source cluster be accessible by NodeManagers on the target cluster (where SyncTable job tasks will be running).
601 Usage:
603 ----
604 $ ./bin/hbase org.apache.hadoop.hbase.mapreduce.SyncTable --help
605 Usage: SyncTable [options] <sourcehashdir> <sourcetable> <targettable>
607 Options:
608  sourcezkcluster  ZK cluster key of the source table
609                   (defaults to cluster in classpath's config)
610  targetzkcluster  ZK cluster key of the target table
611                   (defaults to cluster in classpath's config)
612  dryrun           if true, output counters but no writes
613                   (defaults to false)
614  doDeletes        if false, does not perform deletes
615                   (defaults to true)
616  doPuts           if false, does not perform puts
617                   (defaults to true)
619 Args:
620  sourcehashdir    path to HashTable output dir for source table
621                   (see org.apache.hadoop.hbase.mapreduce.HashTable)
622  sourcetable      Name of the source table to sync from
623  targettable      Name of the target table to sync to
625 Examples:
626  For a dry run SyncTable of tableA from a remote source cluster
627  to a local target cluster:
628  $ bin/hbase org.apache.hadoop.hbase.mapreduce.SyncTable --dryrun=true --sourcezkcluster=zk1.example.com,zk2.example.com,zk3.example.com:2181:/hbase hdfs://nn:9000/hashes/tableA tableA tableA
629 ----
631 The *dryrun* option is useful when a read only, diff report is wanted, as it will produce only COUNTERS indicating the differences, but will not perform
632 any actual changes. It can be used as an alternative to VerifyReplication tool.
634 By default, SyncTable will cause target table to become an exact copy of source table (at least, for the specified startrow/stoprow or/and starttime/endtime).
636 Setting doDeletes to false modifies default behaviour to not delete target cells that are missing on source.
637 Similarly, setting doPuts to false modifies default behaviour to not add missing cells on target. Setting both doDeletes
638 and doPuts to false would give same effect as setting dryrun to true.
640 .Additional info on doDeletes/doPuts
641 [NOTE]
642 ====
643 "doDeletes/doPuts" were only added by
644 link:https://jira.apache.org/jira/browse/HBASE-20305[HBASE-20305], so these may not be available on
645 all released versions.
646 For major 1.x versions, minimum minor release including it is *1.4.10*.
647 For major 2.x versions, minimum minor release including it is *2.1.5*.
648 ====
650 .Set doDeletes to false on Two-Way Replication scenarios
651 [NOTE]
652 ====
653 On Two-Way Replication or other scenarios where both source and target clusters can have data ingested, it's advisable to always set doDeletes option to false,
654 as any additional cell inserted on SyncTable target cluster and not yet replicated to source would be deleted, and potentially lost permanently.
655 ====
657 .Set sourcezkcluster to the actual source cluster ZK quorum
658 [NOTE]
659 ====
660 Although not required, if sourcezkcluster is not set, SyncTable will connect to local HBase cluster for both source and target,
661 which does not give any meaningful result.
662 ====
664 .Remote Clusters on different Kerberos Realms
665 [NOTE]
666 ====
667 Often, remote clusters may be deployed on different Kerberos Realms.
668 link:https://jira.apache.org/jira/browse/HBASE-20586[HBASE-20586] added SyncTable support for
669 cross realm authentication, allowing a SyncTable process running on target cluster to connect to
670 source cluster and read both HashTable output files and the given HBase table when performing the
671 required comparisons.
672 ====
674 [[export]]
675 === Export
677 Export is a utility that will dump the contents of table to HDFS in a sequence file.
678 The Export can be run via a Coprocessor Endpoint or MapReduce. Invoke via:
680 *mapreduce-based Export*
681 ----
682 $ bin/hbase org.apache.hadoop.hbase.mapreduce.Export <tablename> <outputdir> [<versions> [<starttime> [<endtime>]]]
683 ----
685 *endpoint-based Export*
687 NOTE: Make sure the Export coprocessor is enabled by adding `org.apache.hadoop.hbase.coprocessor.Export` to `hbase.coprocessor.region.classes`.
688 ----
689 $ bin/hbase org.apache.hadoop.hbase.coprocessor.Export <tablename> <outputdir> [<versions> [<starttime> [<endtime>]]]
690 ----
691 The outputdir is a HDFS directory that does not exist prior to the export. When done, the exported files will be owned by the user invoking the export command.
693 *The Comparison of Endpoint-based Export And Mapreduce-based Export*
694 |===
695 ||Endpoint-based Export|Mapreduce-based Export
697 |HBase version requirement
698 |2.0+
699 |0.2.1+
701 |Maven dependency
702 |hbase-endpoint
703 |hbase-mapreduce (2.0+), hbase-server(prior to 2.0)
705 |Requirement before dump
706 |mount the endpoint.Export on the target table
707 |deploy the MapReduce framework
709 |Read latency
710 |low, directly read the data from region
711 |normal, traditional RPC scan
713 |Read Scalability
714 |depend on number of regions
715 |depend on number of mappers (see TableInputFormatBase#getSplits)
717 |Timeout
718 |operation timeout. configured by hbase.client.operation.timeout
719 |scan timeout. configured by hbase.client.scanner.timeout.period
721 |Permission requirement
722 |READ, EXECUTE
723 |READ
725 |Fault tolerance
727 |depend on MapReduce
728 |===
731 NOTE: To see usage instructions, run the command with no options. Available options include
732 specifying column families and applying filters during the export.
734 By default, the `Export` tool only exports the newest version of a given cell, regardless of the number of versions stored. To export more than one version, replace *_<versions>_* with the desired number of versions.
736 Note: caching for the input Scan is configured via `hbase.client.scanner.caching` in the job configuration.
738 [[import]]
739 === Import
741 Import is a utility that will load data that has been exported back into HBase.
742 Invoke via:
744 ----
745 $ bin/hbase org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir>
746 ----
748 NOTE: To see usage instructions, run the command with no options.
750 To import 0.94 exported files in a 0.96 cluster or onwards, you need to set system property "hbase.import.version" when running the import command as below:
752 ----
753 $ bin/hbase -Dhbase.import.version=0.94 org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir>
754 ----
756 [[importtsv]]
757 === ImportTsv
759 ImportTsv is a utility that will load data in TSV format into HBase.
760 It has two distinct usages: loading data from TSV format in HDFS into HBase via Puts, and preparing StoreFiles to be loaded via the `completebulkload`.
762 To load data via Puts (i.e., non-bulk loading):
764 ----
765 $ bin/hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.columns=a,b,c <tablename> <hdfs-inputdir>
766 ----
768 To generate StoreFiles for bulk-loading:
770 [source,bourne]
771 ----
772 $ bin/hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.columns=a,b,c -Dimporttsv.bulk.output=hdfs://storefile-outputdir <tablename> <hdfs-data-inputdir>
773 ----
775 These generated StoreFiles can be loaded into HBase via <<completebulkload,completebulkload>>.
777 [[importtsv.options]]
778 ==== ImportTsv Options
780 Running `ImportTsv` with no arguments prints brief usage information:
782 ----
784 Usage: importtsv -Dimporttsv.columns=a,b,c <tablename> <inputdir>
786 Imports the given input directory of TSV data into the specified table.
788 The column names of the TSV data must be specified using the -Dimporttsv.columns
789 option. This option takes the form of comma-separated column names, where each
790 column name is either a simple column family, or a columnfamily:qualifier. The special
791 column name HBASE_ROW_KEY is used to designate that this column should be used
792 as the row key for each imported record. You must specify exactly one column
793 to be the row key, and you must specify a column name for every column that exists in the
794 input data.
796 By default importtsv will load data directly into HBase. To instead generate
797 HFiles of data to prepare for a bulk data load, pass the option:
798   -Dimporttsv.bulk.output=/path/for/output
799   Note: the target table will be created with default column family descriptors if it does not already exist.
801 Other options that may be specified with -D include:
802   -Dimporttsv.skip.bad.lines=false - fail if encountering an invalid line
803   '-Dimporttsv.separator=|' - eg separate on pipes instead of tabs
804   -Dimporttsv.timestamp=currentTimeAsLong - use the specified timestamp for the import
805   -Dimporttsv.mapper.class=my.Mapper - A user-defined Mapper to use instead of org.apache.hadoop.hbase.mapreduce.TsvImporterMapper
806 ----
808 [[importtsv.example]]
809 ==== ImportTsv Example
811 For example, assume that we are loading data into a table called 'datatsv' with a ColumnFamily called 'd' with two columns "c1" and "c2".
813 Assume that an input file exists as follows:
814 ----
816 row1    c1      c2
817 row2    c1      c2
818 row3    c1      c2
819 row4    c1      c2
820 row5    c1      c2
821 row6    c1      c2
822 row7    c1      c2
823 row8    c1      c2
824 row9    c1      c2
825 row10   c1      c2
826 ----
828 For ImportTsv to use this input file, the command line needs to look like this:
830 ----
832  HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-mapreduce-VERSION.jar importtsv -Dimporttsv.columns=HBASE_ROW_KEY,d:c1,d:c2 -Dimporttsv.bulk.output=hdfs://storefileoutput datatsv hdfs://inputfile
833 ----
835 \... and in this example the first column is the rowkey, which is why the HBASE_ROW_KEY is used.
836 The second and third columns in the file will be imported as "d:c1" and "d:c2", respectively.
838 [[importtsv.warning]]
839 ==== ImportTsv Warning
841 If you have preparing a lot of data for bulk loading, make sure the target HBase table is pre-split appropriately.
843 [[importtsv.also]]
844 ==== See Also
846 For more information about bulk-loading HFiles into HBase, see <<arch.bulk.load,arch.bulk.load>>
848 [[completebulkload]]
849 === CompleteBulkLoad
851 The `completebulkload` utility will move generated StoreFiles into an HBase table.
852 This utility is often used in conjunction with output from <<importtsv,importtsv>>.
854 There are two ways to invoke this utility, with explicit classname and via the driver:
856 .Explicit Classname
857 ----
858 $ bin/hbase org.apache.hadoop.hbase.tool.LoadIncrementalHFiles <hdfs://storefileoutput> <tablename>
859 ----
861 .Driver
862 ----
863 HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-mapreduce-VERSION.jar completebulkload <hdfs://storefileoutput> <tablename>
864 ----
866 [[completebulkload.warning]]
867 ==== CompleteBulkLoad Warning
869 Data generated via MapReduce is often created with file permissions that are not compatible with the running HBase process.
870 Assuming you're running HDFS with permissions enabled, those permissions will need to be updated before you run CompleteBulkLoad.
872 For more information about bulk-loading HFiles into HBase, see <<arch.bulk.load,arch.bulk.load>>.
874 [[walplayer]]
875 === WALPlayer
877 WALPlayer is a utility to replay WAL files into HBase.
879 The WAL can be replayed for a set of tables or all tables, and a timerange can be provided (in milliseconds). The WAL is filtered to this set of tables.
880 The output can optionally be mapped to another set of tables.
882 WALPlayer can also generate HFiles for later bulk importing, in that case only a single table and no mapping can be specified.
884 .WALPrettyPrinter/FSHLog Tool
885 [NOTE]
886 ====
887 To read or verify single WAL files or _recovered.edits_ files, since they share the WAL format,
888 see <<_wal_tools>>.
889 ====
891 Invoke via:
893 ----
894 $ bin/hbase org.apache.hadoop.hbase.mapreduce.WALPlayer [options] <wal inputdir> <tables> [<tableMappings>]>
895 ----
897 For example:
899 ----
900 $ bin/hbase org.apache.hadoop.hbase.mapreduce.WALPlayer /backuplogdir oldTable1,oldTable2 newTable1,newTable2
901 ----
903 WALPlayer, by default, runs as a mapreduce job.
904 To NOT run WALPlayer as a mapreduce job on your cluster, force it to run all in the local process by adding the flags `-Dmapreduce.jobtracker.address=local` on the command line.
906 [[walplayer.options]]
907 ==== WALPlayer Options
909 Running `WALPlayer` with no arguments prints brief usage information:
911 ----
912 Usage: WALPlayer [options] <wal inputdir> <tables> [<tableMappings>]
913 Replay all WAL files into HBase.
914 <tables> is a comma separated list of tables.
915 If no tables ("") are specified, all tables are imported.
916 (Be careful, hbase:meta entries will be imported in this case.)
918 WAL entries can be mapped to new set of tables via <tableMappings>.
919 <tableMappings> is a comma separated list of target tables.
920 If specified, each table in <tables> must have a mapping.
922 By default WALPlayer will load data directly into HBase.
923 To generate HFiles for a bulk data load instead, pass the following option:
924   -Dwal.bulk.output=/path/for/output
925   (Only one table can be specified, and no mapping is allowed!)
926 Time range options:
927   -Dwal.start.time=[date|ms]
928   -Dwal.end.time=[date|ms]
929   (The start and the end date of timerange. The dates can be expressed
930   in milliseconds since epoch or in yyyy-MM-dd'T'HH:mm:ss.SS format.
931   E.g. 1234567890120 or 2009-02-13T23:32:30.12)
932 Other options:
933   -Dmapreduce.job.name=jobName
934   Use the specified mapreduce job name for the wal player
935 For performance also consider the following options:
936   -Dmapreduce.map.speculative=false
937   -Dmapreduce.reduce.speculative=false
938 ----
940 [[rowcounter]]
941 === RowCounter
943 link:https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/RowCounter.html[RowCounter] is a mapreduce job to count all the rows of a table.
944 This is a good utility to use as a sanity check to ensure that HBase can read all the blocks of a table if there are any concerns of metadata inconsistency.
945 It will run the mapreduce all in a single process but it will run faster if you have a MapReduce cluster in place for it to exploit.
946 It is possible to limit the time range of data to be scanned by using the `--starttime=[starttime]` and `--endtime=[endtime]` flags.
947 The scanned data can be limited based on keys using the `--range=[startKey],[endKey][;[startKey],[endKey]...]` option.
949 ----
950 $ bin/hbase rowcounter [options] <tablename> [--starttime=<start> --endtime=<end>] [--range=[startKey],[endKey][;[startKey],[endKey]...]] [<column1> <column2>...]
951 ----
953 RowCounter only counts one version per cell.
955 For performance consider to use `-Dhbase.client.scanner.caching=100` and `-Dmapreduce.map.speculative=false` options.
957 [[cellcounter]]
958 === CellCounter
960 HBase ships another diagnostic mapreduce job called link:https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/CellCounter.html[CellCounter].
961 Like RowCounter, it gathers more fine-grained statistics about your table.
962 The statistics gathered by CellCounter are more fine-grained and include:
964 * Total number of rows in the table.
965 * Total number of CFs across all rows.
966 * Total qualifiers across all rows.
967 * Total occurrence of each CF.
968 * Total occurrence of each qualifier.
969 * Total number of versions of each qualifier.
971 The program allows you to limit the scope of the run.
972 Provide a row regex or prefix to limit the rows to analyze.
973 Specify a time range to scan the table by using the `--starttime=<starttime>` and `--endtime=<endtime>` flags.
975 Use `hbase.mapreduce.scan.column.family` to specify scanning a single column family.
977 ----
978 $ bin/hbase cellcounter <tablename> <outputDir> [reportSeparator] [regex or prefix] [--starttime=<starttime> --endtime=<endtime>]
979 ----
981 Note: just like RowCounter, caching for the input Scan is configured via `hbase.client.scanner.caching` in the job configuration.
983 === mlockall
985 It is possible to optionally pin your servers in physical memory making them less likely to be swapped out in oversubscribed environments by having the servers call link:http://linux.die.net/man/2/mlockall[mlockall] on startup.
986 See link:https://issues.apache.org/jira/browse/HBASE-4391[HBASE-4391 Add ability to start RS as root and call mlockall] for how to build the optional library and have it run on startup.
988 [[compaction.tool]]
989 === Offline Compaction Tool
991 *CompactionTool* provides a way of running compactions (either minor or major) as an independent
992 process from the RegionServer. It reuses same internal implementation classes executed by RegionServer
993 compaction feature. However, since this runs on a complete separate independent java process, it
994 releases RegionServers from the overhead involved in rewrite a set of hfiles, which can be critical
995 for latency sensitive use cases.
997 Usage:
998 ----
999 $ ./bin/hbase org.apache.hadoop.hbase.regionserver.CompactionTool
1001 Usage: java org.apache.hadoop.hbase.regionserver.CompactionTool \
1002   [-compactOnce] [-major] [-mapred] [-D<property=value>]* files...
1004 Options:
1005  mapred         Use MapReduce to run compaction.
1006  compactOnce    Execute just one compaction step. (default: while needed)
1007  major          Trigger major compaction.
1009 Note: -D properties will be applied to the conf used.
1010 For example:
1011  To stop delete of compacted file, pass -Dhbase.compactiontool.delete=false
1012  To set tmp dir, pass -Dhbase.tmp.dir=ALTERNATE_DIR
1014 Examples:
1015  To compact the full 'TestTable' using MapReduce:
1016  $ hbase org.apache.hadoop.hbase.regionserver.CompactionTool -mapred hdfs://hbase/data/default/TestTable
1018  To compact column family 'x' of the table 'TestTable' region 'abc':
1019  $ hbase org.apache.hadoop.hbase.regionserver.CompactionTool hdfs://hbase/data/default/TestTable/abc/x
1020 ----
1022 As shown by usage options above, *CompactionTool* can run as a standalone client or a mapreduce job.
1023 When running as mapreduce job, each family dir is handled as an input split, and is processed
1024 by a separate map task.
1026 The *compactionOnce* parameter controls how many compaction cycles will be performed until
1027 *CompactionTool* program decides to finish its work. If omitted, it will assume it should keep
1028 running compactions on each specified family as determined by the given compaction policy
1029 configured. For more info on compaction policy, see <<compaction,compaction>>.
1031 If a major compaction is desired, *major* flag can be specified. If omitted, *CompactionTool* will
1032 assume minor compaction is wanted by default.
1034 It also allows for configuration overrides with `-D` flag. In the usage section above, for example,
1035 `-Dhbase.compactiontool.delete=false` option will instruct compaction engine to not delete original
1036 files from temp folder.
1038 Files targeted for compaction must be specified as parent hdfs dirs. It allows for multiple dirs
1039 definition, as long as each for these dirs are either a *family*, a *region*, or a *table* dir. If a
1040 table or region dir is passed, the program will recursively iterate through related sub-folders,
1041 effectively running compaction for each family found below the table/region level.
1043 Since these dirs are nested under *hbase* hdfs directory tree, *CompactionTool* requires hbase super
1044 user permissions in order to have access to required hfiles.
1046 .Running in MapReduce mode
1047 [NOTE]
1048 ====
1049 MapReduce mode offers the ability to process each family dir in parallel, as a separate map task.
1050 Generally, it would make sense to run in this mode when specifying one or more table dirs as targets
1051 for compactions. The caveat, though, is that if number of families to be compacted become too large,
1052 the related mapreduce job may have indirect impacts on *RegionServers* performance .
1053 Since *NodeManagers* are normally co-located with RegionServers, such large jobs could
1054 compete for IO/Bandwidth resources with the *RegionServers*.
1055 ====
1057 .MajorCompaction completely disabled on RegionServers due performance impacts
1058 [NOTE]
1059 ====
1060 *Major compactions* can be a costly operation (see <<compaction,compaction>>), and can indeed
1061 impact performance on RegionServers, leading operators to completely disable it for critical
1062 low latency application. *CompactionTool* could be used as an alternative in such scenarios,
1063 although, additional custom application logic would need to be implemented, such as deciding
1064 scheduling and selection of tables/regions/families target for a given compaction run.
1065 ====
1067 For additional details about CompactionTool, see also
1068 link:https://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/regionserver/CompactionTool.html[CompactionTool].
1070 === `hbase clean`
1072 The `hbase clean` command cleans HBase data from ZooKeeper, HDFS, or both.
1073 It is appropriate to use for testing.
1074 Run it with no options for usage instructions.
1075 The `hbase clean` command was introduced in HBase 0.98.
1077 ----
1079 $ bin/hbase clean
1080 Usage: hbase clean (--cleanZk|--cleanHdfs|--cleanAll)
1081 Options:
1082         --cleanZk   cleans hbase related data from zookeeper.
1083         --cleanHdfs cleans hbase related data from hdfs.
1084         --cleanAll  cleans hbase related data from both zookeeper and hdfs.
1085 ----
1087 === `hbase pe`
1089 The `hbase pe` command runs the PerformanceEvaluation tool, which is used for testing.
1091 The PerformanceEvaluation tool accepts many different options and commands.
1092 For usage instructions, run the command with no options.
1094 The PerformanceEvaluation tool has received many updates in recent HBase releases, including support for namespaces, support for tags, cell-level ACLs and visibility labels, multiget support for RPC calls, increased sampling sizes, an option to randomly sleep during testing, and ability to "warm up" the cluster before testing starts.
1096 === `hbase ltt`
1098 The `hbase ltt` command runs the LoadTestTool utility, which is used for testing.
1100 You must specify either `-init_only` or at least one of `-write`, `-update`, or `-read`.
1101 For general usage instructions, pass the `-h` option.
1103 The LoadTestTool has received many updates in recent HBase releases, including support for namespaces, support for tags, cell-level ACLS and visibility labels, testing security-related features, ability to specify the number of regions per server, tests for multi-get RPC calls, and tests relating to replication.
1105 [[ops.pre-upgrade]]
1106 === Pre-Upgrade validator
1107 Pre-Upgrade validator tool can be used to check the cluster for known incompatibilities before upgrading from HBase 1 to HBase 2.
1109 [source, bash]
1110 ----
1111 $ bin/hbase pre-upgrade command ...
1112 ----
1114 ==== Coprocessor validation
1116 HBase supports co-processors for a long time, but the co-processor API can be changed between major releases. Co-processor validator tries to determine
1117 whether the old co-processors are still compatible with the actual HBase version.
1119 [source, bash]
1120 ----
1121 $ bin/hbase pre-upgrade validate-cp [-jar ...] [-class ... | -table ... | -config]
1122 Options:
1123  -e            Treat warnings as errors.
1124  -jar <arg>    Jar file/directory of the coprocessor.
1125  -table <arg>  Table coprocessor(s) to check.
1126  -class <arg>  Coprocessor class(es) to check.
1127  -config         Scan jar for observers.
1128 ----
1130 The co-processor classes can be explicitly declared by `-class` option, or they can be obtained from HBase configuration by `-config` option.
1131 Table level co-processors can be also checked by `-table` option. The tool searches for co-processors on its classpath, but it can be extended
1132 by the `-jar` option. It is possible to test multiple classes with multiple `-class`, multiple tables with multiple `-table` options as well as
1133 adding multiple jars to the classpath with multiple `-jar` options.
1135 The tool can report errors and warnings. Errors mean that HBase won't be able to load the coprocessor, because it is incompatible with the current version
1136 of HBase. Warnings mean that the co-processors can be loaded, but they won't work as expected. If `-e` option is given, then the tool will also fail
1137 for warnings.
1139 Please note that this tool cannot validate every aspect of jar files, it just does some static checks.
1141 For example:
1143 [source, bash]
1144 ----
1145 $ bin/hbase pre-upgrade validate-cp -jar my-coprocessor.jar -class MyMasterObserver -class MyRegionObserver
1146 ----
1148 It validates `MyMasterObserver` and `MyRegionObserver` classes which are located in `my-coprocessor.jar`.
1150 [source, bash]
1151 ----
1152 $ bin/hbase pre-upgrade validate-cp -table .*
1153 ----
1155 It validates every table level co-processors where the table name matches to `.*` regular expression.
1157 ==== DataBlockEncoding validation
1158 HBase 2.0 removed `PREFIX_TREE` Data Block Encoding from column families. For further information
1159 please check <<upgrade2.0.prefix-tree.removed,_prefix-tree_ encoding removed>>.
1160 To verify that none of the column families are using incompatible Data Block Encodings in the cluster run the following command.
1162 [source, bash]
1163 ----
1164 $ bin/hbase pre-upgrade validate-dbe
1165 ----
1167 This check validates all column families and print out any incompatibilities. For example:
1169 ----
1170 2018-07-13 09:58:32,028 WARN  [main] tool.DataBlockEncodingValidator: Incompatible DataBlockEncoding for table: t, cf: f, encoding: PREFIX_TREE
1171 ----
1173 Which means that Data Block Encoding of table `t`, column family `f` is incompatible. To fix, use `alter` command in HBase shell:
1175 ----
1176 alter 't', { NAME => 'f', DATA_BLOCK_ENCODING => 'FAST_DIFF' }
1177 ----
1179 Please also validate HFiles, which is described in the next section.
1181 ==== HFile Content validation
1182 Even though Data Block Encoding is changed from `PREFIX_TREE` it is still possible to have HFiles that contain data encoded that way.
1183 To verify that HFiles are readable with HBase 2 please use _HFile content validator_.
1185 [source, bash]
1186 ----
1187 $ bin/hbase pre-upgrade validate-hfile
1188 ----
1190 The tool will log the corrupt HFiles and details about the root cause.
1191 If the problem is about PREFIX_TREE encoding it is necessary to change encodings before upgrading to HBase 2.
1193 The following log message shows an example of incorrect HFiles.
1195 ----
1196 2018-06-05 16:20:46,976 WARN  [hfilevalidator-pool1-t3] hbck.HFileCorruptionChecker: Found corrupt HFile hdfs://example.com:8020/hbase/data/default/t/72ea7f7d625ee30f959897d1a3e2c350/prefix/7e6b3d73263c4851bf2b8590a9b3791e
1197 org.apache.hadoop.hbase.io.hfile.CorruptHFileException: Problem reading HFile Trailer from file hdfs://example.com:8020/hbase/data/default/t/72ea7f7d625ee30f959897d1a3e2c350/prefix/7e6b3d73263c4851bf2b8590a9b3791e
1198     ...
1199 Caused by: java.io.IOException: Invalid data block encoding type in file info: PREFIX_TREE
1200     ...
1201 Caused by: java.lang.IllegalArgumentException: No enum constant org.apache.hadoop.hbase.io.encoding.DataBlockEncoding.PREFIX_TREE
1202     ...
1203 2018-06-05 16:20:47,322 INFO  [main] tool.HFileContentValidator: Corrupted file: hdfs://example.com:8020/hbase/data/default/t/72ea7f7d625ee30f959897d1a3e2c350/prefix/7e6b3d73263c4851bf2b8590a9b3791e
1204 2018-06-05 16:20:47,383 INFO  [main] tool.HFileContentValidator: Corrupted file: hdfs://example.com:8020/hbase/archive/data/default/t/56be41796340b757eb7fff1eb5e2a905/f/29c641ae91c34fc3bee881f45436b6d1
1205 ----
1207 ===== Fixing PREFIX_TREE errors
1209 It's possible to get `PREFIX_TREE` errors after changing Data Block Encoding to a supported one. It can happen
1210 because there are some HFiles which still encoded with `PREFIX_TREE` or there are still some snapshots.
1212 For fixing HFiles, please run a major compaction on the table (it was `default:t` according to the log message):
1214 ----
1215 major_compact 't'
1216 ----
1218 HFiles can be referenced from snapshots, too. It's the case when the HFile is located under `archive/data`.
1219 The first step is to determine which snapshot references that HFile (the name of the file was `29c641ae91c34fc3bee881f45436b6d1`
1220 according to the logs):
1222 [source, bash]
1223 ----
1224 for snapshot in $(hbase snapshotinfo -list-snapshots 2> /dev/null | tail -n -1 | cut -f 1 -d \|);
1226   echo "checking snapshot named '${snapshot}'";
1227   hbase snapshotinfo -snapshot "${snapshot}" -files 2> /dev/null | grep 29c641ae91c34fc3bee881f45436b6d1;
1228 done
1229 ----
1231 The output of this shell script is:
1233 ----
1234 checking snapshot named 't_snap'
1235    1.0 K t/56be41796340b757eb7fff1eb5e2a905/f/29c641ae91c34fc3bee881f45436b6d1 (archive)
1236 ----
1238 Which means `t_snap` snapshot references the incompatible HFile. If the snapshot is still needed,
1239 then it has to be recreated with HBase shell:
1241 ----
1242 # creating a new namespace for the cleanup process
1243 create_namespace 'pre_upgrade_cleanup'
1245 # creating a new snapshot
1246 clone_snapshot 't_snap', 'pre_upgrade_cleanup:t'
1247 alter 'pre_upgrade_cleanup:t', { NAME => 'f', DATA_BLOCK_ENCODING => 'FAST_DIFF' }
1248 major_compact 'pre_upgrade_cleanup:t'
1250 # removing the invalid snapshot
1251 delete_snapshot 't_snap'
1253 # creating a new snapshot
1254 snapshot 'pre_upgrade_cleanup:t', 't_snap'
1256 # removing temporary table
1257 disable 'pre_upgrade_cleanup:t'
1258 drop 'pre_upgrade_cleanup:t'
1259 drop_namespace 'pre_upgrade_cleanup'
1260 ----
1262 For further information, please refer to
1263 link:https://issues.apache.org/jira/browse/HBASE-20649?focusedCommentId=16535476#comment-16535476[HBASE-20649].
1265 === Data Block Encoding Tool
1267 Tests various compression algorithms with different data block encoder for key compression on an existing HFile.
1268 Useful for testing, debugging and benchmarking.
1270 You must specify `-f` which is the full path of the HFile.
1272 The result shows both the performance (MB/s) of compression/decompression and encoding/decoding, and the data savings on the HFile.
1274 ----
1276 $ bin/hbase org.apache.hadoop.hbase.regionserver.DataBlockEncodingTool
1277 Usages: hbase org.apache.hadoop.hbase.regionserver.DataBlockEncodingTool
1278 Options:
1279         -f HFile to analyse (REQUIRED)
1280         -n Maximum number of key/value pairs to process in a single benchmark run.
1281         -b Whether to run a benchmark to measure read throughput.
1282         -c If this is specified, no correctness testing will be done.
1283         -a What kind of compression algorithm use for test. Default value: GZ.
1284         -t Number of times to run each benchmark. Default value: 12.
1285         -omit Number of first runs of every benchmark to omit from statistics. Default value: 2.
1287 ----
1289 [[ops.regionmgt]]
1290 == Region Management
1292 [[ops.regionmgt.majorcompact]]
1293 === Major Compaction
1295 Major compactions can be requested via the HBase shell or link:https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Admin.html#majorCompact-org.apache.hadoop.hbase.TableName-[Admin.majorCompact].
1297 Note: major compactions do NOT do region merges.
1298 See <<compaction,compaction>> for more information about compactions.
1300 [[ops.regionmgt.merge]]
1301 === Merge
1303 Merge is a utility that can merge adjoining regions in the same table (see org.apache.hadoop.hbase.util.Merge).
1305 [source,bourne]
1306 ----
1307 $ bin/hbase org.apache.hadoop.hbase.util.Merge <tablename> <region1> <region2>
1308 ----
1310 If you feel you have too many regions and want to consolidate them, Merge is the utility you need.
1311 Merge must run be done when the cluster is down.
1312 See the link:https://web.archive.org/web/20111231002503/http://ofps.oreilly.com/titles/9781449396107/performance.html[O'Reilly HBase
1313           Book] for an example of usage.
1315 You will need to pass 3 parameters to this application.
1316 The first one is the table name.
1317 The second one is the fully qualified name of the first region to merge, like "table_name,\x0A,1342956111995.7cef47f192318ba7ccc75b1bbf27a82b.". The third one is the fully qualified name for the second region to merge.
1319 Additionally, there is a Ruby script attached to link:https://issues.apache.org/jira/browse/HBASE-1621[HBASE-1621] for region merging.
1321 [[node.management]]
1322 == Node Management
1324 [[decommission]]
1325 === Node Decommission
1327 You can stop an individual RegionServer by running the following script in the HBase directory on the particular node:
1329 ----
1330 $ ./bin/hbase-daemon.sh stop regionserver
1331 ----
1333 The RegionServer will first close all regions and then shut itself down.
1334 On shutdown, the RegionServer's ephemeral node in ZooKeeper will expire.
1335 The master will notice the RegionServer gone and will treat it as a 'crashed' server; it will reassign the nodes the RegionServer was carrying.
1337 .Disable the Load Balancer before Decommissioning a node
1338 [NOTE]
1339 ====
1340 If the load balancer runs while a node is shutting down, then there could be contention between the Load Balancer and the Master's recovery of the just decommissioned RegionServer.
1341 Avoid any problems by disabling the balancer first.
1342 See <<lb,lb>> below.
1343 ====
1345 .Kill Node Tool
1346 [NOTE]
1347 ====
1348 In hbase-2.0, in the bin directory, we added a script named _considerAsDead.sh_ that can be used to kill a regionserver.
1349 Hardware issues could be detected by specialized monitoring tools before the zookeeper timeout has expired. _considerAsDead.sh_ is a simple function to mark a RegionServer as dead.
1350 It deletes all the znodes of the server, starting the recovery process.
1351 Plug in the script into your monitoring/fault detection tools to initiate faster failover.
1352 Be careful how you use this disruptive tool.
1353 Copy the script if you need to make use of it in a version of hbase previous to hbase-2.0.
1354 ====
1356 A downside to the above stop of a RegionServer is that regions could be offline for a good period of time.
1357 Regions are closed in order.
1358 If many regions on the server, the first region to close may not be back online until all regions close and after the master notices the RegionServer's znode gone.
1359 In Apache HBase 0.90.2, we added facility for having a node gradually shed its load and then shutdown itself down.
1360 Apache HBase 0.90.2 added the _graceful_stop.sh_ script.
1361 Here is its usage:
1363 ----
1364 $ ./bin/graceful_stop.sh
1365 Usage: graceful_stop.sh [--config &conf-dir>] [--restart] [--reload] [--thrift] [--rest] &hostname>
1366  thrift      If we should stop/start thrift before/after the hbase stop/start
1367  rest        If we should stop/start rest before/after the hbase stop/start
1368  restart     If we should restart after graceful stop
1369  reload      Move offloaded regions back on to the stopped server
1370  debug       Move offloaded regions back on to the stopped server
1371  hostname    Hostname of server we are to stop
1372 ----
1374 To decommission a loaded RegionServer, run the following: +$
1375           ./bin/graceful_stop.sh HOSTNAME+ where `HOSTNAME` is the host carrying the RegionServer you would decommission.
1377 .On `HOSTNAME`
1378 [NOTE]
1379 ====
1380 The `HOSTNAME` passed to _graceful_stop.sh_ must match the hostname that hbase is using to identify RegionServers.
1381 Check the list of RegionServers in the master UI for how HBase is referring to servers.
1382 It's usually hostname but can also be FQDN.
1383 Whatever HBase is using, this is what you should pass the _graceful_stop.sh_ decommission script.
1384 If you pass IPs, the script is not yet smart enough to make a hostname (or FQDN) of it and so it will fail when it checks if server is currently running; the graceful unloading of regions will not run.
1385 ====
1387 The _graceful_stop.sh_ script will move the regions off the decommissioned RegionServer one at a time to minimize region churn.
1388 It will verify the region deployed in the new location before it will moves the next region and so on until the decommissioned server is carrying zero regions.
1389 At this point, the _graceful_stop.sh_ tells the RegionServer `stop`.
1390 The master will at this point notice the RegionServer gone but all regions will have already been redeployed and because the RegionServer went down cleanly, there will be no WAL logs to split.
1392 [[lb]]
1393 .Load Balancer
1394 [NOTE]
1395 ====
1396 It is assumed that the Region Load Balancer is disabled while the `graceful_stop` script runs (otherwise the balancer and the decommission script will end up fighting over region deployments). Use the shell to disable the balancer:
1398 [source]
1399 ----
1400 hbase(main):001:0> balance_switch false
1401 true
1402 0 row(s) in 0.3590 seconds
1403 ----
1405 This turns the balancer OFF.
1406 To reenable, do:
1408 [source]
1409 ----
1410 hbase(main):001:0> balance_switch true
1411 false
1412 0 row(s) in 0.3590 seconds
1413 ----
1415 The `graceful_stop` will check the balancer and if enabled, will turn it off before it goes to work.
1416 If it exits prematurely because of error, it will not have reset the balancer.
1417 Hence, it is better to manage the balancer apart from `graceful_stop` reenabling it after you are done w/ graceful_stop.
1418 ====
1420 [[draining.servers]]
1421 ==== Decommissioning several Regions Servers concurrently
1423 If you have a large cluster, you may want to decommission more than one machine at a time by gracefully stopping multiple RegionServers concurrently.
1424 To gracefully drain multiple regionservers at the same time, RegionServers can be put into a "draining" state.
1425 This is done by marking a RegionServer as a draining node by creating an entry in ZooKeeper under the _hbase_root/draining_ znode.
1426 This znode has format `name,port,startcode` just like the regionserver entries under _hbase_root/rs_ znode.
1428 Without this facility, decommissioning multiple nodes may be non-optimal because regions that are being drained from one region server may be moved to other regionservers that are also draining.
1429 Marking RegionServers to be in the draining state prevents this from happening.
1430 See this link:http://inchoate-clatter.blogspot.com/2012/03/hbase-ops-automation.html[blog
1431             post] for more details.
1433 [[bad.disk]]
1434 ==== Bad or Failing Disk
1436 It is good having <<dfs.datanode.failed.volumes.tolerated,dfs.datanode.failed.volumes.tolerated>> set if you have a decent number of disks per machine for the case where a disk plain dies.
1437 But usually disks do the "John Wayne" -- i.e.
1438 take a while to go down spewing errors in _dmesg_ -- or for some reason, run much slower than their companions.
1439 In this case you want to decommission the disk.
1440 You have two options.
1441 You can link:https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDataNodeAdminGuide.html[decommission
1442             the datanode] or, less disruptive in that only the bad disks data will be rereplicated, can stop the datanode, unmount the bad volume (You can't umount a volume while the datanode is using it), and then restart the datanode (presuming you have set dfs.datanode.failed.volumes.tolerated > 0). The regionserver will throw some errors in its logs as it recalibrates where to get its data from -- it will likely roll its WAL log too -- but in general but for some latency spikes, it should keep on chugging.
1444 .Short Circuit Reads
1445 [NOTE]
1446 ====
1447 If you are doing short-circuit reads, you will have to move the regions off the regionserver before you stop the datanode; when short-circuiting reading, though chmod'd so regionserver cannot have access, because it already has the files open, it will be able to keep reading the file blocks from the bad disk even though the datanode is down.
1448 Move the regions back after you restart the datanode.
1449 ====
1451 [[rolling]]
1452 === Rolling Restart
1454 Some cluster configuration changes require either the entire cluster, or the RegionServers, to be restarted in order to pick up the changes.
1455 In addition, rolling restarts are supported for upgrading to a minor or maintenance release, and to a major release if at all possible.
1456 See the release notes for release you want to upgrade to, to find out about limitations to the ability to perform a rolling upgrade.
1458 There are multiple ways to restart your cluster nodes, depending on your situation.
1459 These methods are detailed below.
1461 ==== Using the `rolling-restart.sh` Script
1463 HBase ships with a script, _bin/rolling-restart.sh_, that allows you to perform rolling restarts on the entire cluster, the master only, or the RegionServers only.
1464 The script is provided as a template for your own script, and is not explicitly tested.
1465 It requires password-less SSH login to be configured and assumes that you have deployed using a tarball.
1466 The script requires you to set some environment variables before running it.
1467 Examine the script and modify it to suit your needs.
1469 ._rolling-restart.sh_ General Usage
1470 ----
1471 $ ./bin/rolling-restart.sh --help
1472 Usage: rolling-restart.sh [--config <hbase-confdir>] [--rs-only] [--master-only] [--graceful] [--maxthreads xx]
1473 ----
1475 Rolling Restart on RegionServers Only::
1476   To perform a rolling restart on the RegionServers only, use the `--rs-only` option.
1477   This might be necessary if you need to reboot the individual RegionServer or if you make a configuration change that only affects RegionServers and not the other HBase processes.
1479 Rolling Restart on Masters Only::
1480   To perform a rolling restart on the active and backup Masters, use the `--master-only` option.
1481   You might use this if you know that your configuration change only affects the Master and not the RegionServers, or if you need to restart the server where the active Master is running.
1483 Graceful Restart::
1484   If you specify the `--graceful` option, RegionServers are restarted using the _bin/graceful_stop.sh_ script, which moves regions off a RegionServer before restarting it.
1485   This is safer, but can delay the restart.
1487 Limiting the Number of Threads::
1488   To limit the rolling restart to using only a specific number of threads, use the `--maxthreads` option.
1490 [[rolling.restart.manual]]
1491 ==== Manual Rolling Restart
1493 To retain more control over the process, you may wish to manually do a rolling restart across your cluster.
1494 This uses the `graceful-stop.sh` command <<decommission,decommission>>.
1495 In this method, you can restart each RegionServer individually and then move its old regions back into place, retaining locality.
1496 If you also need to restart the Master, you need to do it separately, and restart the Master before restarting the RegionServers using this method.
1497 The following is an example of such a command.
1498 You may need to tailor it to your environment.
1499 This script does a rolling restart of RegionServers only.
1500 It disables the load balancer before moving the regions.
1502 ----
1504 $ for i in `cat conf/regionservers|sort`; do ./bin/graceful_stop.sh --restart --reload --debug $i; done &> /tmp/log.txt &;
1505 ----
1507 Monitor the output of the _/tmp/log.txt_ file to follow the progress of the script.
1509 ==== Logic for Crafting Your Own Rolling Restart Script
1511 Use the following guidelines if you want to create your own rolling restart script.
1513 . Extract the new release, verify its configuration, and synchronize it to all nodes of your cluster using `rsync`, `scp`, or another secure synchronization mechanism.
1515 . Restart the master first.
1516   You may need to modify these commands if your new HBase directory is different from the old one, such as for an upgrade.
1518 ----
1520 $ ./bin/hbase-daemon.sh stop master; ./bin/hbase-daemon.sh start master
1521 ----
1523 . Gracefully restart each RegionServer, using a script such as the following, from the Master.
1525 ----
1527 $ for i in `cat conf/regionservers|sort`; do ./bin/graceful_stop.sh --restart --reload --debug $i; done &> /tmp/log.txt &
1528 ----
1530 If you are running Thrift or REST servers, pass the --thrift or --rest options.
1531 For other available options, run the `bin/graceful-stop.sh --help`              command.
1533 It is important to drain HBase regions slowly when restarting multiple RegionServers.
1534 Otherwise, multiple regions go offline simultaneously and must be reassigned to other nodes, which may also go offline soon.
1535 This can negatively affect performance.
1536 You can inject delays into the script above, for instance, by adding a Shell command such as `sleep`.
1537 To wait for 5 minutes between each RegionServer restart, modify the above script to the following:
1539 ----
1541 $ for i in `cat conf/regionservers|sort`; do ./bin/graceful_stop.sh --restart --reload --debug $i & sleep 5m; done &> /tmp/log.txt &
1542 ----
1544 . Restart the Master again, to clear out the dead servers list and re-enable the load balancer.
1546 [[adding.new.node]]
1547 === Adding a New Node
1549 Adding a new regionserver in HBase is essentially free, you simply start it like this: `$ ./bin/hbase-daemon.sh start regionserver` and it will register itself with the master.
1550 Ideally you also started a DataNode on the same machine so that the RS can eventually start to have local files.
1551 If you rely on ssh to start your daemons, don't forget to add the new hostname in _conf/regionservers_ on the master.
1553 At this point the region server isn't serving data because no regions have moved to it yet.
1554 If the balancer is enabled, it will start moving regions to the new RS.
1555 On a small/medium cluster this can have a very adverse effect on latency as a lot of regions will be offline at the same time.
1556 It is thus recommended to disable the balancer the same way it's done when decommissioning a node and move the regions manually (or even better, using a script that moves them one by one).
1558 The moved regions will all have 0% locality and won't have any blocks in cache so the region server will have to use the network to serve requests.
1559 Apart from resulting in higher latency, it may also be able to use all of your network card's capacity.
1560 For practical purposes, consider that a standard 1GigE NIC won't be able to read much more than _100MB/s_.
1561 In this case, or if you are in a OLAP environment and require having locality, then it is recommended to major compact the moved regions.
1563 [[hbase_metrics]]
1564 == HBase Metrics
1566 HBase emits metrics which adhere to the link:https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/Metrics.html[Hadoop Metrics] API.
1567 Starting with HBase 0.95footnote:[The Metrics system was redone in
1568           HBase 0.96. See Migration
1569             to the New Metrics Hotness – Metrics2 by Elliot Clark for detail], HBase is configured to emit a default set of metrics with a default sampling period of every 10 seconds.
1570 You can use HBase metrics in conjunction with Ganglia.
1571 You can also filter which metrics are emitted and extend the metrics framework to capture custom metrics appropriate for your environment.
1573 === Metric Setup
1575 For HBase 0.95 and newer, HBase ships with a default metrics configuration, or [firstterm]_sink_.
1576 This includes a wide variety of individual metrics, and emits them every 10 seconds by default.
1577 To configure metrics for a given region server, edit the _conf/hadoop-metrics2-hbase.properties_ file.
1578 Restart the region server for the changes to take effect.
1580 To change the sampling rate for the default sink, edit the line beginning with `*.period`.
1581 To filter which metrics are emitted or to extend the metrics framework, see https://hadoop.apache.org/docs/current/api/org/apache/hadoop/metrics2/package-summary.html
1583 .HBase Metrics and Ganglia
1584 [NOTE]
1585 ====
1586 By default, HBase emits a large number of metrics per region server.
1587 Ganglia may have difficulty processing all these metrics.
1588 Consider increasing the capacity of the Ganglia server or reducing the number of metrics emitted by HBase.
1589 See link:https://hadoop.apache.org/docs/current/api/org/apache/hadoop/metrics2/package-summary.html#filtering[Metrics Filtering].
1590 ====
1592 === Disabling Metrics
1594 To disable metrics for a region server, edit the _conf/hadoop-metrics2-hbase.properties_ file and comment out any uncommented lines.
1595 Restart the region server for the changes to take effect.
1597 [[discovering.available.metrics]]
1598 === Discovering Available Metrics
1600 Rather than listing each metric which HBase emits by default, you can browse through the available metrics, either as a JSON output or via JMX.
1601 Different metrics are exposed for the Master process and each region server process.
1603 .Procedure: Access a JSON Output of Available Metrics
1604 . After starting HBase, access the region server's web UI, at pass:[http://REGIONSERVER_HOSTNAME:60030] by default (or port 16030 in HBase 1.0+).
1605 . Click the [label]#Metrics Dump# link near the top.
1606   The metrics for the region server are presented as a dump of the JMX bean in JSON format.
1607   This will dump out all metrics names and their values.
1608   To include metrics descriptions in the listing -- this can be useful when you are exploring what is available -- add a query string of `?description=true` so your URL becomes pass:[http://REGIONSERVER_HOSTNAME:60030/jmx?description=true].
1609   Not all beans and attributes have descriptions.
1610 . To view metrics for the Master, connect to the Master's web UI instead (defaults to pass:[http://localhost:60010] or port 16010 in HBase 1.0+) and click its [label]#Metrics
1611   Dump# link.
1612   To include metrics descriptions in the listing -- this can be useful when you are exploring what is available -- add a query string of `?description=true` so your URL becomes pass:[http://REGIONSERVER_HOSTNAME:60010/jmx?description=true].
1613   Not all beans and attributes have descriptions.
1616 You can use many different tools to view JMX content by browsing MBeans.
1617 This procedure uses `jvisualvm`, which is an application usually available in the JDK.
1619 .Procedure: Browse the JMX Output of Available Metrics
1620 . Start HBase, if it is not already running.
1621 . Run the command `jvisualvm` command on a host with a GUI display.
1622   You can launch it from the command line or another method appropriate for your operating system.
1623 . Be sure the [label]#VisualVM-MBeans# plugin is installed. Browse to *Tools -> Plugins*. Click [label]#Installed# and check whether the plugin is listed.
1624   If not, click [label]#Available Plugins#, select it, and click btn:[Install].
1625   When finished, click btn:[Close].
1626 . To view details for a given HBase process, double-click the process in the [label]#Local# sub-tree in the left-hand panel.
1627   A detailed view opens in the right-hand panel.
1628   Click the [label]#MBeans# tab which appears as a tab in the top of the right-hand panel.
1629 . To access the HBase metrics, navigate to the appropriate sub-bean:
1630 .* Master:
1631 .* RegionServer:
1633 . The name of each metric and its current value is displayed in the [label]#Attributes# tab.
1634   For a view which includes more details, including the description of each attribute, click the [label]#Metadata# tab.
1636 === Units of Measure for Metrics
1638 Different metrics are expressed in different units, as appropriate.
1639 Often, the unit of measure is in the name (as in the metric `shippedKBs`). Otherwise, use the following guidelines.
1640 When in doubt, you may need to examine the source for a given metric.
1642 * Metrics that refer to a point in time are usually expressed as a timestamp.
1643 * Metrics that refer to an age (such as `ageOfLastShippedOp`) are usually expressed in milliseconds.
1644 * Metrics that refer to memory sizes are in bytes.
1645 * Sizes of queues (such as `sizeOfLogQueue`) are expressed as the number of items in the queue.
1646   Determine the size by multiplying by the block size (default is 64 MB in HDFS).
1647 * Metrics that refer to things like the number of a given type of operations (such as `logEditsRead`) are expressed as an integer.
1649 [[master_metrics]]
1650 === Most Important Master Metrics
1652 Note: Counts are usually over the last metrics reporting interval.
1654 hbase.master.numRegionServers::
1655   Number of live regionservers
1657 hbase.master.numDeadRegionServers::
1658   Number of dead regionservers
1660 hbase.master.ritCount ::
1661   The number of regions in transition
1663 hbase.master.ritCountOverThreshold::
1664   The number of regions that have been in transition longer than a threshold time (default: 60 seconds)
1666 hbase.master.ritOldestAge::
1667   The age of the longest region in transition, in milliseconds
1669 [[rs_metrics]]
1670 === Most Important RegionServer Metrics
1672 Note: Counts are usually over the last metrics reporting interval.
1674 hbase.regionserver.regionCount::
1675   The number of regions hosted by the regionserver
1677 hbase.regionserver.storeFileCount::
1678   The number of store files on disk currently managed by the regionserver
1680 hbase.regionserver.storeFileSize::
1681   Aggregate size of the store files on disk
1683 hbase.regionserver.hlogFileCount::
1684   The number of write ahead logs not yet archived
1686 hbase.regionserver.totalRequestCount::
1687   The total number of requests received
1689 hbase.regionserver.readRequestCount::
1690   The number of read requests received
1692 hbase.regionserver.writeRequestCount::
1693   The number of write requests received
1695 hbase.regionserver.numOpenConnections::
1696   The number of open connections at the RPC layer
1698 hbase.regionserver.numActiveHandler::
1699   The number of RPC handlers actively servicing requests
1701 hbase.regionserver.numCallsInGeneralQueue::
1702   The number of currently enqueued user requests
1704 hbase.regionserver.numCallsInReplicationQueue::
1705   The number of currently enqueued operations received from replication
1707 hbase.regionserver.numCallsInPriorityQueue::
1708   The number of currently enqueued priority (internal housekeeping) requests
1710 hbase.regionserver.flushQueueLength::
1711   Current depth of the memstore flush queue.
1712   If increasing, we are falling behind with clearing memstores out to HDFS.
1714 hbase.regionserver.updatesBlockedTime::
1715   Number of milliseconds updates have been blocked so the memstore can be flushed
1717 hbase.regionserver.compactionQueueLength::
1718   Current depth of the compaction request queue.
1719   If increasing, we are falling behind with storefile compaction.
1721 hbase.regionserver.blockCacheHitCount::
1722   The number of block cache hits
1724 hbase.regionserver.blockCacheMissCount::
1725   The number of block cache misses
1727 hbase.regionserver.blockCacheExpressHitPercent ::
1728   The percent of the time that requests with the cache turned on hit the cache
1730 hbase.regionserver.percentFilesLocal::
1731   Percent of store file data that can be read from the local DataNode, 0-100
1733 hbase.regionserver.<op>_<measure>::
1734   Operation latencies, where <op> is one of Append, Delete, Mutate, Get, Replay, Increment; and where <measure> is one of min, max, mean, median, 75th_percentile, 95th_percentile, 99th_percentile
1736 hbase.regionserver.slow<op>Count ::
1737   The number of operations we thought were slow, where <op> is one of the list above
1739 hbase.regionserver.GcTimeMillis::
1740   Time spent in garbage collection, in milliseconds
1742 hbase.regionserver.GcTimeMillisParNew::
1743   Time spent in garbage collection of the young generation, in milliseconds
1745 hbase.regionserver.GcTimeMillisConcurrentMarkSweep::
1746   Time spent in garbage collection of the old generation, in milliseconds
1748 hbase.regionserver.authenticationSuccesses::
1749   Number of client connections where authentication succeeded
1751 hbase.regionserver.authenticationFailures::
1752   Number of client connection authentication failures
1754 hbase.regionserver.mutationsWithoutWALCount ::
1755   Count of writes submitted with a flag indicating they should bypass the write ahead log
1757 [[rs_meta_metrics]]
1758 === Meta Table Load Metrics
1760 HBase meta table metrics collection feature is available in HBase 1.4+ but it is disabled by default, as it can
1761 affect the performance of the cluster. When it is enabled, it helps to monitor client access patterns by collecting
1762 the following statistics:
1764 * number of get, put and delete operations on the `hbase:meta` table
1765 * number of get, put and delete operations made by the top-N clients
1766 * number of operations related to each table
1767 * number of operations related to the top-N regions
1770 When to use the feature::
1771   This feature can help to identify hot spots in the meta table by showing the regions or tables where the meta info is
1772   modified (e.g. by create, drop, split or move tables) or retrieved most frequently. It can also help to find misbehaving
1773   client applications by showing which clients are using the meta table most heavily, which can for example suggest the
1774   lack of meta table buffering or the lack of re-using open client connections in the client application.
1776 .Possible side-effects of enabling this feature
1777 [WARNING]
1778 ====
1779 Having large number of clients and regions in the cluster can cause the registration and tracking of a large amount of
1780 metrics, which can increase the memory and CPU footprint of the HBase region server handling the `hbase:meta` table.
1781 It can also cause the significant increase of the JMX dump size, which can affect the monitoring or log aggregation
1782 system you use beside HBase. It is recommended to turn on this feature only during debugging.
1783 ====
1785 Where to find the metrics in JMX::
1786   Each metric attribute name will start with the ‘MetaTable_’ prefix. For all the metrics you will see five different
1787   JMX attributes: count, mean rate, 1 minute rate, 5 minute rate and 15 minute rate. You will find these metrics in JMX
1788   under the following MBean:
1789   `Hadoop -> HBase -> RegionServer -> Coprocessor.Region.CP_org.apache.hadoop.hbase.coprocessor.MetaTableMetrics`.
1791 .Examples: some Meta Table metrics you can see in your JMX dump
1792 [source,json]
1793 ----
1795   "MetaTable_get_request_count": 77309,
1796   "MetaTable_put_request_mean_rate": 0.06339092997186495,
1797   "MetaTable_table_MyTestTable_request_15min_rate": 1.1020599841623246,
1798   "MetaTable_client_/172.30.65.42_lossy_request_count": 1786
1799   "MetaTable_client_/172.30.65.45_put_request_5min_rate": 0.6189810954855728,
1800   "MetaTable_region_1561131112259.c66e4308d492936179352c80432ccfe0._lossy_request_count": 38342,
1801   "MetaTable_region_1561131043640.5bdffe4b9e7e334172065c853cf0caa6._lossy_request_1min_rate": 0.04925099917433935,
1803 ----
1805 Configuration::
1806   To turn on this feature, you have to enable a custom coprocessor by adding the following section to hbase-site.xml.
1807   This coprocessor will run on all the HBase RegionServers, but will be active (i.e. consume memory / CPU) only on
1808   the server, where the `hbase:meta` table is located. It will produce JMX metrics which can be downloaded from the
1809   web UI of the given RegionServer or by a simple REST call. These metrics will not be present in the JMX dump of the
1810   other RegionServers.
1812 .Enabling the Meta Table Metrics feature
1813 [source,xml]
1814 ----
1815 <property>
1816     <name>hbase.coprocessor.region.classes</name>
1817     <value>org.apache.hadoop.hbase.coprocessor.MetaTableMetrics</value>
1818 </property>
1819 ----
1821 .How the top-N metrics are calculated?
1822 [NOTE]
1823 ====
1824 The 'top-N' type of metrics will be counted using the Lossy Counting Algorithm (as defined in
1825 link:http://www.vldb.org/conf/2002/S10P03.pdf[Motwani, R; Manku, G.S (2002). "Approximate frequency counts over data streams"]),
1826 which is designed to identify elements in a data stream whose frequency count exceed a user-given threshold.
1827 The frequency computed by this algorithm is not always accurate but has an error threshold that can be specified by the
1828 user as a configuration parameter. The run time space required by the algorithm is inversely proportional to the
1829 specified error threshold, hence larger the error parameter, the smaller the footprint and the less accurate are the
1830 metrics.
1832 You can specify the error rate of the algorithm as a floating-point value between 0 and 1 (exclusive), it's default
1833 value is 0.02. Having the error rate set to `E` and having `N` as the total number of meta table operations, then
1834 (assuming the uniform distribution of the activity of low frequency elements) at most `7 / E` meters will be kept and
1835 each kept element will have a frequency higher than `E * N`.
1837 An example: Let’s assume we are interested in the HBase clients that are most active in accessing the meta table.
1838 When there was 1,000,000 operations on the meta table so far and the error rate parameter is set to 0.02, then we can
1839 assume that only at most 350 client IP address related counters will be present in JMX and each of these clients
1840 accessed the meta table at least 20,000 times.
1842 [source,xml]
1843 ----
1844 <property>
1845     <name>hbase.util.default.lossycounting.errorrate</name>
1846     <value>0.02</value>
1847 </property>
1848 ----
1849 ====
1851 [[ops.monitoring]]
1852 == HBase Monitoring
1854 [[ops.monitoring.overview]]
1855 === Overview
1857 The following metrics are arguably the most important to monitor for each RegionServer for "macro monitoring", preferably with a system like link:http://opentsdb.net/[OpenTSDB].
1858 If your cluster is having performance issues it's likely that you'll see something unusual with this group.
1860 HBase::
1861   * See <<rs_metrics,rs metrics>>
1863 OS::
1864   * IO Wait
1865   * User CPU
1867 Java::
1868   * GC
1870 For more information on HBase metrics, see <<hbase_metrics,hbase metrics>>.
1872 [[ops.slow.query]]
1873 === Slow Query Log
1875 The HBase slow query log consists of parseable JSON structures describing the properties of those client operations (Gets, Puts, Deletes, etc.) that either took too long to run, or produced too much output.
1876 The thresholds for "too long to run" and "too much output" are configurable, as described below.
1877 The output is produced inline in the main region server logs so that it is easy to discover further details from context with other logged events.
1878 It is also prepended with identifying tags `(responseTooSlow)`, `(responseTooLarge)`, `(operationTooSlow)`, and `(operationTooLarge)` in order to enable easy filtering with grep, in case the user desires to see only slow queries.
1880 ==== Configuration
1882 There are two configuration knobs that can be used to adjust the thresholds for when queries are logged.
1884 * `hbase.ipc.warn.response.time` Maximum number of milliseconds that a query can be run without being logged.
1885   Defaults to 10000, or 10 seconds.
1886   Can be set to -1 to disable logging by time.
1887 * `hbase.ipc.warn.response.size` Maximum byte size of response that a query can return without being logged.
1888   Defaults to 100 megabytes.
1889   Can be set to -1 to disable logging by size.
1891 ==== Metrics
1893 The slow query log exposes to metrics to JMX.
1895 * `hadoop.regionserver_rpc_slowResponse` a global metric reflecting the durations of all responses that triggered logging.
1896 * `hadoop.regionserver_rpc_methodName.aboveOneSec` A metric reflecting the durations of all responses that lasted for more than one second.
1898 ==== Output
1900 The output is tagged with operation e.g. `(operationTooSlow)` if the call was a client operation, such as a Put, Get, or Delete, which we expose detailed fingerprint information for.
1901 If not, it is tagged `(responseTooSlow)`          and still produces parseable JSON output, but with less verbose information solely regarding its duration and size in the RPC itself. `TooLarge` is substituted for `TooSlow` if the response size triggered the logging, with `TooLarge` appearing even in the case that both size and duration triggered logging.
1903 ==== Example
1906 [source]
1907 ----
1908 2011-09-08 10:01:25,824 WARN org.apache.hadoop.ipc.HBaseServer: (operationTooSlow): {"tables":{"riley2":{"puts":[{"totalColumns":11,"families":{"actions":[{"timestamp":1315501284459,"qualifier":"0","vlen":9667580},{"timestamp":1315501284459,"qualifier":"1","vlen":10122412},{"timestamp":1315501284459,"qualifier":"2","vlen":11104617},{"timestamp":1315501284459,"qualifier":"3","vlen":13430635}]},"row":"cfcd208495d565ef66e7dff9f98764da:0"}],"families":["actions"]}},"processingtimems":956,"client":"10.47.34.63:33623","starttimems":1315501284456,"queuetimems":0,"totalPuts":1,"class":"HRegionServer","responsesize":0,"method":"multiPut"}
1909 ----
1911 Note that everything inside the "tables" structure is output produced by MultiPut's fingerprint, while the rest of the information is RPC-specific, such as processing time and client IP/port.
1912 Other client operations follow the same pattern and the same general structure, with necessary differences due to the nature of the individual operations.
1913 In the case that the call is not a client operation, that detailed fingerprint information will be completely absent.
1915 This particular example, for example, would indicate that the likely cause of slowness is simply a very large (on the order of 100MB) multiput, as we can tell by the "vlen," or value length, fields of each put in the multiPut.
1917 [[slow_log_responses]]
1918 ==== Get Slow Response Log from shell
1919 When an individual RPC exceeds a configurable time bound we log a complaint
1920 by way of the logging subsystem
1922 e.g.
1924 ----
1925 2019-10-02 10:10:22,195 WARN [,queue=15,port=60020] ipc.RpcServer - (responseTooSlow):
1926 {"call":"Scan(org.apache.hadoop.hbase.protobuf.generated.ClientProtos$ScanRequest)",
1927 "starttimems":1567203007549,
1928 "responsesize":6819737,
1929 "method":"Scan",
1930 "param":"region { type: REGION_NAME value: \"t1,\\000\\000\\215\\f)o\\\\\\024\\302\\220\\000\\000\\000\\000\\000\\001\\000\\000\\000\\000\\000\\006\\000\\000\\000\\000\\000\\005\\000\\000<TRUNCATED>",
1931 "processingtimems":28646,
1932 "client":"10.253.196.215:41116",
1933 "queuetimems":22453,
1934 "class":"HRegionServer"}
1935 ----
1937 Unfortunately often the request parameters are truncated as per above Example.
1938 The truncation is unfortunate because it eliminates much of the utility of
1939 the warnings. For example, the region name, the start and end keys, and the
1940 filter hierarchy are all important clues for debugging performance problems
1941 caused by moderate to low selectivity queries or queries made at a high rate.
1943 HBASE-22978 introduces maintaining an in-memory ring buffer of requests that were judged to
1944 be too slow in addition to the responseTooSlow logging. The in-memory representation can be
1945 complete. There is some chance a high rate of requests will cause information on other
1946 interesting requests to be overwritten before it can be read. This is an acceptable trade off.
1948 In order to enable the in-memory ring buffer at RegionServers, we need to enable
1949 config:
1950 ----
1951 hbase.regionserver.slowlog.buffer.enabled
1952 ----
1954 One more config determines the size of the ring buffer:
1955 ----
1956 hbase.regionserver.slowlog.ringbuffer.size
1957 ----
1959 Check the config section for the detailed description.
1961 This config would be disabled by default. Turn it on and these shell commands
1962 would provide expected results from the ring-buffers.
1965 shell commands to retrieve slowlog responses from RegionServers:
1967 ----
1968 Retrieve latest SlowLog Responses maintained by each or specific RegionServers.
1969 Specify '*' to include all RS otherwise array of server names for specific
1970 RS. A server name is the host, port plus startcode of a RegionServer.
1971 e.g.: host187.example.com,60020,1289493121758 (find servername in
1972 master ui or when you do detailed status in shell)
1974 Provide optional filter parameters as Hash.
1975 Default Limit of each server for providing no of slow log records is 10. User can specify
1976 more limit by 'LIMIT' param in case more than 10 records should be retrieved.
1978 Examples:
1980   hbase> get_slowlog_responses '*'                                 => get slowlog responses from all RS
1981   hbase> get_slowlog_responses '*', {'LIMIT' => 50}                => get slowlog responses from all RS
1982                                                                       with 50 records limit (default limit: 10)
1983   hbase> get_slowlog_responses ['SERVER_NAME1', 'SERVER_NAME2']    => get slowlog responses from SERVER_NAME1,
1984                                                                       SERVER_NAME2
1985   hbase> get_slowlog_responses '*', {'REGION_NAME' => 'hbase:meta,,1'}
1986                                                                    => get slowlog responses only related to meta
1987                                                                       region
1988   hbase> get_slowlog_responses '*', {'TABLE_NAME' => 't1'}         => get slowlog responses only related to t1 table
1989   hbase> get_slowlog_responses '*', {'CLIENT_IP' => '192.162.1.40:60225', 'LIMIT' => 100}
1990                                                                    => get slowlog responses with given client
1991                                                                       IP address and get 100 records limit
1992                                                                       (default limit: 10)
1993   hbase> get_slowlog_responses '*', {'REGION_NAME' => 'hbase:meta,,1', 'TABLE_NAME' => 't1'}
1994                                                                    => get slowlog responses with given region name
1995                                                                       or table name
1996   hbase> get_slowlog_responses '*', {'USER' => 'user_name', 'CLIENT_IP' => '192.162.1.40:60225'}
1997                                                                    => get slowlog responses that match either
1998                                                                       provided client IP address or user name
2001 ----
2003 Sometimes output can be long pretty printed json for user to scroll in
2004 a single screen and hence user might prefer
2005 redirecting output of get_slowlog_responses to a file.
2007 Example:
2008 ----
2009 echo "get_slowlog_responses '*'" | hbase shell > xyz.out 2>&1
2010 ----
2013 shell command to clear slowlog responses from RegionServer:
2015 ----
2016 Clears SlowLog Responses maintained by each or specific RegionServers.
2017 Specify array of server names for specific RS. A server name is
2018 the host, port plus startcode of a RegionServer.
2019 e.g.: host187.example.com,60020,1289493121758 (find servername in
2020 master ui or when you do detailed status in shell)
2022 Examples:
2024   hbase> clear_slowlog_responses                                     => clears slowlog responses from all RS
2025   hbase> clear_slowlog_responses ['SERVER_NAME1', 'SERVER_NAME2']    => clears slowlog responses from SERVER_NAME1,
2026                                                                         SERVER_NAME2
2029 ----
2031 === Block Cache Monitoring
2033 Starting with HBase 0.98, the HBase Web UI includes the ability to monitor and report on the performance of the block cache.
2034 To view the block cache reports, see the Block Cache section of the region server UI.
2035 Following are a few examples of the reporting capabilities.
2037 .Basic Info shows the cache implementation.
2038 image::bc_basic.png[]
2040 .Config shows all cache configuration options.
2041 image::bc_config.png[]
2043 .Stats shows statistics about the performance of the cache.
2044 image::bc_stats.png[]
2046 .L1 and L2 show information about the L1 and L2 caches.
2047 image::bc_l1.png[]
2049 This is not an exhaustive list of all the screens and reports available.
2050 Have a look in the Web UI.
2052 === Snapshot Space Usage Monitoring
2054 Starting with HBase 0.95, Snapshot usage information on individual snapshots was shown in the HBase Master Web UI. This was further enhanced starting with HBase 1.3 to show the total Storefile size of the Snapshot Set. The following metrics are shown in the Master Web UI with HBase 1.3 and later.
2056 * Shared Storefile Size is the Storefile size shared between snapshots and active tables.
2057 * Mob Storefile Size is the Mob Storefile size shared between snapshots and active tables.
2058 * Archived Storefile Size is the Storefile size in Archive.
2060 The format of Archived Storefile Size is NNN(MMM). NNN is the total Storefile size in Archive, MMM is the total Storefile size in Archive that is specific to the snapshot (not shared with other snapshots and tables).
2062 .Master Snapshot Overview
2063 image::master-snapshot.png[]
2065 .Snapshot Storefile Stats Example 1
2066 image::1-snapshot.png[]
2068 .Snapshot Storefile Stats Example 2
2069 image::2-snapshots.png[]
2071 .Empty Snapshot Storfile Stats Example
2072 image::empty-snapshots.png[]
2074 == Cluster Replication
2076 NOTE: This information was previously available at
2077 link:https://hbase.apache.org/0.94/replication.html[Cluster Replication].
2079 HBase provides a cluster replication mechanism which allows you to keep one cluster's state synchronized with that of another cluster, using the write-ahead log (WAL) of the source cluster to propagate the changes.
2080 Some use cases for cluster replication include:
2082 * Backup and disaster recovery
2083 * Data aggregation
2084 * Geographic data distribution
2085 * Online data ingestion combined with offline data analytics
2087 NOTE: Replication is enabled at the granularity of the column family.
2088 Before enabling replication for a column family, create the table and all column families to be replicated, on the destination cluster.
2090 NOTE: Replication is asynchronous as we send WAL to another cluster in background, which means that when you want to do recovery through replication, you could loss some data. To address this problem, we have introduced a new feature called synchronous replication. As the mechanism is a bit different so we use a separated section to describe it. Please see
2091 <<Synchronous Replication,Synchronous Replication>>.
2093 === Replication Overview
2095 Cluster replication uses a source-push methodology.
2096 An HBase cluster can be a source (also called master or active, meaning that it is the originator of new data), a destination (also called slave or passive, meaning that it receives data via replication), or can fulfill both roles at once.
2097 Replication is asynchronous, and the goal of replication is eventual consistency.
2098 When the source receives an edit to a column family with replication enabled, that edit is propagated to all destination clusters using the WAL for that for that column family on the RegionServer managing the relevant region.
2100 When data is replicated from one cluster to another, the original source of the data is tracked via a cluster ID which is part of the metadata.
2101 In HBase 0.96 and newer (link:https://issues.apache.org/jira/browse/HBASE-7709[HBASE-7709]), all clusters which have already consumed the data are also tracked.
2102 This prevents replication loops.
2104 The WALs for each region server must be kept in HDFS as long as they are needed to replicate data to any slave cluster.
2105 Each region server reads from the oldest log it needs to replicate and keeps track of its progress processing WALs inside ZooKeeper to simplify failure recovery.
2106 The position marker which indicates a slave cluster's progress, as well as the queue of WALs to process, may be different for every slave cluster.
2108 The clusters participating in replication can be of different sizes.
2109 The master cluster relies on randomization to attempt to balance the stream of replication on the slave clusters.
2110 It is expected that the slave cluster has storage capacity to hold the replicated data, as well as any data it is responsible for ingesting.
2111 If a slave cluster does run out of room, or is inaccessible for other reasons, it throws an error and the master retains the WAL and retries the replication at intervals.
2113 .Consistency Across Replicated Clusters
2114 [WARNING]
2115 ====
2116 How your application builds on top of the HBase API matters when replication is in play. HBase's replication system provides at-least-once delivery of client edits for an enabled column family to each configured destination cluster. In the event of failure to reach a given destination, the replication system will retry sending edits in a way that might repeat a given message. HBase provides two ways of replication, one is the original replication and the other is serial replication. In the previous way of replication, there is not a guaranteed order of delivery for client edits. In the event of a RegionServer failing, recovery of the replication queue happens independent of recovery of the individual regions that server was previously handling. This means that it is possible for the not-yet-replicated edits to be serviced by a RegionServer that is currently slower to replicate than the one that handles edits from after the failure.
2118 The combination of these two properties (at-least-once delivery and the lack of message ordering) means that some destination clusters may end up in a different state if your application makes use of operations that are not idempotent, e.g. Increments.
2120 To solve the problem, HBase now supports serial replication, which sends edits to destination cluster as the order of requests from client. See <<Serial Replication,Serial Replication>>.
2122 ====
2124 .Terminology Changes
2125 [NOTE]
2126 ====
2127 Previously, terms such as [firstterm]_master-master_, [firstterm]_master-slave_, and [firstterm]_cyclical_ were used to describe replication relationships in HBase.
2128 These terms added confusion, and have been abandoned in favor of discussions about cluster topologies appropriate for different scenarios.
2129 ====
2131 .Cluster Topologies
2132 * A central source cluster might propagate changes out to multiple destination clusters, for failover or due to geographic distribution.
2133 * A source cluster might push changes to a destination cluster, which might also push its own changes back to the original cluster.
2134 * Many different low-latency clusters might push changes to one centralized cluster for backup or resource-intensive data analytics jobs.
2135   The processed data might then be replicated back to the low-latency clusters.
2137 Multiple levels of replication may be chained together to suit your organization's needs.
2138 The following diagram shows a hypothetical scenario.
2139 Use the arrows to follow the data paths.
2141 .Example of a Complex Cluster Replication Configuration
2142 image::hbase_replication_diagram.jpg[]
2144 HBase replication borrows many concepts from the [firstterm]_statement-based replication_ design used by MySQL.
2145 Instead of SQL statements, entire WALEdits (consisting of multiple cell inserts coming from Put and Delete operations on the clients) are replicated in order to maintain atomicity.
2147 [[hbase.replication.management]]
2148 === Managing and Configuring Cluster Replication
2149 .Cluster Configuration Overview
2151 . Configure and start the source and destination clusters.
2152   Create tables with the same names and column families on both the source and destination clusters, so that the destination cluster knows where to store data it will receive.
2153 . All hosts in the source and destination clusters should be reachable to each other.
2154 . If both clusters use the same ZooKeeper cluster, you must use a different `zookeeper.znode.parent`, because they cannot write in the same folder.
2155 . On the source cluster, in HBase Shell, add the destination cluster as a peer, using the `add_peer` command.
2156 . On the source cluster, in HBase Shell, enable the table replication, using the `enable_table_replication` command.
2157 . Check the logs to see if replication is taking place. If so, you will see messages like the following, coming from the ReplicationSource.
2158 ----
2159 LOG.info("Replicating "+clusterId + " -> " + peerClusterId);
2160 ----
2162 .Serial Replication Configuration
2163 See <<Serial Replication,Serial Replication>>
2165 .Cluster Management Commands
2166 add_peer <ID> <CLUSTER_KEY>::
2167   Adds a replication relationship between two clusters. +
2168   * ID -- a unique string, which must not contain a hyphen.
2169   * CLUSTER_KEY: composed using the following template, with appropriate place-holders: `hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent`. This value can be found on the Master UI info page.
2170   * STATE(optional): ENABLED or DISABLED, default value is ENABLED
2171 list_peers:: list all replication relationships known by this cluster
2172 enable_peer <ID>::
2173   Enable a previously-disabled replication relationship
2174 disable_peer <ID>::
2175   Disable a replication relationship. HBase will no longer send edits to that
2176   peer cluster, but it still keeps track of all the new WALs that it will need
2177   to replicate if and when it is re-enabled. WALs are retained when enabling or disabling
2178   replication as long as peers exist.
2179 remove_peer <ID>::
2180   Disable and remove a replication relationship. HBase will no longer send edits to that peer cluster or keep track of WALs.
2181 enable_table_replication <TABLE_NAME>::
2182   Enable the table replication switch for all its column families. If the table is not found in the destination cluster then it will create one with the same name and column families.
2183 disable_table_replication <TABLE_NAME>::
2184   Disable the table replication switch for all its column families.
2186 === Serial Replication
2188 Note: this feature is introduced in HBase 2.1
2190 .Function of serial replication
2192 Serial replication supports to push logs to the destination cluster in the same order as logs reach to the source cluster.
2194 .Why need serial replication?
2195 In replication of HBase, we push mutations to destination cluster by reading WAL in each region server. We have a queue for WAL files so we can read them in order of creation time. However, when region-move or RS failure occurs in source cluster, the hlog entries that are not pushed before region-move or RS-failure will be pushed by original RS(for region move) or another RS which takes over the remained hlog of dead RS(for RS failure), and the new entries for the same region(s) will be pushed by the RS which now serves the region(s), but they push the hlog entries of a same region concurrently without coordination.
2197 This treatment can possibly lead to data inconsistency between source and destination clusters:
2199 1. there are put and then delete written to source cluster.
2201 2. due to region-move / RS-failure, they are pushed by different replication-source threads to peer cluster.
2203 3. if delete is pushed to peer cluster before put, and flush and major-compact occurs in peer cluster before put is pushed to peer cluster, the delete is collected and the put remains in peer cluster, but in source cluster the put is masked by the delete, hence data inconsistency between source and destination clusters.
2206 .Serial replication configuration
2208 Set the serial flag to true for a repliation peer. And the default serial flag is false.
2210 * Add a new replication peer which serial flag is true
2212 [source,ruby]
2213 ----
2214 hbase> add_peer '1', CLUSTER_KEY => "server1.cie.com:2181:/hbase", SERIAL => true
2215 ----
2217 * Set a replication peer's serial flag to false
2219 [source,ruby]
2220 ----
2221 hbase> set_peer_serial '1', false
2222 ----
2224 * Set a replication peer's serial flag to true
2226 [source,ruby]
2227 ----
2228 hbase> set_peer_serial '1', true
2229 ----
2231 The serial replication feature had been done firstly in link:https://issues.apache.org/jira/browse/HBASE-9465[HBASE-9465] and then reverted and redone in link:https://issues.apache.org/jira/browse/HBASE-20046[HBASE-20046]. You can find more details in these issues.
2233 === Verifying Replicated Data
2235 The `VerifyReplication` MapReduce job, which is included in HBase, performs a systematic comparison of replicated data between two different clusters. Run the VerifyReplication job on the master cluster, supplying it with the peer ID and table name to use for validation. You can limit the verification further by specifying a time range or specific families. The job's short name is `verifyrep`. To run the job, use a command like the following:
2237 [source,bash]
2238 ----
2239 $ HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` "${HADOOP_HOME}/bin/hadoop" jar "${HBASE_HOME}/hbase-mapreduce-VERSION.jar" verifyrep --starttime=<timestamp> --endtime=<timestamp> --families=<myFam> <ID> <tableName>
2240 ----
2242 The `VerifyReplication` command prints out `GOODROWS` and `BADROWS` counters to indicate rows that did and did not replicate correctly.
2244 === Detailed Information About Cluster Replication
2246 .Replication Architecture Overview
2247 image::replication_overview.png[]
2249 ==== Life of a WAL Edit
2251 A single WAL edit goes through several steps in order to be replicated to a slave cluster.
2253 . An HBase client uses a Put or Delete operation to manipulate data in HBase.
2254 . The region server writes the request to the WAL in a way allows it to be replayed if it is not written successfully.
2255 . If the changed cell corresponds to a column family that is scoped for replication, the edit is added to the queue for replication.
2256 . In a separate thread, the edit is read from the log, as part of a batch process.
2257   Only the KeyValues that are eligible for replication are kept.
2258   Replicable KeyValues are part of a column family whose schema is scoped GLOBAL, are not part of a catalog such as `hbase:meta`, did not originate from the target slave cluster, and have not already been consumed by the target slave cluster.
2259 . The edit is tagged with the master's UUID and added to a buffer.
2260   When the buffer is filled, or the reader reaches the end of the file, the buffer is sent to a random region server on the slave cluster.
2261 . The region server reads the edits sequentially and separates them into buffers, one buffer per table.
2262   After all edits are read, each buffer is flushed using link:https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html[Table], HBase's normal client.
2263   The master's UUID and the UUIDs of slaves which have already consumed the data are preserved in the edits they are applied, in order to prevent replication loops.
2264 . In the master, the offset for the WAL that is currently being replicated is registered in ZooKeeper.
2266 . The first three steps, where the edit is inserted, are identical.
2267 . Again in a separate thread, the region server reads, filters, and edits the log edits in the same way as above.
2268   The slave region server does not answer the RPC call.
2269 . The master sleeps and tries again a configurable number of times.
2270 . If the slave region server is still not available, the master selects a new subset of region server to replicate to, and tries again to send the buffer of edits.
2271 . Meanwhile, the WALs are rolled and stored in a queue in ZooKeeper.
2272   Logs that are [firstterm]_archived_ by their region server, by moving them from the region server's log directory to a central log directory, will update their paths in the in-memory queue of the replicating thread.
2273 . When the slave cluster is finally available, the buffer is applied in the same way as during normal processing.
2274   The master region server will then replicate the backlog of logs that accumulated during the outage.
2276 .Spreading Queue Failover Load
2277 When replication is active, a subset of region servers in the source cluster is responsible for shipping edits to the sink.
2278 This responsibility must be failed over like all other region server functions should a process or node crash.
2279 The following configuration settings are recommended for maintaining an even distribution of replication activity over the remaining live servers in the source cluster:
2281 * Set `replication.source.maxretriesmultiplier` to `300`.
2282 * Set `replication.source.sleepforretries` to `1` (1 second). This value, combined with the value of `replication.source.maxretriesmultiplier`, causes the retry cycle to last about 5 minutes.
2283 * Set `replication.sleep.before.failover` to `30000` (30 seconds) in the source cluster site configuration.
2285 [[cluster.replication.preserving.tags]]
2286 .Preserving Tags During Replication
2287 By default, the codec used for replication between clusters strips tags, such as cell-level ACLs, from cells.
2288 To prevent the tags from being stripped, you can use a different codec which does not strip them.
2289 Configure `hbase.replication.rpc.codec` to use `org.apache.hadoop.hbase.codec.KeyValueCodecWithTags`, on both the source and sink RegionServers involved in the replication.
2290 This option was introduced in link:https://issues.apache.org/jira/browse/HBASE-10322[HBASE-10322].
2292 ==== Replication Internals
2294 Replication State in ZooKeeper::
2295   HBase replication maintains its state in ZooKeeper.
2296   By default, the state is contained in the base node _/hbase/replication_.
2297   This node contains two child nodes, the `Peers` znode and the `RS`                znode.
2299 The `Peers` Znode::
2300   The `peers` znode is stored in _/hbase/replication/peers_ by default.
2301   It consists of a list of all peer replication clusters, along with the status of each of them.
2302   The value of each peer is its cluster key, which is provided in the HBase Shell.
2303   The cluster key contains a list of ZooKeeper nodes in the cluster's quorum, the client port for the ZooKeeper quorum, and the base znode for HBase in HDFS on that cluster.
2305 The `RS` Znode::
2306   The `rs` znode contains a list of WAL logs which need to be replicated.
2307   This list is divided into a set of queues organized by region server and the peer cluster the region server is shipping the logs to.
2308   The rs znode has one child znode for each region server in the cluster.
2309   The child znode name is the region server's hostname, client port, and start code.
2310   This list includes both live and dead region servers.
2312 ==== Choosing Region Servers to Replicate To
2314 When a master cluster region server initiates a replication source to a slave cluster, it first connects to the slave's ZooKeeper ensemble using the provided cluster key . It then scans the _rs/_ directory to discover all the available sinks (region servers that are accepting incoming streams of edits to replicate) and randomly chooses a subset of them using a configured ratio which has a default value of 10%. For example, if a slave cluster has 150 machines, 15 will be chosen as potential recipient for edits that this master cluster region server sends.
2315 Because this selection is performed by each master region server, the probability that all slave region servers are used is very high, and this method works for clusters of any size.
2316 For example, a master cluster of 10 machines replicating to a slave cluster of 5 machines with a ratio of 10% causes the master cluster region servers to choose one machine each at random.
2318 A ZooKeeper watcher is placed on the _${zookeeper.znode.parent}/rs_ node of the slave cluster by each of the master cluster's region servers.
2319 This watch is used to monitor changes in the composition of the slave cluster.
2320 When nodes are removed from the slave cluster, or if nodes go down or come back up, the master cluster's region servers will respond by selecting a new pool of slave region servers to replicate to.
2322 ==== Keeping Track of Logs
2324 Each master cluster region server has its own znode in the replication znodes hierarchy.
2325 It contains one znode per peer cluster (if 5 slave clusters, 5 znodes are created), and each of these contain a queue of WALs to process.
2326 Each of these queues will track the WALs created by that region server, but they can differ in size.
2327 For example, if one slave cluster becomes unavailable for some time, the WALs should not be deleted, so they need to stay in the queue while the others are processed.
2328 See <<rs.failover.details,rs.failover.details>> for an example.
2330 When a source is instantiated, it contains the current WAL that the region server is writing to.
2331 During log rolling, the new file is added to the queue of each slave cluster's znode just before it is made available.
2332 This ensures that all the sources are aware that a new log exists before the region server is able to append edits into it, but this operations is now more expensive.
2333 The queue items are discarded when the replication thread cannot read more entries from a file (because it reached the end of the last block) and there are other files in the queue.
2334 This means that if a source is up to date and replicates from the log that the region server writes to, reading up to the "end" of the current file will not delete the item in the queue.
2336 A log can be archived if it is no longer used or if the number of logs exceeds `hbase.regionserver.maxlogs` because the insertion rate is faster than regions are flushed.
2337 When a log is archived, the source threads are notified that the path for that log changed.
2338 If a particular source has already finished with an archived log, it will just ignore the message.
2339 If the log is in the queue, the path will be updated in memory.
2340 If the log is currently being replicated, the change will be done atomically so that the reader doesn't attempt to open the file when has already been moved.
2341 Because moving a file is a NameNode operation , if the reader is currently reading the log, it won't generate any exception.
2343 ==== Reading, Filtering and Sending Edits
2345 By default, a source attempts to read from a WAL and ship log entries to a sink as quickly as possible.
2346 Speed is limited by the filtering of log entries Only KeyValues that are scoped GLOBAL and that do not belong to catalog tables will be retained.
2347 Speed is also limited by total size of the list of edits to replicate per slave, which is limited to 64 MB by default.
2348 With this configuration, a master cluster region server with three slaves would use at most 192 MB to store data to replicate.
2349 This does not account for the data which was filtered but not garbage collected.
2351 Once the maximum size of edits has been buffered or the reader reaches the end of the WAL, the source thread stops reading and chooses at random a sink to replicate to (from the list that was generated by keeping only a subset of slave region servers). It directly issues a RPC to the chosen region server and waits for the method to return.
2352 If the RPC was successful, the source determines whether the current file has been emptied or it contains more data which needs to be read.
2353 If the file has been emptied, the source deletes the znode in the queue.
2354 Otherwise, it registers the new offset in the log's znode.
2355 If the RPC threw an exception, the source will retry 10 times before trying to find a different sink.
2357 ==== Cleaning Logs
2359 If replication is not enabled, the master's log-cleaning thread deletes old logs using a configured TTL.
2360 This TTL-based method does not work well with replication, because archived logs which have exceeded their TTL may still be in a queue.
2361 The default behavior is augmented so that if a log is past its TTL, the cleaning thread looks up every queue until it finds the log, while caching queues it has found.
2362 If the log is not found in any queues, the log will be deleted.
2363 The next time the cleaning process needs to look for a log, it starts by using its cached list.
2365 NOTE: WALs are saved when replication is enabled or disabled as long as peers exist.
2367 [[rs.failover.details]]
2368 ==== Region Server Failover
2370 When no region servers are failing, keeping track of the logs in ZooKeeper adds no value.
2371 Unfortunately, region servers do fail, and since ZooKeeper is highly available, it is useful for managing the transfer of the queues in the event of a failure.
2373 Each of the master cluster region servers keeps a watcher on every other region server, in order to be notified when one dies (just as the master does). When a failure happens, they all race to create a znode called `lock` inside the dead region server's znode that contains its queues.
2374 The region server that creates it successfully then transfers all the queues to its own znode, one at a time since ZooKeeper does not support renaming queues.
2375 After queues are all transferred, they are deleted from the old location.
2376 The znodes that were recovered are renamed with the ID of the slave cluster appended with the name of the dead server.
2378 Next, the master cluster region server creates one new source thread per copied queue, and each of the source threads follows the read/filter/ship pattern.
2379 The main difference is that those queues will never receive new data, since they do not belong to their new region server.
2380 When the reader hits the end of the last log, the queue's znode is deleted and the master cluster region server closes that replication source.
2382 Given a master cluster with 3 region servers replicating to a single slave with id `2`, the following hierarchy represents what the znodes layout could be at some point in time.
2383 The region servers' znodes all contain a `peers`          znode which contains a single queue.
2384 The znode names in the queues represent the actual file names on HDFS in the form `address,port.timestamp`.
2386 ----
2388 /hbase/replication/rs/
2389   1.1.1.1,60020,123456780/
2390     2/
2391       1.1.1.1,60020.1234  (Contains a position)
2392       1.1.1.1,60020.1265
2393   1.1.1.2,60020,123456790/
2394     2/
2395       1.1.1.2,60020.1214  (Contains a position)
2396       1.1.1.2,60020.1248
2397       1.1.1.2,60020.1312
2398   1.1.1.3,60020,    123456630/
2399     2/
2400       1.1.1.3,60020.1280  (Contains a position)
2401 ----
2403 Assume that 1.1.1.2 loses its ZooKeeper session.
2404 The survivors will race to create a lock, and, arbitrarily, 1.1.1.3 wins.
2405 It will then start transferring all the queues to its local peers znode by appending the name of the dead server.
2406 Right before 1.1.1.3 is able to clean up the old znodes, the layout will look like the following:
2408 ----
2410 /hbase/replication/rs/
2411   1.1.1.1,60020,123456780/
2412     2/
2413       1.1.1.1,60020.1234  (Contains a position)
2414       1.1.1.1,60020.1265
2415   1.1.1.2,60020,123456790/
2416     lock
2417     2/
2418       1.1.1.2,60020.1214  (Contains a position)
2419       1.1.1.2,60020.1248
2420       1.1.1.2,60020.1312
2421   1.1.1.3,60020,123456630/
2422     2/
2423       1.1.1.3,60020.1280  (Contains a position)
2425     2-1.1.1.2,60020,123456790/
2426       1.1.1.2,60020.1214  (Contains a position)
2427       1.1.1.2,60020.1248
2428       1.1.1.2,60020.1312
2429 ----
2431 Some time later, but before 1.1.1.3 is able to finish replicating the last WAL from 1.1.1.2, it dies too.
2432 Some new logs were also created in the normal queues.
2433 The last region server will then try to lock 1.1.1.3's znode and will begin transferring all the queues.
2434 The new layout will be:
2436 ----
2438 /hbase/replication/rs/
2439   1.1.1.1,60020,123456780/
2440     2/
2441       1.1.1.1,60020.1378  (Contains a position)
2443     2-1.1.1.3,60020,123456630/
2444       1.1.1.3,60020.1325  (Contains a position)
2445       1.1.1.3,60020.1401
2447     2-1.1.1.2,60020,123456790-1.1.1.3,60020,123456630/
2448       1.1.1.2,60020.1312  (Contains a position)
2449   1.1.1.3,60020,123456630/
2450     lock
2451     2/
2452       1.1.1.3,60020.1325  (Contains a position)
2453       1.1.1.3,60020.1401
2455     2-1.1.1.2,60020,123456790/
2456       1.1.1.2,60020.1312  (Contains a position)
2457 ----
2459 === Replication Metrics
2461 The following metrics are exposed at the global region server level and at the peer level:
2463 `source.sizeOfLogQueue`::
2464   number of WALs to process (excludes the one which is being processed) at the Replication source
2466 `source.shippedOps`::
2467   number of mutations shipped
2469 `source.logEditsRead`::
2470   number of mutations read from WALs at the replication source
2472 `source.ageOfLastShippedOp`::
2473   age of last batch that was shipped by the replication source
2475 `source.completedLogs`::
2476   The number of write-ahead-log files that have completed their acknowledged sending to the peer associated with this source. Increments to this metric are a part of normal operation of HBase replication.
2478 `source.completedRecoverQueues`::
2479   The number of recovery queues this source has completed sending to the associated peer. Increments to this metric are a part of normal recovery of HBase replication in the face of failed Region Servers.
2481 `source.uncleanlyClosedLogs`::
2482   The number of write-ahead-log files the replication system considered completed after reaching the end of readable entries in the face of an uncleanly closed file.
2484 `source.ignoredUncleanlyClosedLogContentsInBytes`::
2485   When a write-ahead-log file is not closed cleanly, there will likely be some entry that has been partially serialized. This metric contains the number of bytes of such entries the HBase replication system believes were remaining at the end of files skipped in the face of an uncleanly closed file. Those bytes should either be in different file or represent a client write that was not acknowledged.
2487 `source.restartedLogReading`::
2488   The number of times the HBase replication system detected that it failed to correctly parse a cleanly closed write-ahead-log file. In this circumstance, the system replays the entire log from the beginning, ensuring that no edits fail to be acknowledged by the associated peer. Increments to this metric indicate that the HBase replication system is having difficulty correctly handling failures in the underlying distributed storage system. No dataloss should occur, but you should check Region Server log files for details of the failures.
2490 `source.repeatedLogFileBytes`::
2491   When the HBase replication system determines that it needs to replay a given write-ahead-log file, this metric is incremented by the number of bytes the replication system believes had already been acknowledged by the associated peer prior to starting over.
2493 `source.closedLogsWithUnknownFileLength`::
2494   Incremented when the HBase replication system believes it is at the end of a write-ahead-log file but it can not determine the length of that file in the underlying distributed storage system. Could indicate dataloss since the replication system is unable to determine if the end of readable entries lines up with the expected end of the file. You should check Region Server log files for details of the failures.
2497 === Replication Configuration Options
2499 [cols="1,1,1", options="header"]
2500 |===
2501 | Option
2502 | Description
2503 | Default
2505 | zookeeper.znode.parent
2506 | The name of the base ZooKeeper znode used for HBase
2507 | /hbase
2509 | zookeeper.znode.replication
2510 | The name of the base znode used for replication
2511 | replication
2513 | zookeeper.znode.replication.peers
2514 | The name of the peer znode
2515 | peers
2517 | zookeeper.znode.replication.peers.state
2518 | The name of peer-state znode
2519 | peer-state
2521 | zookeeper.znode.replication.rs
2522 | The name of the rs znode
2523 | rs
2525 | replication.sleep.before.failover
2526 | How many milliseconds a worker should sleep before attempting to replicate
2527                 a dead region server's WAL queues.
2530 | replication.executor.workers
2531 | The number of region servers a given region server should attempt to
2532                   failover simultaneously.
2533 | 1
2534 |===
2536 === Monitoring Replication Status
2538 You can use the HBase Shell command `status 'replication'` to monitor the replication status on your cluster. The  command has three variations:
2539 * `status 'replication'` -- prints the status of each source and its sinks, sorted by hostname.
2540 * `status 'replication', 'source'` -- prints the status for each replication source, sorted by hostname.
2541 * `status 'replication', 'sink'` -- prints the status for each replication sink, sorted by hostname.
2543 == Running Multiple Workloads On a Single Cluster
2545 HBase provides the following mechanisms for managing the performance of a cluster
2546 handling multiple workloads:
2547 . <<quota>>
2548 . <<request_queues>>
2549 . <<multiple-typed-queues>>
2551 [[quota]]
2552 === Quotas
2553 HBASE-11598 introduces RPC quotas, which allow you to throttle requests based on
2554 the following limits:
2556 . <<request-quotas,The number or size of requests(read, write, or read+write) in a given timeframe>>
2557 . <<namespace_quotas,The number of tables allowed in a namespace>>
2559 These limits can be enforced for a specified user, table, or namespace.
2561 .Enabling Quotas
2563 Quotas are disabled by default. To enable the feature, set the `hbase.quota.enabled`
2564 property to `true` in _hbase-site.xml_ file for all cluster nodes.
2566 .General Quota Syntax
2567 . THROTTLE_TYPE can be expressed as READ, WRITE, or the default type(read + write).
2568 . Timeframes  can be expressed in the following units: `sec`, `min`, `hour`, `day`
2569 . Request sizes can be expressed in the following units: `B` (bytes), `K` (kilobytes),
2570 `M` (megabytes), `G` (gigabytes), `T` (terabytes), `P` (petabytes)
2571 . Numbers of requests are expressed as an integer followed by the string `req`
2572 . Limits relating to time are expressed as req/time or size/time. For instance `10req/day`
2573 or `100P/hour`.
2574 . Numbers of tables or regions are expressed as integers.
2576 [[request-quotas]]
2577 .Setting Request Quotas
2578 You can set quota rules ahead of time, or you can change the throttle at runtime. The change
2579 will propagate after the quota refresh period has expired. This expiration period
2580 defaults to 5 minutes. To change it, modify the `hbase.quota.refresh.period` property
2581 in `hbase-site.xml`. This property is expressed in milliseconds and defaults to `300000`.
2583 ----
2584 # Limit user u1 to 10 requests per second
2585 hbase> set_quota TYPE => THROTTLE, USER => 'u1', LIMIT => '10req/sec'
2587 # Limit user u1 to 10 read requests per second
2588 hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => READ, USER => 'u1', LIMIT => '10req/sec'
2590 # Limit user u1 to 10 M per day everywhere
2591 hbase> set_quota TYPE => THROTTLE, USER => 'u1', LIMIT => '10M/day'
2593 # Limit user u1 to 10 M write size per sec
2594 hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => WRITE, USER => 'u1', LIMIT => '10M/sec'
2596 # Limit user u1 to 5k per minute on table t2
2597 hbase> set_quota TYPE => THROTTLE, USER => 'u1', TABLE => 't2', LIMIT => '5K/min'
2599 # Limit user u1 to 10 read requests per sec on table t2
2600 hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => READ, USER => 'u1', TABLE => 't2', LIMIT => '10req/sec'
2602 # Remove an existing limit from user u1 on namespace ns2
2603 hbase> set_quota TYPE => THROTTLE, USER => 'u1', NAMESPACE => 'ns2', LIMIT => NONE
2605 # Limit all users to 10 requests per hour on namespace ns1
2606 hbase> set_quota TYPE => THROTTLE, NAMESPACE => 'ns1', LIMIT => '10req/hour'
2608 # Limit all users to 10 T per hour on table t1
2609 hbase> set_quota TYPE => THROTTLE, TABLE => 't1', LIMIT => '10T/hour'
2611 # Remove all existing limits from user u1
2612 hbase> set_quota TYPE => THROTTLE, USER => 'u1', LIMIT => NONE
2614 # List all quotas for user u1 in namespace ns2
2615 hbase> list_quotas USER => 'u1, NAMESPACE => 'ns2'
2617 # List all quotas for namespace ns2
2618 hbase> list_quotas NAMESPACE => 'ns2'
2620 # List all quotas for table t1
2621 hbase> list_quotas TABLE => 't1'
2623 # list all quotas
2624 hbase> list_quotas
2625 ----
2627 You can also place a global limit and exclude a user or a table from the limit by applying the
2628 `GLOBAL_BYPASS` property.
2629 ----
2630 hbase> set_quota NAMESPACE => 'ns1', LIMIT => '100req/min'               # a per-namespace request limit
2631 hbase> set_quota USER => 'u1', GLOBAL_BYPASS => true                     # user u1 is not affected by the limit
2632 ----
2634 [[namespace_quotas]]
2635 .Setting Namespace Quotas
2637 You can specify the maximum number of tables or regions allowed in a given namespace, either
2638 when you create the namespace or by altering an existing namespace, by setting the
2639 `hbase.namespace.quota.maxtables property`  on the namespace.
2641 .Limiting Tables Per Namespace
2642 ----
2643 # Create a namespace with a max of 5 tables
2644 hbase> create_namespace 'ns1', {'hbase.namespace.quota.maxtables'=>'5'}
2646 # Alter an existing namespace to have a max of 8 tables
2647 hbase> alter_namespace 'ns2', {METHOD => 'set', 'hbase.namespace.quota.maxtables'=>'8'}
2649 # Show quota information for a namespace
2650 hbase> describe_namespace 'ns2'
2652 # Alter an existing namespace to remove a quota
2653 hbase> alter_namespace 'ns2', {METHOD => 'unset', NAME=>'hbase.namespace.quota.maxtables'}
2654 ----
2656 .Limiting Regions Per Namespace
2657 ----
2658 # Create a namespace with a max of 10 regions
2659 hbase> create_namespace 'ns1', {'hbase.namespace.quota.maxregions'=>'10'
2661 # Show quota information for a namespace
2662 hbase> describe_namespace 'ns1'
2664 # Alter an existing namespace to have a max of 20 tables
2665 hbase> alter_namespace 'ns2', {METHOD => 'set', 'hbase.namespace.quota.maxregions'=>'20'}
2667 # Alter an existing namespace to remove a quota
2668 hbase> alter_namespace 'ns2', {METHOD => 'unset', NAME=> 'hbase.namespace.quota.maxregions'}
2669 ----
2671 [[request_queues]]
2672 === Request Queues
2673 If no throttling policy is configured, when the RegionServer receives multiple requests,
2674 they are now placed into a queue waiting for a free execution slot (HBASE-6721).
2675 The simplest queue is a FIFO queue, where each request waits for all previous requests in the queue
2676 to finish before running. Fast or interactive queries can get stuck behind large requests.
2678 If you are able to guess how long a request will take, you can reorder requests by
2679 pushing the long requests to the end of the queue and allowing short requests to preempt
2680 them. Eventually, you must still execute the large requests and prioritize the new
2681 requests behind them. The short requests will be newer, so the result is not terrible,
2682 but still suboptimal compared to a mechanism which allows large requests to be split
2683 into multiple smaller ones.
2685 HBASE-10993 introduces such a system for deprioritizing long-running scanners. There
2686 are two types of queues, `fifo` and `deadline`. To configure the type of queue used,
2687 configure the `hbase.ipc.server.callqueue.type` property in `hbase-site.xml`. There
2688 is no way to estimate how long each request may take, so de-prioritization only affects
2689 scans, and is based on the number of “next” calls a scan request has made. An assumption
2690 is made that when you are doing a full table scan, your job is not likely to be interactive,
2691 so if there are concurrent requests, you can delay long-running scans up to a limit tunable by
2692 setting the `hbase.ipc.server.queue.max.call.delay` property. The slope of the delay is calculated
2693 by a simple square root of `(numNextCall * weight)` where the weight is
2694 configurable by setting the `hbase.ipc.server.scan.vtime.weight` property.
2696 [[multiple-typed-queues]]
2697 === Multiple-Typed Queues
2699 You can also prioritize or deprioritize different kinds of requests by configuring
2700 a specified number of dedicated handlers and queues. You can segregate the scan requests
2701 in a single queue with a single handler, and all the other available queues can service
2702 short `Get` requests.
2704 You can adjust the IPC queues and handlers based on the type of workload, using static
2705 tuning options. This approach is an interim first step that will eventually allow
2706 you to change the settings at runtime, and to dynamically adjust values based on the load.
2708 .Multiple Queues
2710 To avoid contention and separate different kinds of requests, configure the
2711 `hbase.ipc.server.callqueue.handler.factor` property, which allows you to increase the number of
2712 queues and control how many handlers can share the same queue., allows admins to increase the number
2713 of queues and decide how many handlers share the same queue.
2715 Using more queues reduces contention when adding a task to a queue or selecting it
2716 from a queue. You can even configure one queue per handler. The trade-off is that
2717 if some queues contain long-running tasks, a handler may need to wait to execute from that queue
2718 rather than stealing from another queue which has waiting tasks.
2720 .Read and Write Queues
2721 With multiple queues, you can now divide read and write requests, giving more priority
2722 (more queues) to one or the other type. Use the `hbase.ipc.server.callqueue.read.ratio`
2723 property to choose to serve more reads or more writes.
2725 .Get and Scan Queues
2726 Similar to the read/write split, you can split gets and scans by tuning the `hbase.ipc.server.callqueue.scan.ratio`
2727 property to give more priority to gets or to scans. A scan ratio of `0.1` will give
2728 more queue/handlers to the incoming gets, which means that more gets can be processed
2729 at the same time and that fewer scans can be executed at the same time. A value of
2730 `0.9` will give more queue/handlers to scans, so the number of scans executed will
2731 increase and the number of gets will decrease.
2733 [[space-quotas]]
2734 === Space Quotas
2736 link:https://issues.apache.org/jira/browse/HBASE-16961[HBASE-16961] introduces a new type of
2737 quotas for HBase to leverage: filesystem quotas. These "space" quotas limit the amount of space
2738 on the filesystem that HBase namespaces and tables can consume. If a user, malicious or ignorant,
2739 has the ability to write data into HBase, with enough time, that user can effectively crash HBase
2740 (or worse HDFS) by consuming all available space. When there is no filesystem space available,
2741 HBase crashes because it can no longer create/sync data to the write-ahead log.
2743 This feature allows a for a limit to be set on the size of a table or namespace. When a space quota is set
2744 on a namespace, the quota's limit applies to the sum of usage of all tables in that namespace.
2745 When a table with a quota exists in a namespace with a quota, the table quota takes priority
2746 over the namespace quota. This allows for a scenario where a large limit can be placed on
2747 a collection of tables, but a single table in that collection can have a fine-grained limit set.
2749 The existing `set_quota` and `list_quota` HBase shell commands can be used to interact with
2750 space quotas. Space quotas are quotas with a `TYPE` of `SPACE` and have `LIMIT` and `POLICY`
2751 attributes. The `LIMIT` is a string that refers to the amount of space on the filesystem
2752 that the quota subject (e.g. the table or namespace) may consume. For example, valid values
2753 of `LIMIT` are `'10G'`, `'2T'`, or `'256M'`. The `POLICY` refers to the action that HBase will
2754 take when the quota subject's usage exceeds the `LIMIT`. The following are valid `POLICY` values.
2756 * `NO_INSERTS` - No new data may be written (e.g. `Put`, `Increment`, `Append`).
2757 * `NO_WRITES` - Same as `NO_INSERTS` but `Deletes` are also disallowed.
2758 * `NO_WRITES_COMPACTIONS` - Same as `NO_WRITES` but compactions are also disallowed.
2759 ** This policy only prevents user-submitted compactions. System can still run compactions.
2760 * `DISABLE` - The table(s) are disabled, preventing all read/write access.
2762 .Setting simple space quotas
2763 ----
2764 # Sets a quota on the table 't1' with a limit of 1GB, disallowing Puts/Increments/Appends when the table exceeds 1GB
2765 hbase> set_quota TYPE => SPACE, TABLE => 't1', LIMIT => '1G', POLICY => NO_INSERTS
2767 # Sets a quota on the namespace 'ns1' with a limit of 50TB, disallowing Puts/Increments/Appends/Deletes
2768 hbase> set_quota TYPE => SPACE, NAMESPACE => 'ns1', LIMIT => '50T', POLICY => NO_WRITES
2770 # Sets a quota on the table 't3' with a limit of 2TB, disallowing any writes and compactions when the table exceeds 2TB.
2771 hbase> set_quota TYPE => SPACE, TABLE => 't3', LIMIT => '2T', POLICY => NO_WRITES_COMPACTIONS
2773 # Sets a quota on the table 't2' with a limit of 50GB, disabling the table when it exceeds 50GB
2774 hbase> set_quota TYPE => SPACE, TABLE => 't2', LIMIT => '50G', POLICY => DISABLE
2775 ----
2777 Consider the following scenario to set up quotas on a namespace, overriding the quota on tables in that namespace
2779 .Table and Namespace space quotas
2780 ----
2781 hbase> create_namespace 'ns1'
2782 hbase> create 'ns1:t1'
2783 hbase> create 'ns1:t2'
2784 hbase> create 'ns1:t3'
2785 hbase> set_quota TYPE => SPACE, NAMESPACE => 'ns1', LIMIT => '100T', POLICY => NO_INSERTS
2786 hbase> set_quota TYPE => SPACE, TABLE => 'ns1:t2', LIMIT => '200G', POLICY => NO_WRITES
2787 hbase> set_quota TYPE => SPACE, TABLE => 'ns1:t3', LIMIT => '20T', POLICY => NO_WRITES
2788 ----
2790 In the above scenario, the tables in the namespace `ns1` will not be allowed to consume more than
2791 100TB of space on the filesystem among each other. The table 'ns1:t2' is only allowed to be 200GB in size, and will
2792 disallow all writes when the usage exceeds this limit. The table 'ns1:t3' is allowed to grow to 20TB in size
2793 and also will disallow all writes then the usage exceeds this limit. Because there is no table quota
2794 on 'ns1:t1', this table can grow up to 100TB, but only if 'ns1:t2' and 'ns1:t3' have a usage of zero bytes.
2795 Practically, it's limit is 100TB less the current usage of 'ns1:t2' and 'ns1:t3'.
2797 [[ops.space.quota.deletion]]
2798 === Disabling Automatic Space Quota Deletion
2800 By default, if a table or namespace is deleted that has a space quota, the quota itself is
2801 also deleted. In some cases, it may be desirable for the space quota to not be automatically deleted.
2802 In these cases, the user may configure the system to not delete any space quota automatically via hbase-site.xml.
2804 [source,java]
2805 ----
2807   <property>
2808     <name>hbase.quota.remove.on.table.delete</name>
2809     <value>false</value>
2810   </property>
2811 ----
2813 The value is set to `true` by default.
2815 === HBase Snapshots with Space Quotas
2817 One common area of unintended-filesystem-use with HBase is via HBase snapshots. Because snapshots
2818 exist outside of the management of HBase tables, it is not uncommon for administrators to suddenly
2819 realize that hundreds of gigabytes or terabytes of space is being used by HBase snapshots which were
2820 forgotten and never removed.
2822 link:https://issues.apache.org/jira/browse/HBASE-17748[HBASE-17748] is the umbrella JIRA issue which
2823 expands on the original space quota functionality to also include HBase snapshots. While this is a confusing
2824 subject, the implementation attempts to present this support in as reasonable and simple of a manner as
2825 possible for administrators. This feature does not make any changes to administrator interaction with
2826 space quotas, only in the internal computation of table/namespace usage. Table and namespace usage will
2827 automatically incorporate the size taken by a snapshot per the rules defined below.
2829 As a review, let's cover a snapshot's lifecycle: a snapshot is metadata which points to
2830 a list of HFiles on the filesystem. This is why creating a snapshot is a very cheap operation; no HBase
2831 table data is actually copied to perform a snapshot. Cloning a snapshot into a new table or restoring
2832 a table is a cheap operation for the same reason; the new table references the files which already exist
2833 on the filesystem without a copy. To include snapshots in space quotas, we need to define which table
2834 "owns" a file when a snapshot references the file ("owns" refers to encompassing the filesystem usage
2835 of that file).
2837 Consider a snapshot which was made against a table. When the snapshot refers to a file and the table no
2838 longer refers to that file, the "originating" table "owns" that file. When multiple snapshots refer to
2839 the same file and no table refers to that file, the snapshot with the lowest-sorting name (lexicographically)
2840 is chosen and the table which that snapshot was created from "owns" that file. HFiles are not "double-counted"
2841  hen a table and one or more snapshots refer to that HFile.
2843 When a table is "rematerialized" (via `clone_snapshot` or `restore_snapshot`), a similar problem of file
2844 ownership arises. In this case, while the rematerialized table references a file which a snapshot also
2845 references, the table does not "own" the file. The table from which the snapshot was created still "owns"
2846 that file. When the rematerialized table is compacted or the snapshot is deleted, the rematerialized table
2847 will uniquely refer to a new file and "own" the usage of that file. Similarly, when a table is duplicated via a snapshot
2848 and `restore_snapshot`, the new table will not consume any quota size until the original table stops referring
2849 to the files, either due to a compaction on the original table, a compaction on the new table, or the
2850 original table being deleted.
2852 One new HBase shell command was added to inspect the computed sizes of each snapshot in an HBase instance.
2854 ----
2855 hbase> list_snapshot_sizes
2856 SNAPSHOT                                      SIZE
2857  t1.s1                                        1159108
2858 ----
2860 [[ops.backup]]
2861 == HBase Backup
2863 There are two broad strategies for performing HBase backups: backing up with a full cluster shutdown, and backing up on a live cluster.
2864 Each approach has pros and cons.
2866 For additional information, see link:http://blog.sematext.com/2011/03/11/hbase-backup-options/[HBase Backup
2867         Options] over on the Sematext Blog.
2869 [[ops.backup.fullshutdown]]
2870 === Full Shutdown Backup
2872 Some environments can tolerate a periodic full shutdown of their HBase cluster, for example if it is being used a back-end analytic capacity and not serving front-end web-pages.
2873 The benefits are that the NameNode/Master are RegionServers are down, so there is no chance of missing any in-flight changes to either StoreFiles or metadata.
2874 The obvious con is that the cluster is down.
2875 The steps include:
2877 [[ops.backup.fullshutdown.stop]]
2878 ==== Stop HBase
2882 [[ops.backup.fullshutdown.distcp]]
2883 ==== Distcp
2885 Distcp could be used to either copy the contents of the HBase directory in HDFS to either the same cluster in another directory, or to a different cluster.
2887 Note: Distcp works in this situation because the cluster is down and there are no in-flight edits to files.
2888 Distcp-ing of files in the HBase directory is not generally recommended on a live cluster.
2890 [[ops.backup.fullshutdown.restore]]
2891 ==== Restore (if needed)
2893 The backup of the hbase directory from HDFS is copied onto the 'real' hbase directory via distcp.
2894 The act of copying these files creates new HDFS metadata, which is why a restore of the NameNode edits from the time of the HBase backup isn't required for this kind of restore, because it's a restore (via distcp) of a specific HDFS directory (i.e., the HBase part) not the entire HDFS file-system.
2896 [[ops.backup.live.replication]]
2897 === Live Cluster Backup - Replication
2899 This approach assumes that there is a second cluster.
2900 See the HBase page on link:https://hbase.apache.org/book.html#_cluster_replication[replication] for more information.
2902 [[ops.backup.live.copytable]]
2903 === Live Cluster Backup - CopyTable
2905 The <<copy.table,copytable>> utility could either be used to copy data from one table to another on the same cluster, or to copy data to another table on another cluster.
2907 Since the cluster is up, there is a risk that edits could be missed in the copy process.
2909 [[ops.backup.live.export]]
2910 === Live Cluster Backup - Export
2912 The <<export,export>> approach dumps the content of a table to HDFS on the same cluster.
2913 To restore the data, the <<import,import>> utility would be used.
2915 Since the cluster is up, there is a risk that edits could be missed in the export process. If you want to know more about HBase back-up and restore see the page on link:http://hbase.apache.org/book.html#backuprestore[Backup and Restore].
2917 [[ops.snapshots]]
2918 == HBase Snapshots
2920 HBase Snapshots allow you to take a copy of a table (both contents and metadata)with a very small performance impact. A Snapshot is an immutable
2921 collection of table metadata and a list of HFiles that comprised the table at the time the Snapshot was taken. A "clone"
2922 of a snapshot creates a new table from that snapshot, and a "restore" of a snapshot returns the contents of a table to
2923 what it was when the snapshot was created. The "clone" and "restore" operations do not require any data to be copied,
2924 as the underlying HFiles (the files which contain the data for an HBase table) are not modified with either action.
2925 Simiarly, exporting a snapshot to another cluster has little impact on RegionServers of the local cluster.
2927 Prior to version 0.94.6, the only way to backup or to clone a table is to use CopyTable/ExportTable, or to copy all the hfiles in HDFS after disabling the table.
2928 The disadvantages of these methods are that you can degrade region server performance (Copy/Export Table) or you need to disable the table, that means no reads or writes; and this is usually unacceptable.
2930 [[ops.snapshots.configuration]]
2931 === Configuration
2933 To turn on the snapshot support just set the `hbase.snapshot.enabled`        property to true.
2934 (Snapshots are enabled by default in 0.95+ and off by default in 0.94.6+)
2936 [source,java]
2937 ----
2939   <property>
2940     <name>hbase.snapshot.enabled</name>
2941     <value>true</value>
2942   </property>
2943 ----
2945 [[ops.snapshots.takeasnapshot]]
2946 === Take a Snapshot
2948 You can take a snapshot of a table regardless of whether it is enabled or disabled.
2949 The snapshot operation doesn't involve any data copying.
2951 ----
2953 $ ./bin/hbase shell
2954 hbase> snapshot 'myTable', 'myTableSnapshot-122112'
2955 ----
2957 .Take a Snapshot Without Flushing
2958 The default behavior is to perform a flush of data in memory before the snapshot is taken.
2959 This means that data in memory is included in the snapshot.
2960 In most cases, this is the desired behavior.
2961 However, if your set-up can tolerate data in memory being excluded from the snapshot, you can use the `SKIP_FLUSH` option of the `snapshot` command to disable and flushing while taking the snapshot.
2963 ----
2964 hbase> snapshot 'mytable', 'snapshot123', {SKIP_FLUSH => true}
2965 ----
2967 WARNING: There is no way to determine or predict whether a very concurrent insert or update will be included in a given snapshot, whether flushing is enabled or disabled.
2968 A snapshot is only a representation of a table during a window of time.
2969 The amount of time the snapshot operation will take to reach each Region Server may vary from a few seconds to a minute, depending on the resource load and speed of the hardware or network, among other factors.
2970 There is also no way to know whether a given insert or update is in memory or has been flushed.
2973 .Take a Snapshot With TTL
2974 Snapshots have a lifecycle that is independent from the table from which they are created.
2975 Although data in a table may be stored with TTL the data files containing them become
2976 frozen by the snapshot. Space consumed by expired cells will not be reclaimed by normal
2977 table housekeeping like compaction. While this is expected it can be inconvenient at scale.
2978 When many snapshots are under management and the data in various tables is expired by
2979 TTL some notion of optional TTL (and optional default TTL) for snapshots could be useful.
2982 ----
2983 hbase> snapshot 'mytable', 'snapshot1234', {TTL => 86400}
2984 ----
2986 The above command creates snapshot `snapshot1234` with TTL of 86400 sec(24 hours)
2987 and hence, the snapshot is supposed to be cleaned up after 24 hours
2991 .Default Snapshot TTL:
2993 - FOREVER by default
2994 - User specified Default TTL with config `hbase.master.snapshot.ttl`
2997 While creating a Snapshot, if TTL in seconds is not specified, by default the snapshot
2998 would not be deleted automatically. i.e. it would be retained forever until it is
2999 manually deleted. However, the user can update this default TTL behavior by
3000 providing default TTL in sec for key: `hbase.master.snapshot.ttl`.
3001 Value 0 for this config indicates TTL: FOREVER
3005 .Enable/Disable Snapshot Auto Cleanup on running cluster:
3007 By default, snapshot auto cleanup based on TTL would be enabled
3008 for any new cluster.
3009 At any point in time, if snapshot cleanup is supposed to be stopped due to
3010 some snapshot restore activity or any other reason, it is advisable
3011 to disable it using shell command:
3013 ----
3014 hbase> snapshot_cleanup_switch false
3015 ----
3017 We can re-enable it using:
3019 ----
3020 hbase> snapshot_cleanup_switch true
3021 ----
3023 The shell command with switch false would disable snapshot auto
3024 cleanup activity based on TTL and return the previous state of
3025 the activity(true: running already, false: disabled already)
3027 A sample output for above commands:
3028 ----
3029 Previous snapshot cleanup state : true
3030 Took 0.0069 seconds
3031 => "true"
3032 ----
3034 We can query whether snapshot auto cleanup is enabled for
3035 cluster using:
3037 ----
3038 hbase> snapshot_cleanup_enabled
3039 ----
3041 The command would return output in true/false.
3043 [[ops.snapshots.list]]
3044 === Listing Snapshots
3046 List all snapshots taken (by printing the names and relative information).
3048 ----
3050 $ ./bin/hbase shell
3051 hbase> list_snapshots
3052 ----
3054 [[ops.snapshots.delete]]
3055 === Deleting Snapshots
3057 You can remove a snapshot, and the files retained for that snapshot will be removed if no longer needed.
3059 ----
3061 $ ./bin/hbase shell
3062 hbase> delete_snapshot 'myTableSnapshot-122112'
3063 ----
3065 [[ops.snapshots.clone]]
3066 === Clone a table from snapshot
3068 From a snapshot you can create a new table (clone operation) with the same data that you had when the snapshot was taken.
3069 The clone operation, doesn't involve data copies, and a change to the cloned table doesn't impact the snapshot or the original table.
3071 ----
3073 $ ./bin/hbase shell
3074 hbase> clone_snapshot 'myTableSnapshot-122112', 'myNewTestTable'
3075 ----
3077 [[ops.snapshots.restore]]
3078 === Restore a snapshot
3080 The restore operation requires the table to be disabled, and the table will be restored to the state at the time when the snapshot was taken, changing both data and schema if required.
3082 ----
3084 $ ./bin/hbase shell
3085 hbase> disable 'myTable'
3086 hbase> restore_snapshot 'myTableSnapshot-122112'
3087 ----
3089 NOTE: Since Replication works at log level and snapshots at file-system level, after a restore, the replicas will be in a different state from the master.
3090 If you want to use restore, you need to stop replication and redo the bootstrap.
3092 In case of partial data-loss due to misbehaving client, instead of a full restore that requires the table to be disabled, you can clone the table from the snapshot and use a Map-Reduce job to copy the data that you need, from the clone to the main one.
3094 [[ops.snapshots.acls]]
3095 === Snapshots operations and ACLs
3097 If you are using security with the AccessController Coprocessor (See <<hbase.accesscontrol.configuration,hbase.accesscontrol.configuration>>), only a global administrator can take, clone, or restore a snapshot, and these actions do not capture the ACL rights.
3098 This means that restoring a table preserves the ACL rights of the existing table, while cloning a table creates a new table that has no ACL rights until the administrator adds them.
3100 [[ops.snapshots.export]]
3101 === Export to another cluster
3103 The ExportSnapshot tool copies all the data related to a snapshot (hfiles, logs, snapshot metadata) to another cluster.
3104 The tool executes a Map-Reduce job, similar to distcp, to copy files between the two clusters, and since it works at file-system level the hbase cluster does not have to be online.
3106 To copy a snapshot called MySnapshot to an HBase cluster srv2 (hdfs:///srv2:8082/hbase) using 16 mappers:
3108 [source,bourne]
3109 ----
3110 $ bin/hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot MySnapshot -copy-to hdfs://srv2:8082/hbase -mappers 16
3111 ----
3113 .Limiting Bandwidth Consumption
3114 You can limit the bandwidth consumption when exporting a snapshot, by specifying the `-bandwidth` parameter, which expects an integer representing megabytes per second.
3115 The following example limits the above example to 200 MB/sec.
3117 [source,bourne]
3118 ----
3119 $ bin/hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot MySnapshot -copy-to hdfs://srv2:8082/hbase -mappers 16 -bandwidth 200
3120 ----
3122 [[snapshots_s3]]
3123 === Storing Snapshots in an Amazon S3 Bucket
3125 You can store and retrieve snapshots from Amazon S3, using the following procedure.
3127 NOTE: You can also store snapshots in Microsoft Azure Blob Storage. See <<snapshots_azure>>.
3129 .Prerequisites
3130 - You must be using HBase 1.0 or higher and Hadoop 2.6.1 or higher, which is the first
3131 configuration that uses the Amazon AWS SDK.
3132 - You must use the `s3a://` protocol to connect to Amazon S3. The older `s3n://`
3133 and `s3://` protocols have various limitations and do not use the Amazon AWS SDK.
3134 - The `s3a://` URI must be configured and available on the server where you run
3135 the commands to export and restore the snapshot.
3137 After you have fulfilled the prerequisites, take the snapshot like you normally would.
3138 Afterward, you can export it using the `org.apache.hadoop.hbase.snapshot.ExportSnapshot`
3139 command like the one below, substituting your own `s3a://` path in the `copy-from`
3140 or `copy-to` directive and substituting or modifying other options as required:
3142 ----
3143 $ hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot \
3144     -snapshot MySnapshot \
3145     -copy-from hdfs://srv2:8082/hbase \
3146     -copy-to s3a://<bucket>/<namespace>/hbase \
3147     -chuser MyUser \
3148     -chgroup MyGroup \
3149     -chmod 700 \
3150     -mappers 16
3151 ----
3153 ----
3154 $ hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot \
3155     -snapshot MySnapshot
3156     -copy-from s3a://<bucket>/<namespace>/hbase \
3157     -copy-to hdfs://srv2:8082/hbase \
3158     -chuser MyUser \
3159     -chgroup MyGroup \
3160     -chmod 700 \
3161     -mappers 16
3162 ----
3164 You can also use the `org.apache.hadoop.hbase.snapshot.SnapshotInfo` utility with the `s3a://` path by including the
3165 `-remote-dir` option.
3167 ----
3168 $ hbase org.apache.hadoop.hbase.snapshot.SnapshotInfo \
3169     -remote-dir s3a://<bucket>/<namespace>/hbase \
3170     -list-snapshots
3171 ----
3173 [[snapshots_azure]]
3174 == Storing Snapshots in Microsoft Azure Blob Storage
3176 You can store snapshots in Microsoft Azure Blog Storage using the same techniques
3177 as in <<snapshots_s3>>.
3179 .Prerequisites
3180 - You must be using HBase 1.2 or higher with Hadoop 2.7.1 or
3181   higher. No version of HBase supports Hadoop 2.7.0.
3182 - Your hosts must be configured to be aware of the Azure blob storage filesystem.
3183   See https://hadoop.apache.org/docs/r2.7.1/hadoop-azure/index.html.
3185 After you meet the prerequisites, follow the instructions
3186 in <<snapshots_s3>>, replacingthe protocol specifier with `wasb://` or `wasbs://`.
3188 [[ops.capacity]]
3189 == Capacity Planning and Region Sizing
3191 There are several considerations when planning the capacity for an HBase cluster and performing the initial configuration.
3192 Start with a solid understanding of how HBase handles data internally.
3194 [[ops.capacity.nodes]]
3195 === Node count and hardware/VM configuration
3197 [[ops.capacity.nodes.datasize]]
3198 ==== Physical data size
3200 Physical data size on disk is distinct from logical size of your data and is affected by the following:
3202 * Increased by HBase overhead
3204 * See <<keyvalue,keyvalue>> and <<keysize,keysize>>.
3205   At least 24 bytes per key-value (cell), can be more.
3206   Small keys/values means more relative overhead.
3207 * KeyValue instances are aggregated into blocks, which are indexed.
3208   Indexes also have to be stored.
3209   Blocksize is configurable on a per-ColumnFamily basis.
3210   See <<regions.arch,regions.arch>>.
3212 * Decreased by <<compression,compression>> and data block encoding, depending on data.
3213   See also link:http://search-hadoop.com/m/lL12B1PFVhp1[this thread].
3214   You might want to test what compression and encoding (if any) make sense for your data.
3215 * Increased by size of region server <<wal,wal>> (usually fixed and negligible - less than half of RS memory size, per RS).
3216 * Increased by HDFS replication - usually x3.
3218 Aside from the disk space necessary to store the data, one RS may not be able to serve arbitrarily large amounts of data due to some practical limits on region count and size (see <<ops.capacity.regions,ops.capacity.regions>>).
3220 [[ops.capacity.nodes.throughput]]
3221 ==== Read/Write throughput
3223 Number of nodes can also be driven by required throughput for reads and/or writes.
3224 The throughput one can get per node depends a lot on data (esp.
3225 key/value sizes) and request patterns, as well as node and system configuration.
3226 Planning should be done for peak load if it is likely that the load would be the main driver of the increase of the node count.
3227 PerformanceEvaluation and <<ycsb,ycsb>> tools can be used to test single node or a test cluster.
3229 For write, usually 5-15Mb/s per RS can be expected, since every region server has only one active WAL.
3230 There's no good estimate for reads, as it depends vastly on data, requests, and cache hit rate. <<perf.casestudy,perf.casestudy>> might be helpful.
3232 [[ops.capacity.nodes.gc]]
3233 ==== JVM GC limitations
3235 RS cannot currently utilize very large heap due to cost of GC.
3236 There's also no good way of running multiple RS-es per server (other than running several VMs per machine). Thus, ~20-24Gb or less memory dedicated to one RS is recommended.
3237 GC tuning is required for large heap sizes.
3238 See <<gcpause,gcpause>>, <<trouble.log.gc,trouble.log.gc>> and elsewhere (TODO: where?)
3240 [[ops.capacity.regions]]
3241 === Determining region count and size
3243 Generally less regions makes for a smoother running cluster (you can always manually split the big regions later (if necessary) to spread the data, or request load, over the cluster); 20-200 regions per RS is a reasonable range.
3244 The number of regions cannot be configured directly (unless you go for fully <<disable.splitting,disable.splitting>>); adjust the region size to achieve the target region size given table size.
3246 When configuring regions for multiple tables, note that most region settings can be set on a per-table basis via link:https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html[HTableDescriptor], as well as shell commands.
3247 These settings will override the ones in `hbase-site.xml`.
3248 That is useful if your tables have different workloads/use cases.
3250 Also note that in the discussion of region sizes here, _HDFS replication factor is not (and should not be) taken into account, whereas
3251           other factors <<ops.capacity.nodes.datasize,ops.capacity.nodes.datasize>> should be._ So, if your data is compressed and replicated 3 ways by HDFS, "9 Gb region" means 9 Gb of compressed data.
3252 HDFS replication factor only affects your disk usage and is invisible to most HBase code.
3254 ==== Viewing the Current Number of Regions
3256 You can view the current number of regions for a given table using the HMaster UI.
3257 In the [label]#Tables# section, the number of online regions for each table is listed in the [label]#Online Regions# column.
3258 This total only includes the in-memory state and does not include disabled or offline regions.
3260 [[ops.capacity.regions.count]]
3261 ==== Number of regions per RS - upper bound
3263 In production scenarios, where you have a lot of data, you are normally concerned with the maximum number of regions you can have per server. <<too_many_regions,too many regions>>          has technical discussion on the subject.
3264 Basically, the maximum number of regions is mostly determined by memstore memory usage.
3265 Each region has its own memstores; these grow up to a configurable size; usually in 128-256 MB range, see <<hbase.hregion.memstore.flush.size,hbase.hregion.memstore.flush.size>>.
3266 One memstore exists per column family (so there's only one per region if there's one CF in the table). The RS dedicates some fraction of total memory to its memstores (see <<hbase.regionserver.global.memstore.size,hbase.regionserver.global.memstore.size>>). If this memory is exceeded (too much memstore usage), it can cause undesirable consequences such as unresponsive server or compaction storms.
3267 A good starting point for the number of regions per RS (assuming one table) is:
3269 [source]
3270 ----
3271 ((RS memory) * (total memstore fraction)) / ((memstore size)*(# column families))
3272 ----
3274 This formula is pseudo-code.
3275 Here are two formulas using the actual tunable parameters, first for HBase 0.98+ and second for HBase 0.94.x.
3277 HBase 0.98.x::
3278 ----
3279 ((RS Xmx) * hbase.regionserver.global.memstore.size) / (hbase.hregion.memstore.flush.size * (# column families))
3280 ----
3281 HBase 0.94.x::
3282 ----
3283 ((RS Xmx) * hbase.regionserver.global.memstore.upperLimit) / (hbase.hregion.memstore.flush.size * (# column families))+
3284 ----
3286 If a given RegionServer has 16 GB of RAM, with default settings, the formula works out to 16384*0.4/128 ~ 51 regions per RS is a starting point.
3287 The formula can be extended to multiple tables; if they all have the same configuration, just use the total number of families.
3289 This number can be adjusted; the formula above assumes all your regions are filled at approximately the same rate.
3290 If only a fraction of your regions are going to be actively written to, you can divide the result by that fraction to get a larger region count.
3291 Then, even if all regions are written to, all region memstores are not filled evenly, and eventually jitter appears even if they are (due to limited number of concurrent flushes). Thus, one can have as many as 2-3 times more regions than the starting point; however, increased numbers carry increased risk.
3293 For write-heavy workload, memstore fraction can be increased in configuration at the expense of block cache; this will also allow one to have more regions.
3295 [[ops.capacity.regions.mincount]]
3296 ==== Number of regions per RS - lower bound
3298 HBase scales by having regions across many servers.
3299 Thus if you have 2 regions for 16GB data, on a 20 node machine your data will be concentrated on just a few machines - nearly the entire cluster will be idle.
3300 This really can't be stressed enough, since a common problem is loading 200MB data into HBase and then wondering why your awesome 10 node cluster isn't doing anything.
3302 On the other hand, if you have a very large amount of data, you may also want to go for a larger number of regions to avoid having regions that are too large.
3304 [[ops.capacity.regions.size]]
3305 ==== Maximum region size
3307 For large tables in production scenarios, maximum region size is mostly limited by compactions - very large compactions, esp.
3308 major, can degrade cluster performance.
3309 Currently, the recommended maximum region size is 10-20Gb, and 5-10Gb is optimal.
3310 For older 0.90.x codebase, the upper-bound of regionsize is about 4Gb, with a default of 256Mb.
3312 The size at which the region is split into two is generally configured via <<hbase.hregion.max.filesize,hbase.hregion.max.filesize>>; for details, see <<arch.region.splits,arch.region.splits>>.
3314 If you cannot estimate the size of your tables well, when starting off, it's probably best to stick to the default region size, perhaps going smaller for hot tables (or manually split hot regions to spread the load over the cluster), or go with larger region sizes if your cell sizes tend to be largish (100k and up).
3316 In HBase 0.98, experimental stripe compactions feature was added that would allow for larger regions, especially for log data.
3317 See <<ops.stripe,ops.stripe>>.
3319 [[ops.capacity.regions.total]]
3320 ==== Total data size per region server
3322 According to above numbers for region size and number of regions per region server, in an optimistic estimate 10 GB x 100 regions per RS will give up to 1TB served per region server, which is in line with some of the reported multi-PB use cases.
3323 However, it is important to think about the data vs cache size ratio at the RS level.
3324 With 1TB of data per server and 10 GB block cache, only 1% of the data will be cached, which may barely cover all block indices.
3326 [[ops.capacity.config]]
3327 === Initial configuration and tuning
3329 First, see <<important_configurations,important configurations>>.
3330 Note that some configurations, more than others, depend on specific scenarios.
3331 Pay special attention to:
3333 * <<hbase.regionserver.handler.count,hbase.regionserver.handler.count>> - request handler thread count, vital for high-throughput workloads.
3334 * <<config.wals,config.wals>> - the blocking number of WAL files depends on your memstore configuration and should be set accordingly to prevent potential blocking when doing high volume of writes.
3336 Then, there are some considerations when setting up your cluster and tables.
3338 [[ops.capacity.config.compactions]]
3339 ==== Compactions
3341 Depending on read/write volume and latency requirements, optimal compaction settings may be different.
3342 See <<compaction,compaction>> for some details.
3344 When provisioning for large data sizes, however, it's good to keep in mind that compactions can affect write throughput.
3345 Thus, for write-intensive workloads, you may opt for less frequent compactions and more store files per regions.
3346 Minimum number of files for compactions (`hbase.hstore.compaction.min`) can be set to higher value; <<hbase.hstore.blockingStoreFiles,hbase.hstore.blockingStoreFiles>> should also be increased, as more files might accumulate in such case.
3347 You may also consider manually managing compactions: <<managed.compactions,managed.compactions>>
3349 [[ops.capacity.config.presplit]]
3350 ==== Pre-splitting the table
3352 Based on the target number of the regions per RS (see <<ops.capacity.regions.count,ops.capacity.regions.count>>) and number of RSes, one can pre-split the table at creation time.
3353 This would both avoid some costly splitting as the table starts to fill up, and ensure that the table starts out already distributed across many servers.
3355 If the table is expected to grow large enough to justify that, at least one region per RS should be created.
3356 It is not recommended to split immediately into the full target number of regions (e.g.
3357 50 * number of RSes), but a low intermediate value can be chosen.
3358 For multiple tables, it is recommended to be conservative with presplitting (e.g.
3359 pre-split 1 region per RS at most), especially if you don't know how much each table will grow.
3360 If you split too much, you may end up with too many regions, with some tables having too many small regions.
3362 For pre-splitting howto, see <<manual_region_splitting_decisions,manual region splitting decisions>> and <<precreate.regions,precreate.regions>>.
3364 [[table.rename]]
3365 == Table Rename
3367 In versions 0.90.x of hbase and earlier, we had a simple script that would rename the hdfs table directory and then do an edit of the hbase:meta table replacing all mentions of the old table name with the new.
3368 The script was called `./bin/rename_table.rb`.
3369 The script was deprecated and removed mostly because it was unmaintained and the operation performed by the script was brutal.
3371 As of hbase 0.94.x, you can use the snapshot facility renaming a table.
3372 Here is how you would do it using the hbase shell:
3374 ----
3375 hbase shell> disable 'tableName'
3376 hbase shell> snapshot 'tableName', 'tableSnapshot'
3377 hbase shell> clone_snapshot 'tableSnapshot', 'newTableName'
3378 hbase shell> delete_snapshot 'tableSnapshot'
3379 hbase shell> drop 'tableName'
3380 ----
3382 or in code it would be as follows:
3384 [source,java]
3385 ----
3386 void rename(Admin admin, String oldTableName, TableName newTableName) {
3387   String snapshotName = randomName();
3388   admin.disableTable(oldTableName);
3389   admin.snapshot(snapshotName, oldTableName);
3390   admin.cloneSnapshot(snapshotName, newTableName);
3391   admin.deleteSnapshot(snapshotName);
3392   admin.deleteTable(oldTableName);
3394 ----
3396 [[rsgroup]]
3397 == RegionServer Grouping
3398 RegionServer Grouping (A.K.A `rsgroup`) is an advanced feature for
3399 partitioning regionservers into distinctive groups for strict isolation. It
3400 should only be used by users who are sophisticated enough to understand the
3401 full implications and have a sufficient background in managing HBase clusters.
3402 It was developed by Yahoo! and they run it at scale on their large grid cluster.
3403 See link:http://www.slideshare.net/HBaseCon/keynote-apache-hbase-at-yahoo-scale[HBase at Yahoo! Scale].
3405 RSGroups can be defined and managed with both admin methods and shell commands.
3406 A server can be added to a group with hostname and port pair and tables
3407 can be moved to this group so that only regionservers in the same rsgroup can
3408 host the regions of the table. The group for a table is stored in its
3409 TableDescriptor, the property name is `hbase.rsgroup.name`. You can also set
3410 this property on a namespace, so it will cause all the tables under this
3411 namespace to be placed into this group. RegionServers and tables can only
3412 belong to one rsgroup at a time. By default, all tables and regionservers
3413 belong to the `default` rsgroup. System tables can also be put into a
3414 rsgroup using the regular APIs. A custom balancer implementation tracks
3415 assignments per rsgroup and makes sure to move regions to the relevant
3416 regionservers in that rsgroup. The rsgroup information is stored in a regular
3417 HBase table, and a zookeeper-based read-only cache is used at cluster bootstrap
3418 time.
3420 To enable, add the following to your hbase-site.xml and restart your Master:
3422 [source,xml]
3423 ----
3424  <property>
3425    <name>hbase.balancer.rsgroup.enabled</name>
3426    <value>true</value>
3427  </property>
3428 ----
3430 Then use the admin/shell _rsgroup_ methods/commands to create and manipulate
3431 RegionServer groups: e.g. to add a rsgroup and then add a server to it.
3432 To see the list of rsgroup commands available in the hbase shell type:
3434 [source, bash]
3435 ----
3436  hbase(main):008:0> help 'rsgroup'
3437  Took 0.5610 seconds
3438 ----
3440 High level, you create a rsgroup that is other than the `default` group using
3441 _add_rsgroup_ command. You then add servers and tables to this group with the
3442 _move_servers_rsgroup_ and _move_tables_rsgroup_ commands. If necessary, run
3443 a balance for the group if tables are slow to migrate to the groups dedicated
3444 server with the _balance_rsgroup_ command (Usually this is not needed). To
3445 monitor effect of the commands, see the `Tables` tab toward the end of the
3446 Master UI home page. If you click on a table, you can see what servers it is
3447 deployed across. You should see here a reflection of the grouping done with
3448 your shell commands. View the master log if issues.
3450 Here is example using a few of the rsgroup commands. To add a group, do as
3451 follows:
3453 [source, bash]
3454 ----
3455  hbase(main):008:0> add_rsgroup 'my_group'
3456  Took 0.5610 seconds
3457 ----
3460 .RegionServer Groups must be Enabled
3461 [NOTE]
3462 ====
3463 If you have not enabled the rsgroup feature and you call any of the rsgroup
3464 admin methods or shell commands the call will fail with a
3465 `DoNotRetryIOException` with a detail message that says the rsgroup feature
3466 is disabled.
3467 ====
3469 Add a server (specified by hostname + port) to the just-made group using the
3470 _move_servers_rsgroup_ command as follows:
3472 [source, bash]
3473 ----
3474  hbase(main):010:0> move_servers_rsgroup 'my_group',['k.att.net:51129']
3475 ----
3477 .Hostname and Port vs ServerName
3478 [NOTE]
3479 ====
3480 The rsgroup feature refers to servers in a cluster with hostname and port only.
3481 It does not make use of the HBase ServerName type identifying RegionServers;
3482 i.e. hostname + port + starttime to distinguish RegionServer instances. The
3483 rsgroup feature keeps working across RegionServer restarts so the starttime of
3484 ServerName -- and hence the ServerName type -- is not appropriate.
3485 Administration
3486 ====
3488 Servers come and go over the lifetime of a Cluster. Currently, you must
3489 manually align the servers referenced in rsgroups with the actual state of
3490 nodes in the running cluster. What we mean by this is that if you decommission
3491 a server, then you must update rsgroups as part of your server decommission
3492 process removing references. Notice that, by calling `clearDeadServers`
3493 manually will also remove the dead servers from any rsgroups, but the problem
3494 is that we will lost track of the dead servers after master restarts, which
3495 means you still need to update the rsgroup by your own.
3497 Please use `Admin.removeServersFromRSGroup` or shell command
3498 _remove_servers_rsgroup_ to remove decommission servers from rsgroup.
3500 The `default` group is not like other rsgroups in that it is dynamic. Its server
3501 list mirrors the current state of the cluster; i.e. if you shutdown a server that
3502 was part of the `default` rsgroup, and then do a _get_rsgroup_ `default` to list
3503 its content in the shell, the server will no longer be listed. For non-default
3504 groups, though a mode may be offline, it will persist in the non-default group’s
3505 list of servers. But if you move the offline server from the non-default rsgroup
3506 to default, it will not show in the `default` list. It will just be dropped.
3508 === Best Practice
3509 The authors of the rsgroup feature, the Yahoo! HBase Engineering team, have been
3510 running it on their grid for a good while now and have come up with a few best
3511 practices informed by their experience.
3513 ==== Isolate System Tables
3514 Either have a system rsgroup where all the system tables are or just leave the
3515 system tables in `default` rsgroup and have all user-space tables are in
3516 non-default rsgroups.
3518 ==== Dead Nodes
3519 Yahoo! Have found it useful at their scale to keep a special rsgroup of dead or
3520 questionable nodes; this is one means of keeping them out of the running until repair.
3522 Be careful replacing dead nodes in an rsgroup. Ensure there are enough live nodes
3523 before you start moving out the dead. Move in good live nodes first if you have to.
3525 === Troubleshooting
3526 Viewing the Master log will give you insight on rsgroup operation.
3528 If it appears stuck, restart the Master process.
3530 === Remove RegionServer Grouping
3531 Simply disable RegionServer Grouping feature is easy, just remove the
3532 'hbase.balancer.rsgroup.enabled' from hbase-site.xml or explicitly set it to
3533 false in hbase-site.xml.
3535 [source,xml]
3536 ----
3537  <property>
3538    <name>hbase.balancer.rsgroup.enabled</name>
3539    <value>false</value>
3540  </property>
3541 ----
3543 But if you change the 'hbase.balancer.rsgroup.enabled' to true, the old rsgroup
3544 configs will take effect again. So if you want to completely remove the
3545 RegionServer Grouping feature from a cluster, so that if the feature is
3546 re-enabled in the future, the old meta data will not affect the functioning of
3547 the cluster, there are more steps to do.
3549 - Move all tables in non-default rsgroups to `default` regionserver group
3550 [source,bash]
3551 ----
3552 #Reassigning table t1 from non default group - hbase shell
3553 hbase(main):005:0> move_tables_rsgroup 'default',['t1']
3554 ----
3555 - Move all regionservers in non-default rsgroups to `default` regionserver group    
3556 [source, bash]
3557 ----
3558 #Reassigning all the servers in the non-default rsgroup to default - hbase shell
3559 hbase(main):008:0> move_servers_rsgroup 'default',['rs1.xxx.com:16206','rs2.xxx.com:16202','rs3.xxx.com:16204']
3560 ----
3561 - Remove all non-default rsgroups. `default` rsgroup created implicitly doesn't have to be removed
3562 [source,bash]
3563 ----
3564 #removing non default rsgroup - hbase shell
3565 hbase(main):009:0> remove_rsgroup 'group2'
3566 ----
3567 - Remove the changes made in `hbase-site.xml` and restart the cluster
3568 - Drop the table `hbase:rsgroup` from `hbase`
3569 [source, bash]
3570 ----
3571 #Through hbase shell drop table hbase:rsgroup
3572 hbase(main):001:0> disable 'hbase:rsgroup'
3573 0 row(s) in 2.6270 seconds
3575 hbase(main):002:0> drop 'hbase:rsgroup'
3576 0 row(s) in 1.2730 seconds
3577 ----
3578 - Remove znode `rsgroup` from the cluster ZooKeeper using zkCli.sh
3579 [source, bash]
3580 ----
3581 #From ZK remove the node /hbase/rsgroup through zkCli.sh
3582 rmr /hbase/rsgroup
3583 ----
3585 === ACL
3586 To enable ACL, add the following to your hbase-site.xml and restart your Master:
3588 [source,xml]
3589 ----
3590 <property>
3591   <name>hbase.security.authorization</name>
3592   <value>true</value>
3593 <property>
3594 ----
3595 [[migrating.rsgroup]]
3596 === Migrating From Old Implementation
3597 The coprocessor `org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint` is
3598 deprected, but for compatible, if you want the pre 3.0.0 hbase client/shell
3599 to communicate with the new hbase cluster, you still need to add this
3600 coprocessor to master.
3602 The `hbase.rsgroup.grouploadbalancer.class` config has been deprecated, as now
3603 the top level load balancer will always be `RSGroupBasedLoadBalaner`, and the
3604 `hbase.master.loadbalancer.class` config is for configuring the balancer within
3605 a group. This also means you should not set `hbase.master.loadbalancer.class`
3606 to `RSGroupBasedLoadBalaner` any more even if rsgroup feature is enabled.
3608 And we have done some special changes for compatibility. First, if coprocessor
3609 `org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint` is specified, the
3610 `hbase.balancer.rsgroup.enabled` flag will be set to true automatically to
3611 enable rs group feature. Second, we will load
3612 `hbase.rsgroup.grouploadbalancer.class` prior to
3613 `hbase.master.loadbalancer.class`. And last, if you do not set
3614 `hbase.rsgroup.grouploadbalancer.class` but only set
3615 `hbase.master.loadbalancer.class` to `RSGroupBasedLoadBalancer`, we will load
3616 the default load balancer to avoid infinite nesting. This means you do not need
3617 to change anything when upgrading if you have already enabled rs group feature.
3619 The main difference comparing to the old implementation is that, now the
3620 rsgroup for a table is stored in `TableDescriptor`, instead of in
3621 `RSGroupInfo`, so the `getTables` method of `RSGroupInfo` has been deprecated.
3622 And if you use the `Admin` methods to get the `RSGroupInfo`, its `getTables`
3623 method will always return empty. This is because that in the old
3624 implementation, this method is a bit broken as you can set rsgroup on namespace
3625 and make all the tables under this namespace into this group but you can not
3626 get these tables through `RSGroupInfo.getTables`. Now you should use the two
3627 new methods `listTablesInRSGroup` and
3628 `getConfiguredNamespacesAndTablesInRSGroup` in `Admin` to get tables and
3629 namespaces in a rsgroup.
3631 Of course the behavior for the old RSGroupAdminEndpoint is not changed,
3632 we will fill the tables field of the RSGroupInfo before returning, to make it
3633 compatible with old hbase client/shell.
3635 When upgrading, the migration between the RSGroupInfo and TableDescriptor will
3636 be done automatically. It will take sometime, but it is fine to restart master
3637 in the middle, the migration will continue after restart. And during the
3638 migration, the rs group feature will still work and in most cases the region
3639 will not be misplaced(since this is only a one time job and will not last too
3640 long so we have not test it very seriously to make sure the region will not be
3641 misplaced always, so we use the word 'in most cases'). The implementation is a
3642 bit tricky, you can see the code in `RSGroupInfoManagerImpl.migrate` if
3643 interested.
3648 [[normalizer]]
3649 == Region Normalizer
3651 The Region Normalizer tries to make Regions all in a table about the same in size.
3652 It does this by finding a rough average. Any region that is larger than twice this
3653 size is split. Any region that is much smaller is merged into an adjacent region.
3654 It is good to run the Normalizer on occasion on a down time after the cluster has
3655 been running a while or say after a burst of activity such as a large delete.
3657 (The bulk of the below detail was copied wholesale from the blog by Romil Choksi at
3658 link:https://community.hortonworks.com/articles/54987/hbase-region-normalizer.html[HBase Region Normalizer])
3660 The Region Normalizer is feature available since HBase-1.2. It runs a set of
3661 pre-calculated merge/split actions to resize regions that are either too
3662 large or too small compared to the average region size for a given table. Region
3663 Normalizer when invoked computes a normalization 'plan' for all of the tables in
3664 HBase. System tables (such as hbase:meta, hbase:namespace, Phoenix system tables
3665 etc) and user tables with normalization disabled are ignored while computing the
3666 plan. For normalization enabled tables, normalization plan is carried out in
3667 parallel across multiple tables.
3669 Normalizer can be enabled or disabled globally for the entire cluster using the
3670 ‘normalizer_switch’ command in the HBase shell. Normalization can also be
3671 controlled on a per table basis, which is disabled by default when a table is
3672 created. Normalization for a table can be enabled or disabled by setting the
3673 NORMALIZATION_ENABLED table attribute to true or false.
3675 To check normalizer status and enable/disable normalizer
3677 [source,bash]
3678 ----
3679 hbase(main):001:0> normalizer_enabled
3680 true 
3681 0 row(s) in 0.4870 seconds
3683 hbase(main):002:0> normalizer_switch false
3684 true 
3685 0 row(s) in 0.0640 seconds
3687 hbase(main):003:0> normalizer_enabled
3688 false 
3689 0 row(s) in 0.0120 seconds
3691 hbase(main):004:0> normalizer_switch true
3692 false
3693 0 row(s) in 0.0200 seconds
3695 hbase(main):005:0> normalizer_enabled
3696 true
3697 0 row(s) in 0.0090 seconds
3698 ----
3700 When enabled, Normalizer is invoked in the background every 5 mins (by default),
3701 which can be configured using `hbase.normalization.period` in `hbase-site.xml`.
3702 Normalizer can also be invoked manually/programmatically at will using HBase shell’s
3703 `normalize` command. HBase by default uses `SimpleRegionNormalizer`, but users can
3704 design their own normalizer as long as they implement the RegionNormalizer Interface.
3705 Details about the logic used by `SimpleRegionNormalizer` to compute its normalization
3706 plan can be found link:https://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html[here].
3708 The below example shows a normalization plan being computed for an user table, and
3709 merge action being taken as a result of the normalization plan computed by SimpleRegionNormalizer.
3711 Consider an user table with some pre-split regions having 3 equally large regions
3712 (about 100K rows) and 1 relatively small region (about 25K rows). Following is the
3713 snippet from an hbase meta table scan showing each of the pre-split regions for 
3714 the user table.
3716 ----
3717 table_p8ddpd6q5z,,1469494305548.68b9892220865cb6048 column=info:regioninfo, timestamp=1469494306375, value={ENCODED => 68b9892220865cb604809c950d1adf48, NAME => 'table_p8ddpd6q5z,,1469494305548.68b989222 09c950d1adf48.   0865cb604809c950d1adf48.', STARTKEY => '', ENDKEY => '1'} 
3718 .... 
3719 table_p8ddpd6q5z,1,1469494317178.867b77333bdc75a028 column=info:regioninfo, timestamp=1469494317848, value={ENCODED => 867b77333bdc75a028bb4c5e4b235f48, NAME => 'table_p8ddpd6q5z,1,1469494317178.867b7733 bb4c5e4b235f48.  3bdc75a028bb4c5e4b235f48.', STARTKEY => '1', ENDKEY => '3'} 
3720 .... 
3721 table_p8ddpd6q5z,3,1469494328323.98f019a753425e7977 column=info:regioninfo, timestamp=1469494328486, value={ENCODED => 98f019a753425e7977ab8636e32deeeb, NAME => 'table_p8ddpd6q5z,3,1469494328323.98f019a7 ab8636e32deeeb.  53425e7977ab8636e32deeeb.', STARTKEY => '3', ENDKEY => '7'} 
3722 .... 
3723 table_p8ddpd6q5z,7,1469494339662.94c64e748979ecbb16 column=info:regioninfo, timestamp=1469494339859, value={ENCODED => 94c64e748979ecbb166f6cc6550e25c6, NAME => 'table_p8ddpd6q5z,7,1469494339662.94c64e74 6f6cc6550e25c6.   8979ecbb166f6cc6550e25c6.', STARTKEY => '7', ENDKEY => '8'} 
3724 .... 
3725 table_p8ddpd6q5z,8,1469494339662.6d2b3f5fd1595ab8e7 column=info:regioninfo, timestamp=1469494339859, value={ENCODED => 6d2b3f5fd1595ab8e7c031876057b1ee, NAME => 'table_p8ddpd6q5z,8,1469494339662.6d2b3f5f c031876057b1ee.   d1595ab8e7c031876057b1ee.', STARTKEY => '8', ENDKEY => ''}  
3726 ----
3727 Invoking the normalizer using ‘normalize’ int the HBase shell, the below log snippet
3728 from HMaster log shows the normalization plan computed as per the logic defined for
3729 SimpleRegionNormalizer. Since the total region size (in MB) for the adjacent smallest
3730 regions in the table is less than the average region size, the normalizer computes a
3731 plan to merge these two regions.
3733 ----
3734 2016-07-26 07:08:26,928 DEBUG [B.fifo.QRpcServer.handler=20,queue=2,port=20000] master.HMaster: Skipping normalization for table: hbase:namespace, as it's either system table or doesn't have auto
3735 normalization turned on
3736 2016-07-26 07:08:26,928 DEBUG [B.fifo.QRpcServer.handler=20,queue=2,port=20000] master.HMaster: Skipping normalization for table: hbase:backup, as it's either system table or doesn't have auto normalization turned on
3737 2016-07-26 07:08:26,928 DEBUG [B.fifo.QRpcServer.handler=20,queue=2,port=20000] master.HMaster: Skipping normalization for table: hbase:meta, as it's either system table or doesn't have auto normalization turned on
3738 2016-07-26 07:08:26,928 DEBUG [B.fifo.QRpcServer.handler=20,queue=2,port=20000] master.HMaster: Skipping normalization for table: table_h2osxu3wat, as it's either system table or doesn't have autonormalization turned on
3739 2016-07-26 07:08:26,928 DEBUG [B.fifo.QRpcServer.handler=20,queue=2,port=20000] normalizer.SimpleRegionNormalizer: Computing normalization plan for table: table_p8ddpd6q5z, number of regions: 5
3740 2016-07-26 07:08:26,929 DEBUG [B.fifo.QRpcServer.handler=20,queue=2,port=20000] normalizer.SimpleRegionNormalizer: Table table_p8ddpd6q5z, total aggregated regions size: 12
3741 2016-07-26 07:08:26,929 DEBUG [B.fifo.QRpcServer.handler=20,queue=2,port=20000] normalizer.SimpleRegionNormalizer: Table table_p8ddpd6q5z, average region size: 2.4
3742 2016-07-26 07:08:26,929 INFO  [B.fifo.QRpcServer.handler=20,queue=2,port=20000] normalizer.SimpleRegionNormalizer: Table table_p8ddpd6q5z, small region size: 0 plus its neighbor size: 0, less thanthe avg size 2.4, merging them
3743 2016-07-26 07:08:26,971 INFO  [B.fifo.QRpcServer.handler=20,queue=2,port=20000] normalizer.MergeNormalizationPlan: Executing merging normalization plan: MergeNormalizationPlan{firstRegion={ENCODED=> d51df2c58e9b525206b1325fd925a971, NAME => 'table_p8ddpd6q5z,,1469514755237.d51df2c58e9b525206b1325fd925a971.', STARTKEY => '', ENDKEY => '1'}, secondRegion={ENCODED => e69c6b25c7b9562d078d9ad3994f5330, NAME => 'table_p8ddpd6q5z,1,1469514767669.e69c6b25c7b9562d078d9ad3994f5330.',
3744 STARTKEY => '1', ENDKEY => '3'}}
3745 ----
3746 Region normalizer as per it’s computed plan, merged the region with start key as ‘’
3747 and end key as ‘1’, with another region having start key as ‘1’ and end key as ‘3’.
3748 Now, that these regions have been merged we see a single new region with start key
3749 as ‘’ and end key as ‘3’
3750 ----
3751 table_p8ddpd6q5z,,1469516907210.e06c9b83c4a252b130e column=info:mergeA, timestamp=1469516907431, 
3752 value=PBUF\x08\xA5\xD9\x9E\xAF\xE2*\x12\x1B\x0A\x07default\x12\x10table_p8ddpd6q5z\x1A\x00"\x011(\x000\x00 ea74d246741ba.   8\x00 
3753 table_p8ddpd6q5z,,1469516907210.e06c9b83c4a252b130e column=info:mergeB, timestamp=1469516907431,
3754 value=PBUF\x08\xB5\xBA\x9F\xAF\xE2*\x12\x1B\x0A\x07default\x12\x10table_p8ddpd6q5z\x1A\x011"\x013(\x000\x0 ea74d246741ba.   08\x00 
3755 table_p8ddpd6q5z,,1469516907210.e06c9b83c4a252b130e column=info:regioninfo, timestamp=1469516907431, value={ENCODED => e06c9b83c4a252b130eea74d246741ba, NAME => 'table_p8ddpd6q5z,,1469516907210.e06c9b83c ea74d246741ba.   4a252b130eea74d246741ba.', STARTKEY => '', ENDKEY => '3'}
3756 .... 
3757 table_p8ddpd6q5z,3,1469514778736.bf024670a847c0adff column=info:regioninfo, timestamp=1469514779417, value={ENCODED => bf024670a847c0adffb74b2e13408b32, NAME => 'table_p8ddpd6q5z,3,1469514778736.bf024670 b74b2e13408b32.  a847c0adffb74b2e13408b32.' STARTKEY => '3', ENDKEY => '7'} 
3758 .... 
3759 table_p8ddpd6q5z,7,1469514790152.7c5a67bc755e649db2 column=info:regioninfo, timestamp=1469514790312, value={ENCODED => 7c5a67bc755e649db22f49af6270f1e1, NAME => 'table_p8ddpd6q5z,7,1469514790152.7c5a67bc 2f49af6270f1e1.  755e649db22f49af6270f1e1.', STARTKEY => '7', ENDKEY => '8'} 
3760 ....
3761 table_p8ddpd6q5z,8,1469514790152.58e7503cda69f98f47 column=info:regioninfo, timestamp=1469514790312, value={ENCODED => 58e7503cda69f98f4755178e74288c3a, NAME => 'table_p8ddpd6q5z,8,1469514790152.58e7503c 55178e74288c3a.  da69f98f4755178e74288c3a.', STARTKEY => '8', ENDKEY => ''}
3762 ----
3764 A similar example can be seen for an user table with 3 smaller regions and 1
3765 relatively large region. For this example, we have an user table with 1 large region containing 100K rows, and 3 relatively smaller regions with about 33K rows each. As seen from the normalization plan, since the larger region is more than twice the average region size it ends being split into two regions – one with start key as ‘1’ and end key as ‘154717’ and the other region with start key as '154717' and end key as ‘3’
3766 ----
3767 2016-07-26 07:39:45,636 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] master.HMaster: Skipping normalization for table: hbase:backup, as it's either system table or doesn't have auto normalization turned on
3768 2016-07-26 07:39:45,636 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] normalizer.SimpleRegionNormalizer: Computing normalization plan for table: table_p8ddpd6q5z, number of regions: 4
3769 2016-07-26 07:39:45,636 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] normalizer.SimpleRegionNormalizer: Table table_p8ddpd6q5z, total aggregated regions size: 12
3770 2016-07-26 07:39:45,636 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] normalizer.SimpleRegionNormalizer: Table table_p8ddpd6q5z, average region size: 3.0
3771 2016-07-26 07:39:45,636 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] normalizer.SimpleRegionNormalizer: No normalization needed, regions look good for table: table_p8ddpd6q5z
3772 2016-07-26 07:39:45,636 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] normalizer.SimpleRegionNormalizer: Computing normalization plan for table: table_h2osxu3wat, number of regions: 5
3773 2016-07-26 07:39:45,636 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] normalizer.SimpleRegionNormalizer: Table table_h2osxu3wat, total aggregated regions size: 7
3774 2016-07-26 07:39:45,636 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] normalizer.SimpleRegionNormalizer: Table table_h2osxu3wat, average region size: 1.4
3775 2016-07-26 07:39:45,636 INFO  [B.fifo.QRpcServer.handler=7,queue=1,port=20000] normalizer.SimpleRegionNormalizer: Table table_h2osxu3wat, large region table_h2osxu3wat,1,1469515926544.27f2fdbb2b6612ea163eb6b40753c3db. has size 4, more than twice avg size, splitting
3776 2016-07-26 07:39:45,640 INFO [B.fifo.QRpcServer.handler=7,queue=1,port=20000] normalizer.SplitNormalizationPlan: Executing splitting normalization plan: SplitNormalizationPlan{regionInfo={ENCODED => 27f2fdbb2b6612ea163eb6b40753c3db, NAME => 'table_h2osxu3wat,1,1469515926544.27f2fdbb2b6612ea163eb6b40753c3db.', STARTKEY => '1', ENDKEY => '3'}, splitPoint=null}
3777 2016-07-26 07:39:45,656 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] master.HMaster: Skipping normalization for table: hbase:namespace, as it's either system table or doesn't have auto normalization turned on
3778 2016-07-26 07:39:45,656 DEBUG [B.fifo.QRpcServer.handler=7,queue=1,port=20000] master.HMaster: Skipping normalization for table: hbase:meta, as it's either system table or doesn't
3779 have auto normalization turned on …..…..….
3780 2016-07-26 07:39:46,246 DEBUG [AM.ZK.Worker-pool2-t278] master.RegionStates: Onlined 54de97dae764b864504704c1c8d3674a on hbase-test-rc-5.openstacklocal,16020,1469419333913 {ENCODED => 54de97dae764b864504704c1c8d3674a, NAME => 'table_h2osxu3wat,1,1469518785661.54de97dae764b864504704c1c8d3674a.', STARTKEY => '1', ENDKEY => '154717'}
3781 2016-07-26 07:39:46,246 INFO  [AM.ZK.Worker-pool2-t278] master.RegionStates: Transition {d6b5625df331cfec84dce4f1122c567f state=SPLITTING_NEW, ts=1469518786246, server=hbase-test-rc-5.openstacklocal,16020,1469419333913} to {d6b5625df331cfec84dce4f1122c567f state=OPEN, ts=1469518786246,
3782 server=hbase-test-rc-5.openstacklocal,16020,1469419333913}
3783 2016-07-26 07:39:46,246 DEBUG [AM.ZK.Worker-pool2-t278] master.RegionStates: Onlined d6b5625df331cfec84dce4f1122c567f on hbase-test-rc-5.openstacklocal,16020,1469419333913 {ENCODED => d6b5625df331cfec84dce4f1122c567f, NAME => 'table_h2osxu3wat,154717,1469518785661.d6b5625df331cfec84dce4f1122c567f.', STARTKEY => '154717', ENDKEY => '3'}
3784 ----
3788 [[auto_reopen_regions]]
3789 == Auto Region Reopen
3791 We can leak store reader references if a coprocessor or core function somehow
3792 opens a scanner, or wraps one, and then does not take care to call close on the
3793 scanner or the wrapped instance. Leaked store files can not be removed even
3794 after it is invalidated via compaction.
3795 A reasonable mitigation for a reader reference
3796 leak would be a fast reopen of the region on the same server.
3797 This will release all resources, like the refcount, leases, etc.
3798 The clients should gracefully ride over this like any other region in
3799 transition.
3800 By default this auto reopen of region feature would be disabled.
3801 To enabled it, please provide high ref count value for config
3802 `hbase.regions.recovery.store.file.ref.count`.
3804 Please refer to config descriptions for
3805 `hbase.master.regions.recovery.check.interval` and
3806 `hbase.regions.recovery.store.file.ref.count`.