From 63e8304e96c06463e3385afc075e90d18a5bdf1e Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Wed, 28 May 2014 07:58:50 -0700 Subject: [PATCH] HBASE-11199 One-time effort to pretty-print the Docbook XML, to make further patch review easier (Misty Stanley-Jones) --- src/main/docbkx/book.xml | 1373 +++++++++++------ src/main/docbkx/case_studies.xml | 262 ++-- src/main/docbkx/community.xml | 265 ++-- src/main/docbkx/configuration.xml | 2186 ++++++++++++++------------- src/main/docbkx/cp.xml | 26 +- src/main/docbkx/developer.xml | 822 +++++----- src/main/docbkx/external_apis.xml | 20 +- src/main/docbkx/getting_started.xml | 332 ++-- src/main/docbkx/ops_mgt.xml | 789 ++++++---- src/main/docbkx/performance.xml | 1334 ++++++++-------- src/main/docbkx/preface.xml | 94 +- src/main/docbkx/rpc.xml | 476 +++--- src/main/docbkx/schema_design.xml | 1775 ++++++++++++---------- src/main/docbkx/security.xml | 1918 ++++++++++++----------- src/main/docbkx/shell.xml | 242 ++- src/main/docbkx/tracing.xml | 307 ++-- src/main/docbkx/troubleshooting.xml | 1453 ++++++++++-------- src/main/docbkx/upgrading.xml | 803 +++++----- src/main/docbkx/zookeeper.xml | 854 +++++------ 19 files changed, 8289 insertions(+), 7042 deletions(-) diff --git a/src/main/docbkx/book.xml b/src/main/docbkx/book.xml index 1fca2be7985..2ac9de3ceb2 100644 --- a/src/main/docbkx/book.xml +++ b/src/main/docbkx/book.xml @@ -19,38 +19,45 @@ * limitations under the License. */ --> - + - <link xlink:href="http://www.hbase.org"> - The Apache HBase™ Reference Guide - </link> - - - - - - - + <link + xlink:href="http://www.hbase.org"> The Apache HBase™ Reference Guide </link> + + + + + + + - 2014Apache Software Foundation. - All Rights Reserved. Apache Hadoop, Hadoop, MapReduce, HDFS, Zookeeper, HBase, and the HBase project logo are trademarks of the Apache Software Foundation. - + + 2014 + Apache Software Foundation. All Rights Reserved. Apache Hadoop, Hadoop, MapReduce, + HDFS, Zookeeper, HBase, and the HBase project logo are trademarks of the Apache Software + Foundation. - - This is the official reference guide of - Apache HBase™, - a distributed, versioned, big data store built on top of - Apache Hadoop™ and - Apache ZooKeeper™. - - + + This is the official reference guide of Apache HBase™, a distributed, versioned, big + data store built on top of Apache Hadoop™ and Apache ZooKeeper™. + @@ -65,151 +72,241 @@ - - - - - + + + + + - + Data Model - In short, applications store data into an HBase table. - Tables are made of rows and columns. - All columns in HBase belong to a particular column family. - Table cells -- the intersection of row and column - coordinates -- are versioned. - A cell’s content is an uninterpreted array of bytes. - - Table row keys are also byte arrays so almost anything can - serve as a row key from strings to binary representations of longs or - even serialized data structures. Rows in HBase tables - are sorted by row key. The sort is byte-ordered. All table accesses are - via the table row key -- its primary key. - + In short, applications store data into an HBase table. Tables are made of rows and + columns. All columns in HBase belong to a particular column family. Table cells -- the + intersection of row and column coordinates -- are versioned. A cell’s content is an + uninterpreted array of bytes. + Table row keys are also byte arrays so almost anything can serve as a row key from strings + to binary representations of longs or even serialized data structures. Rows in HBase tables + are sorted by row key. The sort is byte-ordered. All table accesses are via the table row key + -- its primary key. -
Conceptual View - - The following example is a slightly modified form of the one on page - 2 of the BigTable paper. - There is a table called webtable that contains two column families named - contents and anchor. - In this example, anchor contains two - columns (anchor:cssnsi.com, anchor:my.look.ca) - and contents contains one column (contents:html). - - Column Names - - By convention, a column name is made of its column family prefix and a - qualifier. For example, the - column - contents:html is made up of the column family contents - and html qualifier. - The colon character (:) delimits the column family from the - column family qualifier. - - - Table <varname>webtable</varname> - - - - - - - Row KeyTime StampColumnFamily contentsColumnFamily anchor - - - "com.cnn.www"t9anchor:cnnsi.com = "CNN" - "com.cnn.www"t8anchor:my.look.ca = "CNN.com" - "com.cnn.www"t6contents:html = "<html>..." - "com.cnn.www"t5contents:html = "<html>..." - "com.cnn.www"t3contents:html = "<html>..." - - -
-
-
-
Physical View - - Although at a conceptual level tables may be viewed as a sparse set of rows. - Physically they are stored on a per-column family basis. New columns - (i.e., columnfamily:column) can be added to any - column family without pre-announcing them. - ColumnFamily <varname>anchor</varname> - - - - - - Row KeyTime StampColumn Family anchor - - - "com.cnn.www"t9anchor:cnnsi.com = "CNN" - "com.cnn.www"t8anchor:my.look.ca = "CNN.com" - - -
- ColumnFamily <varname>contents</varname> - - - - - - Row KeyTime StampColumnFamily "contents:" - - - "com.cnn.www"t6contents:html = "<html>..." - "com.cnn.www"t5contents:html = "<html>..." - "com.cnn.www"t3contents:html = "<html>..." - - -
- It is important to note in the diagram above that the empty cells shown in the - conceptual view are not stored since they need not be in a column-oriented - storage format. Thus a request for the value of the contents:html - column at time stamp t8 would return no value. Similarly, a - request for an anchor:my.look.ca value at time stamp - t9 would return no value. However, if no timestamp is - supplied, the most recent value for a particular column would be returned - and would also be the first one found since timestamps are stored in - descending order. Thus a request for the values of all columns in the row - com.cnn.www if no timestamp is specified would be: - the value of contents:html from time stamp - t6, the value of anchor:cnnsi.com - from time stamp t9, the value of - anchor:my.look.ca from time stamp t8. -
- For more information about the internals of how Apache HBase stores data, see . - -
+
+ Conceptual View + The following example is a slightly modified form of the one on page 2 of the BigTable paper. There + is a table called webtable that contains two column families named + contents and anchor. In this example, + anchor contains two columns (anchor:cssnsi.com, + anchor:my.look.ca) and contents contains one column + (contents:html). + Column Names + By convention, a column name is made of its column family prefix and a + qualifier. For example, the column + contents:html is made up of the column family + contents and html qualifier. The colon character + (:) delimits the column family from the column family + qualifier. + + + Table <varname>webtable</varname> + + + + + + + + Row Key + Time Stamp + ColumnFamily contents + ColumnFamily anchor + + + + + "com.cnn.www" + t9 + + anchor:cnnsi.com = "CNN" + + + "com.cnn.www" + t8 + + anchor:my.look.ca = "CNN.com" + + + "com.cnn.www" + t6 + contents:html = "<html>..." + + + + "com.cnn.www" + t5 + contents:html = "<html>..." + + + + "com.cnn.www" + t3 + contents:html = "<html>..." + + + + +
+
+
+
+ Physical View + Although at a conceptual level tables may be viewed as a sparse set of rows. Physically + they are stored on a per-column family basis. New columns (i.e., + columnfamily:column) can be added to any column family without + pre-announcing them. + ColumnFamily <varname>anchor</varname> + + + + + + + Row Key + Time Stamp + Column Family anchor + + + + + "com.cnn.www" + t9 + anchor:cnnsi.com = "CNN" + + + "com.cnn.www" + t8 + anchor:my.look.ca = "CNN.com" + + + +
+ + ColumnFamily <varname>contents</varname> + + + + + + + Row Key + Time Stamp + ColumnFamily "contents:" + + + + + "com.cnn.www" + t6 + contents:html = "<html>..." + + + "com.cnn.www" + t5 + contents:html = "<html>..." + + + "com.cnn.www" + t3 + contents:html = "<html>..." + + + +
It is important to note in the diagram above that the empty cells shown in the + conceptual view are not stored since they need not be in a column-oriented storage format. + Thus a request for the value of the contents:html column at time stamp + t8 would return no value. Similarly, a request for an + anchor:my.look.ca value at time stamp t9 would + return no value. However, if no timestamp is supplied, the most recent value for a + particular column would be returned and would also be the first one found since timestamps + are stored in descending order. Thus a request for the values of all columns in the row + com.cnn.www if no timestamp is specified would be: the value of + contents:html from time stamp t6, the value of + anchor:cnnsi.com from time stamp t9, the value of + anchor:my.look.ca from time stamp t8.
+ For more information about the internals of how Apache HBase stores data, see . +
-
+
Namespace - - A namespace is a logical grouping of tables analogous to a database in relation database - systems. This abstraction lays the groundwork for upcoming multi-tenancy related features: - - Quota Management (HBASE-8410) - Restrict the amount of resources (ie - regions, tables) a namespace can consume. - Namespace Security Administration (HBASE-9206) - provide another - level of security administration for tenants. - Region server groups (HBASE-6721) - A namespace/table can be - pinned onto a subset of regionservers thus guaranteeing a course level of - isolation. + A namespace is a logical grouping of tables analogous to a database in relation + database systems. This abstraction lays the groundwork for upcoming multi-tenancy related + features: + + Quota Management (HBASE-8410) - Restrict the amount of resources (ie regions, + tables) a namespace can consume. + + + Namespace Security Administration (HBASE-9206) - provide another level of security + administration for tenants. + + + Region server groups (HBASE-6721) - A namespace/table can be pinned onto a subset + of regionservers thus guaranteeing a course level of isolation. + -
+
Namespace management - - A namespace can be created, removed or altered. Namespace membership is determined during - table creation by specifying a fully-qualified table name of the form: - - <table namespace>:<table qualifier> - + A namespace can be created, removed or altered. Namespace membership is determined + during table creation by specifying a fully-qualified table name of the form: + + :]]> + Examples - + #Create a namespace create_namespace 'my_ns' @@ -227,20 +324,23 @@ alter_namespace 'my_ns', {METHOD => 'set', 'PROPERTY_NAME' => 'PROPERTY_VALUE'} -
+
Predefined namespaces - - There are two predefined special namespaces: - - hbase - system namespace, used to contain hbase internal tables - default - tables with no explicit specified namespace will automatically - fall into this namespace. - - - - Examples + There are two predefined special namespaces: + + + hbase - system namespace, used to contain hbase internal tables + + + default - tables with no explicit specified namespace will automatically fall into + this namespace. + + + + Examples - + #namespace=foo and table qualifier=bar create 'foo:bar', 'fam' @@ -251,85 +351,85 @@ create 'bar', 'fam'
-
+
Table - - Tables are declared up front at schema definition time. - + Tables are declared up front at schema definition time.
-
+
Row - Row keys are uninterrpreted bytes. Rows are - lexicographically sorted with the lowest order appearing first - in a table. The empty byte array is used to denote both the - start and end of a tables' namespace. + Row keys are uninterrpreted bytes. Rows are lexicographically sorted with the lowest + order appearing first in a table. The empty byte array is used to denote both the start and + end of a tables' namespace.
-
+
Column Family<indexterm><primary>Column Family</primary></indexterm> - - Columns in Apache HBase are grouped into column families. - All column members of a column family have the same prefix. For example, the - columns courses:history and - courses:math are both members of the - courses column family. - The colon character (:) delimits the column family from the - column family qualifierColumn Family Qualifier. - The column family prefix must be composed of - printable characters. The qualifying tail, the - column family qualifier, can be made of any - arbitrary bytes. Column families must be declared up front - at schema definition time whereas columns do not need to be - defined at schema time but can be conjured on the fly while - the table is up an running. - Physically, all column family members are stored together on the - filesystem. Because tunings and - storage specifications are done at the column family level, it is - advised that all column family members have the same general access - pattern and size characteristics. + Columns in Apache HBase are grouped into column families. All + column members of a column family have the same prefix. For example, the columns + courses:history and courses:math are both + members of the courses column family. The colon character + (:) delimits the column family from the column + family qualifierColumn Family Qualifier. + The column family prefix must be composed of printable characters. The + qualifying tail, the column family qualifier, can be made of any + arbitrary bytes. Column families must be declared up front at schema definition time whereas + columns do not need to be defined at schema time but can be conjured on the fly while the + table is up an running. + Physically, all column family members are stored together on the filesystem. Because + tunings and storage specifications are done at the column family level, it is advised that + all column family members have the same general access pattern and size + characteristics. -
-
+
Cells<indexterm><primary>Cells</primary></indexterm> - A {row, column, version} tuple exactly - specifies a cell in HBase. - Cell content is uninterrpreted bytes + A {row, column, version} tuple exactly specifies a + cell in HBase. Cell content is uninterrpreted bytes
-
- Data Model Operations - The four primary data model operations are Get, Put, Scan, and Delete. Operations are applied via - HTable instances. - -
+
+ Data Model Operations + The four primary data model operations are Get, Put, Scan, and Delete. Operations are + applied via HTable + instances. +
Get - Get returns - attributes for a specified row. Gets are executed via - - HTable.get. - + Get + returns attributes for a specified row. Gets are executed via + HTable.get.
-
+
Put - Put either - adds new rows to a table (if the key is new) or can update existing rows (if the key already exists). Puts are executed via - - HTable.put (writeBuffer) or - HTable.batch (non-writeBuffer). - + Put + either adds new rows to a table (if the key is new) or can update existing rows (if the + key already exists). Puts are executed via + HTable.put (writeBuffer) or + HTable.batch (non-writeBuffer).
-
- Scans - Scan allow - iteration over multiple rows for specified attributes. - - The following is an example of a - on an HTable table instance. Assume that a table is populated with rows with keys "row1", "row2", "row3", - and then another set of rows with the keys "abc1", "abc2", and "abc3". The following example shows how startRow and stopRow - can be applied to a Scan instance to return the rows beginning with "row". - +
+ Scans + Scan + allow iteration over multiple rows for specified attributes. + The following is an example of a on an HTable table instance. Assume that a table is + populated with rows with keys "row1", "row2", "row3", and then another set of rows with + the keys "abc1", "abc2", and "abc3". The following example shows how startRow and stopRow + can be applied to a Scan instance to return the rows beginning with "row". + public static final byte[] CF = "cf".getBytes(); public static final byte[] ATTR = "attr".getBytes(); ... @@ -348,122 +448,121 @@ try { rs.close(); // always close the ResultScanner! } - - Note that generally the easiest way to specify a specific stop point for a scan is by using the InclusiveStopFilter class. - -
-
+ Note that generally the easiest way to specify a specific stop point for a scan is by + using the InclusiveStopFilter + class. +
+
Delete - Delete removes - a row from a table. Deletes are executed via - - HTable.delete. - - HBase does not modify data in place, and so deletes are handled by creating new markers called tombstones. - These tombstones, along with the dead values, are cleaned up on major compactions. - - See for more information on deleting versions of columns, and see - for more information on compactions. - + Delete + removes a row from a table. Deletes are executed via + HTable.delete. + HBase does not modify data in place, and so deletes are handled by creating new + markers called tombstones. These tombstones, along with the dead + values, are cleaned up on major compactions. + See for more information on deleting versions of columns, and + see for more information on compactions.
-
+
Versions<indexterm><primary>Versions</primary></indexterm> - A {row, column, version} tuple exactly - specifies a cell in HBase. It's possible to have an - unbounded number of cells where the row and column are the same but the - cell address differs only in its version dimension. + A {row, column, version} tuple exactly specifies a + cell in HBase. It's possible to have an unbounded number of cells where + the row and column are the same but the cell address differs only in its version + dimension. - While rows and column keys are expressed as bytes, the version is - specified using a long integer. Typically this long contains time - instances such as those returned by - java.util.Date.getTime() or - System.currentTimeMillis(), that is: the difference, - measured in milliseconds, between the current time and midnight, January - 1, 1970 UTC. + While rows and column keys are expressed as bytes, the version is specified using a long + integer. Typically this long contains time instances such as those returned by + java.util.Date.getTime() or System.currentTimeMillis(), that is: + the difference, measured in milliseconds, between the current time and midnight, + January 1, 1970 UTC. - The HBase version dimension is stored in decreasing order, so that - when reading from a store file, the most recent values are found - first. + The HBase version dimension is stored in decreasing order, so that when reading from a + store file, the most recent values are found first. - There is a lot of confusion over the semantics of - cell versions, in HBase. In particular, a couple - questions that often come up are: - - If multiple writes to a cell have the same version, are all - versions maintained or just the last? - Currently, only the last written is fetchable. - - + There is a lot of confusion over the semantics of cell versions, in + HBase. In particular, a couple questions that often come up are: + + + If multiple writes to a cell have the same version, are all versions maintained or + just the last? + Currently, only the last written is fetchable. + + - - Is it OK to write cells in a non-increasing version - order? - Yes - - - + + Is it OK to write cells in a non-increasing version order? + Yes + + + - Below we describe how the version dimension in HBase currently - works + Below we describe how the version dimension in HBase currently works See HBASE-2406 - for discussion of HBase versions. Bending time - in HBase makes for a good read on the version, or time, - dimension in HBase. It has more detail on versioning than is - provided here. As of this writing, the limiitation - Overwriting values at existing timestamps - mentioned in the article no longer holds in HBase. This section is - basically a synopsis of this article by Bruno Dumon. + xlink:href="https://issues.apache.org/jira/browse/HBASE-2406">HBASE-2406 for + discussion of HBase versions. Bending time in HBase + makes for a good read on the version, or time, dimension in HBase. It has more detail on + versioning than is provided here. As of this writing, the limiitation + Overwriting values at existing timestamps mentioned in the + article no longer holds in HBase. This section is basically a synopsis of this article + by Bruno Dumon. . -
+
Versions and HBase Operations - In this section we look at the behavior of the version dimension - for each of the core HBase operations. + In this section we look at the behavior of the version dimension for each of the core + HBase operations.
Get/Scan - Gets are implemented on top of Scans. The below discussion of - Get applies equally to Scans. + Gets are implemented on top of Scans. The below discussion of Get + applies equally to Scans. - By default, i.e. if you specify no explicit version, when - doing a get, the cell whose version has the - largest value is returned (which may or may not be the latest one - written, see later). The default behavior can be modified in the - following ways: + By default, i.e. if you specify no explicit version, when doing a + get, the cell whose version has the largest value is returned + (which may or may not be the latest one written, see later). The default behavior can be + modified in the following ways: to return more than one version, see Get.setMaxVersions() + xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Get.html#setMaxVersions()">Get.setMaxVersions() to return versions other than the latest, see Get.setTimeRange() + xlink:href="???">Get.setTimeRange() - To retrieve the latest version that is less than or equal - to a given value, thus giving the 'latest' state of the record - at a certain point in time, just use a range from 0 to the - desired version and set the max versions to 1. + To retrieve the latest version that is less than or equal to a given value, thus + giving the 'latest' state of the record at a certain point in time, just use a range + from 0 to the desired version and set the max versions to 1.
-
- Default Get Example - The following Get will only retrieve the current version of the row - +
+ Default Get Example + The following Get will only retrieve the current version of the row + public static final byte[] CF = "cf".getBytes(); public static final byte[] ATTR = "attr".getBytes(); ... @@ -471,12 +570,12 @@ Get get = new Get(Bytes.toBytes("row1")); Result r = htable.get(get); byte[] b = r.getValue(CF, ATTR); // returns current version of value -
-
- Versioned Get Example - The following Get will return the last 3 versions of the row. - +
+ Versioned Get Example + The following Get will return the last 3 versions of the row. + public static final byte[] CF = "cf".getBytes(); public static final byte[] ATTR = "attr".getBytes(); ... @@ -486,26 +585,25 @@ Result r = htable.get(get); byte[] b = r.getValue(CF, ATTR); // returns current version of value List<KeyValue> kv = r.getColumn(CF, ATTR); // returns all versions of this column -
Put - Doing a put always creates a new version of a - cell, at a certain timestamp. By default the - system uses the server's currentTimeMillis, but - you can specify the version (= the long integer) yourself, on a - per-column level. This means you could assign a time in the past or - the future, or use the long value for non-time purposes. + Doing a put always creates a new version of a cell, at a certain + timestamp. By default the system uses the server's currentTimeMillis, + but you can specify the version (= the long integer) yourself, on a per-column level. + This means you could assign a time in the past or the future, or use the long value for + non-time purposes. - To overwrite an existing value, do a put at exactly the same - row, column, and version as that of the cell you would - overshadow. -
- Implicit Version Example - The following Put will be implicitly versioned by HBase with the current time. - + To overwrite an existing value, do a put at exactly the same row, column, and + version as that of the cell you would overshadow. +
+ Implicit Version Example + The following Put will be implicitly versioned by HBase with the current + time. + public static final byte[] CF = "cf".getBytes(); public static final byte[] ATTR = "attr".getBytes(); ... @@ -513,12 +611,12 @@ Put put = new Put(Bytes.toBytes(row)); put.add(CF, ATTR, Bytes.toBytes( data)); htable.put(put); -
-
- Explicit Version Example - The following Put has the version timestamp explicitly set. - +
+ Explicit Version Example + The following Put has the version timestamp explicitly set. + public static final byte[] CF = "cf".getBytes(); public static final byte[] ATTR = "attr".getBytes(); ... @@ -527,62 +625,63 @@ long explicitTimeInMs = 555; // just an example put.add(CF, ATTR, explicitTimeInMs, Bytes.toBytes(data)); htable.put(put); - Caution: the version timestamp is internally by HBase for things like time-to-live calculations. - It's usually best to avoid setting this timestamp yourself. Prefer using a separate - timestamp attribute of the row, or have the timestamp a part of the rowkey, or both. - + Caution: the version timestamp is internally by HBase for things like time-to-live + calculations. It's usually best to avoid setting this timestamp yourself. Prefer using + a separate timestamp attribute of the row, or have the timestamp a part of the rowkey, + or both.
-
+
Delete - There are three different types of internal delete markers - See Lars Hofhansl's blog for discussion of his attempt - adding another, Scanning in HBase: Prefix Delete Marker: - - Delete: for a specific version of a column. + There are three different types of internal delete markers + See Lars Hofhansl's blog for discussion of his attempt adding another, Scanning + in HBase: Prefix Delete Marker + : + + + Delete: for a specific version of a column. - Delete column: for all versions of a column. + + Delete column: for all versions of a column. - Delete family: for all columns of a particular ColumnFamily + + Delete family: for all columns of a particular ColumnFamily - When deleting an entire row, HBase will internally create a tombstone for each ColumnFamily (i.e., not each individual column). - - Deletes work by creating tombstone - markers. For example, let's suppose we want to delete a row. For - this you can specify a version, or else by default the - currentTimeMillis is used. What this means is - delete all cells where the version is less than or equal to - this version. HBase never modifies data in place, so for - example a delete will not immediately delete (or mark as deleted) - the entries in the storage file that correspond to the delete - condition. Rather, a so-called tombstone is - written, which will mask the deleted values - When HBase does a major compaction, the tombstones are - processed to actually remove the dead values, together with the - tombstones themselves. - . If the version you specified when deleting a row is - larger than the version of any value in the row, then you can - consider the complete row to be deleted. - For an informative discussion on how deletes and versioning interact, see - the thread Put w/ timestamp -> Deleteall -> Put w/ timestamp fails - up on the user mailing list. - Also see for more information on the internal KeyValue format. - - Delete markers are purged during the major compaction of store, - unless the KEEP_DELETED_CELLS is set in the column family. In some - scenarios, users want to keep the deletes for a time and you can set the - delete TTL: hbase.hstore.time.to.purge.deletes in the configuration. - If this delete TTL is not set, or set to 0, all delete markers including those - with future timestamp are purged during the later major compaction. - Otherwise, a delete marker is kept until the major compaction after - marker's timestamp + delete TTL. - + When deleting an entire row, HBase will internally create a tombstone for each + ColumnFamily (i.e., not each individual column). + Deletes work by creating tombstone markers. For example, let's + suppose we want to delete a row. For this you can specify a version, or else by default + the currentTimeMillis is used. What this means is delete all + cells where the version is less than or equal to this version. HBase never + modifies data in place, so for example a delete will not immediately delete (or mark as + deleted) the entries in the storage file that correspond to the delete condition. + Rather, a so-called tombstone is written, which will mask the + deleted values + When HBase does a major compaction, the tombstones are processed to actually + remove the dead values, together with the tombstones themselves. + . If the version you specified when deleting a row is larger than the version + of any value in the row, then you can consider the complete row to be deleted. + For an informative discussion on how deletes and versioning interact, see the thread Put w/ + timestamp -> Deleteall -> Put w/ timestamp fails up on the user mailing + list. + Also see for more information on the internal KeyValue format. + Delete markers are purged during the major compaction of store, unless the + KEEP_DELETED_CELLS is set in the column family. In some scenarios, users want to keep + the deletes for a time and you can set the delete TTL: + hbase.hstore.time.to.purge.deletes in the configuration. If this delete TTL is not set, + or set to 0, all delete markers including those with future timestamp are purged during + the later major compaction. Otherwise, a delete marker is kept until the major + compaction after marker's timestamp + delete TTL.
-
+
Current Limitations @@ -608,18 +707,18 @@ htable.put(put); within the same millisecond.
-
+
Major compactions change query results - - ...create three cell versions at t1, t2 and t3, with a - maximum-versions setting of 2. So when getting all versions, only - the values at t2 and t3 will be returned. But if you delete the - version at t2 or t3, the one at t1 will appear again. Obviously, - once a major compaction has run, such behavior will not be the case - anymore... + + ...create three cell versions at t1, t2 and t3, with a maximum-versions + setting of 2. So when getting all versions, only the values at t2 and t3 will be + returned. But if you delete the version at t2 or t3, the one at t1 will appear again. + Obviously, once a major compaction has run, such behavior will not be the case anymore... See Garbage Collection in Bending - time in HBase + xlink:href="http://outerthought.org/blog/417-ot.html">Bending time in + HBase +
@@ -1452,7 +1551,7 @@ connection.close(); FilterList represents a list of Filters with a relationship of FilterList.Operator.MUST_PASS_ALL or FilterList.Operator.MUST_PASS_ONE between the Filters. The following example shows an 'or' between two - Filters (checking for either 'my value' or 'my other value' on the same attribute). + Filters (checking for either 'my value' or 'my other value' on the same attribute). FilterList list = new FilterList(FilterList.Operator.MUST_PASS_ONE); SingleColumnValueFilter filter1 = new SingleColumnValueFilter( @@ -1471,21 +1570,22 @@ SingleColumnValueFilter filter2 = new SingleColumnValueFilter( list.add(filter2); scan.setFilter(list); -
-
Column Value -
SingleColumnValueFilter +
+ Column Value +
+ SingleColumnValueFilter SingleColumnValueFilter can be used to test column values for equivalence - (CompareOp.EQUAL + xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.html">SingleColumnValueFilter + can be used to test column values for equivalence (CompareOp.EQUAL ), inequality (CompareOp.NOT_EQUAL), or ranges (e.g., CompareOp.GREATER). The following is example of testing equivalence a - column to a String value "my value"... - + column to a String value "my value"... + SingleColumnValueFilter filter = new SingleColumnValueFilter( cf, column, @@ -1494,17 +1594,21 @@ SingleColumnValueFilter filter = new SingleColumnValueFilter( ); scan.setFilter(filter); -
-
Column Value Comparators - There are several Comparator classes in the Filter package that deserve special mention. - These Comparators are used in concert with other Filters, such as . - -
RegexStringComparator - RegexStringComparator - supports regular expressions for value comparisons. - +
+ Column Value Comparators + There are several Comparator classes in the Filter package that deserve special + mention. These Comparators are used in concert with other Filters, such as . +
+ RegexStringComparator + RegexStringComparator + supports regular expressions for value comparisons. + RegexStringComparator comp = new RegexStringComparator("my."); // any value that starts with 'my' SingleColumnValueFilter filter = new SingleColumnValueFilter( cf, @@ -1514,14 +1618,18 @@ SingleColumnValueFilter filter = new SingleColumnValueFilter( ); scan.setFilter(filter); - See the Oracle JavaDoc for supported RegEx patterns in Java. - + See the Oracle JavaDoc for supported + RegEx patterns in Java.
-
SubstringComparator - SubstringComparator - can be used to determine if a given substring exists in a value. The comparison is case-insensitive. - - +
+ SubstringComparator + SubstringComparator + can be used to determine if a given substring exists in a value. The comparison is + case-insensitive. + SubstringComparator comp = new SubstringComparator("y val"); // looking for 'my value' SingleColumnValueFilter filter = new SingleColumnValueFilter( cf, @@ -1532,37 +1640,53 @@ SingleColumnValueFilter filter = new SingleColumnValueFilter( scan.setFilter(filter);
-
BinaryPrefixComparator - See BinaryPrefixComparator. +
+ BinaryPrefixComparator + See BinaryPrefixComparator.
-
BinaryComparator - See BinaryComparator. +
+ BinaryComparator + See BinaryComparator.
-
KeyValue Metadata - As HBase stores data internally as KeyValue pairs, KeyValue Metadata Filters evaluate the existence of keys (i.e., ColumnFamily:Column qualifiers) - for a row, as opposed to values the previous section. - -
FamilyFilter - FamilyFilter can be used - to filter on the ColumnFamily. It is generally a better idea to select ColumnFamilies in the Scan than to do it with a Filter. +
+ KeyValue Metadata + As HBase stores data internally as KeyValue pairs, KeyValue Metadata Filters evaluate + the existence of keys (i.e., ColumnFamily:Column qualifiers) for a row, as opposed to + values the previous section. +
+ FamilyFilter + FamilyFilter + can be used to filter on the ColumnFamily. It is generally a better idea to select + ColumnFamilies in the Scan than to do it with a Filter.
-
QualifierFilter - QualifierFilter can be used - to filter based on Column (aka Qualifier) name. - +
+ QualifierFilter + QualifierFilter + can be used to filter based on Column (aka Qualifier) name.
-
ColumnPrefixFilter - ColumnPrefixFilter can be used - to filter based on the lead portion of Column (aka Qualifier) names. - - A ColumnPrefixFilter seeks ahead to the first column matching the prefix in each row and for each involved column family. It can be used to efficiently - get a subset of the columns in very wide rows. - - Note: The same column qualifier can be used in different column families. This filter returns all matching columns. - - Example: Find all columns in a row and family that start with "abc" - +
+ ColumnPrefixFilter + ColumnPrefixFilter + can be used to filter based on the lead portion of Column (aka Qualifier) names. + A ColumnPrefixFilter seeks ahead to the first column matching the prefix in each row + and for each involved column family. It can be used to efficiently get a subset of the + columns in very wide rows. + Note: The same column qualifier can be used in different column families. This + filter returns all matching columns. + Example: Find all columns in a row and family that start with "abc" + HTableInterface t = ...; byte[] row = ...; byte[] family = ...; @@ -1580,17 +1704,19 @@ for (Result r = rs.next(); r != null; r = rs.next()) { } rs.close(); -
-
MultipleColumnPrefixFilter - MultipleColumnPrefixFilter behaves like ColumnPrefixFilter - but allows specifying multiple prefixes. - - Like ColumnPrefixFilter, MultipleColumnPrefixFilter efficiently seeks ahead to the first column matching the lowest prefix and also seeks past ranges of columns between prefixes. - It can be used to efficiently get discontinuous sets of columns from very wide rows. - - Example: Find all columns in a row and family that start with "abc" or "xyz" - +
+ MultipleColumnPrefixFilter + MultipleColumnPrefixFilter + behaves like ColumnPrefixFilter but allows specifying multiple prefixes. + Like ColumnPrefixFilter, MultipleColumnPrefixFilter efficiently seeks ahead to the + first column matching the lowest prefix and also seeks past ranges of columns between + prefixes. It can be used to efficiently get discontinuous sets of columns from very wide + rows. + Example: Find all columns in a row and family that start with "abc" or "xyz" + HTableInterface t = ...; byte[] row = ...; byte[] family = ...; @@ -1608,19 +1734,22 @@ for (Result r = rs.next(); r != null; r = rs.next()) { } rs.close(); -
-
ColumnRangeFilter - A ColumnRangeFilter allows efficient intra row scanning. - - A ColumnRangeFilter can seek ahead to the first matching column for each involved column family. It can be used to efficiently - get a 'slice' of the columns of a very wide row. - i.e. you have a million columns in a row but you only want to look at columns bbbb-bbdd. - - Note: The same column qualifier can be used in different column families. This filter returns all matching columns. - - Example: Find all columns in a row and family between "bbbb" (inclusive) and "bbdd" (inclusive) - +
+ ColumnRangeFilter + A ColumnRangeFilter + allows efficient intra row scanning. + A ColumnRangeFilter can seek ahead to the first matching column for each involved + column family. It can be used to efficiently get a 'slice' of the columns of a very wide + row. i.e. you have a million columns in a row but you only want to look at columns + bbbb-bbdd. + Note: The same column qualifier can be used in different column families. This + filter returns all matching columns. + Example: Find all columns in a row and family between "bbbb" (inclusive) and "bbdd" + (inclusive) + HTableInterface t = ...; byte[] row = ...; byte[] family = ...; @@ -1639,7 +1768,6 @@ for (Result r = rs.next(); r != null; r = rs.next()) { } rs.close(); - Note: Introduced in HBase 0.92
@@ -2279,18 +2407,297 @@ myHtd.setValue(HTableDescriptor.SPLIT_POLICY, MyCustomSplitPolicy.class.getName(
-
- Compaction - There are two types of compactions: minor and major. Minor compactions will usually pick up a couple of the smaller adjacent - StoreFiles and rewrite them as one. Minors do not drop deletes or expired cells, only major compactions do this. Sometimes a minor compaction - will pick up all the StoreFiles in the Store and in this case it actually promotes itself to being a major compaction. - - After a major compaction runs there will be a single StoreFile per Store, and this will help performance usually. Caution: major compactions rewrite all of the Stores data and on a loaded system, this may not be tenable; - major compactions will usually have to be done manually on large systems. See . - - Compactions will not perform region merges. See for more information on region merging. - -
+
+ Compaction + Compaction is an operation which reduces the number of + StoreFiles, by merging them together, in order to increase performance on read + operations. Compactions can be resource-intensive to perform, and can either help or + hinder performance depending on many factors. + Compactions fall into two categories: minor and major. + Minor compactions usually pick up a small number of small, + adjacent StoreFiles and rewrite them as a single + StoreFile. Minor compactions do not drop deletes or expired + cells. If a minor compaction picks up all the StoreFiles in a + Store, it promotes itself from a minor to a major compaction. + If there are a lot of small files to be compacted, the algorithm tends to favor minor + compactions to "clean up" those small files. + The goal of a major compaction is to end up with a single + StoreFile per store. Major compactions also process delete markers and max versions. + Attempting to process these during a minor compaction could cause side effects. + + + Compaction and Deletions + When an explicit deletion occurs in HBase, the data is not actually deleted. + Instead, a tombstone marker is written. The tombstone marker + prevents the data from being returned with queries. During a major compaction, the + data is actually deleted, and the tombstone marker is removed from the StoreFile. If + the deletion happens because of an expired TTL, no tombstone is created. Instead, the + expired data is filtered out and is not written back to the compacted StoreFile. + + + + Compaction and Versions + When you create a column family, you can specify the maximum number of versions + to keep, by specifying HColumnDescriptor.setMaxVersions(int + versions). The default value is 3. If more versions + than the specified maximum exist, the excess versions are filtered out and not written + back to the compacted StoreFile. + + + + Major Compactions Can Impact Query Results + In some situations, older versions can be inadvertently + resurrected if a newer version is explicitly deleted. See for a more in-depth explanation. This + situation is only possible before the compaction finishes. + + + + In theory, major compactions improve performance. However, on a highly loaded + system, major compactions can require an inappropriate number of resources and adversely + affect performance. In a default configuration, major compactions are scheduled + automatically to run once in a 7-day period. This is usually inappropriate for systems + in production. You can manage major compactions manually. See . + Compactions do not perform region merges. See for more information on region merging. +
+ Algorithm for Compaction File Selection - HBase 0.96.x and newer + The compaction algorithms used by HBase have evolved over time. HBase 0.96 + introduced new algorithms for compaction file selection. To find out about the old + algorithms, see . The rest of this section describes the new algorithm. File + selection happens in several phases and is controlled by several configurable + parameters. These parameters will be explained in context, and then will be given in a + table which shows their descriptions, defaults, and implications of changing + them. + + + The<link + xlink:href="https://issues.apache.org/jira/browse/HBASE-7842">Exploring Compaction Policy</link> + HBASE-7842 + was introduced in HBase 0.96 and represents a major change in the algorithms for + file selection for compactions. Its goal is to do the most impactful compaction with + the lowest cost, in situations where a lot of files need compaction. In such a + situation, the list of all eligible files is "explored", and files are grouped by + size before any ratio-based algorithms are run. This favors clean-up of large + numbers of small files before larger files are considered. For more details, refer + to the link to the JIRA. Most of the code for this change can be reviewed in + hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/ExploringCompactionPolicy.java. + + + + Algorithms for Determining File List and Compaction Type + + Create a list of all files which can possibly be compacted, ordered by + sequence ID. + + The first phase is to create a list of all candidates for compaction. A list + is created of all StoreFiles not already in the compaction queue, and all files + newer than the newest file that is currently being compacted. This list of files + is ordered by the sequence ID. The sequence ID is generated when a Put is + appended to the write-ahead log (WAL), and is stored in the metadata of the + StoreFile. + + + + Check to see if major compaction is required because there are too many + StoreFiles and the memstore is too large. + + A store can only have hbase.hstore.blockingStoreFiles. If + the store has too many files, you cannot flush data. In addition, you cannot + perform an insert if the memstore is over + hbase.hregion.memstore.flush.size. Normally, minor + compactions will alleviate this situation. However, if the normal compaction + algorithm do not find any normally-eligible StoreFiles, a major compaction is + the only way to get out of this situation, and is forced. This is also called a + size-based or size-triggered major compaction. + + + + If this compaction was user-requested, do a major compaction. + + Compactions can run on a schedule or can be initiated manually. If a + compaction is requested manually, it is always a major compaction. If the + compaction is user-requested, the major compaction still happens even if the are + more than hbase.hstore.compaction.max files that need + compaction. + + + + Exclude files which are too large. + + The purpose of compaction is to merge small files together, and it is + counterproductive to compact files which are too large. Files larger than + hbase.hstore.compaction.max.size are excluded from + consideration. + + + + If configured, exclude bulk-loaded files. + + You may decide to exclude bulk-loaded files from compaction, in the bulk + load operation, by specifying the + hbase.mapreduce.hfileoutputformat.compaction.exclude + parameter. If a bulk-loaded file was excluded, it is removed from + consideration at this point. + + + + If there are too many files to compact, do a minor compaction. + + The maximum number of files allowed in a major compaction is controlled by + the hbase.hstore.compaction.max parameter. If the list + contains more than this number of files, a compaction that would otherwise be a + major compaction is downgraded to a minor compaction. However, a user-requested + major compaction still occurs even if there are more than + hbase.hstore.compaction.max files to compact. + + + + Only run the compaction if enough files need to be compacted. + + If the list contains fewer than + hbase.hstore.compaction.min files to compact, compaction is + aborted. + + + + If this is a minor compaction, determine which files are eligible, based upon + the hbase.store.compaction.ratio. + + The value of the hbase.store.compaction.ratio parameter + is multiplied by the sum of files smaller than a given file, to determine + whether that file is selected for compaction during a minor compaction. For + instance, if hbase.store.compaction.ratio is 1.2, FileX is 5 mb, FileY is 2 mb, + and FileZ is 3 mb: + 5 <= 1.2 x (2 + 3) or 5 <= 6 + In this scenario, FileX is eligible for minor compaction. If FileX were 7 + mb, it would not be eligible for minor compaction. This ratio favors smaller + files. You can configure a different ratio for use in off-peak hours, using the + parameter hbase.hstore.compaction.ratio.offpeak, if you also + configure hbase.offpeak.start.hour and + hbase.offpeak.end.hour. + + + + If major compactions are not managed manually, and it has been too long since + the last major compaction, run a major compaction anyway. + + If the last major compaction was too long ago and there is more than one + file to be compacted, a major compaction is run, even if it would otherwise have + been minor. By default, the maximum time between major compactions is 7 days, + plus or minus a 4.8 hour period, and determined randomly within those + parameters. Prior to HBase 0.96, the major compaction period was 24 hours. This + is also referred to as a time-based or time-triggered major compaction. See + hbase.hregion.majorcompaction in the table below to tune or + disable time-based major compactions. + + + +
+ Parameters Used by Compaction Algorithm + + This table contains the main configuration parameters for compaction. This + list is not exhaustive. To tune these parameters from the defaults, edit the + hbase-default.xml file. For a full list of all + configuration parameters available, see . + + + + + Parameter + Description + Default + + + + + hbase.hstore.compaction.min + The minimum number of files which must be eligible for compaction before + compaction can run. + 3 + + + hbase.hstore.compaction.max + The maximum number of files which will be selected for a single minor + compaction, regardless of the number of eligible files. + 10 + + + hbase.hstore.compaction.min.size + A StoreFile smaller than this size (in bytes) will always be eligible for + minor compaction. + 10 + + + hbase.hstore.compaction.max.size + A StoreFile larger than this size (in bytes) will be excluded from minor + compaction. + 1000 + + + hbase.store.compaction.ratio + For minor compaction, this ratio is used to determine whether a given + file is eligible for compaction. Its effect is to limit compaction of large + files. Expressed as a floating-point decimal. + 1.2F + + + hbase.hstore.compaction.ratio.offpeak + The compaction ratio used during off-peak compactions, if off-peak is + enabled. Expressed as a floating-point decimal. This allows for more + aggressive compaction, because in theory, the cluster is under less load. + Ignored if off-peak is disabled (default). + 5.0F + + + hbase.offpeak.start.hour + The start of off-peak hours, expressed as an integer between 0 and 23, + inclusive. Set to -1 to disable off-peak. + -1 (disabled) + + + hbase.offpeak.end.hour + The end of off-peak hours, expressed as an integer between 0 and 23, + inclusive. Set to -1 to disable off-peak. + -1 (disabled) + + + hbase.regionserver.thread.compaction.throttle + Throttles compaction if too much of a backlog of compaction work + exists. + 2 x hbase.hstore.compaction.max x hbase.hregion.memstore.flush.size + (which defaults to 128) + + + hbase.hregion.majorcompaction + Time between major compactions, expressed in milliseconds. Set to 0 to + disable time-based automatic major compactions. User-requested and size-based + major compactions will still run. + 7 days (604800000 milliseconds) + + + hbase.hregion.majorcompaction.jitter + A multiplier applied to majorCompactionPeriod to cause compaction to + occur a given amount of time either side of majorCompactionPeriod. The smaller + the number, the closer the compactions will happen to the + hbase.hregion.majorcompaction interval. Expressed as a + floating-point decimal. + .50F + + + +
+
+ +
Compaction File Selection To understand the core algorithm for StoreFile selection, there is some ASCII-art in the Store source code that will serve as useful reference. It has been copied below: diff --git a/src/main/docbkx/case_studies.xml b/src/main/docbkx/case_studies.xml index 15169a8aa43..262f0ee821d 100644 --- a/src/main/docbkx/case_studies.xml +++ b/src/main/docbkx/case_studies.xml @@ -1,5 +1,7 @@ - Apache HBase Case Studies -
+
Overview - This chapter will describe a variety of performance and troubleshooting case studies that can - provide a useful blueprint on diagnosing Apache HBase cluster issues. - For more information on Performance and Troubleshooting, see and . - + This chapter will describe a variety of performance and troubleshooting case studies that + can provide a useful blueprint on diagnosing Apache HBase cluster issues. + For more information on Performance and Troubleshooting, see and .
- -
+ +
Schema Design - See the schema design case studies here: + See the schema design case studies here: - -
- -
+ +
+ + +
Performance/Troubleshooting - -
+ +
Case Study #1 (Performance Issue On A Single Node) -
Scenario - Following a scheduled reboot, one data node began exhibiting unusual behavior. Routine MapReduce - jobs run against HBase tables which regularly completed in five or six minutes began taking 30 or 40 minutes - to finish. These jobs were consistently found to be waiting on map and reduce tasks assigned to the troubled data node - (e.g., the slow map tasks all had the same Input Split). - The situation came to a head during a distributed copy, when the copy was severely prolonged by the lagging node. - +
+ Scenario + Following a scheduled reboot, one data node began exhibiting unusual behavior. + Routine MapReduce jobs run against HBase tables which regularly completed in five or six + minutes began taking 30 or 40 minutes to finish. These jobs were consistently found to be + waiting on map and reduce tasks assigned to the troubled data node (e.g., the slow map + tasks all had the same Input Split). The situation came to a head during a distributed + copy, when the copy was severely prolonged by the lagging node.
-
Hardware - Datanodes: - - Two 12-core processors - Six Enerprise SATA disks - 24GB of RAM - Two bonded gigabit NICs - - - Network: - - 10 Gigabit top-of-rack switches - 20 Gigabit bonded interconnects between racks. - - +
+ Hardware + + Datanodes: + + Two 12-core processors + + + Six Enerprise SATA disks + + + 24GB of RAM + + + Two bonded gigabit NICs + + + + Network: + + 10 Gigabit top-of-rack switches + + + 20 Gigabit bonded interconnects between racks. + +
-
Hypotheses -
HBase "Hot Spot" Region - We hypothesized that we were experiencing a familiar point of pain: a "hot spot" region in an HBase table, - where uneven key-space distribution can funnel a huge number of requests to a single HBase region, bombarding the RegionServer - process and cause slow response time. Examination of the HBase Master status page showed that the number of HBase requests to the - troubled node was almost zero. Further, examination of the HBase logs showed that there were no region splits, compactions, or other region transitions - in progress. This effectively ruled out a "hot spot" as the root cause of the observed slowness. - +
+ Hypotheses +
+ HBase "Hot Spot" Region + We hypothesized that we were experiencing a familiar point of pain: a "hot spot" + region in an HBase table, where uneven key-space distribution can funnel a huge number + of requests to a single HBase region, bombarding the RegionServer process and cause slow + response time. Examination of the HBase Master status page showed that the number of + HBase requests to the troubled node was almost zero. Further, examination of the HBase + logs showed that there were no region splits, compactions, or other region transitions + in progress. This effectively ruled out a "hot spot" as the root cause of the observed + slowness.
-
HBase Region With Non-Local Data - Our next hypothesis was that one of the MapReduce tasks was requesting data from HBase that was not local to the datanode, thus - forcing HDFS to request data blocks from other servers over the network. Examination of the datanode logs showed that there were very - few blocks being requested over the network, indicating that the HBase region was correctly assigned, and that the majority of the necessary - data was located on the node. This ruled out the possibility of non-local data causing a slowdown. - -
-
Excessive I/O Wait Due To Swapping Or An Over-Worked Or Failing Hard Disk - After concluding that the Hadoop and HBase were not likely to be the culprits, we moved on to troubleshooting the datanode's hardware. - Java, by design, will periodically scan its entire memory space to do garbage collection. If system memory is heavily overcommitted, the Linux - kernel may enter a vicious cycle, using up all of its resources swapping Java heap back and forth from disk to RAM as Java tries to run garbage - collection. Further, a failing hard disk will often retry reads and/or writes many times before giving up and returning an error. This can manifest - as high iowait, as running processes wait for reads and writes to complete. Finally, a disk nearing the upper edge of its performance envelope will - begin to cause iowait as it informs the kernel that it cannot accept any more data, and the kernel queues incoming data into the dirty write pool in memory. - However, using vmstat(1) and free(1), we could see that no swap was being used, and the amount of disk IO was only a few kilobytes per second. - +
+ HBase Region With Non-Local Data + Our next hypothesis was that one of the MapReduce tasks was requesting data from + HBase that was not local to the datanode, thus forcing HDFS to request data blocks from + other servers over the network. Examination of the datanode logs showed that there were + very few blocks being requested over the network, indicating that the HBase region was + correctly assigned, and that the majority of the necessary data was located on the node. + This ruled out the possibility of non-local data causing a slowdown.
-
Slowness Due To High Processor Usage - Next, we checked to see whether the system was performing slowly simply due to very high computational load. top(1) showed that the system load - was higher than normal, but vmstat(1) and mpstat(1) showed that the amount of processor being used for actual computation was low. - -
-
Network Saturation (The Winner) - Since neither the disks nor the processors were being utilized heavily, we moved on to the performance of the network interfaces. The datanode had two - gigabit ethernet adapters, bonded to form an active-standby interface. ifconfig(8) showed some unusual anomalies, namely interface errors, overruns, framing errors. - While not unheard of, these kinds of errors are exceedingly rare on modern hardware which is operating as it should: - +
+ Excessive I/O Wait Due To Swapping Or An Over-Worked Or Failing Hard Disk + After concluding that the Hadoop and HBase were not likely to be the culprits, we + moved on to troubleshooting the datanode's hardware. Java, by design, will periodically + scan its entire memory space to do garbage collection. If system memory is heavily + overcommitted, the Linux kernel may enter a vicious cycle, using up all of its resources + swapping Java heap back and forth from disk to RAM as Java tries to run garbage + collection. Further, a failing hard disk will often retry reads and/or writes many times + before giving up and returning an error. This can manifest as high iowait, as running + processes wait for reads and writes to complete. Finally, a disk nearing the upper edge + of its performance envelope will begin to cause iowait as it informs the kernel that it + cannot accept any more data, and the kernel queues incoming data into the dirty write + pool in memory. However, using vmstat(1) and free(1), we could + see that no swap was being used, and the amount of disk IO was only a few kilobytes per + second. +
+
+ Slowness Due To High Processor Usage + Next, we checked to see whether the system was performing slowly simply due to very + high computational load. top(1) showed that the system load was higher than + normal, but vmstat(1) and mpstat(1) showed that the amount of + processor being used for actual computation was low. +
+
+ Network Saturation (The Winner) + Since neither the disks nor the processors were being utilized heavily, we moved on + to the performance of the network interfaces. The datanode had two gigabit ethernet + adapters, bonded to form an active-standby interface. ifconfig(8) showed + some unusual anomalies, namely interface errors, overruns, framing errors. While not + unheard of, these kinds of errors are exceedingly rare on modern hardware which is + operating as it should: + $ /sbin/ifconfig bond0 bond0 Link encap:Ethernet HWaddr 00:00:00:00:00:00 inet addr:10.x.x.x Bcast:10.x.x.255 Mask:255.255.255.0 @@ -115,12 +154,13 @@ RX packets:2990700159 errors:12 dropped:0 overruns:1 frame:6 <--- Lo TX packets:3443518196 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2416328868676 (2.4 TB) TX bytes:3464991094001 (3.4 TB) - - - These errors immediately lead us to suspect that one or more of the ethernet interfaces might have negotiated the wrong line speed. This was confirmed both by running an ICMP ping - from an external host and observing round-trip-time in excess of 700ms, and by running ethtool(8) on the members of the bond interface and discovering that the active interface - was operating at 100Mbs/, full duplex. - + + These errors immediately lead us to suspect that one or more of the ethernet + interfaces might have negotiated the wrong line speed. This was confirmed both by + running an ICMP ping from an external host and observing round-trip-time in excess of + 700ms, and by running ethtool(8) on the members of the bond interface and + discovering that the active interface was operating at 100Mbs/, full duplex. + $ sudo ethtool eth0 Settings for eth0: Supported ports: [ TP ] @@ -147,45 +187,53 @@ Supports Wake-on: umbg Wake-on: g Current message level: 0x00000003 (3) Link detected: yes - - - In normal operation, the ICMP ping round trip time should be around 20ms, and the interface speed and duplex should read, "1000MB/s", and, "Full", respectively. - + + In normal operation, the ICMP ping round trip time should be around 20ms, and the + interface speed and duplex should read, "1000MB/s", and, "Full", respectively.
-
-
Resolution - After determining that the active ethernet adapter was at the incorrect speed, we used the ifenslave(8) command to make the standby interface - the active interface, which yielded an immediate improvement in MapReduce performance, and a 10 times improvement in network throughput: - - On the next trip to the datacenter, we determined that the line speed issue was ultimately caused by a bad network cable, which was replaced. -
-
-
+
+ Resolution + After determining that the active ethernet adapter was at the incorrect speed, we + used the ifenslave(8) command to make the standby interface the active + interface, which yielded an immediate improvement in MapReduce performance, and a 10 times + improvement in network throughput: + On the next trip to the datacenter, we determined that the line speed issue was + ultimately caused by a bad network cable, which was replaced. +
+
+ +
Case Study #2 (Performance Research 2012) - Investigation results of a self-described "we're not sure what's wrong, but it seems slow" problem. - http://gbif.blogspot.com/2012/03/hbase-performance-evaluation-continued.html + Investigation results of a self-described "we're not sure what's wrong, but it seems + slow" problem. http://gbif.blogspot.com/2012/03/hbase-performance-evaluation-continued.html
- -
+ +
Case Study #3 (Performance Research 2010)) - - Investigation results of general cluster performance from 2010. Although this research is on an older version of the codebase, this writeup - is still very useful in terms of approach. - http://hstack.org/hbase-performance-testing/ + Investigation results of general cluster performance from 2010. Although this research + is on an older version of the codebase, this writeup is still very useful in terms of + approach. http://hstack.org/hbase-performance-testing/
- -
+ +
Case Study #4 (xcievers Config) - Case study of configuring xceivers, and diagnosing errors from mis-configurations. - http://www.larsgeorge.com/2012/03/hadoop-hbase-and-xceivers.html - - See also . + Case study of configuring xceivers, and diagnosing errors from + mis-configurations. http://www.larsgeorge.com/2012/03/hadoop-hbase-and-xceivers.html + See also .
- -
- + +
+ + diff --git a/src/main/docbkx/community.xml b/src/main/docbkx/community.xml index ae5573fbdb6..9bdaa39c05e 100644 --- a/src/main/docbkx/community.xml +++ b/src/main/docbkx/community.xml @@ -1,13 +1,15 @@ - - - Community -
- Decisions -
- Feature Branches - Feature Branches are easy to make. You do not have to be a committer to make one. Just request the name of your branch be added to JIRA up on the - developer's mailing list and a committer will add it for you. Thereafter you can file issues against your feature branch in Apache HBase JIRA. Your code you - keep elsewhere -- it should be public so it can be observed -- and you can update dev mailing list on progress. When the feature is ready for commit, - 3 +1s from committers will get your feature mergedSee HBase, mail # dev - Thoughts about large feature dev branches - -
-
- Patch +1 Policy - -The below policy is something we put in place 09/2012. It is a -suggested policy rather than a hard requirement. We want to try it -first to see if it works before we cast it in stone. - - -Apache HBase is made of -components. -Components have one or more s. See the 'Description' field on the -components -JIRA page for who the current owners are by component. - - -Patches that fit within the scope of a single Apache HBase component require, -at least, a +1 by one of the component's owners before commit. If -owners are absent -- busy or otherwise -- two +1s by non-owners will -suffice. - - -Patches that span components need at least two +1s before they can be -committed, preferably +1s by owners of components touched by the -x-component patch (TODO: This needs tightening up but I think fine for -first pass). - - -Any -1 on a patch by anyone vetos a patch; it cannot be committed -until the justification for the -1 is addressed. - -
-
- How to set fix version in JIRA on issue resolve - Here is how we agreed to set versions in JIRA when we - resolve an issue. If trunk is going to be 0.98.0 then: - - - Commit only to trunk: Mark with 0.98 - - - Commit to 0.95 and trunk : Mark with 0.98, and 0.95.x - - - Commit to 0.94.x and 0.95, and trunk: Mark with 0.98, 0.95.x, and 0.94.x - - - Commit to 89-fb: Mark with 89-fb. - - - Commit site fixes: no version - - - -
-
- Policy on when to set a RESOLVED JIRA as CLOSED - We agreed - that for issues that list multiple releases in their Fix Version/s field, - CLOSE the issue on the release of any of the versions listed; subsequent change - to the issue must happen in a new JIRA. - -
-
- Only transient state in ZooKeeper! - -You should be able to kill the data in zookeeper and hbase should ride over it recreating the zk content as it goes. -This is an old adage around these parts. We just made note of it now. We also are currently in violation of this -basic tenet -- replication at least keeps permanent state in zk -- but we are working to undo this breaking of a -golden rule. - -
+ Community +
+ Decisions +
+ Feature Branches + Feature Branches are easy to make. You do not have to be a committer to make one. Just + request the name of your branch be added to JIRA up on the developer's mailing list and a + committer will add it for you. Thereafter you can file issues against your feature branch in + Apache HBase JIRA. Your code you keep elsewhere -- it should be public so it can be observed + -- and you can update dev mailing list on progress. When the feature is ready for commit, 3 + +1s from committers will get your feature merged + See HBase, mail # dev - Thoughts + about large feature dev branches + +
-
- Community Roles -
- Component Owner/Lieutenant - -Component owners are listed in the description field on this Apache HBase JIRA components -page. The owners are listed in the 'Description' field rather than in the 'Component -Lead' field because the latter only allows us list one individual -whereas it is encouraged that components have multiple owners. - - -Owners or component lieutenants are volunteers who are (usually, but not necessarily) expert in -their component domain and may have an agenda on how they think their -Apache HBase component should evolve. - - -Duties include: - - - -Owners will try and review patches that land within their component's scope. - - - - -If applicable, if an owner has an agenda, they will publish their -goals or the design toward which they are driving their component - - - - - -If you would like to be volunteer as a component owner, just write the -dev list and we'll sign you up. Owners do not need to be committers. - -
+
+ Patch +1 Policy + The below policy is something we put in place 09/2012. It is a suggested policy rather + than a hard requirement. We want to try it first to see if it works before we cast it in + stone. + Apache HBase is made of components. + Components have one or more s. See the 'Description' field on the components + JIRA page for who the current owners are by component. + Patches that fit within the scope of a single Apache HBase component require, at least, + a +1 by one of the component's owners before commit. If owners are absent -- busy or + otherwise -- two +1s by non-owners will suffice. + Patches that span components need at least two +1s before they can be committed, + preferably +1s by owners of components touched by the x-component patch (TODO: This needs + tightening up but I think fine for first pass). + Any -1 on a patch by anyone vetos a patch; it cannot be committed until the + justification for the -1 is addressed.
-
- Commit Message format - We agreed - to the following SVN commit message format: -HBASE-xxxxx <title>. (<contributor>) -If the person making the commit is the contributor, leave off the '(<contributor>)' element. +
+ How to set fix version in JIRA on issue resolve + Here is how we agreed to set versions in + JIRA when we resolve an issue. If trunk is going to be 0.98.0 then: + + + Commit only to trunk: Mark with 0.98 + + + Commit to 0.95 and trunk : Mark with 0.98, and 0.95.x + + + Commit to 0.94.x and 0.95, and trunk: Mark with 0.98, 0.95.x, and 0.94.x + + + Commit to 89-fb: Mark with 89-fb. + + + Commit site fixes: no version + + +
+
+ Policy on when to set a RESOLVED JIRA as CLOSED + We agreed that for issues that + list multiple releases in their Fix Version/s field, CLOSE the issue on + the release of any of the versions listed; subsequent change to the issue must happen in a + new JIRA. +
+
+ Only transient state in ZooKeeper! + You should be able to kill the data in zookeeper and hbase should ride over it + recreating the zk content as it goes. This is an old adage around these parts. We just made + note of it now. We also are currently in violation of this basic tenet -- replication at + least keeps permanent state in zk -- but we are working to undo this breaking of a golden + rule. +
+
+
+ Community Roles +
+ Component Owner/Lieutenant + Component owners are listed in the description field on this Apache HBase JIRA components + page. The owners are listed in the 'Description' field rather than in the 'Component Lead' + field because the latter only allows us list one individual whereas it is encouraged that + components have multiple owners. + Owners or component lieutenants are volunteers who are (usually, but not necessarily) + expert in their component domain and may have an agenda on how they think their Apache HBase + component should evolve. + + Component Owner Duties + + Owners will try and review patches that land within their component's scope. -
- + + + If applicable, if an owner has an agenda, they will publish their goals or the + design toward which they are driving their component + + + If you would like to be volunteer as a component owner, just write the dev list and + we'll sign you up. Owners do not need to be committers. +
+
+
+ Commit Message format + We agreed to the following SVN + commit message format: + HBASE-xxxxx <title>. (<contributor>) If the person + making the commit is the contributor, leave off the '(<contributor>)' element. +
+ diff --git a/src/main/docbkx/configuration.xml b/src/main/docbkx/configuration.xml index 25e1f1376ad..cd86bef9c03 100644 --- a/src/main/docbkx/configuration.xml +++ b/src/main/docbkx/configuration.xml @@ -1,13 +1,15 @@ - - - Apache HBase Configuration - This chapter is the Not-So-Quick start guide to Apache HBase configuration. It goes - over system requirements, Hadoop setup, the different Apache HBase run modes, and the - various configurations in HBase. Please read this chapter carefully. At a minimum - ensure that all have - been satisfied. Failure to do so will cause you (and us) grief debugging strange errors - and/or data loss. + Apache HBase Configuration + This chapter is the Not-So-Quick start guide to Apache HBase configuration. It goes over + system requirements, Hadoop setup, the different Apache HBase run modes, and the various + configurations in HBase. Please read this chapter carefully. At a minimum ensure that all have been satisfied. Failure to do so will cause you (and us) + grief debugging strange errors and/or data loss. - - Apache HBase uses the same configuration system as Apache Hadoop. - To configure a deploy, edit a file of environment variables - in conf/hbase-env.sh -- this configuration - is used mostly by the launcher shell scripts getting the cluster - off the ground -- and then add configuration to an XML file to - do things like override HBase defaults, tell HBase what Filesystem to - use, and the location of the ZooKeeper ensemble - - -Be careful editing XML. Make sure you close all elements. -Run your file through xmllint or similar -to ensure well-formedness of your document after an edit session. - - - . - + Apache HBase uses the same configuration system as Apache Hadoop. To configure a deploy, + edit a file of environment variables in conf/hbase-env.sh -- this + configuration is used mostly by the launcher shell scripts getting the cluster off the ground -- + and then add configuration to an XML file to do things like override HBase defaults, tell HBase + what Filesystem to use, and the location of the ZooKeeper ensemble. + Be careful editing XML. Make sure you close all elements. Run your file through + xmllint or similar to ensure well-formedness of your document after an + edit session. + - When running in distributed mode, after you make - an edit to an HBase configuration, make sure you copy the - content of the conf directory to - all nodes of the cluster. HBase will not do this for you. - Use rsync. For most configuration, a restart is -needed for servers to pick up changes (caveat dynamic config. to be described later below). + When running in distributed mode, after you make an edit to an HBase configuration, make + sure you copy the content of the conf directory to all nodes of the + cluster. HBase will not do this for you. Use rsync. For most configuration, a + restart is needed for servers to pick up changes (caveat dynamic config. to be described later + below). -
+
Basic Prerequisites - This section lists required services and some required system configuration. - + This section lists required services and some required system configuration. -
- Java - Just like Hadoop, HBase requires at least Java 6 from - Oracle. - +
+ Java + Just like Hadoop, HBase requires at least Java 6 from Oracle.
-
- Operating System -
+
+ Operating System +
ssh - ssh must be installed and - sshd must be running to use Hadoop's scripts to - manage remote Hadoop and HBase daemons. You must be able to ssh to all - nodes, including your local node, using passwordless login (Google - "ssh passwordless login"). If on mac osx, see the section, - SSH: Setting up Remote Desktop and Enabling Self-Login - on the hadoop wiki. + ssh must be installed and sshd must be running + to use Hadoop's scripts to manage remote Hadoop and HBase daemons. You must be able to ssh + to all nodes, including your local node, using passwordless login (Google "ssh + passwordless login"). If on mac osx, see the section, SSH: + Setting up Remote Desktop and Enabling Self-Login on the hadoop wiki.
-
+
DNS - HBase uses the local hostname to self-report its IP address. - Both forward and reverse DNS resolving must work in versions of - HBase previous to 0.92.0 - The hadoop-dns-checker tool can be used to verify - DNS is working correctly on the cluster. The project README file provides detailed instructions on usage. -. + HBase uses the local hostname to self-report its IP address. Both forward and reverse + DNS resolving must work in versions of HBase previous to 0.92.0 + The hadoop-dns-checker + tool can be used to verify DNS is working correctly on the cluster. The project README + file provides detailed instructions on usage. + . - If your machine has multiple interfaces, HBase will use the - interface that the primary hostname resolves to. + If your machine has multiple interfaces, HBase will use the interface that the primary + hostname resolves to. If this is insufficient, you can set - hbase.regionserver.dns.interface to indicate the - primary interface. This only works if your cluster configuration is - consistent and every host has the same network interface - configuration. + hbase.regionserver.dns.interface to indicate the primary interface. + This only works if your cluster configuration is consistent and every host has the same + network interface configuration. - Another alternative is setting - hbase.regionserver.dns.nameserver to choose a - different nameserver than the system wide default. + Another alternative is setting hbase.regionserver.dns.nameserver to + choose a different nameserver than the system wide default.
-
+
Loopback IP - Previous to hbase-0.96.0, HBase expects the loopback IP address to be 127.0.0.1. See -
+ Previous to hbase-0.96.0, HBase expects the loopback IP address to be 127.0.0.1. See +
-
+
NTP - The clocks on cluster members should be in basic alignments. - Some skew is tolerable but wild skew could generate odd behaviors. Run - NTP - on your cluster, or an equivalent. + The clocks on cluster members should be in basic alignments. Some skew is tolerable + but wild skew could generate odd behaviors. Run NTP on your + cluster, or an equivalent. - If you are having problems querying data, or "weird" cluster - operations, check system time! + If you are having problems querying data, or "weird" cluster operations, check system + time!
-
+
<varname>ulimit</varname><indexterm> <primary>ulimit</primary> - </indexterm> - and - <varname>nproc</varname><indexterm> + </indexterm> and <varname>nproc</varname><indexterm> <primary>nproc</primary> - </indexterm> + </indexterm> - Apache HBase is a database. It uses a lot of files all at the same time. - The default ulimit -n -- i.e. user file limit -- of 1024 on most *nix systems - is insufficient (On mac os x its 256). Any significant amount of loading will - lead you to . - You may also notice errors such as... - 2010-04-06 03:04:37,542 INFO org.apache.hadoop.hdfs.DFSClient: Exception increateBlockOutputStream java.io.EOFException - 2010-04-06 03:04:37,542 INFO org.apache.hadoop.hdfs.DFSClient: Abandoning block blk_-6935524980745310745_1391901 - Do yourself a favor and change the upper bound on the - number of file descriptors. Set it to north of 10k. The math runs roughly as follows: per ColumnFamily - there is at least one StoreFile and possibly up to 5 or 6 if the region is under load. Multiply the - average number of StoreFiles per ColumnFamily times the number of regions per RegionServer. For example, assuming - that a schema had 3 ColumnFamilies per region with an average of 3 StoreFiles per ColumnFamily, - and there are 100 regions per RegionServer, the JVM will open 3 * 3 * 100 = 900 file descriptors - (not counting open jar files, config files, etc.) - - You should also up the hbase users' - nproc setting; under load, a low-nproc - setting could manifest as OutOfMemoryError - See Jack Levin's major hdfs issues - note up on the user list. - The requirement that a database requires upping of system limits - is not peculiar to Apache HBase. See for example the section - Setting Shell Limits for the Oracle User in - - Short Guide to install Oracle 10 on Linux.. - - - To be clear, upping the file descriptors and nproc for the user who is - running the HBase process is an operating system configuration, not an - HBase configuration. Also, a common mistake is that administrators - will up the file descriptors for a particular user but for whatever - reason, HBase will be running as some one else. HBase prints in its - logs as the first line the ulimit its seeing. Ensure its correct. - - A useful read setting config on you hadoop cluster is Aaron - Kimballs' Configuration - Parameters: What can you just ignore? + Apache HBase is a database. It uses a lot of files all at the same time. The default + ulimit -n -- i.e. user file limit -- of 1024 on most *nix systems is insufficient (On mac + os x its 256). Any significant amount of loading will lead you to . You may also notice errors such as the + following: + +2010-04-06 03:04:37,542 INFO org.apache.hadoop.hdfs.DFSClient: Exception increateBlockOutputStream java.io.EOFException +2010-04-06 03:04:37,542 INFO org.apache.hadoop.hdfs.DFSClient: Abandoning block blk_-6935524980745310745_1391901 + + Do yourself a favor and change the upper bound on the number of file descriptors. Set + it to north of 10k. The math runs roughly as follows: per ColumnFamily there is at least + one StoreFile and possibly up to 5 or 6 if the region is under load. Multiply the average + number of StoreFiles per ColumnFamily times the number of regions per RegionServer. For + example, assuming that a schema had 3 ColumnFamilies per region with an average of 3 + StoreFiles per ColumnFamily, and there are 100 regions per RegionServer, the JVM will open + 3 * 3 * 100 = 900 file descriptors (not counting open jar files, config files, etc.) + You should also up the hbase users' nproc setting; under load, a + low-nproc setting could manifest as OutOfMemoryError. + See Jack Levin's major hdfs issues note up on the user list. + + + The requirement that a database requires upping of system limits is not peculiar + to Apache HBase. See for example the section Setting Shell Limits for the + Oracle User in Short Guide + to install Oracle 10 on Linux. -
+ To be clear, upping the file descriptors and nproc for the user who is running the + HBase process is an operating system configuration, not an HBase configuration. Also, a + common mistake is that administrators will up the file descriptors for a particular user + but for whatever reason, HBase will be running as some one else. HBase prints in its logs + as the first line the ulimit its seeing. Ensure its correct. + A useful read setting config on you hadoop cluster is Aaron Kimballs' Configuration + Parameters: What can you just ignore? + + +
<varname>ulimit</varname> on Ubuntu - If you are on Ubuntu you will need to make the following - changes: + If you are on Ubuntu you will need to make the following changes: - In the file /etc/security/limits.conf add - a line like: hadoop - nofile 32768 - Replace hadoop with whatever user is running - Hadoop and HBase. If you have separate users, you will need 2 - entries, one for each user. In the same file set nproc hard and soft - limits. For example: hadoop soft/hard nproc 32000. + In the file /etc/security/limits.conf add a line like: + hadoop - nofile 32768 + Replace hadoop with whatever user is running Hadoop and HBase. If + you have separate users, you will need 2 entries, one for each user. In the same file + set nproc hard and soft limits. For example: + hadoop soft/hard nproc 32000 + In the file /etc/pam.d/common-session add as the last line in + the file: session required pam_limits.so Otherwise the + changes in /etc/security/limits.conf won't be applied. - In the file /etc/pam.d/common-session add - as the last line in the file: session required pam_limits.so - Otherwise the changes in /etc/security/limits.conf won't be - applied. - - Don't forget to log out and back in again for the changes to - take effect! + Don't forget to log out and back in again for the changes to take effect!
-
+
Windows Previous to hbase-0.96.0, Apache HBase was little tested running on Windows. Running a - production install of HBase on top of Windows is not recommended. + production install of HBase on top of Windows is not recommended. If you are running HBase on Windows pre-hbase-0.96.0, you must install Cygwin to have a *nix-like - environment for the shell scripts. The full details are explained in - the Windows - Installation guide. Also - search our user mailing list to pick - up latest fixes figured by Windows users. - Post-hbase-0.96.0, hbase runs natively on windows with supporting *.cmd scripts bundled. - + xlink:href="http://cygwin.com/">Cygwin to have a *nix-like environment for the + shell scripts. The full details are explained in the Windows Installation guide. Also search + our user mailing list to pick up latest fixes figured by Windows users. + Post-hbase-0.96.0, hbase runs natively on windows with supporting + *.cmd scripts bundled.
-
+
+ -
- <link - xlink:href="http://hadoop.apache.org">Hadoop</link><indexterm> - <primary>Hadoop</primary> - </indexterm> - The below table shows some information about what versions of Hadoop are supported by various HBase versions. - Based on the version of HBase, you should select the most appropriate version of Hadoop. - We are not in the Hadoop distro selection business. - You can use Hadoop distributions from Apache, or learn about vendor distributions of - Hadoop at - - Hadoop 2.x is better than Hadoop 1.x - Hadoop 2.x is faster, with more features such as short-circuit reads which will help improve your - HBase random read profile as well important bug fixes that will improve your overall HBase experience. - You should run Hadoop 2 rather than Hadoop 1. HBase 0.98 deprecates use of Hadoop1. - HBase 1.0 will not support Hadoop1. - - - - Hadoop version support matrix - - - - - - - - - HBase-0.92.xHBase-0.94.xHBase-0.96.xHBase-0.98.xSupport for Hadoop 1.x is deprecated.HBase-1.0.xHadoop 1.x is NOT supported - - Hadoop-0.20.205S X XXX - Hadoop-0.22.x S X XXX - Hadoop-1.0.0-1.0.2HBase requires hadoop 1.0.3 at a minimum; there is an issue where we cannot find KerberosUtil compiling against earlier versions of Hadoop. X X XXX - Hadoop-1.0.3+S S SXX - Hadoop-1.1.x NT S SXX - Hadoop-0.23.x X S NTXX - Hadoop-2.0.x-alpha X NT XXX - Hadoop-2.1.0-beta X NT SXX - Hadoop-2.2.0 X NTTo get 0.94.x to run on hadoop 2.2.0, - you need to change the hadoop 2 and protobuf versions in the pom.xml: - - Here is a diff with pom.xml changes: - - + <link + xlink:href="http://hadoop.apache.org">Hadoop</link><indexterm> + <primary>Hadoop</primary> + </indexterm> + The below table shows some information about what versions of Hadoop are supported by + various HBase versions. Based on the version of HBase, you should select the most + appropriate version of Hadoop. We are not in the Hadoop distro selection business. You can + use Hadoop distributions from Apache, or learn about vendor distributions of Hadoop at + + Hadoop 2.x is better than Hadoop 1.x + Hadoop 2.x is faster, with more features such as short-circuit reads which will help + improve your HBase random read profile as well important bug fixes that will improve your + overall HBase experience. You should run Hadoop 2 rather than Hadoop 1. HBase 0.98 + deprecates use of Hadoop1. HBase 1.0 will not support Hadoop1. + + Use the following legend to interpret this table: + + S = supported and tested, + X = not supported, + NT = it should run, but not tested enough. + + +
+ Hadoop version support matrix + + + + + + + + + + + HBase-0.92.x + HBase-0.94.x + HBase-0.96.x + HBase-0.98.x + Support for Hadoop 1.x is deprecated. + + HBase-1.0.x + Hadoop 1.x is NOT supported + + + + + + Hadoop-0.20.205 + S + X + X + X + X + + + Hadoop-0.22.x + S + X + X + X + X + + + Hadoop-1.0.0-1.0.2 + HBase requires hadoop 1.0.3 at a minimum; there is an issue where we cannot + find KerberosUtil compiling against earlier versions of Hadoop. + + + X + X + X + X + X + + + Hadoop-1.0.3+ + S + S + S + X + X + + + Hadoop-1.1.x + NT + S + S + X + X + + + Hadoop-0.23.x + X + S + NT + X + X + + + Hadoop-2.0.x-alpha + X + NT + X + X + X + + + Hadoop-2.1.0-beta + X + NT + S + X + X + + + Hadoop-2.2.0 + X + NT + To get 0.94.x to run on hadoop 2.2.0, you need to change the hadoop 2 and + protobuf versions in the pom.xml: Here is a diff with + pom.xml changes: + 2.2.0 1.6.1 - ]]> - The next step is to regenerate Protobuf files and assuming that the Protobuf has been installed: - - Go to the hbase root folder, using the command line; - - Type the following commands: - - - - - - - - - - Building against the hadoop 2 profile by running something like the following command: - - $ mvn clean install assembly:single -Dhadoop.profile=2.0 -DskipTests - SSNT - Hadoop-2.3.xX NT SSNT - Hadoop-2.4.xX NT SSS - Hadoop-2.5.xX NT SSS + ]]> + + The next step is to regenerate Protobuf files and assuming that the Protobuf + has been installed: + + + Go to the hbase root folder, using the command line; + + + Type the following commands: + + + + + + + + + Building against the hadoop 2 profile by running something like the + following command: + $ mvn clean install assembly:single -Dhadoop.profile=2.0 -DskipTests + + S + S + NT + + + Hadoop-2.3.x + X + NT + S + S + NT + + + Hadoop-2.4.x + X + NT + S + S + S + + + Hadoop-2.5.x + X + NT + S + S + S + -
+ + + - Where - - S = supported and tested, - X = not supported, - NT = it should run, but not tested enough. - + + Replace the Hadoop Bundled With HBase! + Because HBase depends on Hadoop, it bundles an instance of the Hadoop jar under its + lib directory. The bundled jar is ONLY for use in standalone mode. + In distributed mode, it is critical that the version of Hadoop that + is out on your cluster match what is under HBase. Replace the hadoop jar found in the + HBase lib directory with the hadoop jar you are running on your cluster to avoid version + mismatch issues. Make sure you replace the jar in HBase everywhere on your cluster. Hadoop + version mismatch issues have various manifestations but often all looks like its hung up. - Replace the Hadoop Bundled With HBase! - - Because HBase depends on Hadoop, it bundles an instance of the Hadoop jar under its lib directory. The bundled jar is ONLY for use in standalone mode. In distributed mode, it is critical that the version of Hadoop that is out on your cluster match what is under HBase. Replace the hadoop jar found in the HBase lib directory with the hadoop jar you are running on your cluster to avoid version mismatch issues. Make sure you replace the jar in HBase everywhere on your cluster. Hadoop version mismatch issues have various manifestations but often all looks like its hung up. - - -
- Apache HBase 0.92 and 0.94 - HBase 0.92 and 0.94 versions can work with Hadoop versions, 0.20.205, 0.22.x, 1.0.x, and 1.1.x. HBase-0.94 can additionally work with Hadoop-0.23.x and 2.x, but you may have to recompile the code using the specific maven profile (see top level pom.xml) -
+
+
+ Apache HBase 0.92 and 0.94 + HBase 0.92 and 0.94 versions can work with Hadoop versions, 0.20.205, 0.22.x, 1.0.x, + and 1.1.x. HBase-0.94 can additionally work with Hadoop-0.23.x and 2.x, but you may have + to recompile the code using the specific maven profile (see top level pom.xml) +
-
- Apache HBase 0.96 - - As of Apache HBase 0.96.x, Apache Hadoop 1.0.x at least is required. Hadoop 2 is strongly encouraged (faster but also has fixes that help MTTR). - We will no longer run properly on older Hadoops such as 0.20.205 or branch-0.20-append. Do not move to Apache HBase 0.96.x if you cannot upgrade your HadoopSee HBase, mail # dev - DISCUSS: Have hbase require at least hadoop 1.0.0 in hbase 0.96.0?. -
+
+ Apache HBase 0.96 + As of Apache HBase 0.96.x, Apache Hadoop 1.0.x at least is required. Hadoop 2 is + strongly encouraged (faster but also has fixes that help MTTR). We will no longer run + properly on older Hadoops such as 0.20.205 or branch-0.20-append. Do not move to Apache + HBase 0.96.x if you cannot upgrade your Hadoop. + See HBase, mail # dev - DISCUSS: + Have hbase require at least hadoop 1.0.0 in hbase 0.96.0? + +
-
- Hadoop versions 0.20.x - 1.x - - HBase will lose data unless it is running on an HDFS that has a durable - sync implementation. DO NOT use Hadoop 0.20.2, Hadoop 0.20.203.0, and Hadoop 0.20.204.0 which DO NOT have this attribute. Currently only Hadoop versions 0.20.205.x or any release in excess of this version -- this includes hadoop-1.0.0 -- have a working, durable sync - - The Cloudera blog post An update on Apache Hadoop 1.0 - by Charles Zedlweski has a nice exposition on how all the Hadoop versions relate. - Its worth checking out if you are having trouble making sense of the - Hadoop version morass. - - . Sync has to be explicitly enabled by setting - dfs.support.append equal - to true on both the client side -- in hbase-site.xml - -- and on the serverside in hdfs-site.xml (The sync - facility HBase needs is a subset of the append code path). - - <property> - <name>dfs.support.append</name> - <value>true</value> - </property> - - You will have to restart your cluster after making this edit. Ignore the chicken-little - comment you'll find in the hdfs-default.xml in the - description for the dfs.support.append configuration. - -
-
- Apache HBase on Secure Hadoop - Apache HBase will run on any Hadoop 0.20.x that incorporates Hadoop - security features as long as you do as - suggested above and replace the Hadoop jar that ships with HBase - with the secure version. If you want to read more about how to setup - Secure HBase, see . -
+
+ Hadoop versions 0.20.x - 1.x + HBase will lose data unless it is running on an HDFS that has a durable + sync implementation. DO NOT use Hadoop 0.20.2, Hadoop 0.20.203.0, and + Hadoop 0.20.204.0 which DO NOT have this attribute. Currently only Hadoop versions + 0.20.205.x or any release in excess of this version -- this includes hadoop-1.0.0 -- have + a working, durable sync + The Cloudera blog post An + update on Apache Hadoop 1.0 by Charles Zedlweski has a nice exposition on how + all the Hadoop versions relate. Its worth checking out if you are having trouble + making sense of the Hadoop version morass. + . Sync has to be explicitly enabled by setting + dfs.support.append equal to true on both the client side -- in + hbase-site.xml -- and on the serverside in + hdfs-site.xml (The sync facility HBase needs is a subset of the + append code path). + + dfs.support.append + true +]]> + You will have to restart your cluster after making this edit. Ignore the + chicken-little comment you'll find in the hdfs-default.xml in the + description for the dfs.support.append configuration. +
+
+ Apache HBase on Secure Hadoop + Apache HBase will run on any Hadoop 0.20.x that incorporates Hadoop security features + as long as you do as suggested above and replace the Hadoop jar that ships with HBase with + the secure version. If you want to read more about how to setup Secure HBase, see . +
-
+
<varname>dfs.datanode.max.transfer.threads</varname><indexterm> <primary>xcievers</primary> </indexterm> - An Hadoop HDFS datanode has an upper bound on the number of - files that it will serve at any one time. The upper bound parameter is - called xcievers (yes, this is misspelled). Again, - before doing any loading, make sure you have configured Hadoop's - conf/hdfs-site.xml setting the - xceivers value to at least the following: + An Hadoop HDFS datanode has an upper bound on the number of files that it will serve + at any one time. The upper bound parameter is called xcievers (yes, + this is misspelled). Again, before doing any loading, make sure you have configured + Hadoop's conf/hdfs-site.xml setting the xceivers + value to at least the following: + + dfs.datanode.max.transfer.threads + 4096 + + ]]> + + Be sure to restart your HDFS after making the above configuration. + + Not having this configuration in place makes for strange looking failures. Eventually + you'll see a complain in the datanode logs complaining about the xcievers exceeded, but on + the run up to this one manifestation is complaint about missing blocks. For example: + See Hadoop + HDFS: Deceived by Xciever for an informative rant on xceivering. + + See also + + 10/12/08 20:10:31 INFO hdfs.DFSClient: Could not obtain block + blk_XXXXXXXXXXXXXXXXXXXXXX_YYYYYYYY from any node: java.io.IOException: No live nodes + contain current block. Will get new block locations from namenode and retry... + +
+
+ +
+ +
+ HBase run modes: Standalone and Distributed + + HBase has two run modes: and . Out of the box, HBase runs in standalone mode. Whatever your mode, + you will need to configure HBase by editing files in the HBase conf + directory. At a minimum, you must edit conf/hbase-env.sh to tell HBase which + java to use. In this file you set HBase environment variables such as the + heapsize and other options for the JVM, the preferred location for + log files, etc. Set JAVA_HOME to point at the root of your + java install. + +
+ Standalone HBase + + This is the default mode. Standalone mode is what is described in the section. In standalone mode, HBase does not use HDFS -- it uses + the local filesystem instead -- and it runs all HBase daemons and a local ZooKeeper all up + in the same JVM. Zookeeper binds to a well known port so clients may talk to HBase. +
+ +
+ Distributed + + Distributed mode can be subdivided into distributed but all daemons run on a single node + -- a.k.a pseudo-distributed-- and + fully-distributed where the daemons are spread across all nodes in + the cluster + The pseudo-distributed vs fully-distributed nomenclature comes from Hadoop. + . + + Pseudo-distributed mode can run against the local filesystem or it can run against an + instance of the Hadoop Distributed File System (HDFS). + Fully-distributed mode can ONLY run on HDFS. See the Hadoop + requirements and instructions for how to set up HDFS. + + Below we describe the different distributed setups. Starting, verification and + exploration of your install, whether a pseudo-distributed or + fully-distributed configuration is described in a section that + follows, . The same verification script applies to both deploy types. +
+ Pseudo-distributed + + A pseudo-distributed mode is simply a fully-distributed mode run on a single host. Use + this configuration testing and prototyping on HBase. Do not use this configuration for + production nor for evaluating HBase performance. + + First, if you want to run on HDFS rather than on the local filesystem, setup your + HDFS. You can set up HDFS also in pseudo-distributed mode (TODO: Add pointer to HOWTO doc; + the hadoop site doesn't have any any more). Ensure you have a working HDFS before + proceeding. + + Next, configure HBase. Edit conf/hbase-site.xml. This is the file + into which you add local customizations and overrides. At a minimum, you must tell HBase + to run in (pseudo-)distributed mode rather than in default standalone mode. To do this, + set the hbase.cluster.distributed property to true (Its default is + false). The absolute bare-minimum hbase-site.xml + is therefore as follows: + + + hbase.cluster.distributed + true + + +]]> + + With this configuration, HBase will start up an HBase Master process, a ZooKeeper + server, and a RegionServer process running against the local filesystem writing to + wherever your operating system stores temporary files into a directory named + hbase-YOUR_USER_NAME. + + Such a setup, using the local filesystem and writing to the operating systems's + temporary directory is an ephemeral setup; the Hadoop local filesystem -- which is what + HBase uses when it is writing the local filesytem does not support sync + so unless the system is shutdown properly, the data will be lost. Writing to the operating + system's temporary directory can also make for data loss when the machine is restarted as + this directory is usually cleared on reboot. For a more permanent setup, see the next + example where we make use of an instance of HDFS; HBase data will be written to the Hadoop + distributed filesystem rather than to the local filesystem's tmp directory. + In this conf/hbase-site.xml example, the + hbase.rootdir property points to the local HDFS instance homed on the + node h-24-30.example.com. + + Let HBase create <filename>${hbase.rootdir}</filename> + Let HBase create the hbase.rootdir directory. If you don't, + you'll get warning saying HBase needs a migration run because the directory is missing + files expected by HBase (it'll create them if you let it). + - <property> - <name>dfs.datanode.max.transfer.threads</name> - <value>4096</value> - </property> - - - Be sure to restart your HDFS after making the above - configuration. - - Not having this configuration in place makes for strange looking - failures. Eventually you'll see a complain in the datanode logs - complaining about the xcievers exceeded, but on the run up to this one - manifestation is complaint about missing blocks. For example: - 10/12/08 20:10:31 INFO hdfs.DFSClient: Could not obtain block - blk_XXXXXXXXXXXXXXXXXXXXXX_YYYYYYYY from any node: - java.io.IOException: No live nodes contain current block. Will get new - block locations from namenode and retry... - See Hadoop HDFS: Deceived by Xciever for an informative rant on xceivering. - See also - -
- -
-
- -
- HBase run modes: Standalone and Distributed - - HBase has two run modes: and . Out of the box, HBase runs in - standalone mode. Whatever your mode, you will need to configure HBase by editing files in the HBase conf - directory. At a minimum, you must edit conf/hbase-env.sh to tell HBase which - java to use. In this file you set HBase environment - variables such as the heapsize and other options for the - JVM, the preferred location for log files, - etc. Set JAVA_HOME to point at the root of your - java install. - -
- Standalone HBase - - This is the default mode. Standalone mode is what is described - in the section. In - standalone mode, HBase does not use HDFS -- it uses the local - filesystem instead -- and it runs all HBase daemons and a local - ZooKeeper all up in the same JVM. Zookeeper binds to a well known port - so clients may talk to HBase. -
- -
- Distributed - - Distributed mode can be subdivided into distributed but all - daemons run on a single node -- a.k.a - pseudo-distributed-- and - fully-distributed where the daemons are spread - across all nodes in the cluster - The pseudo-distributed vs fully-distributed nomenclature - comes from Hadoop. - . - - Pseudo-distributed mode can run against the local filesystem or - it can run against an instance of the Hadoop - Distributed File System (HDFS). Fully-distributed mode can - ONLY run on HDFS. See the Hadoop - requirements and instructions for how to set up HDFS. - - Below we describe the different distributed setups. Starting, - verification and exploration of your install, whether a - pseudo-distributed or - fully-distributed configuration is described in a - section that follows, . The same verification script applies to both - deploy types. - - - - - - -
- Pseudo-distributed - - A pseudo-distributed mode is simply a fully-distributed mode run on - a single host. Use this configuration testing and prototyping on - HBase. Do not use this configuration for production nor for - evaluating HBase performance. - - First, if you want to run on HDFS rather than on the local filesystem, - setup your HDFS. You can set up HDFS also in pseudo-distributed mode - (TODO: Add pointer to HOWTO doc; the hadoop site doesn't have any any more). - Ensure you have a working HDFS before proceeding. - - - Next, configure HBase. Edit conf/hbase-site.xml. - This is the file into which you add local customizations and overrides. - At a minimum, you must tell HBase to run in (pseudo-)distributed mode rather than - in default standalone mode. To do this, set the hbase.cluster.distributed - property to true (Its default is false). The absolute bare-minimum - hbase-site.xml is therefore as follows: - -<configuration> - <property> - <name>hbase.cluster.distributed</name> - <value>true</value> - </property> -</configuration> - -With this configuration, HBase will start up an HBase Master process, a ZooKeeper server, -and a RegionServer process running against the -local filesystem writing to wherever your operating system stores temporary files into a directory -named hbase-YOUR_USER_NAME. - -Such a setup, using the local filesystem and -writing to the operating systems's temporary directory is an ephemeral setup; the Hadoop -local filesystem -- which is what HBase uses when it is writing the local filesytem does not -support sync so unless the system is shutdown properly, the data will be lost. Writing to -the operating system's temporary directory can also make for data loss when the machine -is restarted as this directory is usually cleared on reboot. For a more permanent -setup, see the next example where we make use of an instance of HDFS; HBase data will -be written to the Hadoop distributed filesystem rather than to the local filesystem's -tmp directory. -In this conf/hbase-site.xml example, the -hbase.rootdir property points to the local HDFS instance -homed on the node h-24-30.example.com. - - Let HBase create <filename>${hbase.rootdir}</filename> - Let HBase create the hbase.rootdir - directory. If you don't, you'll get warning saying HBase needs a - migration run because the directory is missing files expected by - HBase (it'll create them if you let it). - - <configuration> <property> <name>hbase.rootdir</name> @@ -523,315 +644,296 @@ homed on the node h-24-30.example.com. <value>true</value> </property> </configuration> - - - Now skip to for how to start and verify your - pseudo-distributed install. - See for notes on how to start extra Masters and - RegionServers when running pseudo-distributed. - + -
- Pseudo-distributed Extras + Now skip to for how to start and verify your pseudo-distributed install. + See for notes on how to start extra Masters and RegionServers + when running pseudo-distributed. + -
- Startup - To start up the initial HBase cluster... - % bin/start-hbase.sh - - To start up an extra backup master(s) on the same server run... - % bin/local-master-backup.sh start 1 - ... the '1' means use ports 16001 & 16011, and this backup master's - logfile will be at - logs/hbase-${USER}-1-master-${HOSTNAME}.log. - - To startup multiple backup masters run... % bin/local-master-backup.sh start 2 3 You can start up to 9 backup masters (10 total). - - To start up more regionservers... - % bin/local-regionservers.sh start 1 - ... where '1' means use ports 16201 & 16301 and its logfile will be at - `logs/hbase-${USER}-1-regionserver-${HOSTNAME}.log. - - To add 4 more regionservers in addition to the one you just started by running... % bin/local-regionservers.sh start 2 3 4 5 - This supports up to 99 extra regionservers (100 total). - -
-
- Stop - Assuming you want to stop master backup # 1, run... - % cat /tmp/hbase-${USER}-1-master.pid |xargs kill -9 - Note that bin/local-master-backup.sh stop 1 will try to stop the cluster along with the master. - - To stop an individual regionserver, run... - % bin/local-regionservers.sh stop 1 - - -
+
+ Pseudo-distributed Extras -
+
+ Startup + To start up the initial HBase cluster... + % bin/start-hbase.sh + To start up an extra backup master(s) on the same server run... + % bin/local-master-backup.sh start 1 + ... the '1' means use ports 16001 & 16011, and this backup master's logfile + will be at logs/hbase-${USER}-1-master-${HOSTNAME}.log. + To startup multiple backup masters run... + % bin/local-master-backup.sh start 2 3 + You can start up to 9 backup masters (10 total). + To start up more regionservers... + % bin/local-regionservers.sh start 1 + ... where '1' means use ports 16201 & 16301 and its logfile will be at + `logs/hbase-${USER}-1-regionserver-${HOSTNAME}.log. + To add 4 more regionservers in addition to the one you just started by + running... + % bin/local-regionservers.sh start 2 3 4 5 + This supports up to 99 extra regionservers (100 total). +
+
+ Stop + Assuming you want to stop master backup # 1, run... + % cat /tmp/hbase-${USER}-1-master.pid |xargs kill -9 + Note that bin/local-master-backup.sh stop 1 will try to stop the cluster along + with the master. + To stop an individual regionserver, run... + % bin/local-regionservers.sh stop 1 +
+
-
- Fully-distributed - For running a fully-distributed operation on more than one - host, make the following configurations. In - hbase-site.xml, add the property - hbase.cluster.distributed and set it to - true and point the HBase - hbase.rootdir at the appropriate HDFS NameNode - and location in HDFS where you would like HBase to write data. For - example, if you namenode were running at namenode.example.org on - port 8020 and you wanted to home your HBase in HDFS at - /hbase, make the following - configuration. +
+ Fully-distributed - -<configuration> + For running a fully-distributed operation on more than one host, make the following + configurations. In hbase-site.xml, add the property + hbase.cluster.distributed and set it to true and + point the HBase hbase.rootdir at the appropriate HDFS NameNode and + location in HDFS where you would like HBase to write data. For example, if you namenode + were running at namenode.example.org on port 8020 and you wanted to home your HBase in + HDFS at /hbase, make the following configuration. + + ... - <property> - <name>hbase.rootdir</name> - <value>hdfs://namenode.example.org:8020/hbase</value> - <description>The directory shared by RegionServers. - </description> - </property> - <property> - <name>hbase.cluster.distributed</name> - <value>true</value> - <description>The mode the cluster will be in. Possible values are + + hbase.rootdir + hdfs://namenode.example.org:8020/hbase + The directory shared by RegionServers. + + + + hbase.cluster.distributed + true + The mode the cluster will be in. Possible values are false: standalone and pseudo-distributed setups with managed Zookeeper true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh) - </description> - </property> + + ... -</configuration> - + +]]> + -
- <filename>regionservers</filename> +
+ <filename>regionservers</filename> - In addition, a fully-distributed mode requires that you - modify conf/regionservers. The - file - lists all hosts that you would have running - HRegionServers, one host per line (This - file in HBase is like the Hadoop slaves - file). All servers listed in this file will be started and stopped - when HBase cluster start or stop is run. -
+ In addition, a fully-distributed mode requires that you modify + conf/regionservers. The file lists all hosts that you would have running + HRegionServers, one host per line (This file in HBase is + like the Hadoop slaves file). All servers listed in this file will + be started and stopped when HBase cluster start or stop is run. +
-
- ZooKeeper and HBase - See section for ZooKeeper setup for HBase. -
+
+ ZooKeeper and HBase + See section for ZooKeeper setup for HBase. +
-
- HDFS Client Configuration +
+ HDFS Client Configuration - Of note, if you have made HDFS client - configuration on your Hadoop cluster -- i.e. - configuration you want HDFS clients to use as opposed to - server-side configurations -- HBase will not see this - configuration unless you do one of the following: + Of note, if you have made HDFS client configuration on your + Hadoop cluster -- i.e. configuration you want HDFS clients to use as opposed to + server-side configurations -- HBase will not see this configuration unless you do one of + the following: - - - Add a pointer to your HADOOP_CONF_DIR - to the HBASE_CLASSPATH environment variable - in hbase-env.sh. - + + + Add a pointer to your HADOOP_CONF_DIR to the + HBASE_CLASSPATH environment variable in + hbase-env.sh. + - - Add a copy of hdfs-site.xml (or - hadoop-site.xml) or, better, symlinks, - under ${HBASE_HOME}/conf, or - + + Add a copy of hdfs-site.xml (or + hadoop-site.xml) or, better, symlinks, under + ${HBASE_HOME}/conf, or + - - if only a small set of HDFS client configurations, add - them to hbase-site.xml. - - + + if only a small set of HDFS client configurations, add them to + hbase-site.xml. + + - An example of such an HDFS client configuration is - dfs.replication. If for example, you want to - run with a replication factor of 5, hbase will create files with - the default of 3 unless you do the above to make the configuration - available to HBase. -
+ An example of such an HDFS client configuration is + dfs.replication. If for example, you want to run with a replication + factor of 5, hbase will create files with the default of 3 unless you do the above to + make the configuration available to HBase.
+
-
- Running and Confirming Your Installation +
+ Running and Confirming Your Installation - Make sure HDFS is running first. Start and stop the Hadoop HDFS - daemons by running bin/start-hdfs.sh over in the - HADOOP_HOME directory. You can ensure it started - properly by testing the put and - get of files into the Hadoop filesystem. HBase does - not normally use the mapreduce daemons. These do not need to be - started. + Make sure HDFS is running first. Start and stop the Hadoop HDFS daemons by running + bin/start-hdfs.sh over in the HADOOP_HOME + directory. You can ensure it started properly by testing the put and + get of files into the Hadoop filesystem. HBase does not normally use + the mapreduce daemons. These do not need to be started. + If you are managing your own ZooKeeper, start it and confirm its + running else, HBase will start up ZooKeeper for you as part of its start process. + Start HBase with the following command: + bin/start-hbase.sh + Run the above from the HBASE_HOME directory. + You should now have a running HBase instance. HBase logs can be found in the + logs subdirectory. Check them out especially if HBase had trouble + starting. + + HBase also puts up a UI listing vital attributes. By default its deployed on the Master + host at port 16010 (HBase RegionServers listen on port 16020 by default and put up an + informational http server at 16030). If the Master were running on a host named + master.example.org on the default port, to see the Master's homepage + you'd point your browser at http://master.example.org:16010. + + Prior to HBase 0.98, the default ports the master ui was deployed on port 16010, and the + HBase RegionServers would listen on port 16020 by default and put up an informational http + server at 16030. + + Once HBase has started, see the for how to create tables, add data, scan your insertions, and + finally disable and drop your tables. + + To stop HBase after exiting the HBase shell enter + $ ./bin/stop-hbase.sh +stopping hbase............... + Shutdown can take a moment to complete. It can take longer if your cluster is comprised + of many machines. If you are running a distributed operation, be sure to wait until HBase + has shut down completely before stopping the Hadoop daemons. +
+
+ - If you are managing your own ZooKeeper, - start it and confirm its running else, HBase will start up ZooKeeper - for you as part of its start process. +
+ Configuration Files - - - Start HBase with the following command: - - - - bin/start-hbase.sh - - Run the above from the HBASE_HOME directory. - - You should now have a running HBase instance. HBase logs can be - found in the logs subdirectory. Check them out - especially if HBase had trouble starting. - - - - HBase also puts up a UI listing vital attributes. By default its - deployed on the Master host at port 16010 (HBase RegionServers listen - on port 16020 by default and put up an informational http server at - 16030). If the Master were running on a host named - master.example.org on the default port, to see the - Master's homepage you'd point your browser at - http://master.example.org:16010. - - Prior to HBase 0.98, the default ports the master ui was deployed - on port 16010, and the HBase RegionServers would listen - on port 16020 by default and put up an informational http server at - 16030. - - - Once HBase has started, see the for how to - create tables, add data, scan your insertions, and finally disable and - drop your tables. - - - - To stop HBase after exiting the HBase shell enter - $ ./bin/stop-hbase.sh -stopping hbase............... Shutdown can take a moment to - complete. It can take longer if your cluster is comprised of many - machines. If you are running a distributed operation, be sure to wait - until HBase has shut down completely before stopping the Hadoop - daemons. - - -
-
- - - -
- Configuration Files - -
- <filename>hbase-site.xml</filename> and <filename>hbase-default.xml</filename> - Just as in Hadoop where you add site-specific HDFS configuration - to the hdfs-site.xml file, - for HBase, site specific customizations go into - the file conf/hbase-site.xml. - For the list of configurable properties, see - - below or view the raw hbase-default.xml - source file in the HBase source code at - src/main/resources. - - - Not all configuration options make it out to - hbase-default.xml. Configuration - that it is thought rare anyone would change can exist only - in code; the only way to turn up such configurations is - via a reading of the source code itself. - - - Currently, changes here will require a cluster restart for HBase to notice the change. - - - - + + -
- +
+ <para> - <emphasis>This file is fallback content</emphasis>. If you are seeing this, something is wrong with the build of the HBase documentation or you are doing pre-build verification. - </para> - <para> - The file hbase-default.xml is generated as part of - the build of the hbase site. See the hbase <filename>pom.xml</filename>. - The generated file is a docbook glossary. - </para> + <emphasis>This file is fallback content</emphasis>. If you are seeing this, something + is wrong with the build of the HBase documentation or you are doing pre-build + verification. </para> + <para> The file hbase-default.xml is generated as part of the build of the hbase site. + See the hbase <filename>pom.xml</filename>. The generated file is a docbook glossary. </para> <section> <title>IDs that are auto-generated and cause validation errors if not present - - Each of these is a reference to a configuration file parameter which will cause an error if you are using the fallback content here. This is a dirty dirty hack. - -
+ Each of these is a reference to a configuration file parameter which will cause + an error if you are using the fallback content here. This is a dirty dirty hack. +
fail.fast.expired.active.master
-
+
"hbase.hregion.memstore.flush.size"
-
+
hbase.hstore.bytes.per.checksum
-
+
hbase.online.schema.update.enable
-
+
hbase.regionserver.global.memstore.size
-
+
hbase.hregion.max.filesize
-
+
hbase.hstore.BlockingStoreFiles
-
+
hfile.block.cache.size
-
+
copy.table
-
+
hbase.hstore.checksum.algorithm
-
+
hbase.zookeeper.useMulti
-
+
hbase.hregion.memstore.block.multiplier
-
+
hbase.regionserver.global.memstore.size.lower.limit
@@ -841,52 +943,45 @@ stopping hbase............... Shutdown can take a moment to
-
+
<filename>hbase-env.sh</filename> - Set HBase environment variables in this file. - Examples include options to pass the JVM on start of - an HBase daemon such as heap size and garbage collector configs. - You can also set configurations for HBase configuration, log directories, - niceness, ssh options, where to locate process pid files, - etc. Open the file at - conf/hbase-env.sh and peruse its content. - Each option is fairly well documented. Add your own environment - variables here if you want them read by HBase daemons on startup. - - Changes here will require a cluster restart for HBase to notice the change. - -
+ Set HBase environment variables in this file. Examples include options to pass the JVM + on start of an HBase daemon such as heap size and garbage collector configs. You can also + set configurations for HBase configuration, log directories, niceness, ssh options, where to + locate process pid files, etc. Open the file at conf/hbase-env.sh and + peruse its content. Each option is fairly well documented. Add your own environment + variables here if you want them read by HBase daemons on startup. + Changes here will require a cluster restart for HBase to notice the change. +
-
+
<filename>log4j.properties</filename> - Edit this file to change rate at which HBase files - are rolled and to change the level at which HBase logs messages. - - - Changes here will require a cluster restart for HBase to notice the change - though log levels can be changed for particular daemons via the HBase UI. - -
+ Edit this file to change rate at which HBase files are rolled and to change the level at + which HBase logs messages. + Changes here will require a cluster restart for HBase to notice the change though log + levels can be changed for particular daemons via the HBase UI. +
-
Client configuration and dependencies connecting to an HBase cluster - If you are running HBase in standalone mode, you don't need to configure anything for your client to work - provided that they are all on the same machine. - - Since the HBase Master may move around, clients bootstrap by looking to ZooKeeper for - current critical locations. ZooKeeper is where all these values are kept. Thus clients - require the location of the ZooKeeper ensemble information before they can do anything else. - Usually this the ensemble location is kept out in the hbase-site.xml and - is picked up by the client from the CLASSPATH. +
+ Client configuration and dependencies connecting to an HBase cluster + If you are running HBase in standalone mode, you don't need to configure anything for + your client to work provided that they are all on the same machine. + Since the HBase Master may move around, clients bootstrap by looking to ZooKeeper for + current critical locations. ZooKeeper is where all these values are kept. Thus clients + require the location of the ZooKeeper ensemble information before they can do anything else. + Usually this the ensemble location is kept out in the hbase-site.xml + and is picked up by the client from the CLASSPATH. - If you are configuring an IDE to run a HBase client, you should - include the conf/ directory on your classpath so - hbase-site.xml settings can be found (or - add src/test/resources to pick up the hbase-site.xml - used by tests). - - - Minimally, a client of HBase needs several libraries in its CLASSPATH when connecting to a cluster, including: - + If you are configuring an IDE to run a HBase client, you should include the + conf/ directory on your classpath so + hbase-site.xml settings can be found (or add + src/test/resources to pick up the hbase-site.xml used by tests). + Minimally, a client of HBase needs several libraries in its + CLASSPATH when connecting to a cluster, including: + commons-configuration (commons-configuration-1.6.jar) commons-lang (commons-lang-2.5.jar) commons-logging (commons-logging-1.1.1.jar) @@ -897,10 +992,8 @@ slf4j-api (slf4j-api-1.5.8.jar) slf4j-log4j (slf4j-log4j12-1.5.8.jar) zookeeper (zookeeper-3.4.2.jar) - - An example basic hbase-site.xml for client only - might look as follows: - An example basic hbase-site.xml for client only might look as + follows: @@ -912,124 +1005,123 @@ zookeeper (zookeeper-3.4.2.jar) ]]> - + -
+
Java client configuration - The configuration used by a Java client is kept - in an HBaseConfiguration instance. - The factory method on HBaseConfiguration, HBaseConfiguration.create();, - on invocation, will read in the content of the first hbase-site.xml found on - the client's CLASSPATH, if one is present - (Invocation will also factor in any hbase-default.xml found; - an hbase-default.xml ships inside the hbase.X.X.X.jar). - It is also possible to specify configuration directly without having to read from a - hbase-site.xml. For example, to set the ZooKeeper - ensemble for the cluster programmatically do as follows: - Configuration config = HBaseConfiguration.create(); + The configuration used by a Java client is kept in an HBaseConfiguration + instance. The factory method on HBaseConfiguration, + HBaseConfiguration.create();, on invocation, will read in the content of + the first hbase-site.xml found on the client's + CLASSPATH, if one is present (Invocation will also factor in any + hbase-default.xml found; an hbase-default.xml ships inside the + hbase.X.X.X.jar). It is also possible to specify configuration + directly without having to read from a hbase-site.xml. For example, + to set the ZooKeeper ensemble for the cluster programmatically do as follows: + Configuration config = HBaseConfiguration.create(); config.set("hbase.zookeeper.quorum", "localhost"); // Here we are running zookeeper locally - If multiple ZooKeeper instances make up your ZooKeeper ensemble, - they may be specified in a comma-separated list (just as in the hbase-site.xml file). - This populated Configuration instance can then be passed to an - HTable, - and so on. - -
-
+ If multiple ZooKeeper instances make up your ZooKeeper ensemble, they may be specified in + a comma-separated list (just as in the hbase-site.xml file). This + populated Configuration instance can then be passed to an HTable, + and so on. +
+
-
+
+ -
- Example Configurations +
+ Example Configurations -
- Basic Distributed HBase Install +
+ Basic Distributed HBase Install - Here is an example basic configuration for a distributed ten - node cluster. The nodes are named example0, - example1, etc., through node - example9 in this example. The HBase Master and the - HDFS namenode are running on the node example0. - RegionServers run on nodes - example1-example9. A 3-node - ZooKeeper ensemble runs on example1, - example2, and example3 on the - default ports. ZooKeeper data is persisted to the directory - /export/zookeeper. Below we show what the main - configuration files -- hbase-site.xml, - regionservers, and - hbase-env.sh -- found in the HBase - conf directory might look like. + Here is an example basic configuration for a distributed ten node cluster. The nodes are + named example0, example1, etc., through node + example9 in this example. The HBase Master and the HDFS namenode are + running on the node example0. RegionServers run on nodes + example1-example9. A 3-node ZooKeeper ensemble runs + on example1, example2, and example3 + on the default ports. ZooKeeper data is persisted to the directory + /export/zookeeper. Below we show what the main configuration files -- + hbase-site.xml, regionservers, and + hbase-env.sh -- found in the HBase conf + directory might look like. -
- <filename>hbase-site.xml</filename> +
+ <filename>hbase-site.xml</filename> - - -<?xml version="1.0"?> -<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> -<configuration> - <property> - <name>hbase.zookeeper.quorum</name> - <value>example1,example2,example3</value> - <description>The directory shared by RegionServers. - </description> - </property> - <property> - <name>hbase.zookeeper.property.dataDir</name> - <value>/export/zookeeper</value> - <description>Property from ZooKeeper's config zoo.cfg. + + + + + + hbase.zookeeper.quorum + example1,example2,example3 + The directory shared by RegionServers. + + + + hbase.zookeeper.property.dataDir + /export/zookeeper + Property from ZooKeeper's config zoo.cfg. The directory where the snapshot is stored. - </description> - </property> - <property> - <name>hbase.rootdir</name> - <value>hdfs://example0:8020/hbase</value> - <description>The directory shared by RegionServers. - </description> - </property> - <property> - <name>hbase.cluster.distributed</name> - <value>true</value> - <description>The mode the cluster will be in. Possible values are + + + + hbase.rootdir + hdfs://example0:8020/hbase + The directory shared by RegionServers. + + + + hbase.cluster.distributed + true + The mode the cluster will be in. Possible values are false: standalone and pseudo-distributed setups with managed Zookeeper true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh) - </description> - </property> -</configuration> + + + +]]> + +
- -
+
+ <filename>regionservers</filename> -
- <filename>regionservers</filename> + In this file you list the nodes that will run RegionServers. In our case, these nodes + are example1-example9. - In this file you list the nodes that will run RegionServers. - In our case, these nodes are example1-example9. - + +example1 +example2 +example3 +example4 +example5 +example6 +example7 +example8 +example9 + +
- - example1 - example2 - example3 - example4 - example5 - example6 - example7 - example8 - example9 - -
+
+ <filename>hbase-env.sh</filename> -
- <filename>hbase-env.sh</filename> + Below we use a diff to show the differences from default in the + hbase-env.sh file. Here we are setting the HBase heap to be 4G + instead of the default 1G. - Below we use a diff to show the differences - from default in the hbase-env.sh file. Here we - are setting the HBase heap to be 4G instead of the default - 1G. - - + $ git diff hbase-env.sh diff --git a/conf/hbase-env.sh b/conf/hbase-env.sh @@ -1046,257 +1138,278 @@ index e70ebc6..96f8c27 100644 # Extra Java runtime options. # Below are what we set by default. May only work with SUN JVM. - + - Use rsync to copy the content of the - conf directory to all nodes of the - cluster. + Use rsync to copy the content of the conf + directory to all nodes of the cluster. +
+
+
+ + + +
+ The Important Configurations + Below we list what the important Configurations. We've divided this + section into required configuration and worth-a-look recommended configs. + + +
+ Required Configurations + Review the and sections. +
+ Big Cluster Configurations + If a cluster with a lot of regions, it is possible if an eager beaver regionserver + checks in soon after master start while all the rest in the cluster are laggardly, this + first server to checkin will be assigned all regions. If lots of regions, this first + server could buckle under the load. To prevent the above scenario happening up the + hbase.master.wait.on.regionservers.mintostart from its default value + of 1. See HBASE-6389 Modify the + conditions to ensure that Master waits for sufficient number of Region Servers before + starting region assignments for more detail. +
+
+ If a backup Master, making primary Master fail fast + If the primary Master loses its connection with ZooKeeper, it will fall into a loop + where it keeps trying to reconnect. Disable this functionality if you are running more + than one Master: i.e. a backup Master. Failing to do so, the dying Master may continue to + receive RPCs though another Master has assumed the role of primary. See the configuration . +
+
+ +
+ Recommended Configurations +
+ ZooKeeper Configuration +
+ <varname>zookeeper.session.timeout</varname> + The default timeout is three minutes (specified in milliseconds). This means that if + a server crashes, it will be three minutes before the Master notices the crash and + starts recovery. You might like to tune the timeout down to a minute or even less so the + Master notices failures the sooner. Before changing this value, be sure you have your + JVM garbage collection configuration under control otherwise, a long garbage collection + that lasts beyond the ZooKeeper session timeout will take out your RegionServer (You + might be fine with this -- you probably want recovery to start on the server if a + RegionServer has been in GC for a long period of time). + + To change this configuration, edit hbase-site.xml, copy the + changed file around the cluster and restart. + + We set this value high to save our having to field noob questions up on the mailing + lists asking why a RegionServer went down during a massive import. The usual cause is + that their JVM is untuned and they are running into long GC pauses. Our thinking is that + while users are getting familiar with HBase, we'd save them having to know all of its + intricacies. Later when they've built some confidence, then they can play with + configuration such as this. +
+
+ Number of ZooKeeper Instances + See .
-
- - -
- The Important Configurations - Below we list what the important - Configurations. We've divided this section into - required configuration and worth-a-look recommended configs. - - - -
Required Configurations - Review the and sections. - -
Big Cluster Configurations - If a cluster with a lot of regions, it is possible if an eager beaver - regionserver checks in soon after master start while all the rest in the - cluster are laggardly, this first server to checkin will be assigned all - regions. If lots of regions, this first server could buckle under the - load. To prevent the above scenario happening up the - hbase.master.wait.on.regionservers.mintostart from its - default value of 1. See - HBASE-6389 Modify the conditions to ensure that Master waits for sufficient number of Region Servers before starting region assignments - for more detail. - +
+ HDFS Configurations +
+ dfs.datanode.failed.volumes.tolerated + This is the "...number of volumes that are allowed to fail before a datanode stops + offering service. By default any volume failure will cause a datanode to shutdown" from + the hdfs-default.xml description. If you have > three or four + disks, you might want to set this to 1 or if you have many disks, two or more. +
-
If a backup Master, making primary Master fail fast - If the primary Master loses its connection with ZooKeeper, it will fall into a loop where it - keeps trying to reconnect. Disable this functionality if you are running more than one Master: - i.e. a backup Master. Failing to do so, the dying Master may continue to receive RPCs though - another Master has assumed the role of primary. - See the configuration . - - +
+ <varname>hbase.regionserver.handler.count</varname> + This setting defines the number of threads that are kept open to answer incoming + requests to user tables. The rule of thumb is to keep this number low when the payload per + request approaches the MB (big puts, scans using a large cache) and high when the payload + is small (gets, small puts, ICVs, deletes). The total size of the queries in progress is + limited by the setting "ipc.server.max.callqueue.size". + It is safe to set that number to the maximum number of incoming clients if their + payload is small, the typical example being a cluster that serves a website since puts + aren't typically buffered and most of the operations are gets. + The reason why it is dangerous to keep this setting high is that the aggregate size + of all the puts that are currently happening in a region server may impose too much + pressure on its memory, or even trigger an OutOfMemoryError. A region server running on + low memory will trigger its JVM's garbage collector to run more frequently up to a point + where GC pauses become noticeable (the reason being that all the memory used to keep all + the requests' payloads cannot be trashed, no matter how hard the garbage collector tries). + After some time, the overall cluster throughput is affected since every request that hits + that region server will take longer, which exacerbates the problem even more. + You can get a sense of whether you have too little or too many handlers by on an individual RegionServer then tailing its logs (Queued + requests consume memory).
-
- -
Recommended Configurations -
- ZooKeeper Configuration -
<varname>zookeeper.session.timeout</varname> - The default timeout is three minutes (specified in milliseconds). This means - that if a server crashes, it will be three minutes before the Master notices - the crash and starts recovery. You might like to tune the timeout down to - a minute or even less so the Master notices failures the sooner. - Before changing this value, be sure you have your JVM garbage collection - configuration under control otherwise, a long garbage collection that lasts - beyond the ZooKeeper session timeout will take out - your RegionServer (You might be fine with this -- you probably want recovery to start - on the server if a RegionServer has been in GC for a long period of time). - - To change this configuration, edit hbase-site.xml, - copy the changed file around the cluster and restart. - - We set this value high to save our having to field noob questions up on the mailing lists asking - why a RegionServer went down during a massive import. The usual cause is that their JVM is untuned and - they are running into long GC pauses. Our thinking is that - while users are getting familiar with HBase, we'd save them having to know all of its - intricacies. Later when they've built some confidence, then they can play - with configuration such as this. - -
-
Number of ZooKeeper Instances - See . - -
-
-
- HDFS Configurations -
- dfs.datanode.failed.volumes.tolerated - This is the "...number of volumes that are allowed to fail before a datanode stops offering service. By default - any volume failure will cause a datanode to shutdown" from the hdfs-default.xml - description. If you have > three or four disks, you might want to set this to 1 or if you have many disks, - two or more. - -
-
-
<varname>hbase.regionserver.handler.count</varname> - - This setting defines the number of threads that are kept open to answer - incoming requests to user tables. The rule of thumb is to keep this - number low when the payload per request approaches the MB (big puts, scans using - a large cache) and high when the payload is small (gets, small puts, ICVs, deletes). - The total size of the queries in progress is limited by the setting - "ipc.server.max.callqueue.size". - - - It is safe to set that number to the - maximum number of incoming clients if their payload is small, the typical example - being a cluster that serves a website since puts aren't typically buffered - and most of the operations are gets. - - - The reason why it is dangerous to keep this setting high is that the aggregate - size of all the puts that are currently happening in a region server may impose - too much pressure on its memory, or even trigger an OutOfMemoryError. A region server - running on low memory will trigger its JVM's garbage collector to run more frequently - up to a point where GC pauses become noticeable (the reason being that all the memory - used to keep all the requests' payloads cannot be trashed, no matter how hard the - garbage collector tries). After some time, the overall cluster - throughput is affected since every request that hits that region server will take longer, - which exacerbates the problem even more. - - You can get a sense of whether you have too little or too many handlers by - - on an individual RegionServer then tailing its logs (Queued requests - consume memory). - -
-
+
Configuration for large memory machines - - HBase ships with a reasonable, conservative configuration that will - work on nearly all - machine types that people might want to test with. If you have larger - machines -- HBase has 8G and larger heap -- you might the following configuration options helpful. - TODO. - + HBase ships with a reasonable, conservative configuration that will work on nearly + all machine types that people might want to test with. If you have larger machines -- + HBase has 8G and larger heap -- you might the following configuration options helpful. + TODO.
-
- Compression - You should consider enabling ColumnFamily compression. There are several options that are near-frictionless and in most all cases boost - performance by reducing the size of StoreFiles and thus reducing I/O. - - See for more information. +
+ Compression + You should consider enabling ColumnFamily compression. There are several options that + are near-frictionless and in most all cases boost performance by reducing the size of + StoreFiles and thus reducing I/O. + See for more information.
-
Configuring the size and number of WAL files - HBase uses to recover the memstore data that has not been flushed to disk in case of an RS failure. These WAL files should be configured to be slightly smaller than HDFS block (by default, HDFS block is 64Mb and WAL file is ~60Mb). - HBase also has a limit on number of WAL files, designed to ensure there's never too much data that needs to be replayed during recovery. This limit needs to be set according to memstore configuration, so that all the necessary data would fit. It is recommended to allocated enough WAL files to store at least that much data (when all memstores are close to full). - For example, with 16Gb RS heap, default memstore settings (0.4), and default WAL file size (~60Mb), 16Gb*0.4/60, the starting point for WAL file count is ~109. - However, as all memstores are not expected to be full all the time, less WAL files can be allocated. +
+ Configuring the size and number of WAL files + HBase uses to recover the memstore data that has not been flushed to disk in case + of an RS failure. These WAL files should be configured to be slightly smaller than HDFS + block (by default, HDFS block is 64Mb and WAL file is ~60Mb). + HBase also has a limit on number of WAL files, designed to ensure there's never too + much data that needs to be replayed during recovery. This limit needs to be set according + to memstore configuration, so that all the necessary data would fit. It is recommended to + allocated enough WAL files to store at least that much data (when all memstores are close + to full). For example, with 16Gb RS heap, default memstore settings (0.4), and default WAL + file size (~60Mb), 16Gb*0.4/60, the starting point for WAL file count is ~109. However, as + all memstores are not expected to be full all the time, less WAL files can be + allocated.
-
- Managed Splitting - - Rather than let HBase auto-split your Regions, manage the splitting manually - What follows is taken from the javadoc at the head of - the org.apache.hadoop.hbase.util.RegionSplitter tool - added to HBase post-0.90.0 release. - - . - With growing amounts of data, splits will continually be needed. Since - you always know exactly what regions you have, long-term debugging and - profiling is much easier with manual splits. It is hard to trace the logs to - understand region level problems if it keeps splitting and getting renamed. - Data offlining bugs + unknown number of split regions == oh crap! If an - HLog or StoreFile - was mistakenly unprocessed by HBase due to a weird bug and - you notice it a day or so later, you can be assured that the regions - specified in these files are the same as the current regions and you have - less headaches trying to restore/replay your data. - You can finely tune your compaction algorithm. With roughly uniform data - growth, it's easy to cause split / compaction storms as the regions all - roughly hit the same data size at the same time. With manual splits, you can - let staggered, time-based major compactions spread out your network IO load. - - - How do I turn off automatic splitting? Automatic splitting is determined by the configuration value - hbase.hregion.max.filesize. It is not recommended that you set this - to Long.MAX_VALUE in case you forget about manual splits. A suggested setting - is 100GB, which would result in > 1hr major compactions if reached. - - What's the optimal number of pre-split regions to create? - Mileage will vary depending upon your application. - You could start low with 10 pre-split regions / server and watch as data grows - over time. It's better to err on the side of too little regions and rolling split later. - A more complicated answer is that this depends upon the largest storefile - in your region. With a growing data size, this will get larger over time. You - want the largest region to be just big enough that the Store compact - selection algorithm only compacts it due to a timed major. If you don't, your - cluster can be prone to compaction storms as the algorithm decides to run - major compactions on a large series of regions all at once. Note that - compaction storms are due to the uniform data growth, not the manual split - decision. - - If you pre-split your regions too thin, you can increase the major compaction -interval by configuring HConstants.MAJOR_COMPACTION_PERIOD. If your data size -grows too large, use the (post-0.90.0 HBase) org.apache.hadoop.hbase.util.RegionSplitter -script to perform a network IO safe rolling split -of all regions. - +
+ Managed Splitting + Rather than let HBase auto-split your Regions, manage the splitting manually + What follows is taken from the javadoc at the head of the + org.apache.hadoop.hbase.util.RegionSplitter tool added to + HBase post-0.90.0 release. + . With growing amounts of data, splits will continually be needed. Since you + always know exactly what regions you have, long-term debugging and profiling is much + easier with manual splits. It is hard to trace the logs to understand region level + problems if it keeps splitting and getting renamed. Data offlining bugs + unknown number + of split regions == oh crap! If an HLog or + StoreFile was mistakenly unprocessed by HBase due to a weird bug + and you notice it a day or so later, you can be assured that the regions specified in + these files are the same as the current regions and you have less headaches trying to + restore/replay your data. You can finely tune your compaction algorithm. With roughly + uniform data growth, it's easy to cause split / compaction storms as the regions all + roughly hit the same data size at the same time. With manual splits, you can let + staggered, time-based major compactions spread out your network IO load. + How do I turn off automatic splitting? Automatic splitting is determined by the + configuration value hbase.hregion.max.filesize. It is not recommended that + you set this to Long.MAX_VALUE in case you forget about manual splits. + A suggested setting is 100GB, which would result in > 1hr major compactions if reached. + What's the optimal number of pre-split regions to create? Mileage will vary depending + upon your application. You could start low with 10 pre-split regions / server and watch as + data grows over time. It's better to err on the side of too little regions and rolling + split later. A more complicated answer is that this depends upon the largest storefile in + your region. With a growing data size, this will get larger over time. You want the + largest region to be just big enough that the Store compact + selection algorithm only compacts it due to a timed major. If you don't, your cluster can + be prone to compaction storms as the algorithm decides to run major compactions on a large + series of regions all at once. Note that compaction storms are due to the uniform data + growth, not the manual split decision. + If you pre-split your regions too thin, you can increase the major compaction + interval by configuring HConstants.MAJOR_COMPACTION_PERIOD. If your + data size grows too large, use the (post-0.90.0 HBase) + org.apache.hadoop.hbase.util.RegionSplitter script to perform a + network IO safe rolling split of all regions.
-
Managed Compactions - A common administrative technique is to manage major compactions manually, rather than letting - HBase do it. By default, HConstants.MAJOR_COMPACTION_PERIOD is one day and major compactions - may kick in when you least desire it - especially on a busy system. To turn off automatic major compactions set - the value to 0. - - It is important to stress that major compactions are absolutely necessary for StoreFile cleanup, the only variant is when - they occur. They can be administered through the HBase shell, or via - HBaseAdmin. - - For more information about compactions and the compaction file selection process, see +
+ Managed Compactions + A common administrative technique is to manage major compactions manually, rather than + letting HBase do it. By default, HConstants.MAJOR_COMPACTION_PERIOD is + one day and major compactions may kick in when you least desire it - especially on a busy + system. To turn off automatic major compactions set the value to 0. + It is important to stress that major compactions are absolutely necessary for + StoreFile cleanup, the only variant is when they occur. They can be administered through + the HBase shell, or via HBaseAdmin. + For more information about compactions and the compaction file selection process, see
-
Speculative Execution - Speculative Execution of MapReduce tasks is on by default, and for HBase clusters it is generally advised to turn off - Speculative Execution at a system-level unless you need it for a specific case, where it can be configured per-job. - Set the properties mapreduce.map.speculative and - mapreduce.reduce.speculative to false. - +
+ Speculative Execution + Speculative Execution of MapReduce tasks is on by default, and for HBase clusters it + is generally advised to turn off Speculative Execution at a system-level unless you need + it for a specific case, where it can be configured per-job. Set the properties + mapreduce.map.speculative and + mapreduce.reduce.speculative to false.
-
- -
Other Configurations -
Balancer - The balancer is a periodic operation which is run on the master to redistribute regions on the cluster. It is configured via - hbase.balancer.period and defaults to 300000 (5 minutes). - See for more information on the LoadBalancer. - -
-
Disabling Blockcache - Do not turn off block cache (You'd do it by setting hbase.block.cache.size to zero). - Currently we do not do well if you do this because the regionserver will spend all its time loading hfile - indices over and over again. If your working set it such that block cache does you no good, at least - size the block cache such that hfile indices will stay up in the cache (you can get a rough idea - on the size you need by surveying regionserver UIs; you'll see index block size accounted near the - top of the webpage). -
-
- <link xlink:href="http://en.wikipedia.org/wiki/Nagle's_algorithm">Nagle's</link> or the small package problem - If a big 40ms or so occasional delay is seen in operations against HBase, - try the Nagles' setting. For example, see the user mailing list thread, - Inconsistent scan performance with caching set to 1 - and the issue cited therein where setting notcpdelay improved scan speeds. You might also - see the graphs on the tail of HBASE-7008 Set scanner caching to a better default - where our Lars Hofhansl tries various data sizes w/ Nagle's on and off measuring the effect.
-
- Better Mean Time to Recover (MTTR) - This section is about configurations that will make servers come back faster after a fail. - See the Deveraj Das an Nicolas Liochon blog post - Introduction to HBase Mean Time to Recover (MTTR) - for a brief introduction. - The issue HBASE-8354 forces Namenode into loop with lease recovery requests - is messy but has a bunch of good discussion toward the end on low timeouts and how to effect faster recovery including citation of fixes - added to HDFS. Read the Varun Sharma comments. The below suggested configurations are Varun's suggestions distilled and tested. Make sure you are - running on a late-version HDFS so you have the fixes he refers too and himself adds to HDFS that help HBase MTTR - (e.g. HDFS-3703, HDFS-3712, and HDFS-4791 -- hadoop 2 for sure has them and late hadoop 1 has some). - Set the following in the RegionServer. - + +
+ Other Configurations +
+ Balancer + The balancer is a periodic operation which is run on the master to redistribute + regions on the cluster. It is configured via hbase.balancer.period and + defaults to 300000 (5 minutes). + See for more information on the LoadBalancer. + +
+
+ Disabling Blockcache + Do not turn off block cache (You'd do it by setting + hbase.block.cache.size to zero). Currently we do not do well if you + do this because the regionserver will spend all its time loading hfile indices over and + over again. If your working set it such that block cache does you no good, at least size + the block cache such that hfile indices will stay up in the cache (you can get a rough + idea on the size you need by surveying regionserver UIs; you'll see index block size + accounted near the top of the webpage). +
+
+ <link + xlink:href="http://en.wikipedia.org/wiki/Nagle's_algorithm">Nagle's</link> or the small + package problem + If a big 40ms or so occasional delay is seen in operations against HBase, try the + Nagles' setting. For example, see the user mailing list thread, Inconsistent + scan performance with caching set to 1 and the issue cited therein where setting + notcpdelay improved scan speeds. You might also see the graphs on the tail of HBASE-7008 Set scanner + caching to a better default where our Lars Hofhansl tries various data sizes w/ + Nagle's on and off measuring the effect. +
+
+ Better Mean Time to Recover (MTTR) + This section is about configurations that will make servers come back faster after a + fail. See the Deveraj Das an Nicolas Liochon blog post Introduction + to HBase Mean Time to Recover (MTTR) for a brief introduction. + The issue HBASE-8354 forces Namenode + into loop with lease recovery requests is messy but has a bunch of good + discussion toward the end on low timeouts and how to effect faster recovery including + citation of fixes added to HDFS. Read the Varun Sharma comments. The below suggested + configurations are Varun's suggestions distilled and tested. Make sure you are running on + a late-version HDFS so you have the fixes he refers too and himself adds to HDFS that help + HBase MTTR (e.g. HDFS-3703, HDFS-3712, and HDFS-4791 -- hadoop 2 for sure has them and + late hadoop 1 has some). Set the following in the RegionServer. + hbase.lease.recovery.dfs.timeout 23000 How much time we allow elapse between calls to recover lease. @@ -1307,8 +1420,11 @@ of all regions. 10000 Down the DFS timeout from 60 to 10 seconds. ]]> -And on the namenode/datanode side, set the following to enable 'staleness' introduced in HDFS-3703, HDFS-3912. - + + + And on the namenode/datanode side, set the following to enable 'staleness' introduced + in HDFS-3703, HDFS-3912. + dfs.client.socket-timeout 10000 Down the DFS timeout from 60 to 10 seconds. @@ -1343,12 +1459,12 @@ And on the namenode/datanode side, set the following to enable 'staleness' intro true Enable stale state in hdfs ]]> - - -
- +
-
+
- +
+ + + diff --git a/src/main/docbkx/cp.xml b/src/main/docbkx/cp.xml index 71f0c75785b..0dac7b76a5f 100644 --- a/src/main/docbkx/cp.xml +++ b/src/main/docbkx/cp.xml @@ -1,12 +1,15 @@ - - Apache HBase Coprocessors - The idea of HBase coprocessors was inspired by Google's BigTable coprocessors. The Apache HBase Blog on Coprocessor is a very good documentation on that. It has detailed information about the coprocessor framework, terminology, management, and so on. - + The idea of HBase coprocessors was inspired by Google's BigTable coprocessors. The Apache HBase Blog + on Coprocessor is a very good documentation on that. It has detailed information about + the coprocessor framework, terminology, management, and so on. - diff --git a/src/main/docbkx/developer.xml b/src/main/docbkx/developer.xml index 92eadb58f00..73d7cac0e67 100644 --- a/src/main/docbkx/developer.xml +++ b/src/main/docbkx/developer.xml @@ -1,13 +1,15 @@ - - +
+
Submitting a patch again - - Sometimes committers ask for changes for a patch. After incorporating the suggested/requested changes, follow the following process to submit the patch again. - + Sometimes committers ask for changes for a patch. After incorporating the + suggested/requested changes, follow the following process to submit the patch again. Do not delete the old patch file @@ -1341,20 +1432,22 @@ Bar bar = foo.getBar(); <--- imagine there's an extra space(s) after the 'Cancel Patch' on JIRA.. bug status will change back to Open - Attach new patch file (e.g. HBASE_XXXX-v2.patch) using 'Files --> Attach' + Attach new patch file (e.g. HBASE_XXXX-v2.patch) using 'Files --> + Attach' - Click on 'Submit Patch'. Now the bug status will say 'Patch Available'. + Click on 'Submit Patch'. Now the bug status will say 'Patch + Available'. - Committers will review the patch. Rinse and repeat as many times as needed :-) + Committers will review the patch. Rinse and repeat as many times as needed + :-)
Submitting incremental patches - - At times you may want to break a big change into mulitple patches. Here is a sample work-flow using git - + At times you may want to break a big change into mulitple patches. Here is a + sample work-flow using git patch 1: @@ -1374,7 +1467,8 @@ Bar bar = foo.getBar(); <--- imagine there's an extra space(s) after the save your work $ git add file1 file2 $ git commit -am 'saved after HBASE_XXXX-1.patch' - now you have your own branch, that is different from remote master branch + now you have your own branch, that is different from remote + master branch make more changes... diff --git a/src/main/docbkx/external_apis.xml b/src/main/docbkx/external_apis.xml index 81b823b4b30..69f53656f52 100644 --- a/src/main/docbkx/external_apis.xml +++ b/src/main/docbkx/external_apis.xml @@ -1,13 +1,15 @@ - - Getting Started - +
Introduction - - will get you up and - running on a single-node, standalone instance of HBase. - + + will get you up and running on a single-node, standalone instance of + HBase.
- -
+ +
Quick Start - - This guide describes setup of a standalone HBase instance. It will - run against the local filesystem. In later sections we will take you through - how to run HBase on Apache Hadoop's HDFS, a distributed filesystem. This section - shows you how to create a table in HBase, inserting - rows into your new HBase table via the HBase shell, and then cleaning - up and shutting down your standalone, local filesystem-based HBase instance. The below exercise - should take no more than ten minutes (not including download time). - - Local Filesystem and Durability - Using HBase with a LocalFileSystem does not currently guarantee durability. - The HDFS local filesystem implementation will lose edits if files are not properly - closed -- which is very likely to happen when experimenting with a new download. - You need to run HBase on HDFS to ensure all writes are preserved. Running - against the local filesystem though will get you off the ground quickly and get you - familiar with how the general system works so lets run with it for now. See - and its associated issues for more details. - - Loopback IP - The below advice is for hbase-0.94.x and older versions only. We believe this fixed in hbase-0.96.0 and beyond - (let us know if we have it wrong). There should be no need of the below modification to /etc/hosts in - later versions of HBase. - - HBase expects the loopback IP address to be 127.0.0.1. Ubuntu and some other distributions, - for example, will default to 127.0.1.1 and this will cause problems for you - See Why does HBase care about /etc/hosts? for detail.. - - /etc/hosts should look something like this: - - 127.0.0.1 localhost - 127.0.0.1 ubuntu.ubuntu-domain ubuntu - - + + This guide describes setup of a standalone HBase instance. It will run against the local + filesystem. In later sections we will take you through how to run HBase on Apache Hadoop's + HDFS, a distributed filesystem. This section shows you how to create a table in HBase, + inserting rows into your new HBase table via the HBase shell, and then + cleaning up and shutting down your standalone, local filesystem-based HBase instance. The + below exercise should take no more than ten minutes (not including download time). + + Local Filesystem and Durability + Using HBase with a LocalFileSystem does not currently guarantee durability. The HDFS + local filesystem implementation will lose edits if files are not properly closed -- which is + very likely to happen when experimenting with a new download. You need to run HBase on HDFS + to ensure all writes are preserved. Running against the local filesystem though will get you + off the ground quickly and get you familiar with how the general system works so lets run + with it for now. See and its associated issues + for more details. - - + + Loopback IP + The below advice is for hbase-0.94.x and older versions only. We believe this + fixed in hbase-0.96.0 and beyond (let us know if we have it wrong). There + should be no need of the below modification to /etc/hosts in later + versions of HBase. + + HBase expects the loopback IP address to be 127.0.0.1. Ubuntu and some other + distributions, for example, will default to 127.0.1.1 and this will cause problems for you + See Why does + HBase care about /etc/hosts? for detail. + . + /etc/hosts should look something like this: + +127.0.0.1 localhost +127.0.0.1 ubuntu.ubuntu-domain ubuntu + + + + +
Download and unpack the latest stable release. - + Choose a download site from this list of Apache Download - Mirrors. Click on the suggested top link. This will take you to a - mirror of HBase Releases. Click on the folder named - stable and then download the file that ends in - .tar.gz to your local filesystem; e.g. - hbase-0.94.2.tar.gz. - - Decompress and untar your download and then change into the - unpacked directory. - - $ tar xfz hbase-.tar.gz -$ cd hbase- - - - At this point, you are ready to start HBase. But before starting - it, edit conf/hbase-site.xml, the file you write - your site-specific configurations into. Set - hbase.rootdir, the directory HBase writes data to, - and hbase.zookeeper.property.dataDir, the directory - ZooKeeper writes its data too: - <?xml version="1.0"?> -<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> -<configuration> - <property> - <name>hbase.rootdir</name> - <value>file:///DIRECTORY/hbase</value> - </property> - <property> - <name>hbase.zookeeper.property.dataDir</name> - <value>/DIRECTORY/zookeeper</value> - </property> -</configuration> Replace DIRECTORY in the above with the - path to the directory you would have HBase and ZooKeeper write their data. By default, - hbase.rootdir is set to /tmp/hbase-${user.name} - and similarly so for the default ZooKeeper data location which means you'll lose all - your data whenever your server reboots unless you change it (Most operating systems clear - /tmp on restart). + xlink:href="http://www.apache.org/dyn/closer.cgi/hbase/">Apache Download Mirrors. + Click on the suggested top link. This will take you to a mirror of HBase + Releases. Click on the folder named stable and then + download the file that ends in .tar.gz to your local filesystem; e.g. + hbase-0.94.2.tar.gz. + + Decompress and untar your download and then change into the unpacked directory. + + .tar.gz +$ cd hbase-]]> + + + At this point, you are ready to start HBase. But before starting it, edit + conf/hbase-site.xml, the file you write your site-specific + configurations into. Set hbase.rootdir, the directory HBase writes data + to, and hbase.zookeeper.property.dataDir, the directory ZooKeeper writes + its data too: + + + + + hbase.rootdir + file:///DIRECTORY/hbase + + + hbase.zookeeper.property.dataDir + /DIRECTORY/zookeeper + +]]> + Replace DIRECTORY in the above with the path to the directory you + would have HBase and ZooKeeper write their data. By default, + hbase.rootdir is set to /tmp/hbase-${user.name} + and similarly so for the default ZooKeeper data location which means you'll lose all your + data whenever your server reboots unless you change it (Most operating systems clear + /tmp on restart).
- -
+ +
Start HBase - - Now start HBase:$ ./bin/start-hbase.sh -starting Master, logging to logs/hbase-user-master-example.org.out - - You should now have a running standalone HBase instance. In - standalone mode, HBase runs all daemons in the the one JVM; i.e. both - the HBase and ZooKeeper daemons. HBase logs can be found in the - logs subdirectory. Check them out especially if - it seems HBase had trouble starting. - + + Now start HBase: + $ ./bin/start-hbase.sh +starting Master, logging to logs/hbase-user-master-example.org.out + + You should now have a running standalone HBase instance. In standalone mode, HBase runs + all daemons in the the one JVM; i.e. both the HBase and ZooKeeper daemons. HBase logs can be + found in the logs subdirectory. Check them out especially if it seems + HBase had trouble starting. + Is <application>java</application> installed? - - All of the above presumes a 1.6 version of Oracle - java is installed on your machine and - available on your path (See ); i.e. when you type - java, you see output that describes the - options the java program takes (HBase requires java 6). If this is not - the case, HBase will not start. Install java, edit - conf/hbase-env.sh, uncommenting the - JAVA_HOME line pointing it to your java install, then, + + All of the above presumes a 1.6 version of Oracle java is + installed on your machine and available on your path (See ); i.e. when you type java, you see output + that describes the options the java program takes (HBase requires java 6). If this is not + the case, HBase will not start. Install java, edit conf/hbase-env.sh, + uncommenting the JAVA_HOME line pointing it to your java install, then, retry the steps above.
- -
+ +
Shell Exercises - + Connect to your running HBase via the shell. - - $ ./bin/hbase shell -HBase Shell; enter 'help<RETURN>' for list of supported commands. -Type "exit<RETURN>" to leave the HBase Shell + + ' for list of supported commands. +Type "exit" to leave the HBase Shell Version: 0.90.0, r1001068, Fri Sep 24 13:55:42 PDT 2010 -hbase(main):001:0> - - Type help and then - <RETURN> to see a listing of shell commands and - options. Browse at least the paragraphs at the end of the help emission - for the gist of how variables and command arguments are entered into the - HBase shell; in particular note how table names, rows, and columns, - etc., must be quoted. - - Create a table named test with a single column family named cf. - Verify its creation by listing all tables and then insert some +hbase(main):001:0>]]> + + Type help and then <RETURN> to see a listing + of shell commands and options. Browse at least the paragraphs at the end of the help + emission for the gist of how variables and command arguments are entered into the HBase + shell; in particular note how table names, rows, and columns, etc., must be quoted. + + Create a table named test with a single column family named + cf. Verify its creation by listing all tables and then insert some values. - - hbase(main):003:0> create 'test', 'cf' + + create 'test', 'cf' 0 row(s) in 1.2200 seconds -hbase(main):003:0> list 'test' +hbase(main):003:0> list 'test' .. 1 row(s) in 0.0550 seconds -hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1' +hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1' 0 row(s) in 0.0560 seconds -hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2' +hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2' 0 row(s) in 0.0370 seconds -hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3' -0 row(s) in 0.0450 seconds - +hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3' +0 row(s) in 0.0450 seconds]]> + Above we inserted 3 values, one at a time. The first insert is at - row1, column cf:a with a value of - value1. Columns in HBase are comprised of a column family prefix -- - cf in this example -- followed by a colon and then a - column qualifier suffix (a in this case). - + row1, column cf:a with a value of + value1. Columns in HBase are comprised of a column family prefix -- + cf in this example -- followed by a colon and then a column qualifier + suffix (a in this case). + Verify the data insert by running a scan of the table as follows - - hbase(main):007:0> scan 'test' + + scan 'test' ROW COLUMN+CELL row1 column=cf:a, timestamp=1288380727188, value=value1 row2 column=cf:b, timestamp=1288380738440, value=value2 row3 column=cf:c, timestamp=1288380747365, value=value3 -3 row(s) in 0.0590 seconds - +3 row(s) in 0.0590 seconds]]> + Get a single row - - hbase(main):008:0> get 'test', 'row1' + + get 'test', 'row1' COLUMN CELL cf:a timestamp=1288380727188, value=value1 -1 row(s) in 0.0400 seconds - - Now, disable and drop your table. This will clean up all done - above. - - hbase(main):012:0> disable 'test' +1 row(s) in 0.0400 seconds]]> + + Now, disable and drop your table. This will clean up all done above. + + h disable 'test' 0 row(s) in 1.0930 seconds -hbase(main):013:0> drop 'test' -0 row(s) in 0.0770 seconds - +hbase(main):013:0> drop 'test' +0 row(s) in 0.0770 seconds ]]> + Exit the shell by typing exit. - - hbase(main):014:0> exit + + exit]]>
- -
+ +
Stopping HBase - + Stop your hbase instance by running the stop script. - - $ ./bin/stop-hbase.sh -stopping hbase............... + + $ ./bin/stop-hbase.sh +stopping hbase...............
- +
Where to go next - - The above described standalone setup is good for testing and - experiments only. In the next chapter, , - we'll go into depth on the different HBase run modes, system requirements - running HBase, and critical configurations setting up a distributed HBase deploy. + + The above described standalone setup is good for testing and experiments only. In the + next chapter, , we'll go into depth on the different HBase run modes, system + requirements running HBase, and critical configurations setting up a distributed HBase + deploy.
- + diff --git a/src/main/docbkx/ops_mgt.xml b/src/main/docbkx/ops_mgt.xml index 34c5471d179..0fdc1f285d5 100644 --- a/src/main/docbkx/ops_mgt.xml +++ b/src/main/docbkx/ops_mgt.xml @@ -1,8 +1,14 @@ - + Apache HBase Operational Management This chapter will cover operational tools and practices required of a running Apache HBase - cluster. The subject of operations is related to the topics of , , and but is a distinct topic in - itself. + cluster. The subject of operations is related to the topics of , , and but is a distinct topic in itself. -
+
HBase Tools and Utilities Here we list HBase tools for administration, analysis, fixup, and debugging. -
+
Canary There is a Canary class can help users to canary-test the HBase cluster status, with every column-family for every regions or regionservers granularity. To see the usage, use @@ -61,10 +70,20 @@ private static final int ERROR_EXIT_CODE = 4; the 3 regionservers. see following table. - - - - + + + + RegionServer @@ -81,7 +100,7 @@ private static final int ERROR_EXIT_CODE = 4; rs2 r2 - + rs3 @@ -94,7 +113,7 @@ private static final int ERROR_EXIT_CODE = 4; Following are some examples based on the previous given case.
Canary test for every column family (store) of every region of every table - $ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary + $ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary 3/12/09 03:26:32 INFO tool.Canary: read from region test-01,,1386230156732.0e3c7d77ffb6361ea1b996ac1042ca9a. column family cf1 in 2ms 13/12/09 03:26:32 INFO tool.Canary: read from region test-01,,1386230156732.0e3c7d77ffb6361ea1b996ac1042ca9a. column family cf2 in 2ms @@ -105,7 +124,7 @@ private static final int ERROR_EXIT_CODE = 4; 13/12/09 03:26:32 INFO tool.Canary: read from region test-02,,1386559511167.aa2951a86289281beee480f107bb36ee. column family cf2 in 3ms 13/12/09 03:26:32 INFO tool.Canary: read from region test-02,0004883,1386559511167.cbda32d5e2e276520712d84eaaa29d84. column family cf1 in 31ms 13/12/09 03:26:32 INFO tool.Canary: read from region test-02,0004883,1386559511167.cbda32d5e2e276520712d84eaaa29d84. column family cf2 in 8ms - + So you can see, table test-01 has two regions and two column families, so the Canary tool will pick 4 small piece of data from 4 (2 region * 2 store) different stores. This is a default behavior of the this tool does. @@ -115,23 +134,23 @@ private static final int ERROR_EXIT_CODE = 4; Canary test for every column family (store) of every region of specific table(s) You can also test one or more specific tables. - $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary test-01 test-02 + $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary test-01 test-02
Canary test with regionserver granularity This will pick one small piece of data from each regionserver, and can also put your resionserver name as input options for canary-test specific regionservers. - $ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -regionserver + $ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -regionserver 13/12/09 06:05:17 INFO tool.Canary: Read from table:test-01 on region server:rs2 in 72ms 13/12/09 06:05:17 INFO tool.Canary: Read from table:test-02 on region server:rs3 in 34ms -13/12/09 06:05:17 INFO tool.Canary: Read from table:test-01 on region server:rs1 in 56ms +13/12/09 06:05:17 INFO tool.Canary: Read from table:test-01 on region server:rs1 in 56ms
Canary test with regular expression pattern This will test both table test-01 and test-02. - $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary -e test-0[1-2] + $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary -e test-0[1-2]
@@ -139,10 +158,10 @@ private static final int ERROR_EXIT_CODE = 4; Run repeatedly with interval defined in option -interval whose default value is 6 seconds. This daemon will stop itself and return non-zero error code if any error occurs, due to the default value of option -f is true. - $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary -daemon + $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary -daemon Run repeatedly with internal 5 seconds and will not stop itself even error occurs in the test. - $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary -daemon -interval 50000 -f false + $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary -daemon -interval 50000 -f false
@@ -152,23 +171,26 @@ private static final int ERROR_EXIT_CODE = 4; Master, which would bring the clients hung. So we provide the timeout option to kill the canary test forcefully and return non-zero error code as well. This run sets the timeout value to 60 seconds, the default value is 600 seconds. - $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary -t 600000 + $ ${HBASE_HOME}/bin/hbase orghapache.hadoop.hbase.tool.Canary -t 600000
-
+
Health Checker You can configure HBase to run a script on a period and if it fails N times - (configurable), have the server exit. See HBASE-7351 Periodic health - check script for configurations and detail. + (configurable), have the server exit. See HBASE-7351 Periodic health check script for configurations and + detail.
-
+
Driver There is a Driver class that is executed by the HBase jar can be used to invoke frequently accessed utilities. For example, - HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-VERSION.jar + HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-VERSION.jar An example program must be given as the first argument. Valid program names are: @@ -179,45 +201,52 @@ Valid program names are: importtsv: Import data in TSV format. rowcounter: Count rows in HBase table verifyrep: Compare the data from tables in two different clusters. WARNING: It doesn't work for incrementColumnValues'd cells since the timestamp is chan - +
-
+
HBase <application>hbck</application> An fsck for your HBase install To run hbck against your HBase cluster run $ ./bin/hbase hbck At the end of the command's output it prints - OK or INCONSISTENCY. If your cluster reports + OK or INCONSISTENCY. If your cluster reports inconsistencies, pass -details to see more detail emitted. If inconsistencies, run hbck a few times because the inconsistency may be transient (e.g. cluster is starting up or a region is splitting). Passing -fix may correct the inconsistency (This latter is an experimental feature). - For more information, see . + For more information, see .
-
+
HFile Tool - See . + See .
-
+
WAL Tools -
+
<classname>FSHLog</classname> tool The main method on FSHLog offers manual split and dump facilities. Pass it WALs or the product of a split, the content of the recovered.edits. directory. - You can get a textual dump of a WAL file content by doing the - following: $ ./bin/hbase org.apache.hadoop.hbase.regionserver.wal.FSHLog --dump hdfs://example.org:8020/hbase/.logs/example.org,60020,1283516293161/10.10.21.10%3A60020.1283973724012 The - return code will be non-zero if issues with the file so you can test wholesomeness of file - by redirecting STDOUT to /dev/null and testing the program - return. + You can get a textual dump of a WAL file content by doing the following: + $ ./bin/hbase org.apache.hadoop.hbase.regionserver.wal.FSHLog --dump hdfs://example.org:8020/hbase/.logs/example.org,60020,1283516293161/10.10.21.10%3A60020.1283973724012 + The return code will be non-zero if issues with the file so you can test wholesomeness + of file by redirecting STDOUT to /dev/null and testing the + program return. - Similarly you can force a split of a log file directory by - doing: $ ./bin/hbase org.apache.hadoop.hbase.regionserver.wal.FSHLog --split hdfs://example.org:8020/hbase/.logs/example.org,60020,1283516293161/ + Similarly you can force a split of a log file directory by doing: + $ ./bin/hbase org.apache.hadoop.hbase.regionserver.wal.FSHLog --split hdfs://example.org:8020/hbase/.logs/example.org,60020,1283516293161/ -
+
<classname>HLogPrettyPrinter</classname> HLogPrettyPrinter is a tool with configurable options to print the contents of an HLog. @@ -225,46 +254,67 @@ Valid program names are:
-
+
Compression Tool - See . + See .
-
+
CopyTable CopyTable is a utility that can copy part or of all of a table, either to the same cluster or another cluster. The target table must first exist. The usage is as follows: - $ bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable [--starttime=X] [--endtime=Y] [--new.name=NEW] [--peer.adr=ADR] tablename - + $ bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable [--starttime=X] [--endtime=Y] [--new.name=NEW] [--peer.adr=ADR] tablename + - + Options - - starttime Beginning of the time range. Without endtime means - starttime to forever. - - - endtime End of the time range. Without endtime means starttime to - forever. - - - versions Number of cell versions to copy. - - - new.name New table's name. - - - peer.adr Address of the peer cluster given in the format - hbase.zookeeper.quorum:hbase.zookeeper.client.port:zookeeper.znode.parent - - - families Comma-separated list of ColumnFamilies to copy. - - - all.cells Also copy delete markers and uncollected deleted cells - (advanced option). - - + + starttime + + Beginning of the time range. Without endtime means starttime to forever. + + + + endtime + + End of the time range. Without endtime means starttime to forever. + + + + versions + + Number of cell versions to copy. + + + + new.name + + New table's name. + + + + peer.adr + + Address of the peer cluster given in the format + hbase.zookeeper.quorum:hbase.zookeeper.client.port:zookeeper.znode.parent + + + + families + + Comma-separated list of ColumnFamilies to copy. + + + + all.cells + + Also copy delete markers and uncollected deleted cells (advanced option). + + + Args: @@ -273,9 +323,9 @@ Valid program names are: Example of copying 'TestTable' to a cluster that uses replication for a 1 hour window: - $ bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable + $ bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --starttime=1265875194289 --endtime=1265878794289 ---peer.adr=server1,server2,server3:2181:/hbase TestTable +--peer.adr=server1,server2,server3:2181:/hbase TestTable Scanner Caching Caching for the input Scan is configured via hbase.client.scanner.caching @@ -287,49 +337,54 @@ Valid program names are: --versions=n is explicitly specified in the command. See Jonathan Hsieh's Online HBase Backups with CopyTable blog post for more on - CopyTable. + xlink:href="http://www.cloudera.com/blog/2012/06/online-hbase-backups-with-copytable-2/">Online + HBase Backups with CopyTable blog post for more on CopyTable. +
-
+
Export Export is a utility that will dump the contents of table to HDFS in a sequence file. Invoke via: - $ bin/hbase org.apache.hadoop.hbase.mapreduce.Export <tablename> <outputdir> [<versions> [<starttime> [<endtime>]]] - + $ bin/hbase org.apache.hadoop.hbase.mapreduce.Export <tablename> <outputdir> [<versions> [<starttime> [<endtime>]]] + Note: caching for the input Scan is configured via hbase.client.scanner.caching in the job configuration.
-
+
Import Import is a utility that will load data that has been exported back into HBase. Invoke via: - $ bin/hbase org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir> - + $ bin/hbase org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir> + 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: - $ bin/hbase -Dhbase.import.version=0.94 org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir> - + $ bin/hbase -Dhbase.import.version=0.94 org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir> +
-
+
ImportTsv ImportTsv is a utility that will load data in TSV format into HBase. 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. To load data via Puts (i.e., non-bulk loading): - $ bin/hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.columns=a,b,c <tablename> <hdfs-inputdir> - + $ bin/hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.columns=a,b,c <tablename> <hdfs-inputdir> + To generate StoreFiles for bulk-loading: $ bin/hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.columns=a,b,c -Dimporttsv.bulk.output=hdfs://storefile-outputdir <tablename> <hdfs-data-inputdir> - These generated StoreFiles can be loaded into HBase via . -
+ These generated StoreFiles can be loaded into HBase via . +
ImportTsv Options - Running ImportTsv with no arguments prints brief usage information: - + Running ImportTsv with no arguments prints brief usage + information: + Usage: importtsv -Dimporttsv.columns=a,b,c <tablename> <inputdir> Imports the given input directory of TSV data into the specified table. @@ -352,14 +407,15 @@ Other options that may be specified with -D include: '-Dimporttsv.separator=|' - eg separate on pipes instead of tabs -Dimporttsv.timestamp=currentTimeAsLong - use the specified timestamp for the import -Dimporttsv.mapper.class=my.Mapper - A user-defined Mapper to use instead of org.apache.hadoop.hbase.mapreduce.TsvImporterMapper - +
-
+
ImportTsv Example For example, assume that we are loading data into a table called 'datatsv' with a ColumnFamily called 'd' with two columns "c1" and "c2". Assume that an input file exists as follows: - + row1 c1 c2 row2 c1 c2 row3 c1 c2 @@ -370,51 +426,56 @@ row7 c1 c2 row8 c1 c2 row9 c1 c2 row10 c1 c2 - + For ImportTsv to use this imput file, the command line needs to look like this: - + HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-VERSION.jar importtsv -Dimporttsv.columns=HBASE_ROW_KEY,d:c1,d:c2 -Dimporttsv.bulk.output=hdfs://storefileoutput datatsv hdfs://inputfile - + ... and in this example the first column is the rowkey, which is why the HBASE_ROW_KEY is used. The second and third columns in the file will be imported as "d:c1" and "d:c2", respectively.
-
+
ImportTsv Warning If you have preparing a lot of data for bulk loading, make sure the target HBase table is pre-split appropriately.
-
+
See Also For more information about bulk-loading HFiles into HBase, see + linkend="arch.bulk.load" />
-
+
CompleteBulkLoad The completebulkload utility will move generated StoreFiles into an HBase - table. This utility is often used in conjunction with output from . + table. This utility is often used in conjunction with output from . There are two ways to invoke this utility, with explicit classname and via the driver: - $ bin/hbase org.apache.hadoop.hbase.mapreduce.LoadIncrementalHFiles <hdfs://storefileoutput> <tablename> - + $ bin/hbase org.apache.hadoop.hbase.mapreduce.LoadIncrementalHFiles <hdfs://storefileoutput> <tablename> + .. and via the Driver.. - HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-VERSION.jar completebulkload <hdfs://storefileoutput> <tablename> - -
+ HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-VERSION.jar completebulkload <hdfs://storefileoutput> <tablename> + +
CompleteBulkLoad Warning Data generated via MapReduce is often created with file permissions that are not compatible with the running HBase process. Assuming you're running HDFS with permissions enabled, those permissions will need to be updated before you run CompleteBulkLoad. For more information about bulk-loading HFiles into HBase, see . + linkend="arch.bulk.load" />.
-
+
WALPlayer WALPlayer is a utility to replay WAL files into HBase. The WAL can be replayed for a set of tables or all tables, and a timerange can be @@ -423,32 +484,32 @@ row10 c1 c2 WALPlayer can also generate HFiles for later bulk importing, in that case only a single table and no mapping can be specified. Invoke via: - $ bin/hbase org.apache.hadoop.hbase.mapreduce.WALPlayer [options] <wal inputdir> <tables> [<tableMappings>]> - + $ bin/hbase org.apache.hadoop.hbase.mapreduce.WALPlayer [options] <wal inputdir> <tables> [<tableMappings>]> + For example: - $ bin/hbase org.apache.hadoop.hbase.mapreduce.WALPlayer /backuplogdir oldTable1,oldTable2 newTable1,newTable2 - + $ bin/hbase org.apache.hadoop.hbase.mapreduce.WALPlayer /backuplogdir oldTable1,oldTable2 newTable1,newTable2 + WALPlayer, by default, runs as a mapreduce job. 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.
-
+
RowCounter and CellCounter RowCounter is a mapreduce job to count all the rows of a table. 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. 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. - $ bin/hbase org.apache.hadoop.hbase.mapreduce.RowCounter <tablename> [<column1> <column2>...] - + xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/RowCounter.html">RowCounter + is a mapreduce job to count all the rows of a table. 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. 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. + $ bin/hbase org.apache.hadoop.hbase.mapreduce.RowCounter <tablename> [<column1> <column2>...] + Note: caching for the input Scan is configured via hbase.client.scanner.caching in the job configuration. HBase ships another diagnostic mapreduce job called CellCounter. Like RowCounter, it gathers more fine-grained statistics about your - table. The statistics gathered by RowCounter are more fine-grained and include: + xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/CellCounter.html">CellCounter. + Like RowCounter, it gathers more fine-grained statistics about your table. The statistics + gathered by RowCounter are more fine-grained and include: Total number of rows in the table. @@ -472,11 +533,12 @@ row10 c1 c2 The program allows you to limit the scope of the run. Provide a row regex or prefix to limit the rows to analyze. Use hbase.mapreduce.scan.column.family to specify scanning a single column family. - $ bin/hbase org.apache.hadoop.hbase.mapreduce.CellCounter <tablename> <outputDir> [regex or prefix] + $ bin/hbase org.apache.hadoop.hbase.mapreduce.CellCounter <tablename> <outputDir> [regex or prefix] Note: just like RowCounter, caching for the input Scan is configured via hbase.client.scanner.caching in the job configuration.
-
+
mlockall 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 for how to build the optional library and have it run on startup.
-
+
Offline Compaction Tool See the usage for the Compaction Tool. Run it like this ./bin/hbase + xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/regionserver/CompactionTool.html">Compaction + Tool. Run it like this ./bin/hbase org.apache.hadoop.hbase.regionserver.CompactionTool
@@ -497,17 +560,19 @@ row10 c1 c2
-
+
Region Management -
+
Major Compaction Major compactions can be requested via the HBase shell or HBaseAdmin.majorCompact. - Note: major compactions do NOT do region merges. See for - more information about compactions. + xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HBaseAdmin.html#majorCompact%28java.lang.String%29">HBaseAdmin.majorCompact. + Note: major compactions do NOT do region merges. See for more information about compactions.
-
+
Merge Merge is a utility that can merge adjoining regions in the same table (see org.apache.hadoop.hbase.util.Merge). @@ -527,13 +592,15 @@ row10 c1 c2
-
+
Node Management -
+
Node Decommission You can stop an individual RegionServer by running the following script in the HBase directory on the particular node: - $ ./bin/hbase-daemon.sh stop regionserver + $ ./bin/hbase-daemon.sh stop regionserver The RegionServer will first close all regions and then shut itself down. On shutdown, the RegionServer's ephemeral node in ZooKeeper will expire. The master will notice the RegionServer gone and will treat it as a 'crashed' server; it will reassign the nodes the @@ -542,8 +609,8 @@ row10 c1 c2 Disable the Load Balancer before Decommissioning a node 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. Avoid any problems by disabling the balancer first. See - below. + RegionServer. Avoid any problems by disabling the balancer first. See below. A downside to the above stop of a RegionServer is that regions could be offline for a good period of time. Regions are closed in order. If many regions on the server, the first @@ -551,14 +618,14 @@ row10 c1 c2 the RegionServer's znode gone. In Apache HBase 0.90.2, we added facility for having a node gradually shed its load and then shutdown itself down. Apache HBase 0.90.2 added the graceful_stop.sh script. Here is its usage: - $ ./bin/graceful_stop.sh + $ ./bin/graceful_stop.sh Usage: graceful_stop.sh [--config &conf-dir>] [--restart] [--reload] [--thrift] [--rest] &hostname> thrift If we should stop/start thrift before/after the hbase stop/start rest If we should stop/start rest before/after the hbase stop/start restart If we should restart after graceful stop reload Move offloaded regions back on to the stopped server debug Move offloaded regions back on to the stopped server - hostname Hostname of server we are to stop + hostname Hostname of server we are to stop To decommission a loaded RegionServer, run the following: $ ./bin/graceful_stop.sh HOSTNAME where HOSTNAME is the host carrying the RegionServer you would decommission. @@ -581,7 +648,8 @@ Usage: graceful_stop.sh [--config &conf-dir>] [--restart] [--reload] [--thri 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. - + Load Balancer It is assumed that the Region Load Balancer is disabled while the graceful_stop script runs (otherwise the balancer and the @@ -600,7 +668,8 @@ false graceful_stop reenabling it after you are done w/ graceful_stop. -
+
Decommissioning several Regions Servers concurrently If you have a large cluster, you may want to decommission more than one machine at a time by gracefully stopping mutiple RegionServers concurrently. To gracefully drain @@ -614,25 +683,27 @@ false that are also draining. Marking RegionServers to be in the draining state prevents this from happening See this blog post for more details. + xlink:href="http://inchoate-clatter.blogspot.com/2012/03/hbase-ops-automation.html">blog + post for more details. .
-
+
Bad or Failing Disk - It is good having set if you - have a decent number of disks per machine for the case where a disk plain dies. But - usually disks do the "John Wayne" -- i.e. take a while to go down spewing errors in - dmesg -- or for some reason, run much slower than their companions. - In this case you want to decommission the disk. You have two options. You can decommission 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. + It is good having set if you have a decent number of + disks per machine for the case where a disk plain dies. But usually disks do the "John + Wayne" -- i.e. take a while to go down spewing errors in dmesg -- or + for some reason, run much slower than their companions. In this case you want to + decommission the disk. You have two options. You can decommission + 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. Short Circuit Reads If you are doing short-circuit reads, you will have to move the regions off the @@ -643,13 +714,13 @@ false
-
+
Rolling Restart You can also ask this script to restart a RegionServer after the shutdown AND move its old regions back into place. The latter you might do to retain data locality. A primitive rolling restart might be effected by running something like the following: - $ for i in `cat conf/regionservers|sort`; do ./bin/graceful_stop.sh --restart --reload --debug $i; done &> /tmp/log.txt & - + $ for i in `cat conf/regionservers|sort`; do ./bin/graceful_stop.sh --restart --reload --debug $i; done &> /tmp/log.txt & Tail the output of /tmp/log.txt to follow the scripts progress. The above does RegionServers only. The script will also disable the load balancer before moving the regions. You'd need to do the master update separately. Do it before you run the @@ -689,7 +760,8 @@ false multiple regions go offline simultaneously as they are re-assigned to other nodes. Depending on your usage patterns, this might not be desirable.
-
+
Adding a New Node 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 @@ -713,126 +785,151 @@ false
-
+
HBase Metrics -
+
Metric Setup - See Metrics for an - introduction and how to enable Metrics emission. Still valid for HBase 0.94.x. + See Metrics for an introduction and + how to enable Metrics emission. Still valid for HBase 0.94.x. For HBase 0.95.x and up, see + xlink:href="http://hadoop.apache.org/docs/current/api/org/apache/hadoop/metrics2/package-summary.html" />
-
+
Warning To Ganglia Users Warning to Ganglia Users: by default, HBase will emit a LOT of metrics per RegionServer which may swamp your installation. Options include either increasing Ganglia server capacity, or configuring HBase to emit fewer metrics.
-
+
Most Important RegionServer Metrics -
+
<varname>blockCacheExpressCachingRatio (formerly blockCacheHitCachingRatio)</varname> Block cache hit caching ratio (0 to 100). The cache-hit ratio for reads configured to look in the cache (i.e., cacheBlocks=true).
-
+
<varname>callQueueLength</varname> Point in time length of the RegionServer call queue. If requests arrive faster than the RegionServer handlers can process them they will back up in the callQueue.
-
+
<varname>compactionQueueLength (formerly compactionQueueSize)</varname> Point in time length of the compaction queue. This is the number of Stores in the RegionServer that have been targeted for compaction.
-
+
<varname>flushQueueSize</varname> Point in time number of enqueued regions in the MemStore awaiting flush.
-
+
<varname>hdfsBlocksLocalityIndex</varname> Point in time percentage of HDFS blocks that are local to this RegionServer. The higher the better.
-
+
<varname>memstoreSizeMB</varname> Point in time sum of all the memstore sizes in this RegionServer (MB). Watch for this nearing or exceeding the configured high-watermark for MemStore memory in the RegionServer.
-
+
<varname>numberOfOnlineRegions</varname> Point in time number of regions served by the RegionServer. This is an important metric to track for RegionServer-Region density.
-
+
<varname>readRequestsCount</varname> Number of read requests for this RegionServer since startup. Note: this is a 32-bit integer and can roll.
-
+
<varname>slowHLogAppendCount</varname> Number of slow HLog append writes for this RegionServer since startup, where "slow" is > 1 second. This is a good "canary" metric for HDFS.
-
+
<varname>usedHeapMB</varname> Point in time amount of memory used by the RegionServer (MB).
-
+
<varname>writeRequestsCount</varname> Number of write requests for this RegionServer since startup. Note: this is a 32-bit integer and can roll.
-
+
Other RegionServer Metrics -
+
<varname>blockCacheCount</varname> Point in time block cache item count in memory. This is the number of blocks of StoreFiles (HFiles) in the cache.
-
+
<varname>blockCacheEvictedCount</varname> Number of blocks that had to be evicted from the block cache due to heap size constraints by RegionServer since startup.
-
+
<varname>blockCacheFreeMB</varname> Point in time block cache memory available (MB).
-
+
<varname>blockCacheHitCount</varname> Number of blocks of StoreFiles (HFiles) read from the cache by RegionServer since startup.
-
+
<varname>blockCacheHitRatio</varname> Block cache hit ratio (0 to 100) from RegionServer startup. Includes all read requests, although those with cacheBlocks=false will always read from disk and be counted as a "cache miss", which means that full-scan MapReduce jobs can affect this metric significantly.
-
+
<varname>blockCacheMissCount</varname> Number of blocks of StoreFiles (HFiles) requested but not read from the cache from RegionServer startup.
-
+
<varname>blockCacheSizeMB</varname> Point in time block cache size in memory (MB). i.e., memory in use by the BlockCache
-
+
<varname>fsPreadLatency*</varname> There are several filesystem positional read latency (ms) metrics, all measured from RegionServer startup.
-
+
<varname>fsReadLatency*</varname> There are several filesystem read latency (ms) metrics, all measured from RegionServer startup. The issue with interpretation is that ALL reads go into this metric (e.g., @@ -840,25 +937,29 @@ false metric is only interesting "over time" when comparing major releases of HBase or your own code.
-
+
<varname>fsWriteLatency*</varname> There are several filesystem write latency (ms) metrics, all measured from RegionServer startup. The issue with interpretation is that ALL writes go into this metric (e.g., single-record Puts, full table re-writes due to compaction). This metric is only interesting "over time" when comparing major releases of HBase or your own code.
-
+
<varname>NumberOfStores</varname> Point in time number of Stores open on the RegionServer. A Store corresponds to a ColumnFamily. For example, if a table (which contains the column family) has 3 regions on a RegionServer, there will be 3 stores open for that column family.
-
+
<varname>NumberOfStorefiles</varname> Point in time number of StoreFiles open on the RegionServer. A store may have more than one StoreFile (HFile).
-
+
<varname>requestsPerSecond</varname> Point in time number of read and write requests. Requests correspond to RegionServer RPC calls, thus a single Get will result in 1 request, but a Scan with caching set to 1000 @@ -867,16 +968,19 @@ false readRequestsCount and writeRequestsCount in terms of measuring activity due to this metric being periodic.
-
+
<varname>storeFileIndexSizeMB</varname> Point in time sum of all the StoreFile index sizes in this RegionServer (MB)
-
+
HBase Monitoring -
+
Overview The following metrics are arguably the most important to monitor for each RegionServer for "macro monitoring", preferably with a system like HBase: - See + See @@ -904,10 +1009,12 @@ false GC - For more information on HBase metrics, see . + For more information on HBase metrics, see .
-
+
Slow Query Log 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 @@ -988,30 +1095,35 @@ false
-
+
Cluster Replication - See Cluster - Replication. + See Cluster Replication.
-
+
HBase Backup There are two broad strategies for performing HBase backups: backing up with a full cluster shutdown, and backing up on a live cluster. Each approach has pros and cons. For additional information, see HBase Backup Options over on the Sematext Blog. -
+
Full Shutdown Backup 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. 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. The obvious con is that the cluster is down. The steps include: -
+
Stop HBase
-
+
Distcp 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. @@ -1019,7 +1131,8 @@ false in-flight edits to files. Distcp-ing of files in the HBase directory is not generally recommended on a live cluster.
-
+
Restore (if needed) The backup of the hbase directory from HDFS is copied onto the 'real' hbase directory via distcp. The act of copying these files creates new HDFS metadata, which is why a @@ -1028,30 +1141,37 @@ false the HBase part) not the entire HDFS file-system.
-
+
Live Cluster Backup - Replication This approach assumes that there is a second cluster. See the HBase page on replication for more information.
-
+
Live Cluster Backup - CopyTable - The 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. + The 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. Since the cluster is up, there is a risk that edits could be missed in the copy process.
-
+
Live Cluster Backup - Export - The approach dumps the content of a table to HDFS on the same - cluster. To restore the data, the utility would be used. + The approach dumps the content of a table to HDFS on the same cluster. To + restore the data, the utility would be used. Since the cluster is up, there is a risk that edits could be missed in the export process.
-
+
HBase Snapshots HBase Snapshots allow you to take a snapshot of a table without too much impact on Region Servers. Snapshot, Clone and restore operations don't involve data copying. Also, Exporting @@ -1061,7 +1181,8 @@ false 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. -
+
Configuration To turn on the snapshot support just set the hbase.snapshot.enabled property to true. (Snapshots are enabled by default in 0.95+ and off by default in @@ -1073,7 +1194,8 @@ false </property>
-
+
Take a Snapshot You can take a snapshot of a table regardless of whether it is enabled or disabled. The snapshot operation doesn't involve any data copying. @@ -1082,7 +1204,8 @@ $ ./bin/hbase shell hbase> snapshot 'myTable', 'myTableSnapshot-122112'
-
+
Listing Snapshots List all snapshots taken (by printing the names and relative information). @@ -1090,7 +1213,8 @@ $ ./bin/hbase shell hbase> list_snapshots
-
+
Deleting Snapshots You can remove a snapshot, and the files retained for that snapshot will be removed if no longer needed. @@ -1099,7 +1223,8 @@ $ ./bin/hbase shell hbase> delete_snapshot 'myTableSnapshot-122112'
-
+
Clone a table from snapshot From a snapshot you can create a new table (clone operation) with the same data that you had when the snapshot was taken. The clone operation, doesn't involve data copies, and a @@ -1109,7 +1234,8 @@ $ ./bin/hbase shell hbase> clone_snapshot 'myTableSnapshot-122112', 'myNewTestTable'
-
+
Restore a snapshot 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 @@ -1128,15 +1254,17 @@ hbase> restore_snapshot 'myTableSnapshot-122112' 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.
-
+
Snapshots operations and ACLs If you are using security with the AccessController Coprocessor (See ), only a global administrator can take, + linkend="hbase.accesscontrol.configuration" />), only a global administrator can take, clone, or restore a snapshot, and these actions do not capture the ACL rights. 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.
-
+
Export to another cluster The ExportSnapshot tool copies all the data related to a snapshot (hfiles, logs, snapshot metadata) to another cluster. The tool executes a Map-Reduce job, similar to @@ -1149,14 +1277,17 @@ hbase> restore_snapshot 'myTableSnapshot-122112'
-
+
Capacity Planning and Region Sizing There are several considerations when planning the capacity for an HBase cluster and performing the initial configuration. Start with a solid understanding of how HBase handles data internally. -
+
Node count and hardware/VM configuration -
+
Physical data size Physical data size on disk is distinct from logical size of your data and is affected by the following: @@ -1165,26 +1296,31 @@ hbase> restore_snapshot 'myTableSnapshot-122112' Increased by HBase overhead - See and . At least 24 - bytes per key-value (cell), can be more. Small keys/values means more relative - overhead. + See and . At least 24 bytes per key-value (cell), can be more. Small + keys/values means more relative overhead. KeyValue instances are aggregated into blocks, which are indexed. Indexes also - have to be stored. Blocksize is configurable on a per-ColumnFamily basis. See - . + have to be stored. Blocksize is configurable on a per-ColumnFamily basis. See . - Decreased by and - data block encoding, depending on data. See also Decreased by and data block encoding, depending on data. See + also this thread. You might want to test what compression and encoding (if any) make sense for your data. - Increased by size of region server - (usually fixed and negligible - less than half of RS memory size, per RS). + Increased by size of region server (usually fixed and negligible - less than half of RS + memory size, per RS). Increased by HDFS replication - usually x3. @@ -1192,66 +1328,79 @@ hbase> restore_snapshot 'myTableSnapshot-122112' 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 ). + (see ).
-
+
Read/Write throughput Number of nodes can also be driven by required thoughput for reads and/or writes. The throughput one can get per node depends a lot on data (esp. key/value sizes) and request patterns, as well as node and system configuration. 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. - PerformanceEvaluation and tools can be - used to test single node or a test cluster. + PerformanceEvaluation and tools can be used to test single node or a test + cluster. For write, usually 5-15Mb/s per RS can be expected, since every region server has only one active WAL. There's no good estimate for reads, as it depends vastly on data, - requests, and cache hit rate. might be helpful. + requests, and cache hit rate. might be helpful.
-
+
JVM GC limitations RS cannot currently utilize very large heap due to cost of GC. 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. GC tuning is required - for large heap sizes. See , and - elsewhere (TODO: where?) + for large heap sizes. See , and elsewhere (TODO: where?)
-
+
Determining region count and size 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. The number of regions cannot be - configured directly (unless you go for fully ); adjust the region size to achieve the target + configured directly (unless you go for fully ); adjust the region size to achieve the target region size given table size. When configuring regions for multiple tables, note that most region settings can be set on a per-table basis via HTableDescriptor, as well as shell commands. These settings will override the ones - in hbase-site.xml. That is useful if your tables have different + xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html">HTableDescriptor, + as well as shell commands. These settings will override the ones in + hbase-site.xml. That is useful if your tables have different workloads/use cases. - Also note that in the discussion of region sizes here, HDFS - replication factor is not (and should not be) taken into account, whereas other factors - should - be. So, if your data is compressed and replicated 3 ways by HDFS, "9 Gb region" - means 9 Gb of compressed data. HDFS replication factor only affects your disk usage and is - invisible to most HBase code. -
+ Also note that in the discussion of region sizes here, HDFS replication factor is not (and should not be) taken into account, whereas + other factors should be. So, if your data is compressed and + replicated 3 ways by HDFS, "9 Gb region" means 9 Gb of compressed data. HDFS replication + factor only affects your disk usage and is invisible to most HBase code. +
Number of regions per RS - upper bound 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. - has technical discussion on the subject; in short, maximum number of regions is mostly - determined by memstore memory usage. Each region has its own memstores; these grow up to a - configurable size; usually in 128-256Mb range, see . There's one memstore per column family + the maximum number of regions you can have per server. has technical discussion on the subject; in short, maximum + number of regions is mostly determined by memstore memory usage. Each region has its own + memstores; these grow up to a configurable size; usually in 128-256Mb range, see . There's one memstore per column family (so there's only one per region if there's one CF in the table). RS dedicates some - fraction of total memory (see ) - to region memstores. If this memory is exceeded (too much memstore usage), undesirable - consequences such as unresponsive server, or later compaction storms, can result. Thus, a - good starting point for the number of regions per RS (assuming one table) is: + fraction of total memory (see ) to region memstores. If this + memory is exceeded (too much memstore usage), undesirable consequences such as + unresponsive server, or later compaction storms, can result. Thus, a good starting point + for the number of regions per RS (assuming one table) is: (RS memory)*(total memstore fraction)/((memstore size)*(# column families)) E.g. if RS has 16Gb RAM, with default settings, it is 16384*0.4/128 ~ 51 regions per @@ -1268,7 +1417,8 @@ hbase> restore_snapshot 'myTableSnapshot-122112' expense of block cache; this will also allow one to have more regions.
-
+
Number of regions per RS - lower bound HBase scales by having regions across many servers. Thus if you have 2 regions for 16GB data, on a 20 node machine your data will be concentrated on just a few machines - @@ -1279,7 +1429,8 @@ hbase> restore_snapshot 'myTableSnapshot-122112' for a larger number of regions to avoid having regions that are too large.
-
+
Maximum region size For large tables in production scenarios, maximum region size is mostly limited by compactions - very large compactions, esp. major, can degrade cluster performance. @@ -1287,17 +1438,19 @@ hbase> restore_snapshot 'myTableSnapshot-122112' older 0.90.x codebase, the upper-bound of regionsize is about 4Gb, with a default of 256Mb. The size at which the region is split into two is generally configured via ; for details, see . + linkend="hbase.hregion.max.filesize" />; for details, see . 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). In HBase 0.98, experimental stripe compactions feature was added that would allow for - larger regions, especially for log data. See . + larger regions, especially for log data. See .
-
+
Total data size per region server 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 @@ -1309,42 +1462,50 @@ hbase> restore_snapshot 'myTableSnapshot-122112'
-
+
Initial configuration and tuning - First, see . Note that some configurations, - more than others, depend on specific scenarios. Pay special attention to: + First, see . Note that some configurations, more than others, + depend on specific scenarios. Pay special attention to: - - request handler thread count, - vital for high-throughput workloads. + - request handler thread count, vital + for high-throughput workloads. - - 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. + - 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. Then, there are some considerations when setting up your cluster and tables. -
+
Compactions Depending on read/write volume and latency requirements, optimal compaction settings - may be different. See for some details. + may be different. See for some details. When provisioning for large data sizes, however, it's good to keep in mind that compactions can affect write throughput. Thus, for write-intensive workloads, you may opt for less frequent compactions and more store files per regions. Minimum number of files for compactions (hbase.hstore.compaction.min) can be set to higher - value; should also be increased, as more - files might accumulate in such case. You may also consider manually managing compactions: - + value; should also be increased, as more files + might accumulate in such case. You may also consider manually managing compactions:
-
+
Pre-splitting the table Based on the target number of the regions per RS (see ) and number of RSes, - one can pre-split the table at creation time. 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. + linkend="ops.capacity.regions.count" + xrefstyle="template:above" />) and number of RSes, one can pre-split the table at + creation time. 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. If the table is expected to grow large enough to justify that, at least one region per RS should be created. It is not recommended to split immediately into the full target number of regions (e.g. 50 * number of RSes), but a low intermediate value can be chosen. @@ -1352,14 +1513,16 @@ hbase> restore_snapshot 'myTableSnapshot-122112' pre-split 1 region per RS at most), especially if you don't know how much each table will grow. If you split too much, you may end up with too many regions, with some tables having too many small regions. - For pre-splitting howto, see . + For pre-splitting howto, see .
-
+
Table Rename 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 @@ -1368,19 +1531,19 @@ hbase> restore_snapshot 'myTableSnapshot-122112' performed by the script was brutal. As of hbase 0.94.x, you can use the snapshot facility renaming a table. Here is how you would do it using the hbase shell: - hbase shell> disable 'tableName' + disable 'tableName' hbase shell> snapshot 'tableName', 'tableSnapshot' hbase shell> clone_snapshot 'tableSnapshot', 'newTableName' hbase shell> delete_snapshot 'tableSnapshot' -hbase shell> drop 'tableName' +hbase shell> drop 'tableName']]> or in code it would be as follows: - void rename(HBaseAdmin admin, String oldTableName, String newTableName) { -String snapshotName = randomName(); -admin.disableTable(oldTableName); -admin.snapshot(snapshotName, oldTableName); -admin.cloneSnapshot(snapshotName, newTableName); -admin.deleteSnapshot(snapshotName); -admin.deleteTable(oldTableName); + void rename(HBaseAdmin admin, String oldTableName, String newTableName) { + String snapshotName = randomName(); + admin.disableTable(oldTableName); + admin.snapshot(snapshotName, oldTableName); + admin.cloneSnapshot(snapshotName, newTableName); + admin.deleteSnapshot(snapshotName); + admin.deleteTable(oldTableName); }
diff --git a/src/main/docbkx/performance.xml b/src/main/docbkx/performance.xml index a56c52293f8..cbe600e3816 100644 --- a/src/main/docbkx/performance.xml +++ b/src/main/docbkx/performance.xml @@ -1,13 +1,15 @@ - - Apache HBase Performance Tuning -
+
Operating System -
- Memory - RAM, RAM, RAM. Don't starve HBase. -
-
- 64-bit - Use a 64-bit platform (and 64-bit JVM). -
-
- Swapping - Watch out for swapping. Set swappiness to 0. -
+
+ Memory + RAM, RAM, RAM. Don't starve HBase. +
+
+ 64-bit + Use a 64-bit platform (and 64-bit JVM). +
+
+ Swapping + Watch out for swapping. Set swappiness to 0. +
-
+
Network Perhaps the most important factor in avoiding network issues degrading Hadoop and HBase performance is the switching hardware that is used, decisions made early in the scope of the project can cause major problems when you double or triple the size of your cluster (or more). - - Important items to consider: - - Switching capacity of the device - Number of systems connected - Uplink capacity - - -
- Single Switch - The single most important factor in this configuration is that the switching capacity of the hardware is capable of - handling the traffic which can be generated by all systems connected to the switch. Some lower priced commodity hardware - can have a slower switching capacity than could be utilized by a full switch. - -
-
- Multiple Switches - Multiple switches are a potential pitfall in the architecture. The most common configuration of lower priced hardware is a - simple 1Gbps uplink from one switch to another. This often overlooked pinch point can easily become a bottleneck for cluster communication. - Especially with MapReduce jobs that are both reading and writing a lot of data the communication across this uplink could be saturated. - - Mitigation of this issue is fairly simple and can be accomplished in multiple ways: - - Use appropriate hardware for the scale of the cluster which you're attempting to build. - Use larger single switch configurations i.e. single 48 port as opposed to 2x 24 port - Configure port trunking for uplinks to utilize multiple interfaces to increase cross switch bandwidth. + Important items to consider: + + Switching capacity of the device + + + Number of systems connected + + + Uplink capacity + - + +
+ Single Switch + The single most important factor in this configuration is that the switching capacity of + the hardware is capable of handling the traffic which can be generated by all systems + connected to the switch. Some lower priced commodity hardware can have a slower switching + capacity than could be utilized by a full switch.
-
+
+ Multiple Switches + Multiple switches are a potential pitfall in the architecture. The most common + configuration of lower priced hardware is a simple 1Gbps uplink from one switch to another. + This often overlooked pinch point can easily become a bottleneck for cluster communication. + Especially with MapReduce jobs that are both reading and writing a lot of data the + communication across this uplink could be saturated. + Mitigation of this issue is fairly simple and can be accomplished in multiple ways: + + + Use appropriate hardware for the scale of the cluster which you're attempting to + build. + + + Use larger single switch configurations i.e. single 48 port as opposed to 2x 24 + port + + + Configure port trunking for uplinks to utilize multiple interfaces to increase cross + switch bandwidth. + + +
+
Multiple Racks - Multiple rack configurations carry the same potential issues as multiple switches, and can suffer performance degradation from two main areas: - - Poor switch capacity performance - Insufficient uplink to another rack - - If the the switches in your rack have appropriate switching capacity to handle all the hosts at full speed, the next most likely issue will be caused by homing - more of your cluster across racks. The easiest way to avoid issues when spanning multiple racks is to use port trunking to create a bonded uplink to other racks. - The downside of this method however, is in the overhead of ports that could potentially be used. An example of this is, creating an 8Gbps port channel from rack - A to rack B, using 8 of your 24 ports to communicate between racks gives you a poor ROI, using too few however can mean you're not getting the most out of your cluster. - - Using 10Gbe links between racks will greatly increase performance, and assuming your switches support a 10Gbe uplink or allow for an expansion card will allow you to - save your ports for machines as opposed to uplinks. - + Multiple rack configurations carry the same potential issues as multiple switches, and + can suffer performance degradation from two main areas: + + + Poor switch capacity performance + + + Insufficient uplink to another rack + + + If the the switches in your rack have appropriate switching capacity to handle all the + hosts at full speed, the next most likely issue will be caused by homing more of your + cluster across racks. The easiest way to avoid issues when spanning multiple racks is to use + port trunking to create a bonded uplink to other racks. The downside of this method however, + is in the overhead of ports that could potentially be used. An example of this is, creating + an 8Gbps port channel from rack A to rack B, using 8 of your 24 ports to communicate between + racks gives you a poor ROI, using too few however can mean you're not getting the most out + of your cluster. + Using 10Gbe links between racks will greatly increase performance, and assuming your + switches support a 10Gbe uplink or allow for an expansion card will allow you to save your + ports for machines as opposed to uplinks.
-
+
Network Interfaces - Are all the network interfaces functioning correctly? Are you sure? See the Troubleshooting Case Study in . - + Are all the network interfaces functioning correctly? Are you sure? See the + Troubleshooting Case Study in .
-
+
+ -
+
Java -
+
The Garbage Collector and Apache HBase -
+
Long GC pauses - In his presentation, Avoiding - Full GCs with MemStore-Local Allocation Buffers, Todd Lipcon - describes two cases of stop-the-world garbage collections common in - HBase, especially during loading; CMS failure modes and old generation - heap fragmentation brought. To address the first, start the CMS - earlier than default by adding - -XX:CMSInitiatingOccupancyFraction and setting it down - from defaults. Start at 60 or 70 percent (The lower you bring down the - threshold, the more GCing is done, the more CPU used). To address the - second fragmentation issue, Todd added an experimental facility, - MSLAB, that - must be explicitly enabled in Apache HBase 0.90.x (Its defaulted to be on in - Apache 0.92.x HBase). See hbase.hregion.memstore.mslab.enabled - to true in your Configuration. See the cited - slides for background and detailThe latest jvms do better - regards fragmentation so make sure you are running a recent release. - Read down in the message, - Identifying concurrent mode failures caused by fragmentation.. - Be aware that when enabled, each MemStore instance will occupy at least - an MSLAB instance of memory. If you have thousands of regions or lots - of regions each with many column families, this allocation of MSLAB - may be responsible for a good portion of your heap allocation and in - an extreme case cause you to OOME. Disable MSLAB in this case, or - lower the amount of memory it uses or float less regions per server. - - If you have a write-heavy workload, check out - HBASE-8163 MemStoreChunkPool: An improvement for JAVA GC when using MSLAB. - It describes configurations to lower the amount of young GC during write-heavy loadings. If you do not have HBASE-8163 installed, and you are - trying to improve your young GC times, one trick to consider -- courtesy of our Liang Xie -- is to set the GC config -XX:PretenureSizeThreshold in hbase-env.sh - to be just smaller than the size of hbase.hregion.memstore.mslab.chunksize so MSLAB allocations happen in the - tenured space directly rather than first in the young gen. You'd do this because these MSLAB allocations are going to likely make it - to the old gen anyways and rather than pay the price of a copies between s0 and s1 in eden space followed by the copy up from - young to old gen after the MSLABs have achieved sufficient tenure, save a bit of YGC churn and allocate in the old gen directly. - - For more information about GC logs, see . - + In his presentation, Avoiding Full GCs + with MemStore-Local Allocation Buffers, Todd Lipcon describes two cases of + stop-the-world garbage collections common in HBase, especially during loading; CMS failure + modes and old generation heap fragmentation brought. To address the first, start the CMS + earlier than default by adding -XX:CMSInitiatingOccupancyFraction and setting + it down from defaults. Start at 60 or 70 percent (The lower you bring down the threshold, + the more GCing is done, the more CPU used). To address the second fragmentation issue, + Todd added an experimental facility, MSLAB, that + must be explicitly enabled in Apache HBase 0.90.x (Its defaulted to be on in Apache 0.92.x + HBase). See hbase.hregion.memstore.mslab.enabled to true in your + Configuration. See the cited slides for background and detail + The latest jvms do better regards fragmentation so make sure you are running a + recent release. Read down in the message, Identifying + concurrent mode failures caused by fragmentation. + . Be aware that when enabled, each MemStore instance will occupy at least an + MSLAB instance of memory. If you have thousands of regions or lots of regions each with + many column families, this allocation of MSLAB may be responsible for a good portion of + your heap allocation and in an extreme case cause you to OOME. Disable MSLAB in this case, + or lower the amount of memory it uses or float less regions per server. + If you have a write-heavy workload, check out HBASE-8163 + MemStoreChunkPool: An improvement for JAVA GC when using MSLAB. It describes + configurations to lower the amount of young GC during write-heavy loadings. If you do not + have HBASE-8163 installed, and you are trying to improve your young GC times, one trick to + consider -- courtesy of our Liang Xie -- is to set the GC config + -XX:PretenureSizeThreshold in hbase-env.sh to be + just smaller than the size of hbase.hregion.memstore.mslab.chunksize so + MSLAB allocations happen in the tenured space directly rather than first in the young gen. + You'd do this because these MSLAB allocations are going to likely make it to the old gen + anyways and rather than pay the price of a copies between s0 and s1 in eden space followed + by the copy up from young to old gen after the MSLABs have achieved sufficient tenure, + save a bit of YGC churn and allocate in the old gen directly. + For more information about GC logs, see .
-
+
HBase Configurations - See . + See . -
+
Managing Compactions For larger systems, managing compactions and splits may be - something you want to consider. + linkend="disable.splitting">compactions and splits may be something you want to + consider.
-
- <varname>hbase.regionserver.handler.count</varname> - See . - +
+ <varname>hbase.regionserver.handler.count</varname> + See .
-
- <varname>hfile.block.cache.size</varname> - See . - A memory setting for the RegionServer process. - -
-
- <varname>hbase.regionserver.global.memstore.size</varname> - See . - This memory setting is often adjusted for the RegionServer process depending on needs. - -
-
- <varname>hbase.regionserver.global.memstore.size.lower.limit</varname> - See . - This memory setting is often adjusted for the RegionServer process depending on needs. - -
-
- <varname>hbase.hstore.blockingStoreFiles</varname> - See . - If there is blocking in the RegionServer logs, increasing this can help. - -
-
- <varname>hbase.hregion.memstore.block.multiplier</varname> - See . - If there is enough RAM, increasing this can help. - -
-
- <varname>hbase.regionserver.checksum.verify</varname> - Have HBase write the checksum into the datablock and save - having to do the checksum seek whenever you read. - - See , - and - For more information see the - release note on HBASE-5074 support checksums in HBase block cache. - -
- -
- - - - -
- ZooKeeper - See for information on configuring ZooKeeper, and see the part - about having a dedicated disk. - -
-
- Schema Design - -
- Number of Column Families - See . -
-
- Key and Attribute Lengths - See . See also for - compression caveats. -
-
Table RegionSize - The regionsize can be set on a per-table basis via setFileSize on - HTableDescriptor in the - event where certain tables require different regionsizes than the configured default regionsize. - - See for more information. - -
-
- Bloom Filters - Bloom Filters can be enabled per-ColumnFamily. - Use HColumnDescriptor.setBloomFilterType(NONE | ROW | - ROWCOL) to enable blooms per Column Family. Default = - NONE for no bloom filters. If - ROW, the hash of the row will be added to the bloom - on each insert. If ROWCOL, the hash of the row + - column family name + column family qualifier will be added to the bloom on - each key insert. - See HColumnDescriptor and - for more information or this answer up in quora, -How are bloom filters used in HBase?. - -
-
ColumnFamily BlockSize - The blocksize can be configured for each ColumnFamily in a table, and this defaults to 64k. Larger cell values require larger blocksizes. - There is an inverse relationship between blocksize and the resulting StoreFile indexes (i.e., if the blocksize is doubled then the resulting - indexes should be roughly halved). - - See HColumnDescriptor - and for more information. - -
-
- In-Memory ColumnFamilies - ColumnFamilies can optionally be defined as in-memory. Data is still persisted to disk, just like any other ColumnFamily. - In-memory blocks have the highest priority in the , but it is not a guarantee that the entire table - will be in memory. - - See HColumnDescriptor for more information. - -
-
- Compression - Production systems should use compression with their ColumnFamily definitions. See for more information. +
+ <varname>hfile.block.cache.size</varname> + See . A memory setting for the RegionServer process. -
However... - Compression deflates data on disk. When it's in-memory (e.g., in the - MemStore) or on the wire (e.g., transferring between RegionServer and Client) it's inflated. - So while using ColumnFamily compression is a best practice, but it's not going to completely eliminate - the impact of over-sized Keys, over-sized ColumnFamily names, or over-sized Column names. - - See on for schema design tips, and for more information on HBase stores data internally. - +
+
+ <varname>hbase.regionserver.global.memstore.size</varname> + See . This memory setting is often + adjusted for the RegionServer process depending on needs. +
+
+ <varname>hbase.regionserver.global.memstore.size.lower.limit</varname> + See . This memory setting is + often adjusted for the RegionServer process depending on needs. +
+
+ <varname>hbase.hstore.blockingStoreFiles</varname> + See . If there is blocking in the RegionServer + logs, increasing this can help. +
+
+ <varname>hbase.hregion.memstore.block.multiplier</varname> + See . If there is enough RAM, increasing + this can help. +
+
+ <varname>hbase.regionserver.checksum.verify</varname> + Have HBase write the checksum into the datablock and save having to do the checksum seek + whenever you read. + + See , and For more information see the release note on HBASE-5074 support checksums + in HBase block cache. +
+ +
+ + + + +
+ ZooKeeper + See for information on configuring ZooKeeper, and see the part about + having a dedicated disk. +
+
+ Schema Design + +
+ Number of Column Families + See . +
+
+ Key and Attribute Lengths + See . See also for compression caveats. +
+
+ Table RegionSize + The regionsize can be set on a per-table basis via setFileSize on HTableDescriptor + in the event where certain tables require different regionsizes than the configured default + regionsize. + See for more information. +
+
+ Bloom Filters + Bloom Filters can be enabled per-ColumnFamily. Use + HColumnDescriptor.setBloomFilterType(NONE | ROW | ROWCOL) to enable blooms + per Column Family. Default = NONE for no bloom filters. If + ROW, the hash of the row will be added to the bloom on each insert. If + ROWCOL, the hash of the row + column family name + column family + qualifier will be added to the bloom on each key insert. + See HColumnDescriptor + and for more information or this answer up in quora, How are bloom + filters used in HBase?. +
+
+ ColumnFamily BlockSize + The blocksize can be configured for each ColumnFamily in a table, and this defaults to + 64k. Larger cell values require larger blocksizes. There is an inverse relationship between + blocksize and the resulting StoreFile indexes (i.e., if the blocksize is doubled then the + resulting indexes should be roughly halved). + See HColumnDescriptor + and for more information. +
+
+ In-Memory ColumnFamilies + ColumnFamilies can optionally be defined as in-memory. Data is still persisted to disk, + just like any other ColumnFamily. In-memory blocks have the highest priority in the , but it is not a guarantee that the entire table will be in + memory. + See HColumnDescriptor + for more information. +
+
+ Compression + Production systems should use compression with their ColumnFamily definitions. See for more information. +
+ However... + Compression deflates data on disk. When it's in-memory (e.g., in + the MemStore) or on the wire (e.g., transferring between RegionServer and Client) it's + inflated. So while using ColumnFamily compression is a best practice, but it's not going + to completely eliminate the impact of over-sized Keys, over-sized ColumnFamily names, or + over-sized Column names. + See on for schema design tips, and for more information on HBase stores data internally.
-
+
+ -
+
HBase General Patterns -
+
Constants - When people get started with HBase they have a tendency to write code that looks like this: - + When people get started with HBase they have a tendency to write code that looks like + this: + Get get = new Get(rowkey); Result r = htable.get(get); byte[] b = r.getValue(Bytes.toBytes("cf"), Bytes.toBytes("attr")); // returns current version of value - - But especially when inside loops (and MapReduce jobs), converting the columnFamily and column-names - to byte-arrays repeatedly is surprisingly expensive. - It's better to use constants for the byte-arrays, like this: - + + But especially when inside loops (and MapReduce jobs), converting the columnFamily and + column-names to byte-arrays repeatedly is surprisingly expensive. It's better to use + constants for the byte-arrays, like this: + public static final byte[] CF = "cf".getBytes(); public static final byte[] ATTR = "attr".getBytes(); ... Get get = new Get(rowkey); Result r = htable.get(get); byte[] b = r.getValue(CF, ATTR); // returns current version of value - - +
-
+
Writing to HBase -
+
Batch Loading - Use the bulk load tool if you can. See - . - Otherwise, pay attention to the below. - -
+ Use the bulk load tool if you can. See . Otherwise, pay attention to the below. +
+ -
- - Table Creation: Pre-Creating Regions - - -Tables in HBase are initially created with one region by default. For bulk imports, this means that all clients will write to the same region -until it is large enough to split and become distributed across the cluster. A useful pattern to speed up the bulk import process is to pre-create empty regions. - Be somewhat conservative in this, because too-many regions can actually degrade performance. - - There are two different approaches to pre-creating splits. The first approach is to rely on the default HBaseAdmin strategy - (which is implemented in Bytes.split)... - - +
+ Table Creation: Pre-Creating Regions + Tables in HBase are initially created with one region by default. For bulk imports, + this means that all clients will write to the same region until it is large enough to split + and become distributed across the cluster. A useful pattern to speed up the bulk import + process is to pre-create empty regions. Be somewhat conservative in this, because too-many + regions can actually degrade performance. + There are two different approaches to pre-creating splits. The first approach is to rely + on the default HBaseAdmin strategy (which is implemented in + Bytes.split)... + byte[] startKey = ...; // your lowest keuy byte[] endKey = ...; // your highest key int numberOfRegions = ...; // # of regions to create admin.createTable(table, startKey, endKey, numberOfRegions); - - And the other approach is to define the splits yourself... - - + + And the other approach is to define the splits yourself... + byte[][] splits = ...; // create your own splits admin.createTable(table, splits); - - See for issues related to understanding your keyspace and pre-creating regions. - -
-
- - Table Creation: Deferred Log Flush - - -The default behavior for Puts using the Write Ahead Log (WAL) is that HLog edits will be written immediately. If deferred log flush is used, -WAL edits are kept in memory until the flush period. The benefit is aggregated and asynchronous HLog- writes, but the potential downside is that if - the RegionServer goes down the yet-to-be-flushed edits are lost. This is safer, however, than not using WAL at all with Puts. - - -Deferred log flush can be configured on tables via HTableDescriptor. The default value of hbase.regionserver.optionallogflushinterval is 1000ms. - + See for issues related to understanding your keyspace and + pre-creating regions. +
+
+ Table Creation: Deferred Log Flush + The default behavior for Puts using the Write Ahead Log (WAL) is that + HLog edits will be written immediately. If deferred log flush is + used, WAL edits are kept in memory until the flush period. The benefit is aggregated and + asynchronous HLog- writes, but the potential downside is that if the + RegionServer goes down the yet-to-be-flushed edits are lost. This is safer, however, than + not using WAL at all with Puts. + Deferred log flush can be configured on tables via HTableDescriptor. + The default value of hbase.regionserver.optionallogflushinterval is + 1000ms.
-
- HBase Client: AutoFlush +
+ HBase Client: AutoFlush - When performing a lot of Puts, make sure that setAutoFlush is set - to false on your HTable - instance. Otherwise, the Puts will be sent one at a time to the - RegionServer. Puts added via htable.add(Put) and htable.add( <List> Put) - wind up in the same write buffer. If autoFlush = false, - these messages are not sent until the write-buffer is filled. To - explicitly flush the messages, call flushCommits. - Calling close on the HTable - instance will invoke flushCommits. + When performing a lot of Puts, make sure that setAutoFlush is set to false on your HTable + instance. Otherwise, the Puts will be sent one at a time to the RegionServer. Puts added via + htable.add(Put) and htable.add( <List> Put) wind up in + the same write buffer. If autoFlush = false, these messages are not sent until + the write-buffer is filled. To explicitly flush the messages, call + flushCommits. Calling close on the + HTable instance will invoke + flushCommits.
-
- HBase Client: Turn off WAL on Puts - A frequently discussed option for increasing throughput on Puts is to call writeToWAL(false). Turning this off means - that the RegionServer will not write the Put to the Write Ahead Log, - only into the memstore, HOWEVER the consequence is that if there - is a RegionServer failure there will be data loss. - If writeToWAL(false) is used, do so with extreme caution. You may find in actuality that - it makes little difference if your load is well distributed across the cluster. - - In general, it is best to use WAL for Puts, and where loading throughput - is a concern to use bulk loading techniques instead. - +
+ HBase Client: Turn off WAL on Puts + A frequently discussed option for increasing throughput on Puts + is to call writeToWAL(false). Turning this off means that the RegionServer will + not write the Put to the Write Ahead Log, only + into the memstore, HOWEVER the consequence is that if there is a RegionServer failure + there will be data loss. If writeToWAL(false) is used, + do so with extreme caution. You may find in actuality that it makes little difference if + your load is well distributed across the cluster. + In general, it is best to use WAL for Puts, and where loading throughput is a concern to + use bulk loading techniques instead.
-
+
HBase Client: Group Puts by RegionServer - In addition to using the writeBuffer, grouping Puts by RegionServer can reduce the number of client RPC calls per writeBuffer flush. - There is a utility HTableUtil currently on TRUNK that does this, but you can either copy that or implement your own version for - those still on 0.90.x or earlier. - + In addition to using the writeBuffer, grouping Puts by + RegionServer can reduce the number of client RPC calls per writeBuffer flush. There is a + utility HTableUtil currently on TRUNK that does this, but you can + either copy that or implement your own version for those still on 0.90.x or earlier.
-
- MapReduce: Skip The Reducer +
+ MapReduce: Skip The Reducer When writing a lot of data to an HBase table from a MR job (e.g., with TableOutputFormat), and specifically where Puts are being emitted - from the Mapper, skip the Reducer step. When a Reducer step is used, all of the output (Puts) from the Mapper will get spooled to disk, then sorted/shuffled to other - Reducers that will most likely be off-node. It's far more efficient to just write directly to HBase. - - For summary jobs where HBase is used as a source and a sink, then writes will be coming from the Reducer step (e.g., summarize values then write out result). - This is a different processing problem than from the the above case. + xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableOutputFormat.html">TableOutputFormat), + and specifically where Puts are being emitted from the Mapper, skip the Reducer step. When a + Reducer step is used, all of the output (Puts) from the Mapper will get spooled to disk, + then sorted/shuffled to other Reducers that will most likely be off-node. It's far more + efficient to just write directly to HBase. + For summary jobs where HBase is used as a source and a sink, then writes will be coming + from the Reducer step (e.g., summarize values then write out result). This is a different + processing problem than from the the above case. +
+ +
+ Anti-Pattern: One Hot Region + If all your data is being written to one region at a time, then re-read the section on + processing timeseries data. + Also, if you are pre-splitting regions and all your data is still + winding up in a single region even though your keys aren't monotonically increasing, confirm + that your keyspace actually works with the split strategy. There are a variety of reasons + that regions may appear "well split" but won't work with your data. As the HBase client + communicates directly with the RegionServers, this can be obtained via HTable.getRegionLocation. + See , as well as
-
- Anti-Pattern: One Hot Region - If all your data is being written to one region at a time, then re-read the - section on processing timeseries data. - Also, if you are pre-splitting regions and all your data is still winding up in a single region even though - your keys aren't monotonically increasing, confirm that your keyspace actually works with the split strategy. There are a - variety of reasons that regions may appear "well split" but won't work with your data. As - the HBase client communicates directly with the RegionServers, this can be obtained via - HTable.getRegionLocation. - - See , as well as
+ -
- -
+
Reading from HBase - The mailing list can help if you are having performance issues. - For example, here is a good general thread on what to look at addressing - read-time issues: HBase Random Read latency > 100ms -
+ The mailing list can help if you are having performance issues. For example, here is a + good general thread on what to look at addressing read-time issues: HBase Random Read latency > + 100ms +
Scan Caching - If HBase is used as an input source for a MapReduce job, for - example, make sure that the input Scan - instance to the MapReduce job has setCaching set to something greater - than the default (which is 1). Using the default value means that the - map-task will make call back to the region-server for every record - processed. Setting this value to 500, for example, will transfer 500 - rows at a time to the client to be processed. There is a cost/benefit to - have the cache value be large because it costs more in memory for both - client and RegionServer, so bigger isn't always better. -
+ If HBase is used as an input source for a MapReduce job, for example, make sure that the + input Scan + instance to the MapReduce job has setCaching set to something + greater than the default (which is 1). Using the default value means that the map-task will + make call back to the region-server for every record processed. Setting this value to 500, + for example, will transfer 500 rows at a time to the client to be processed. There is a + cost/benefit to have the cache value be large because it costs more in memory for both + client and RegionServer, so bigger isn't always better. +
Scan Caching in MapReduce Jobs - Scan settings in MapReduce jobs deserve special attention. Timeouts can result (e.g., UnknownScannerException) - in Map tasks if it takes longer to process a batch of records before the client goes back to the RegionServer for the - next set of data. This problem can occur because there is non-trivial processing occuring per row. If you process - rows quickly, set caching higher. If you process rows more slowly (e.g., lots of transformations per row, writes), - then set caching lower. - - Timeouts can also happen in a non-MapReduce use case (i.e., single threaded HBase client doing a Scan), but the - processing that is often performed in MapReduce jobs tends to exacerbate this issue. - + Scan settings in MapReduce jobs deserve special attention. Timeouts can result (e.g., + UnknownScannerException) in Map tasks if it takes longer to process a batch of records + before the client goes back to the RegionServer for the next set of data. This problem can + occur because there is non-trivial processing occuring per row. If you process rows + quickly, set caching higher. If you process rows more slowly (e.g., lots of + transformations per row, writes), then set caching lower. + Timeouts can also happen in a non-MapReduce use case (i.e., single threaded HBase + client doing a Scan), but the processing that is often performed in MapReduce jobs tends + to exacerbate this issue.
-
+
Scan Attribute Selection - Whenever a Scan is used to process large numbers of rows (and especially when used - as a MapReduce source), be aware of which attributes are selected. If scan.addFamily is called - then all of the attributes in the specified ColumnFamily will be returned to the client. - If only a small number of the available attributes are to be processed, then only those attributes should be specified - in the input scan because attribute over-selection is a non-trivial performance penalty over large datasets. - + Whenever a Scan is used to process large numbers of rows (and especially when used as a + MapReduce source), be aware of which attributes are selected. If scan.addFamily + is called then all of the attributes in the specified ColumnFamily will + be returned to the client. If only a small number of the available attributes are to be + processed, then only those attributes should be specified in the input scan because + attribute over-selection is a non-trivial performance penalty over large datasets.
-
+
Avoid scan seeks - When columns are selected explicitly with scan.addColumn, HBase will schedule seek operations to seek between the - selected columns. When rows have few columns and each column has only a few versions this can be inefficient. A seek operation is generally - slower if does not seek at least past 5-10 columns/versions or 512-1024 bytes. - In order to opportunistically look ahead a few columns/versions to see if the next column/version can be found that - way before a seek operation is scheduled, a new attribute Scan.HINT_LOOKAHEAD can be set the on Scan object. The following code instructs the - RegionServer to attempt two iterations of next before a seek is scheduled: + When columns are selected explicitly with scan.addColumn, HBase will + schedule seek operations to seek between the selected columns. When rows have few columns + and each column has only a few versions this can be inefficient. A seek operation is + generally slower if does not seek at least past 5-10 columns/versions or 512-1024 + bytes. + In order to opportunistically look ahead a few columns/versions to see if the next + column/version can be found that way before a seek operation is scheduled, a new attribute + Scan.HINT_LOOKAHEAD can be set the on Scan object. The following code + instructs the RegionServer to attempt two iterations of next before a seek is + scheduled: + Scan scan = new Scan(); scan.addColumn(...); scan.setAttribute(Scan.HINT_LOOKAHEAD, Bytes.toBytes(2)); table.getScanner(scan); - -
-
- MapReduce - Input Splits - For MapReduce jobs that use HBase tables as a source, if there a pattern where the "slow" map tasks seem to - have the same Input Split (i.e., the RegionServer serving the data), see the - Troubleshooting Case Study in . - + +
+
+ MapReduce - Input Splits + For MapReduce jobs that use HBase tables as a source, if there a pattern where the + "slow" map tasks seem to have the same Input Split (i.e., the RegionServer serving the + data), see the Troubleshooting Case Study in .
-
+
Close ResultScanners - This isn't so much about improving performance but rather - avoiding performance problems. If you forget to - close ResultScanners - you can cause problems on the RegionServers. Always have ResultScanner - processing enclosed in try/catch blocks... + This isn't so much about improving performance but rather avoiding + performance problems. If you forget to close ResultScanners + you can cause problems on the RegionServers. Always have ResultScanner processing enclosed + in try/catch blocks... + Scan scan = new Scan(); // set attrs... ResultScanner rs = htable.getScanner(scan); @@ -511,184 +601,201 @@ try { } finally { rs.close(); // always close the ResultScanner! } -htable.close(); +htable.close(); +
-
+
Block Cache Scan - instances can be set to use the block cache in the RegionServer via the - setCacheBlocks method. For input Scans to MapReduce jobs, this should be - false. For frequently accessed rows, it is advisable to use the block - cache. + xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Scan.html">Scan + instances can be set to use the block cache in the RegionServer via the + setCacheBlocks method. For input Scans to MapReduce jobs, this + should be false. For frequently accessed rows, it is advisable to use the + block cache.
-
+
Optimal Loading of Row Keys - When performing a table scan - where only the row keys are needed (no families, qualifiers, values or timestamps), add a FilterList with a - MUST_PASS_ALL operator to the scanner using setFilter. The filter list - should include both a FirstKeyOnlyFilter - and a KeyOnlyFilter. - Using this filter combination will result in a worst case scenario of a RegionServer reading a single value from disk - and minimal network traffic to the client for a single row. + When performing a table scan + where only the row keys are needed (no families, qualifiers, values or timestamps), add a + FilterList with a MUST_PASS_ALL operator to the scanner using + setFilter. The filter list should include both a FirstKeyOnlyFilter + and a KeyOnlyFilter. + Using this filter combination will result in a worst case scenario of a RegionServer reading + a single value from disk and minimal network traffic to the client for a single row. +
+
+ Concurrency: Monitor Data Spread + When performing a high number of concurrent reads, monitor the data spread of the target + tables. If the target table(s) have too few regions then the reads could likely be served + from too few nodes. + See , as well as
-
- Concurrency: Monitor Data Spread - When performing a high number of concurrent reads, monitor the data spread of the target tables. If the target table(s) have - too few regions then the reads could likely be served from too few nodes. - See , as well as -
-
- Bloom Filters - Enabling Bloom Filters can save your having to go to disk and - can help improve read latencies. - Bloom filters were developed over in HBase-1200 - Add bloomfilters. - For description of the development process -- why static blooms - rather than dynamic -- and for an overview of the unique properties - that pertain to blooms in HBase, as well as possible future - directions, see the Development Process section - of the document BloomFilters - in HBase attached to HBase-1200. - - The bloom filters described here are actually version two of - blooms in HBase. In versions up to 0.19.x, HBase had a dynamic bloom - option based on work done by the European Commission One-Lab - Project 034819. The core of the HBase bloom work was later - pulled up into Hadoop to implement org.apache.hadoop.io.BloomMapFile. - Version 1 of HBase blooms never worked that well. Version 2 is a - rewrite from scratch though again it starts with the one-lab - work. - - See also . - +
+ Bloom Filters + Enabling Bloom Filters can save your having to go to disk and can help improve read + latencies. + Bloom filters were developed + over in HBase-1200 Add + bloomfilters. + For description of the development process -- why static blooms rather than dynamic + -- and for an overview of the unique properties that pertain to blooms in HBase, as well + as possible future directions, see the Development Process section + of the document BloomFilters + in HBase attached to HBase-1200. + + The bloom filters described here are actually version two of blooms in HBase. In + versions up to 0.19.x, HBase had a dynamic bloom option based on work done by the European Commission One-Lab Project 034819. + The core of the HBase bloom work was later pulled up into Hadoop to implement + org.apache.hadoop.io.BloomMapFile. Version 1 of HBase blooms never worked that well. + Version 2 is a rewrite from scratch though again it starts with the one-lab work. + + See also . -
- Bloom StoreFile footprint +
+ Bloom StoreFile footprint - Bloom filters add an entry to the StoreFile - general FileInfo data structure and then two - extra entries to the StoreFile metadata - section. + Bloom filters add an entry to the StoreFile general + FileInfo data structure and then two extra entries to the + StoreFile metadata section. -
- BloomFilter in the <classname>StoreFile</classname> - <classname>FileInfo</classname> data structure +
+ BloomFilter in the <classname>StoreFile</classname> + <classname>FileInfo</classname> data structure - FileInfo has a - BLOOM_FILTER_TYPE entry which is set to - NONE, ROW or - ROWCOL. + FileInfo has a BLOOM_FILTER_TYPE entry + which is set to NONE, ROW or + ROWCOL. +
+ +
+ BloomFilter entries in <classname>StoreFile</classname> metadata + + BLOOM_FILTER_META holds Bloom Size, Hash Function used, etc. Its + small in size and is cached on StoreFile.Reader load + BLOOM_FILTER_DATA is the actual bloomfilter data. Obtained + on-demand. Stored in the LRU cache, if it is enabled (Its enabled by default). +
+
+ Bloom Filter Configuration +
+ <varname>io.hfile.bloom.enabled</varname> global kill switch -
- BloomFilter entries in <classname>StoreFile</classname> - metadata + io.hfile.bloom.enabled in Configuration serves + as the kill switch in case something goes wrong. Default = + true. +
- BLOOM_FILTER_META holds Bloom Size, Hash - Function used, etc. Its small in size and is cached on - StoreFile.Reader load - BLOOM_FILTER_DATA is the actual bloomfilter - data. Obtained on-demand. Stored in the LRU cache, if it is enabled - (Its enabled by default). +
+ <varname>io.hfile.bloom.error.rate</varname> + + io.hfile.bloom.error.rate = average false positive rate. Default + = 1%. Decrease rate by ½ (e.g. to .5%) == +1 bit per bloom entry. +
+ +
+ <varname>io.hfile.bloom.max.fold</varname> + + io.hfile.bloom.max.fold = guaranteed minimum fold rate. Most + people should leave this alone. Default = 7, or can collapse to at least 1/128th of + original size. See the Development Process section of the document BloomFilters + in HBase for more on what this option means. +
-
-
- Bloom Filter Configuration -
- <varname>io.hfile.bloom.enabled</varname> global kill - switch +
+ - io.hfile.bloom.enabled in - Configuration serves as the kill switch in case - something goes wrong. Default = true. -
+
+ -
- <varname>io.hfile.bloom.error.rate</varname> - - io.hfile.bloom.error.rate = average false - positive rate. Default = 1%. Decrease rate by ½ (e.g. to .5%) == +1 - bit per bloom entry. -
- -
- <varname>io.hfile.bloom.max.fold</varname> - - io.hfile.bloom.max.fold = guaranteed minimum - fold rate. Most people should leave this alone. Default = 7, or can - collapse to at least 1/128th of original size. See the - Development Process section of the document BloomFilters - in HBase for more on what this option means. -
-
-
- -
- -
+
Deleting from HBase -
- Using HBase Tables as Queues - HBase tables are sometimes used as queues. In this case, special care must be taken to regularly perform major compactions on tables used in - this manner. As is documented in , marking rows as deleted creates additional StoreFiles which then need to be processed - on reads. Tombstones only get cleaned up with major compactions. - - See also and HBaseAdmin.majorCompact. - -
-
- Delete RPC Behavior - Be aware that htable.delete(Delete) doesn't use the writeBuffer. It will execute an RegionServer RPC with each invocation. - For a large number of deletes, consider htable.delete(List). - - See - -
-
- -
HDFS - Because HBase runs on it is important to understand how it works and how it affects - HBase. - -
Current Issues With Low-Latency Reads - The original use-case for HDFS was batch processing. As such, there low-latency reads were historically not a priority. - With the increased adoption of Apache HBase this is changing, and several improvements are already in development. - See the - Umbrella Jira Ticket for HDFS Improvements for HBase. +
+ Using HBase Tables as Queues + HBase tables are sometimes used as queues. In this case, special care must be taken to + regularly perform major compactions on tables used in this manner. As is documented in , marking rows as deleted creates additional StoreFiles which then + need to be processed on reads. Tombstones only get cleaned up with major compactions. + See also and HBaseAdmin.majorCompact.
-
- Leveraging local data -Since Hadoop 1.0.0 (also 0.22.1, 0.23.1, CDH3u3 and HDP 1.0) via -HDFS-2246, -it is possible for the DFSClient to take a "short circuit" and -read directly from the disk instead of going through the DataNode when the -data is local. What this means for HBase is that the RegionServers can -read directly off their machine's disks instead of having to open a -socket to talk to the DataNode, the former being generally much -fasterSee JD's Performance Talk. -Also see HBase, mail # dev - read short circuit thread for -more discussion around short circuit reads. - -To enable "short circuit" reads, it will depend on your version of Hadoop. - The original shortcircuit read patch was much improved upon in Hadoop 2 in - HDFS-347. - See for details - on the difference between the old and new implementations. See - Hadoop shortcircuit reads configuration page - for how to enable the latter, better version of shortcircuit. -For example, here is a minimal config. enabling short-circuit reads added to -hbase-site.xml: - +
+ Delete RPC Behavior + Be aware that htable.delete(Delete) doesn't use the writeBuffer. It will + execute an RegionServer RPC with each invocation. For a large number of deletes, consider + htable.delete(List). + See + +
+
+ + +
+ HDFS + Because HBase runs on it is important to understand how it works and how it affects HBase. +
+ Current Issues With Low-Latency Reads + The original use-case for HDFS was batch processing. As such, there low-latency reads + were historically not a priority. With the increased adoption of Apache HBase this is + changing, and several improvements are already in development. See the Umbrella Jira Ticket for HDFS + Improvements for HBase. +
+
+ Leveraging local data + Since Hadoop 1.0.0 (also 0.22.1, 0.23.1, CDH3u3 and HDP 1.0) via HDFS-2246, it is + possible for the DFSClient to take a "short circuit" and read directly from the disk instead + of going through the DataNode when the data is local. What this means for HBase is that the + RegionServers can read directly off their machine's disks instead of having to open a socket + to talk to the DataNode, the former being generally much faster + See JD's Performance + Talk + . Also see HBase, mail # dev - read short + circuit thread for more discussion around short circuit reads. + To enable "short circuit" reads, it will depend on your version of Hadoop. The original + shortcircuit read patch was much improved upon in Hadoop 2 in HDFS-347. See + for details on the difference between the old and new implementations. See Hadoop + shortcircuit reads configuration page for how to enable the latter, better version + of shortcircuit. For example, here is a minimal config. enabling short-circuit reads added + to hbase-site.xml: + dfs.client.read.shortcircuit true @@ -705,74 +812,85 @@ For example, here is a minimal config. enabling short-circuit reads added to TCP port of the DataNode. ]]> -Be careful about permissions for the directory that hosts the shared domain -socket; dfsclient will complain if open to other than the hbase user. -If you are running on an old Hadoop, one that is without - HDFS-347 but that - has -HDFS-2246, -you must set two configurations. -First, the hdfs-site.xml needs to be amended. Set -the property dfs.block.local-path-access.user -to be the only user that can use the shortcut. -This has to be the user that started HBase. Then in hbase-site.xml, -set dfs.client.read.shortcircuit to be true - - - -Services -- at least the HBase RegionServers -- will need to be restarted in order to pick up the new -configurations. - - - dfs.client.read.shortcircuit.buffer.size - The default for this value is too high when running on a highly trafficed HBase. - In HBase, if this value has not been set, we set it down from the default of 1M to 128k - (Since HBase 0.98.0 and 0.96.1). See HBASE-8143 HBase on Hadoop 2 with local short circuit reads (ssr) causes OOM). - The Hadoop DFSClient in HBase will allocate a direct byte buffer of this size for each - block it has open; given HBase keeps its HDFS files open all the time, this can add up quickly. - -
+ Be careful about permissions for the directory that hosts the shared domain socket; + dfsclient will complain if open to other than the hbase user. + If you are running on an old Hadoop, one that is without HDFS-347 but that + has HDFS-2246, you + must set two configurations. First, the hdfs-site.xml needs to be amended. Set the + property dfs.block.local-path-access.user to be the + only user that can use the shortcut. This has to be the user that + started HBase. Then in hbase-site.xml, set + dfs.client.read.shortcircuit to be true + + + + Services -- at least the HBase RegionServers -- will need to be restarted in order to + pick up the new configurations. + + dfs.client.read.shortcircuit.buffer.size + The default for this value is too high when running on a highly trafficed HBase. In + HBase, if this value has not been set, we set it down from the default of 1M to 128k + (Since HBase 0.98.0 and 0.96.1). See HBASE-8143 HBase on Hadoop + 2 with local short circuit reads (ssr) causes OOM). The Hadoop DFSClient in HBase + will allocate a direct byte buffer of this size for each block it has + open; given HBase keeps its HDFS files open all the time, this can add up quickly. + +
-
Performance Comparisons of HBase vs. HDFS - A fairly common question on the dist-list is why HBase isn't as performant as HDFS files in a batch context (e.g., as - a MapReduce source or sink). The short answer is that HBase is doing a lot more than HDFS (e.g., reading the KeyValues, - returning the most current row or specified timestamps, etc.), and as such HBase is 4-5 times slower than HDFS in this - processing context. There is room for improvement and this gap will, over time, be reduced, but HDFS - will always be faster in this use-case. - +
+ Performance Comparisons of HBase vs. HDFS + A fairly common question on the dist-list is why HBase isn't as performant as HDFS files + in a batch context (e.g., as a MapReduce source or sink). The short answer is that HBase is + doing a lot more than HDFS (e.g., reading the KeyValues, returning the most current row or + specified timestamps, etc.), and as such HBase is 4-5 times slower than HDFS in this + processing context. There is room for improvement and this gap will, over time, be reduced, + but HDFS will always be faster in this use-case.
-
Amazon EC2 - Performance questions are common on Amazon EC2 environments because it is a shared environment. You will - not see the same throughput as a dedicated server. In terms of running tests on EC2, run them several times for the same - reason (i.e., it's a shared environment and you don't know what else is happening on the server). - - If you are running on EC2 and post performance questions on the dist-list, please state this fact up-front that - because EC2 issues are practically a separate class of performance issues. - +
+ Amazon EC2 + Performance questions are common on Amazon EC2 environments because it is a shared + environment. You will not see the same throughput as a dedicated server. In terms of running + tests on EC2, run them several times for the same reason (i.e., it's a shared environment and + you don't know what else is happening on the server). + If you are running on EC2 and post performance questions on the dist-list, please state + this fact up-front that because EC2 issues are practically a separate class of performance + issues.
-
Collocating HBase and MapReduce - It is often recommended to have different clusters for HBase and MapReduce. A better qualification of this is: - don't collocate a HBase that serves live requests with a heavy MR workload. OLTP and OLAP-optimized systems have - conflicting requirements and one will lose to the other, usually the former. For example, short latency-sensitive - disk reads will have to wait in line behind longer reads that are trying to squeeze out as much throughput as - possible. MR jobs that write to HBase will also generate flushes and compactions, which will in turn invalidate - blocks in the . - - If you need to process the data from your live HBase cluster in MR, you can ship the deltas with - or use replication to get the new data in real time on the OLAP cluster. In the worst case, if you really need to - collocate both, set MR to use less Map and Reduce slots than you'd normally configure, possibly just one. - - When HBase is used for OLAP operations, it's preferable to set it up in a hardened way like configuring the ZooKeeper session - timeout higher and giving more memory to the MemStores (the argument being that the Block Cache won't be used much - since the workloads are usually long scans). - +
+ Collocating HBase and MapReduce + It is often recommended to have different clusters for HBase and MapReduce. A better + qualification of this is: don't collocate a HBase that serves live requests with a heavy MR + workload. OLTP and OLAP-optimized systems have conflicting requirements and one will lose to + the other, usually the former. For example, short latency-sensitive disk reads will have to + wait in line behind longer reads that are trying to squeeze out as much throughput as + possible. MR jobs that write to HBase will also generate flushes and compactions, which will + in turn invalidate blocks in the . + If you need to process the data from your live HBase cluster in MR, you can ship the + deltas with or use replication to get the new data in real time on the OLAP + cluster. In the worst case, if you really need to collocate both, set MR to use less Map and + Reduce slots than you'd normally configure, possibly just one. + When HBase is used for OLAP operations, it's preferable to set it up in a hardened way + like configuring the ZooKeeper session timeout higher and giving more memory to the MemStores + (the argument being that the Block Cache won't be used much since the workloads are usually + long scans).
-
Case Studies - For Performance and Troubleshooting Case Studies, see . - +
+ Case Studies + For Performance and Troubleshooting Case Studies, see .
diff --git a/src/main/docbkx/preface.xml b/src/main/docbkx/preface.xml index 7d05abed2ee..ff8efb991eb 100644 --- a/src/main/docbkx/preface.xml +++ b/src/main/docbkx/preface.xml @@ -1,12 +1,15 @@ - - - Preface + Preface - This is the official reference guide for the HBase version it ships with. - Herein you will find either the definitive documentation on an HBase topic - as of its standing when the referenced HBase version shipped, or it - will point to the location in javadoc, - JIRA - or wiki where - the pertinent information can be found. + This is the official reference guide for the HBase version it ships with. Herein you + will find either the definitive documentation on an HBase topic as of its standing when the + referenced HBase version shipped, or it will point to the location in javadoc, JIRA or wiki where the pertinent + information can be found. - This reference guide is a work in progress. The source for this guide can - be found at src/main/docbkx in a checkout of the hbase - project. This reference guide is marked up using - DocBook from which the - the finished guide is generated as part of the 'site' build target. Run - mvn site to generate this documentation. - Amendments and improvements to the documentation are welcomed. Add a - patch to an issue up in the HBase JIRA. + This reference guide is a work in progress. The source for this guide can be found at + src/main/docbkx in a checkout of the hbase project. This reference + guide is marked up using DocBook from which the the finished guide is + generated as part of the 'site' build target. Run mvn site + to generate this documentation. Amendments and improvements to the documentation are + welcomed. Add a patch to an issue up in the HBase JIRA. - - Heads-up if this is your first foray into the world of distributed computing... - - If this is your first foray into the wonderful world of - Distributed Computing, then you are in for - some interesting times. First off, distributed systems are - hard; making a distributed system hum requires a disparate - skillset that spans systems (hardware and software) and - networking. Your cluster' operation can hiccup because of any - of a myriad set of reasons from bugs in HBase itself through misconfigurations - -- misconfiguration of HBase but also operating system misconfigurations -- - through to hardware problems whether it be a bug in your network card - drivers or an underprovisioned RAM bus (to mention two recent - examples of hardware issues that manifested as "HBase is slow"). - You will also need to do a recalibration if up to this your - computing has been bound to a single box. Here is one good - starting point: - Fallacies of Distributed Computing. - That said, you are welcome. Its a fun place to be. Yours, the HBase Community. - - + + Heads-up if this is your first foray into the world of distributed + computing... + If this is your first foray into the wonderful world of Distributed Computing, then + you are in for some interesting times. First off, distributed systems are hard; making a + distributed system hum requires a disparate skillset that spans systems (hardware and + software) and networking. Your cluster' operation can hiccup because of any of a myriad + set of reasons from bugs in HBase itself through misconfigurations -- misconfiguration + of HBase but also operating system misconfigurations -- through to hardware problems + whether it be a bug in your network card drivers or an underprovisioned RAM bus (to + mention two recent examples of hardware issues that manifested as "HBase is slow"). You + will also need to do a recalibration if up to this your computing has been bound to a + single box. Here is one good starting point: Fallacies + of Distributed Computing. That said, you are welcome. Its a fun place to be. + Yours, the HBase Community. + diff --git a/src/main/docbkx/rpc.xml b/src/main/docbkx/rpc.xml index cbc59b79707..5745a33c79e 100644 --- a/src/main/docbkx/rpc.xml +++ b/src/main/docbkx/rpc.xml @@ -1,13 +1,15 @@ - - - 0.95 RPC Specification - In 0.95, all client/server communication is done with - protobuf’ed Messages rather than with - Hadoop Writables. - Our RPC wire format therefore changes. - This document describes the client/server request/response protocol and our new RPC wire-format. - - For what RPC is like in 0.94 and previous, - see Benoît/Tsuna’s Unofficial Hadoop / HBase RPC protocol documentation. - For more background on how we arrived at this spec., see - HBase RPC: WIP - -
Goals - - - - A wire-format we can evolve - - - A format that does not require our rewriting server core or - radically changing its current architecture (for later). - - - -
-
TODO - - - - List of problems with currently specified format and where - we would like to go in a version2, etc. For example, what would we - have to change if anything to move server async or to support - streaming/chunking? - - - Diagram on how it works - - - A grammar that succinctly describes the wire-format. Currently - we have these words and the content of the rpc protobuf idl but - a grammar for the back and forth would help with groking rpc. Also, - a little state machine on client/server interactions would help - with understanding (and ensuring correct implementation). - - - -
-
RPC - The client will send setup information on connection establish. - Thereafter, the client invokes methods against the remote server sending a protobuf Message and receiving a protobuf Message in response. - Communication is synchronous. All back and forth is preceded by an int that has the total length of the request/response. - Optionally, Cells(KeyValues) can be passed outside of protobufs in follow-behind Cell blocks (because - we can’t protobuf megabytes of KeyValues or Cells). - These CellBlocks are encoded and optionally compressed. - - For more detail on the protobufs involved, see the - RPC.proto file in trunk. + 0.95 RPC Specification + In 0.95, all client/server communication is done with protobuf’ed Messages rather than + with Hadoop + Writables. Our RPC wire format therefore changes. This document describes the + client/server request/response protocol and our new RPC wire-format. + + For what RPC is like in 0.94 and previous, see Benoît/Tsuna’s Unofficial + Hadoop / HBase RPC protocol documentation. For more background on how we arrived + at this spec., see HBase + RPC: WIP + +
+ Goals + + + + A wire-format we can evolve + + + A format that does not require our rewriting server core or radically + changing its current architecture (for later). + + + +
+
+ TODO + + + + List of problems with currently specified format and where we would like + to go in a version2, etc. For example, what would we have to change if + anything to move server async or to support streaming/chunking? + + + Diagram on how it works + + + A grammar that succinctly describes the wire-format. Currently we have + these words and the content of the rpc protobuf idl but a grammar for the + back and forth would help with groking rpc. Also, a little state machine on + client/server interactions would help with understanding (and ensuring + correct implementation). + + + +
+
+ RPC + The client will send setup information on connection establish. Thereafter, the client + invokes methods against the remote server sending a protobuf Message and receiving a + protobuf Message in response. Communication is synchronous. All back and forth is + preceded by an int that has the total length of the request/response. Optionally, + Cells(KeyValues) can be passed outside of protobufs in follow-behind Cell blocks + (because we + can’t protobuf megabytes of KeyValues or Cells). These CellBlocks are encoded + and optionally compressed. + + For more detail on the protobufs involved, see the RPC.proto + file in trunk. -
- Connection Setup - Client initiates connection. -
Client - On connection setup, client sends a preamble followed by a connection header. - +
+ Connection Setup + Client initiates connection. +
+ Client + On connection setup, client sends a preamble followed by a connection header. -
- <preamble> - <MAGIC 4 byte integer> <1 byte RPC Format Version> <1 byte auth type> We need the auth method spec. here so the connection header is encoded if auth enabled. - E.g.: HBas0x000x50 -- 4 bytes of MAGIC -- ‘HBas’ -- plus one-byte of version, 0 in this case, and one byte, 0x50 (SIMPLE). of an auth type. -
+
+ <preamble> + <MAGIC 4 byte integer> <1 byte RPC Format Version> <1 byte auth type> We need the auth method spec. here so the connection header is encoded if auth enabled. + E.g.: HBas0x000x50 -- 4 bytes of MAGIC -- ‘HBas’ -- plus one-byte of + version, 0 in this case, and one byte, 0x50 (SIMPLE). of an auth + type. +
-
- <Protobuf ConnectionHeader Message> - Has user info, and “protocol”, as well as the encoders and compression the client will use sending CellBlocks. - CellBlock encoders and compressors are for the life of the connection. - CellBlock encoders implement org.apache.hadoop.hbase.codec.Codec. - CellBlocks may then also be compressed. - Compressors implement org.apache.hadoop.io.compress.CompressionCodec. - This protobuf is written using writeDelimited so is prefaced by a pb varint - with its serialized length -
-
+
+ <Protobuf ConnectionHeader Message> + Has user info, and “protocol”, as well as the encoders and compression the + client will use sending CellBlocks. CellBlock encoders and compressors are + for the life of the connection. CellBlock encoders implement + org.apache.hadoop.hbase.codec.Codec. CellBlocks may then also be compressed. + Compressors implement org.apache.hadoop.io.compress.CompressionCodec. This + protobuf is written using writeDelimited so is prefaced by a pb varint with + its serialized length +
+
+ -
Server - After client sends preamble and connection header, - server does NOT respond if successful connection setup. - No response means server is READY to accept requests and to give out response. - If the version or authentication in the preamble is not agreeable or the server has trouble parsing the preamble, - it will throw a org.apache.hadoop.hbase.ipc.FatalConnectionException explaining the error and will then disconnect. - If the client in the connection header -- i.e. the protobuf’d Message that comes after the connection preamble -- asks for for a - Service the server does not support or a codec the server does not have, again we throw a FatalConnectionException with explanation. -
-
+
+ Server + After client sends preamble and connection header, server does NOT respond if + successful connection setup. No response means server is READY to accept + requests and to give out response. If the version or authentication in the + preamble is not agreeable or the server has trouble parsing the preamble, it + will throw a org.apache.hadoop.hbase.ipc.FatalConnectionException explaining the + error and will then disconnect. If the client in the connection header -- i.e. + the protobuf’d Message that comes after the connection preamble -- asks for for + a Service the server does not support or a codec the server does not have, again + we throw a FatalConnectionException with explanation. +
+
-
Request - After a Connection has been set up, client makes requests. Server responds. - A request is made up of a protobuf RequestHeader followed by a protobuf Message parameter. - The header includes the method name and optionally, metadata on the optional CellBlock that may be following. - The parameter type suits the method being invoked: i.e. if we are doing a getRegionInfo request, - the protobuf Message param will be an instance of GetRegionInfoRequest. - The response will be a GetRegionInfoResponse. - The CellBlock is optionally used ferrying the bulk of the RPC data: i.e Cells/KeyValues. - -
Request Parts -
<Total Length> - The request is prefaced by an int that holds the total length of what follows. -
-
<Protobuf RequestHeader Message> - Will have call.id, trace.id, and method name, etc. including optional Metadata on the Cell block IFF one is following. - Data is protobuf’d inline in this pb Message or optionally comes in the following CellBlock -
-
<Protobuf Param Message> - If the method being invoked is getRegionInfo, if you study the Service descriptor for the client to regionserver protocol, - you will find that the request sends a GetRegionInfoRequest protobuf Message param in this position. -
-
<CellBlock> - An encoded and optionally compressed Cell block. -
-
-
+
+ Request + After a Connection has been set up, client makes requests. Server responds. + A request is made up of a protobuf RequestHeader followed by a protobuf Message + parameter. The header includes the method name and optionally, metadata on the + optional CellBlock that may be following. The parameter type suits the method being + invoked: i.e. if we are doing a getRegionInfo request, the protobuf Message param + will be an instance of GetRegionInfoRequest. The response will be a + GetRegionInfoResponse. The CellBlock is optionally used ferrying the bulk of the RPC + data: i.e Cells/KeyValues. +
+ Request Parts +
+ <Total Length> + The request is prefaced by an int that holds the total length of what + follows. +
+
+ <Protobuf RequestHeader Message> + Will have call.id, trace.id, and method name, etc. including optional + Metadata on the Cell block IFF one is following. Data is protobuf’d inline + in this pb Message or optionally comes in the following CellBlock +
+
+ <Protobuf Param Message> + If the method being invoked is getRegionInfo, if you study the Service + descriptor for the client to regionserver protocol, you will find that the + request sends a GetRegionInfoRequest protobuf Message param in this + position. +
+
+ <CellBlock> + An encoded and optionally compressed Cell block. +
+
+ +
+ -
Response - Same as Request, it is a protobuf ResponseHeader followed by a protobuf Message response where the Message response type suits the method invoked. - Bulk of the data may come in a following CellBlock. -
Response Parts -
<Total Length> - The response is prefaced by an int that holds the total length of what follows. -
-
<Protobuf ResponseHeader Message> - Will have call.id, etc. Will include exception if failed processing.  Optionally includes metadata on optional, IFF there is a CellBlock following. -
+
+ Response + Same as Request, it is a protobuf ResponseHeader followed by a protobuf Message + response where the Message response type suits the method invoked. Bulk of the data + may come in a following CellBlock. +
+ Response Parts +
+ <Total Length> + The response is prefaced by an int that holds the total length of what + follows. +
+
+ <Protobuf ResponseHeader Message> + Will have call.id, etc. Will include exception if failed processing. +  Optionally includes metadata on optional, IFF there is a CellBlock + following. +
-
<Protobuf Response Message> - Return or may be nothing if exception. If the method being invoked is getRegionInfo, if you study the Service descriptor for the client to regionserver protocol, - you will find that the response sends a GetRegionInfoResponse protobuf Message param in this position. -
-
<CellBlock> - An encoded and optionally compressed Cell block. -
-
-
+
+ <Protobuf Response Message> + Return or may be nothing if exception. If the method being invoked is + getRegionInfo, if you study the Service descriptor for the client to + regionserver protocol, you will find that the response sends a + GetRegionInfoResponse protobuf Message param in this position. +
+
+ <CellBlock> + An encoded and optionally compressed Cell block. +
+
+ +
+ -
Exceptions - There are two distinct types. - There is the request failed which is encapsulated inside the response header for the response. - The connection stays open to receive new requests. - The second type, the FatalConnectionException, kills the connection. - Exceptions can carry extra information. - See the ExceptionResponse protobuf type. - It has a flag to indicate do-no-retry as well as other miscellaneous payload to help improve client responsiveness. -
-
CellBlocks - These are not versioned. - Server can do the codec or it cannot. - If new version of a codec with say, tighter encoding, then give it a new class name. - Codecs will live on the server for all time so old clients can connect. -
-
+
+ Exceptions + There are two distinct types. There is the request failed which is encapsulated + inside the response header for the response. The connection stays open to receive + new requests. The second type, the FatalConnectionException, kills the + connection. + Exceptions can carry extra information. See the ExceptionResponse protobuf type. + It has a flag to indicate do-no-retry as well as other miscellaneous payload to help + improve client responsiveness. +
+
+ CellBlocks + These are not versioned. Server can do the codec or it cannot. If new version of a + codec with say, tighter encoding, then give it a new class name. Codecs will live on + the server for all time so old clients can connect. +
+
-
Notes -
Constraints - In some part, current wire-format -- i.e. all requests and responses preceeded by a length -- has been dictated by current server non-async architecture. -
-
One fat pb request or header+param - We went with pb header followed by pb param making a request and a pb header followed by pb response for now. - Doing header+param rather than a single protobuf Message with both header and param content: - - - - Is closer to what we currently have - - - Having a single fat pb requires extra copying putting the already pb’d param into the body of the fat request pb (and same making result) - - - We can decide whether to accept the request or not before we read the param; for example, the request might be low priority.  As is, we read header+param in one go as server is currently implemented so this is a TODO. - - - - The advantages are minor.  If later, fat request has clear advantage, can roll out a v2 later. -
-
RPC Configurations -
CellBlock Codecs - To enable a codec other than the default KeyValueCodec, - set hbase.client.rpc.codec - to the name of the Codec class to use. Codec must implement hbase's Codec Interface. After connection setup, - all passed cellblocks will be sent with this codec. The server will return cellblocks using this same codec as long - as the codec is on the servers' CLASSPATH (else you will get UnsupportedCellCodecException). - To change the default codec, set hbase.client.default.rpc.codec. - - To disable cellblocks completely and to go pure protobuf, set the default to the - empty String and do not specify a codec in your Configuration. So, set hbase.client.default.rpc.codec - to the empty string and do not set hbase.client.rpc.codec. - This will cause the client to connect to the server with no codec specified. - If a server sees no codec, it will return all responses in pure protobuf. - Running pure protobuf all the time will be slower than running with cellblocks. - -
-
Compression - Uses hadoops compression codecs. To enable compressing of passed CellBlocks, set hbase.client.rpc.compressor - to the name of the Compressor to use. Compressor must implement Hadoops' CompressionCodec Interface. After connection setup, - all passed cellblocks will be sent compressed. The server will return cellblocks compressed using this same compressor as long - as the compressor is on its CLASSPATH (else you will get UnsupportedCompressionCodecException). -
-
-
+
+ Notes +
+ Constraints + In some part, current wire-format -- i.e. all requests and responses preceeded by + a length -- has been dictated by current server non-async architecture. +
+
+ One fat pb request or header+param + We went with pb header followed by pb param making a request and a pb header + followed by pb response for now. Doing header+param rather than a single protobuf + Message with both header and param content: + + + + Is closer to what we currently have + + + Having a single fat pb requires extra copying putting the already pb’d + param into the body of the fat request pb (and same making + result) + + + We can decide whether to accept the request or not before we read the + param; for example, the request might be low priority.  As is, we read + header+param in one go as server is currently implemented so this is a + TODO. + + + + The advantages are minor.  If later, fat request has clear advantage, can roll out + a v2 later. +
+
+ RPC Configurations +
+ CellBlock Codecs + To enable a codec other than the default KeyValueCodec, + set hbase.client.rpc.codec to the name of the Codec class to + use. Codec must implement hbase's Codec Interface. After + connection setup, all passed cellblocks will be sent with this codec. The server + will return cellblocks using this same codec as long as the codec is on the + servers' CLASSPATH (else you will get + UnsupportedCellCodecException). + To change the default codec, set + hbase.client.default.rpc.codec. + To disable cellblocks completely and to go pure protobuf, set the default to + the empty String and do not specify a codec in your Configuration. So, set + hbase.client.default.rpc.codec to the empty string and do + not set hbase.client.rpc.codec. This will cause the client to + connect to the server with no codec specified. If a server sees no codec, it + will return all responses in pure protobuf. Running pure protobuf all the time + will be slower than running with cellblocks. +
+
+ Compression + Uses hadoops compression codecs. To enable compressing of passed CellBlocks, + set hbase.client.rpc.compressor to the name of the Compressor + to use. Compressor must implement Hadoops' CompressionCodec Interface. After + connection setup, all passed cellblocks will be sent compressed. The server will + return cellblocks compressed using this same compressor as long as the + compressor is on its CLASSPATH (else you will get + UnsupportedCompressionCodecException). +
+
+
diff --git a/src/main/docbkx/schema_design.xml b/src/main/docbkx/schema_design.xml index a79f1754975..2fdeb000b20 100644 --- a/src/main/docbkx/schema_design.xml +++ b/src/main/docbkx/schema_design.xml @@ -1,13 +1,15 @@ - - HBase and Schema Design - A good general introduction on the strength and weaknesses modelling on - the various non-rdbms datastores is Ian Varley's Master thesis, - No Relation: The Mixed Blessings of Non-Relational Databases. - Recommended. Also, read for how HBase stores data internally, and the section on - . - -
- - Schema Creation - - HBase schemas can be created or updated with - or by using HBaseAdmin in the Java API. - - Tables must be disabled when making ColumnFamily modifications, for example: - + A good general introduction on the strength and weaknesses modelling on the various + non-rdbms datastores is Ian Varley's Master thesis, No Relation: + The Mixed Blessings of Non-Relational Databases. Recommended. Also, read for how HBase stores data internally, and the section on . +
+ Schema Creation + HBase schemas can be created or updated with or by using HBaseAdmin + in the Java API. + Tables must be disabled when making ColumnFamily modifications, for example: + Configuration config = HBaseConfiguration.create(); HBaseAdmin admin = new HBaseAdmin(conf); String table = "myTable"; @@ -55,110 +57,134 @@ HColumnDescriptor cf2 = ...; admin.modifyColumn(table, cf2); // modifying existing ColumnFamily admin.enableTable(table); - - See for more information about configuring client connections. - Note: online schema changes are supported in the 0.92.x codebase, but the 0.90.x codebase requires the table - to be disabled. - -
Schema Updates - When changes are made to either Tables or ColumnFamilies (e.g., region size, block size), these changes - take effect the next time there is a major compaction and the StoreFiles get re-written. - - See for more information on StoreFiles. - + + See for more information about configuring client + connections. + Note: online schema changes are supported in the 0.92.x codebase, but the 0.90.x codebase + requires the table to be disabled. +
+ Schema Updates + When changes are made to either Tables or ColumnFamilies (e.g., region size, block + size), these changes take effect the next time there is a major compaction and the + StoreFiles get re-written. + See for more information on StoreFiles.
-
- - On the number of column families - - - HBase currently does not do well with anything above two or three column families so keep the number - of column families in your schema low. Currently, flushing and compactions are done on a per Region basis so - if one column family is carrying the bulk of the data bringing on flushes, the adjacent families - will also be flushed though the amount of data they carry is small. When many column families the - flushing and compaction interaction can make for a bunch of needless i/o loading (To be addressed by - changing flushing and compaction to work on a per column family basis). For more information - on compactions, see . - - Try to make do with one column family if you can in your schemas. Only introduce a - second and third column family in the case where data access is usually column scoped; - i.e. you query one column family or the other but usually not both at the one time. - -
Cardinality of ColumnFamilies - Where multiple ColumnFamilies exist in a single table, be aware of the cardinality (i.e., number of rows). - If ColumnFamilyA has 1 million rows and ColumnFamilyB has 1 billion rows, ColumnFamilyA's data will likely be spread - across many, many regions (and RegionServers). This makes mass scans for ColumnFamilyA less efficient. - +
+ On the number of column families + HBase currently does not do well with anything above two or three column families so keep + the number of column families in your schema low. Currently, flushing and compactions are done + on a per Region basis so if one column family is carrying the bulk of the data bringing on + flushes, the adjacent families will also be flushed though the amount of data they carry is + small. When many column families the flushing and compaction interaction can make for a bunch + of needless i/o loading (To be addressed by changing flushing and compaction to work on a per + column family basis). For more information on compactions, see . + Try to make do with one column family if you can in your schemas. Only introduce a second + and third column family in the case where data access is usually column scoped; i.e. you query + one column family or the other but usually not both at the one time. +
+ Cardinality of ColumnFamilies + Where multiple ColumnFamilies exist in a single table, be aware of the cardinality + (i.e., number of rows). If ColumnFamilyA has 1 million rows and ColumnFamilyB has 1 billion + rows, ColumnFamilyA's data will likely be spread across many, many regions (and + RegionServers). This makes mass scans for ColumnFamilyA less efficient.
-
Rowkey Design -
- - Monotonically Increasing Row Keys/Timeseries Data - - - In the HBase chapter of Tom White's book Hadoop: The Definitive Guide (O'Reilly) there is a an optimization note on watching out for a phenomenon where an import process walks in lock-step with all clients in concert pounding one of the table's regions (and thus, a single node), then moving onto the next region, etc. With monotonically increasing row-keys (i.e., using a timestamp), this will happen. See this comic by IKai Lan on why monotonically increasing row keys are problematic in BigTable-like datastores: - monotonically increasing values are bad. The pile-up on a single region brought on - by monotonically increasing keys can be mitigated by randomizing the input records to not be in sorted order, but in general it's best to avoid using a timestamp or a sequence (e.g. 1, 2, 3) as the row-key. - - If you do need to upload time series data into HBase, you should - study OpenTSDB as a - successful example. It has a page describing the schema it uses in - HBase. The key format in OpenTSDB is effectively [metric_type][event_timestamp], which would appear at first glance to contradict the previous advice about not using a timestamp as the key. However, the difference is that the timestamp is not in the lead position of the key, and the design assumption is that there are dozens or hundreds (or more) of different metric types. Thus, even with a continual stream of input data with a mix of metric types, the Puts are distributed across various points of regions in the table. - - See for some rowkey design examples. - -
-
+
+ Rowkey Design +
+ Monotonically Increasing Row Keys/Timeseries Data + In the HBase chapter of Tom White's book Hadoop: The Definitive Guide + (O'Reilly) there is a an optimization note on watching out for a phenomenon where an import + process walks in lock-step with all clients in concert pounding one of the table's regions + (and thus, a single node), then moving onto the next region, etc. With monotonically + increasing row-keys (i.e., using a timestamp), this will happen. See this comic by IKai Lan + on why monotonically increasing row keys are problematic in BigTable-like datastores: monotonically + increasing values are bad. The pile-up on a single region brought on by + monotonically increasing keys can be mitigated by randomizing the input records to not be in + sorted order, but in general it's best to avoid using a timestamp or a sequence (e.g. 1, 2, + 3) as the row-key. + If you do need to upload time series data into HBase, you should study OpenTSDB as a successful example. It has a page + describing the schema it uses in HBase. The key + format in OpenTSDB is effectively [metric_type][event_timestamp], which would appear at + first glance to contradict the previous advice about not using a timestamp as the key. + However, the difference is that the timestamp is not in the lead + position of the key, and the design assumption is that there are dozens or hundreds (or + more) of different metric types. Thus, even with a continual stream of input data with a mix + of metric types, the Puts are distributed across various points of regions in the table. + See for some rowkey design examples. +
+
Try to minimize row and column sizes Or why are my StoreFile indices large? - In HBase, values are always freighted with their coordinates; as a - cell value passes through the system, it'll be accompanied by its - row, column name, and timestamp - always. If your rows and column names - are large, especially compared to the size of the cell value, then - you may run up against some interesting scenarios. One such is - the case described by Marc Limotte at the tail of - HBASE-3551 - (recommended!). - Therein, the indices that are kept on HBase storefiles () - to facilitate random access may end up occupyng large chunks of the HBase - allotted RAM because the cell value coordinates are large. - Mark in the above cited comment suggests upping the block size so - entries in the store file index happen at a larger interval or - modify the table schema so it makes for smaller rows and column - names. - Compression will also make for larger indices. See - the thread a question storefileIndexSize - up on the user mailing list. - - Most of the time small inefficiencies don't matter all that much. Unfortunately, - this is a case where they do. Whatever patterns are selected for ColumnFamilies, attributes, and rowkeys they could be repeated - several billion times in your data. - See for more information on HBase stores data internally to see why this is important. -
Column Families - Try to keep the ColumnFamily names as small as possible, preferably one character (e.g. "d" for data/default). - - See for more information on HBase stores data internally to see why this is important. -
-
Attributes - Although verbose attribute names (e.g., "myVeryImportantAttribute") are easier to read, prefer shorter attribute names (e.g., "via") - to store in HBase. - - See for more information on HBase stores data internally to see why this is important. -
-
Rowkey Length - Keep them as short as is reasonable such that they can still be useful for required data access (e.g., Get vs. Scan). - A short key that is useless for data access is not better than a longer key with better get/scan properties. Expect tradeoffs - when designing rowkeys. - -
-
Byte Patterns - A long is 8 bytes. You can store an unsigned number up to 18,446,744,073,709,551,615 in those eight bytes. - If you stored this number as a String -- presuming a byte per character -- you need nearly 3x the bytes. - - Not convinced? Below is some sample code that you can run on your own. - + In HBase, values are always freighted with their coordinates; as a cell value passes + through the system, it'll be accompanied by its row, column name, and timestamp - always. If + your rows and column names are large, especially compared to the size of the cell value, + then you may run up against some interesting scenarios. One such is the case described by + Marc Limotte at the tail of HBASE-3551 + (recommended!). Therein, the indices that are kept on HBase storefiles () to facilitate random access may end up occupyng large chunks of the + HBase allotted RAM because the cell value coordinates are large. Mark in the above cited + comment suggests upping the block size so entries in the store file index happen at a larger + interval or modify the table schema so it makes for smaller rows and column names. + Compression will also make for larger indices. See the thread a + question storefileIndexSize up on the user mailing list. + Most of the time small inefficiencies don't matter all that much. Unfortunately, this is + a case where they do. Whatever patterns are selected for ColumnFamilies, attributes, and + rowkeys they could be repeated several billion times in your data. + See for more information on HBase stores data internally to see why this + is important. +
+ Column Families + Try to keep the ColumnFamily names as small as possible, preferably one character + (e.g. "d" for data/default). + See for more information on HBase stores data internally to see why + this is important. +
+
+ Attributes + Although verbose attribute names (e.g., "myVeryImportantAttribute") are easier to + read, prefer shorter attribute names (e.g., "via") to store in HBase. + See for more information on HBase stores data internally to see why + this is important. +
+
+ Rowkey Length + Keep them as short as is reasonable such that they can still be useful for required + data access (e.g., Get vs. Scan). A short key that is useless for data access is not + better than a longer key with better get/scan properties. Expect tradeoffs when designing + rowkeys. +
+
+ Byte Patterns + A long is 8 bytes. You can store an unsigned number up to 18,446,744,073,709,551,615 + in those eight bytes. If you stored this number as a String -- presuming a byte per + character -- you need nearly 3x the bytes. + Not convinced? Below is some sample code that you can run on your own. + // long // long l = 1234567890L; @@ -178,11 +204,11 @@ System.out.println("md5 digest bytes length: " + digest.length); // returns 1 String sDigest = new String(digest); byte[] sbDigest = Bytes.toBytes(sDigest); System.out.println("md5 digest as string length: " + sbDigest.length); // returns 26 - - - Unfortunately, using a binary representation of a type will make your data harder to read outside of your code. For example, - this is what you will see in the shell when you increment a value: - + + Unfortunately, using a binary representation of a type will make your data harder to + read outside of your code. For example, this is what you will see in the shell when you + increment a value: + hbase(main):001:0> incr 't', 'r', 'f:q', 1 COUNTER VALUE = 1 @@ -190,53 +216,67 @@ hbase(main):002:0> get 't', 'r' COLUMN CELL f:q timestamp=1369163040570, value=\x00\x00\x00\x00\x00\x00\x00\x01 1 row(s) in 0.0310 seconds - - The shell makes a best effort to print a string, and it this case it decided to just print the hex. The same will - happen to your row keys inside the region names. It can be okay if you know what's being stored, but it might also - be unreadable if arbitrary data can be put in the same cells. This is the main trade-off. - -
+
+ The shell makes a best effort to print a string, and it this case it decided to just + print the hex. The same will happen to your row keys inside the region names. It can be + okay if you know what's being stored, but it might also be unreadable if arbitrary data + can be put in the same cells. This is the main trade-off. +
-
Reverse Timestamps - - Reverse Scan API - - HBASE-4811 implements an API to scan a table or a range within a table in reverse, reducing the need to optimize your schema for forward or reverse scanning. This feature is available in HBase 0.98 and later. See for more information. - - +
+ Reverse Timestamps + + Reverse Scan API + + HBASE-4811 + implements an API to scan a table or a range within a table in reverse, reducing the need + to optimize your schema for forward or reverse scanning. This feature is available in + HBase 0.98 and later. See + for more information. + - A common problem in database processing is quickly finding the most recent version of a value. A technique using reverse timestamps - as a part of the key can help greatly with a special case of this problem. Also found in the HBase chapter of Tom White's book Hadoop: The Definitive Guide (O'Reilly), - the technique involves appending (Long.MAX_VALUE - timestamp) to the end of any key, e.g., [key][reverse_timestamp]. - - The most recent value for [key] in a table can be found by performing a Scan for [key] and obtaining the first record. Since HBase keys - are in sorted order, this key sorts before any older row-keys for [key] and thus is first. - - This technique would be used instead of using where the intent is to hold onto all versions - "forever" (or a very long time) and at the same time quickly obtain access to any other version by using the same Scan technique. - + A common problem in database processing is quickly finding the most recent version of a + value. A technique using reverse timestamps as a part of the key can help greatly with a + special case of this problem. Also found in the HBase chapter of Tom White's book Hadoop: + The Definitive Guide (O'Reilly), the technique involves appending (Long.MAX_VALUE - + timestamp) to the end of any key, e.g., [key][reverse_timestamp]. + The most recent value for [key] in a table can be found by performing a Scan for [key] + and obtaining the first record. Since HBase keys are in sorted order, this key sorts before + any older row-keys for [key] and thus is first. + This technique would be used instead of using where the intent is to hold onto all versions "forever" (or a + very long time) and at the same time quickly obtain access to any other version by using the + same Scan technique.
-
- Rowkeys and ColumnFamilies - Rowkeys are scoped to ColumnFamilies. Thus, the same rowkey could exist in each ColumnFamily that exists in a table without collision. - +
+ Rowkeys and ColumnFamilies + Rowkeys are scoped to ColumnFamilies. Thus, the same rowkey could exist in each + ColumnFamily that exists in a table without collision.
-
Immutability of Rowkeys - Rowkeys cannot be changed. The only way they can be "changed" in a table is if the row is deleted and then re-inserted. - This is a fairly common question on the HBase dist-list so it pays to get the rowkeys right the first time (and/or before you've - inserted a lot of data). - +
+ Immutability of Rowkeys + Rowkeys cannot be changed. The only way they can be "changed" in a table is if the row + is deleted and then re-inserted. This is a fairly common question on the HBase dist-list so + it pays to get the rowkeys right the first time (and/or before you've inserted a lot of + data).
-
Relationship Between RowKeys and Region Splits - If you pre-split your table, it is critical to understand how your rowkey will be distributed across - the region boundaries. As an example of why this is important, consider the example of using displayable hex characters as the - lead position of the key (e.g., "0000000000000000" to "ffffffffffffffff"). Running those key ranges through Bytes.split - (which is the split strategy used when creating regions in HBaseAdmin.createTable(byte[] startKey, byte[] endKey, numRegions) - for 10 regions will generate the following splits... - - - +
+ Relationship Between RowKeys and Region Splits + If you pre-split your table, it is critical to understand how your + rowkey will be distributed across the region boundaries. As an example of why this is + important, consider the example of using displayable hex characters as the lead position of + the key (e.g., "0000000000000000" to "ffffffffffffffff"). Running those + key ranges through Bytes.split (which is the split strategy used when creating + regions in HBaseAdmin.createTable(byte[] startKey, byte[] endKey, numRegions) + for 10 regions will generate the following splits... + 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 // 0 54 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 // 6 61 -67 -67 -67 -67 -67 -67 -67 -67 -67 -67 -67 -67 -67 -67 -68 // = @@ -246,27 +286,28 @@ COLUMN CELL 88 -40 -40 -40 -40 -40 -40 -40 -40 -40 -40 -40 -40 -40 -40 -44 // X 95 -97 -97 -97 -97 -97 -97 -97 -97 -97 -97 -97 -97 -97 -97 -102 // _ 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 // f - - ... (note: the lead byte is listed to the right as a comment.) Given that the first split is a '0' and the last split is an 'f', - everything is great, right? Not so fast. - - The problem is that all the data is going to pile up in the first 2 regions and the last region thus creating a "lumpy" (and - possibly "hot") region problem. To understand why, refer to an ASCII Table. - '0' is byte 48, and 'f' is byte 102, but there is a huge gap in byte values (bytes 58 to 96) that will never appear in this - keyspace because the only values are [0-9] and [a-f]. Thus, the middle regions regions will - never be used. To make pre-spliting work with this example keyspace, a custom definition of splits (i.e., and not relying on the - built-in split method) is required. - - Lesson #1: Pre-splitting tables is generally a best practice, but you need to pre-split them in such a way that all the - regions are accessible in the keyspace. While this example demonstrated the problem with a hex-key keyspace, the same problem can happen - with any keyspace. Know your data. - - Lesson #2: While generally not advisable, using hex-keys (and more generally, displayable data) can still work with pre-split - tables as long as all the created regions are accessible in the keyspace. - - To conclude this example, the following is an example of how appropriate splits can be pre-created for hex-keys:. - -public static boolean createTable(HBaseAdmin admin, HTableDescriptor table, byte[][] splits) + + ... (note: the lead byte is listed to the right as a comment.) Given that the first + split is a '0' and the last split is an 'f', everything is great, right? Not so fast. + The problem is that all the data is going to pile up in the first 2 regions and the last + region thus creating a "lumpy" (and possibly "hot") region problem. To understand why, refer + to an ASCII Table. '0' is byte 48, and 'f' is byte + 102, but there is a huge gap in byte values (bytes 58 to 96) that will never + appear in this keyspace because the only values are [0-9] and [a-f]. Thus, the + middle regions regions will never be used. To make pre-spliting work with this example + keyspace, a custom definition of splits (i.e., and not relying on the built-in split method) + is required. + Lesson #1: Pre-splitting tables is generally a best practice, but you need to pre-split + them in such a way that all the regions are accessible in the keyspace. While this example + demonstrated the problem with a hex-key keyspace, the same problem can happen with + any keyspace. Know your data. + Lesson #2: While generally not advisable, using hex-keys (and more generally, + displayable data) can still work with pre-split tables as long as all the created regions + are accessible in the keyspace. + To conclude this example, the following is an example of how appropriate splits can be + pre-created for hex-keys:. + -
-
-
- - Number of Versions - -
Maximum Number of Versions - The maximum number of row versions to store is configured per column - family via HColumnDescriptor. - The default for max versions is 1. - This is an important parameter because as described in - section HBase does not overwrite row values, but rather - stores different values per row by time (and qualifier). Excess versions are removed during major - compactions. The number of max versions may need to be increased or decreased depending on application needs. - - It is not recommended setting the number of max versions to an exceedingly high level (e.g., hundreds or more) unless those old values are - very dear to you because this will greatly increase StoreFile size. - -
-
- - Minimum Number of Versions - - Like maximum number of row versions, the minimum number of row versions to keep is configured per column - family via HColumnDescriptor. - The default for min versions is 0, which means the feature is disabled. - The minimum number of row versions parameter is used together with the time-to-live parameter and can be combined with the - number of row versions parameter to allow configurations such as - "keep the last T minutes worth of data, at most N versions, but keep at least M versions around" - (where M is the value for minimum number of row versions, M<N). - This parameter should only be set when time-to-live is enabled for a column family and must be less than the - number of row versions. - +}]]>
-
- - Supported Datatypes - - HBase supports a "bytes-in/bytes-out" interface via Put and - Result, so anything that can be - converted to an array of bytes can be stored as a value. Input could be strings, numbers, complex objects, or even images as long as they can rendered as bytes. - - There are practical limits to the size of values (e.g., storing 10-50MB objects in HBase would probably be too much to ask); - search the mailling list for conversations on this topic. All rows in HBase conform to the , and - that includes versioning. Take that into consideration when making your design, as well as block size for the ColumnFamily. - + +
+ Number of Versions +
+ Maximum Number of Versions + The maximum number of row versions to store is configured per column family via HColumnDescriptor. + The default for max versions is 1. This is an important parameter because as described in section HBase does not overwrite row values, + but rather stores different values per row by time (and qualifier). Excess versions are + removed during major compactions. The number of max versions may need to be increased or + decreased depending on application needs. + It is not recommended setting the number of max versions to an exceedingly high level + (e.g., hundreds or more) unless those old values are very dear to you because this will + greatly increase StoreFile size. +
+
+ Minimum Number of Versions + Like maximum number of row versions, the minimum number of row versions to keep is + configured per column family via HColumnDescriptor. + The default for min versions is 0, which means the feature is disabled. The minimum number + of row versions parameter is used together with the time-to-live parameter and can be + combined with the number of row versions parameter to allow configurations such as "keep the + last T minutes worth of data, at most N versions, but keep at least M versions + around" (where M is the value for minimum number of row versions, M<N). This + parameter should only be set when time-to-live is enabled for a column family and must be + less than the number of row versions. +
+
+
+ Supported Datatypes + HBase supports a "bytes-in/bytes-out" interface via Put + and Result, + so anything that can be converted to an array of bytes can be stored as a value. Input could + be strings, numbers, complex objects, or even images as long as they can rendered as bytes. + There are practical limits to the size of values (e.g., storing 10-50MB objects in HBase + would probably be too much to ask); search the mailling list for conversations on this topic. + All rows in HBase conform to the , and that includes versioning. Take that into consideration when + making your design, as well as block size for the ColumnFamily. -
+
Counters - - One supported datatype that deserves special mention are "counters" (i.e., the ability to do atomic increments of numbers). See - Increment in HTable. - - Synchronization on counters are done on the RegionServer, not in the client. - + One supported datatype that deserves special mention are "counters" (i.e., the ability + to do atomic increments of numbers). See Increment + in HTable. + Synchronization on counters are done on the RegionServer, not in the client.
-
Joins - If you have multiple tables, don't forget to factor in the potential for into the schema design. - +
+ Joins + If you have multiple tables, don't forget to factor in the potential for into the schema design.
-
- Time To Live (TTL) - ColumnFamilies can set a TTL length in seconds, and HBase will automatically delete rows once the expiration time is reached. - This applies to all versions of a row - even the current one. The TTL time encoded in the HBase for the row is specified in UTC. - - See HColumnDescriptor for more information. - +
+ Time To Live (TTL) + ColumnFamilies can set a TTL length in seconds, and HBase will automatically delete rows + once the expiration time is reached. This applies to all versions of a + row - even the current one. The TTL time encoded in the HBase for the row is specified in UTC. + See HColumnDescriptor + for more information.
-
- - Keeping Deleted Cells - - ColumnFamilies can optionally keep deleted cells. That means deleted cells can still be retrieved with - Get or - Scan operations, - as long these operations have a time range specified that ends before the timestamp of any delete that would affect the cells. - This allows for point in time queries even in the presence of deletes. - - - Deleted cells are still subject to TTL and there will never be more than "maximum number of versions" deleted cells. - A new "raw" scan options returns all deleted rows and the delete markers. - - See HColumnDescriptor for more information. - +
+ Keeping Deleted Cells + ColumnFamilies can optionally keep deleted cells. That means deleted cells can still be + retrieved with Get + or Scan + operations, as long these operations have a time range specified that ends before the + timestamp of any delete that would affect the cells. This allows for point in time queries + even in the presence of deletes. + Deleted cells are still subject to TTL and there will never be more than "maximum number + of versions" deleted cells. A new "raw" scan options returns all deleted rows and the delete + markers. + See HColumnDescriptor + for more information.
-
- - Secondary Indexes and Alternate Query Paths - - This section could also be titled "what if my table rowkey looks like this but I also want to query my table like that." - A common example on the dist-list is where a row-key is of the format "user-timestamp" but there are reporting requirements on activity across users for certain - time ranges. Thus, selecting by user is easy because it is in the lead position of the key, but time is not. - - There is no single answer on the best way to handle this because it depends on... - - Number of users - Data size and data arrival rate - Flexibility of reporting requirements (e.g., completely ad-hoc date selection vs. pre-configured ranges) - Desired execution speed of query (e.g., 90 seconds may be reasonable to some for an ad-hoc report, whereas it may be too long for others) - - ... and solutions are also influenced by the size of the cluster and how much processing power you have to throw at the solution. - Common techniques are in sub-sections below. This is a comprehensive, but not exhaustive, list of approaches. - - It should not be a surprise that secondary indexes require additional cluster space and +
+ Secondary Indexes and Alternate Query Paths + This section could also be titled "what if my table rowkey looks like + this but I also want to query my table like that." + A common example on the dist-list is where a row-key is of the format "user-timestamp" but + there are reporting requirements on activity across users for certain time ranges. Thus, + selecting by user is easy because it is in the lead position of the key, but time is not. + There is no single answer on the best way to handle this because it depends on... + + + Number of users + + + Data size and data arrival rate + + + Flexibility of reporting requirements (e.g., completely ad-hoc date selection vs. + pre-configured ranges) + + + Desired execution speed of query (e.g., 90 seconds may be reasonable to some for an + ad-hoc report, whereas it may be too long for others) + + + ... and solutions are also influenced by the size of the cluster and how much processing + power you have to throw at the solution. Common techniques are in sub-sections below. This is + a comprehensive, but not exhaustive, list of approaches. + It should not be a surprise that secondary indexes require additional cluster space and processing. This is precisely what happens in an RDBMS because the act of creating an alternate index requires both space and processing cycles to update. RDBMS products are more advanced in this regard to handle alternative index management out of the box. However, HBase scales better at larger data volumes, so this is a feature trade-off. - Pay attention to when implementing any of these approaches. - Additionally, see the David Butler response in this dist-list thread HBase, mail # user - Stargate+hbase - -
- - Filter Query - - Depending on the case, it may be appropriate to use . In this case, no secondary index is created. - However, don't try a full-scan on a large table like this from an application (i.e., single-threaded client). - -
-
- - Periodic-Update Secondary Index - - A secondary index could be created in an other table which is periodically updated via a MapReduce job. The job could be executed intra-day, but depending on - load-strategy it could still potentially be out of sync with the main data table. - See for more information. -
-
- - Dual-Write Secondary Index - - Another strategy is to build the secondary index while publishing data to the cluster (e.g., write to data table, write to index table). - If this is approach is taken after a data table already exists, then bootstrapping will be needed for the secondary index with a MapReduce job (see ). -
-
- - Summary Tables - - Where time-ranges are very wide (e.g., year-long report) and where the data is voluminous, summary tables are a common approach. - These would be generated with MapReduce jobs into another table. - See for more information. -
-
- - Coprocessor Secondary Index - - Coprocessors act like RDBMS triggers. These were added in 0.92. For more information, see - -
-
-
Constraints - HBase currently supports 'constraints' in traditional (SQL) database parlance. The advised usage for Constraints is in enforcing business rules for attributes in the table (eg. make sure values are in the range 1-10). - Constraints could also be used to enforce referential integrity, but this is strongly discouraged as it will dramatically decrease the write throughput of the tables where integrity checking is enabled. - Extensive documentation on using Constraints can be found at: Constraint since version 0.94. + Pay attention to when implementing any of these approaches. + Additionally, see the David Butler response in this dist-list thread HBase, + mail # user - Stargate+hbase +
+ Filter Query + Depending on the case, it may be appropriate to use . In this case, no secondary index is created. However, don't + try a full-scan on a large table like this from an application (i.e., single-threaded + client). +
+
+ Periodic-Update Secondary Index + A secondary index could be created in an other table which is periodically updated via a + MapReduce job. The job could be executed intra-day, but depending on load-strategy it could + still potentially be out of sync with the main data table. + See for more information. +
+
+ Dual-Write Secondary Index + Another strategy is to build the secondary index while publishing data to the cluster + (e.g., write to data table, write to index table). If this is approach is taken after a data + table already exists, then bootstrapping will be needed for the secondary index with a + MapReduce job (see ). +
+
+ Summary Tables + Where time-ranges are very wide (e.g., year-long report) and where the data is + voluminous, summary tables are a common approach. These would be generated with MapReduce + jobs into another table. + See for more information. +
+
+ Coprocessor Secondary Index + Coprocessors act like RDBMS triggers. These were added in 0.92. For more information, + see + +
-
Schema Design Case Studies - The following will describe some typical data ingestion use-cases with HBase, and how the rowkey design and construction - can be approached. Note: this is just an illustration of potential approaches, not an exhaustive list. - Know your data, and know your processing requirements. - - It is highly recommended that you read the rest of the first, before reading - these case studies. - - Thee following case studies are described: - - Log Data / Timeseries Data - Log Data / Timeseries on Steroids - Customer/Order - Tall/Wide/Middle Schema Design - List Data - - -
+
+ Constraints + HBase currently supports 'constraints' in traditional (SQL) database parlance. The advised + usage for Constraints is in enforcing business rules for attributes in the table (eg. make + sure values are in the range 1-10). Constraints could also be used to enforce referential + integrity, but this is strongly discouraged as it will dramatically decrease the write + throughput of the tables where integrity checking is enabled. Extensive documentation on using + Constraints can be found at: Constraint + since version 0.94. +
+
+ Schema Design Case Studies + The following will describe some typical data ingestion use-cases with HBase, and how the + rowkey design and construction can be approached. Note: this is just an illustration of + potential approaches, not an exhaustive list. Know your data, and know your processing + requirements. + It is highly recommended that you read the rest of the first, before reading these case studies. + The following case studies are described: + + + Log Data / Timeseries Data + + + Log Data / Timeseries on Steroids + + + Customer/Order + + + Tall/Wide/Middle Schema Design + + + List Data + + +
Case Study - Log Data and Timeseries Data - Assume that the following data elements are being collected. - - Hostname - Timestamp - Log event - Value/message - - We can store them in an HBase table called LOG_DATA, but what will the rowkey be? - From these attributes the rowkey will be some combination of hostname, timestamp, and log-event - but what specifically? - -
+ Assume that the following data elements are being collected. + + + Hostname + + + Timestamp + + + Log event + + + Value/message + + + We can store them in an HBase table called LOG_DATA, but what will the rowkey be? From + these attributes the rowkey will be some combination of hostname, timestamp, and log-event - + but what specifically? +
Timestamp In The Rowkey Lead Position - The rowkey [timestamp][hostname][log-event] suffers from the monotonically increasing rowkey problem - described in . - - There is another pattern frequently mentioned in the dist-lists about “bucketing” timestamps, by performing a mod operation - on the timestamp. If time-oriented scans are important, this could be a useful approach. Attention must be paid to the number - of buckets, because this will require the same number of scans to return results. - + The rowkey [timestamp][hostname][log-event] suffers from the + monotonically increasing rowkey problem described in . + There is another pattern frequently mentioned in the dist-lists about “bucketing” + timestamps, by performing a mod operation on the timestamp. If time-oriented scans are + important, this could be a useful approach. Attention must be paid to the number of + buckets, because this will require the same number of scans to return results. + long bucket = timestamp % numBuckets; - - … to construct: - + + … to construct: + [bucket][timestamp][hostname][log-event] - - As stated above, to select data for a particular timerange, a Scan will need to be performed for each bucket. 100 buckets, - for example, will provide a wide distribution in the keyspace but it will require 100 Scans to obtain data for a single - timestamp, so there are trade-offs. - -
-
+ + As stated above, to select data for a particular timerange, a Scan will need to be + performed for each bucket. 100 buckets, for example, will provide a wide distribution in + the keyspace but it will require 100 Scans to obtain data for a single timestamp, so there + are trade-offs. +
+ +
Host In The Rowkey Lead Position - The rowkey [hostname][log-event][timestamp] is a candidate if there is a large-ish number of hosts to spread - the writes and reads across the keyspace. This approach would be useful if scanning by hostname was a priority. - -
-
+ The rowkey [hostname][log-event][timestamp] is a candidate if there is a + large-ish number of hosts to spread the writes and reads across the keyspace. This + approach would be useful if scanning by hostname was a priority. +
+ +
Timestamp, or Reverse Timestamp? - If the most important access path is to pull most recent events, then storing the timestamps as reverse-timestamps - (e.g., timestamp = Long.MAX_VALUE – timestamp) will create the property of being able to do a Scan on - [hostname][log-event] to obtain the quickly obtain the most recently captured events. - - Neither approach is wrong, it just depends on what is most appropriate for the situation. - - - Reverse Scan API - - HBASE-4811 implements an API to scan a table or a range within a table in reverse, reducing the need to optimize your schema for forward or reverse scanning. This feature is available in HBase 0.98 and later. See for more information. - - -
-
+ If the most important access path is to pull most recent events, then storing the + timestamps as reverse-timestamps (e.g., timestamp = Long.MAX_VALUE – + timestamp) will create the property of being able to do a Scan on + [hostname][log-event] to obtain the quickly obtain the most recently + captured events. + Neither approach is wrong, it just depends on what is most appropriate for the + situation. + + Reverse Scan API + + HBASE-4811 + implements an API to scan a table or a range within a table in reverse, reducing the + need to optimize your schema for forward or reverse scanning. This feature is available + in HBase 0.98 and later. See + for more information. + +
+ +
Variangle Length or Fixed Length Rowkeys? - It is critical to remember that rowkeys are stamped on every column in HBase. If the hostname is “a” and the event type - is “e1” then the resulting rowkey would be quite small. However, what if the ingested hostname is - “myserver1.mycompany.com” and the event type is “com.package1.subpackage2.subsubpackage3.ImportantService”? - - It might make sense to use some substitution in the rowkey. There are at least two approaches: hashed and numeric. - In the Hostname In The Rowkey Lead Position example, it might look like this: - - Composite Rowkey With Hashes: - - [MD5 hash of hostname] = 16 bytes - [MD5 hash of event-type] = 16 bytes - [timestamp] = 8 bytes - - - Composite Rowkey With Numeric Substitution: - - For this approach another lookup table would be needed in addition to LOG_DATA, called LOG_TYPES. - The rowkey of LOG_TYPES would be: - - [type] (e.g., byte indicating hostname vs. event-type) - [bytes] variable length bytes for raw hostname or event-type. - - A column for this rowkey could be a long with an assigned number, which could be obtained by using an - HBase counter. - - So the resulting composite rowkey would be: - - [substituted long for hostname] = 8 bytes - [substituted long for event type] = 8 bytes - [timestamp] = 8 bytes - - In either the Hash or Numeric substitution approach, the raw values for hostname and event-type can be stored as columns. - -
-
-
+ It is critical to remember that rowkeys are stamped on every column in HBase. If the + hostname is “a” and the event type is “e1” then the resulting rowkey would be quite small. + However, what if the ingested hostname is “myserver1.mycompany.com” and the event type is + “com.package1.subpackage2.subsubpackage3.ImportantService”? + It might make sense to use some substitution in the rowkey. There are at least two + approaches: hashed and numeric. In the Hostname In The Rowkey Lead Position example, it + might look like this: + Composite Rowkey With Hashes: + + + [MD5 hash of hostname] = 16 bytes + + + [MD5 hash of event-type] = 16 bytes + + + [timestamp] = 8 bytes + + + Composite Rowkey With Numeric Substitution: + For this approach another lookup table would be needed in addition to LOG_DATA, called + LOG_TYPES. The rowkey of LOG_TYPES would be: + + + [type] (e.g., byte indicating hostname vs. event-type) + + + [bytes] variable length bytes for raw hostname or event-type. + + + A column for this rowkey could be a long with an assigned number, which could be + obtained by using an HBase + counter. + So the resulting composite rowkey would be: + + + [substituted long for hostname] = 8 bytes + + + [substituted long for event type] = 8 bytes + + + [timestamp] = 8 bytes + + + In either the Hash or Numeric substitution approach, the raw values for hostname and + event-type can be stored as columns. +
+ +
+ +
Case Study - Log Data and Timeseries Data on Steroids - This effectively is the OpenTSDB approach. What OpenTSDB does is re-write data and pack rows into columns for - certain time-periods. For a detailed explanation, see: http://opentsdb.net/schema.html, - and Lessons Learned from OpenTSDB - from HBaseCon2012. - - But this is how the general concept works: data is ingested, for example, in this manner… - + This effectively is the OpenTSDB approach. What OpenTSDB does is re-write data and pack + rows into columns for certain time-periods. For a detailed explanation, see: http://opentsdb.net/schema.html, and Lessons + Learned from OpenTSDB from HBaseCon2012. + But this is how the general concept works: data is ingested, for example, in this + manner… + [hostname][log-event][timestamp1] [hostname][log-event][timestamp2] [hostname][log-event][timestamp3] - - … with separate rowkeys for each detailed event, but is re-written like this… - - [hostname][log-event][timerange] - - … and each of the above events are converted into columns stored with a time-offset relative to the beginning timerange - (e.g., every 5 minutes). This is obviously a very advanced processing technique, but HBase makes this possible. - -
- -
+ + … with separate rowkeys for each detailed event, but is re-written like this… + [hostname][log-event][timerange] + … and each of the above events are converted into columns stored with a time-offset + relative to the beginning timerange (e.g., every 5 minutes). This is obviously a very + advanced processing technique, but HBase makes this possible. +
+ + +
Case Study - Customer/Order - Assume that HBase is used to store customer and order information. There are two core record-types being ingested: - a Customer record type, and Order record type. - - The Customer record type would include all the things that you’d typically expect: - - Customer number - Customer name - Address (e.g., city, state, zip) - Phone numbers, etc. - - - The Order record type would include things like: - - Customer number - Order number - Sales date - A series of nested objects for shipping locations and line-items (see - for details) - - - Assuming that the combination of customer number and sales order uniquely identify an order, these two attributes will compose - the rowkey, and specifically a composite key such as: - - [customer number][order number] - - … for a ORDER table. However, there are more design decisions to make: are the raw values the best choices for rowkeys? - - The same design questions in the Log Data use-case confront us here. What is the keyspace of the customer number, and what is the -format (e.g., numeric? alphanumeric?) As it is advantageous to use fixed-length keys in HBase, as well as keys that can support a -reasonable spread in the keyspace, similar options appear: - - Composite Rowkey With Hashes: + Assume that HBase is used to store customer and order information. There are two core + record-types being ingested: a Customer record type, and Order record type. + The Customer record type would include all the things that you’d typically expect: - [MD5 of customer number] = 16 bytes - [MD5 of order number] = 16 bytes + + Customer number + + + Customer name + + + Address (e.g., city, state, zip) + + + Phone numbers, etc. + - - Composite Numeric/Hash Combo Rowkey: + The Order record type would include things like: - [substituted long for customer number] = 8 bytes - [MD5 of order number] = 16 bytes + + Customer number + + + Order number + + + Sales date + + + A series of nested objects for shipping locations and line-items (see for details) + - -
- Single Table? Multiple Tables? - A traditional design approach would have separate tables for CUSTOMER and SALES. Another option is to pack multiple - record types into a single table (e.g., CUSTOMER++). - - Customer Record Type Rowkey: - - [customer-id] - [type] = type indicating ‘1’ for customer record type - - - Order Record Type Rowkey: - - [customer-id] - [type] = type indicating ‘2’ for order record type - [order] - - - The advantage of this particular CUSTOMER++ approach is that organizes many different record-types by customer-id - (e.g., a single scan could get you everything about that customer). The disadvantage is that it’s not as easy to scan for - a particular record-type. - + Assuming that the combination of customer number and sales order uniquely identify an + order, these two attributes will compose the rowkey, and specifically a composite key such + as: + [customer number][order number] + … for a ORDER table. However, there are more design decisions to make: are the + raw values the best choices for rowkeys? + The same design questions in the Log Data use-case confront us here. What is the + keyspace of the customer number, and what is the format (e.g., numeric? alphanumeric?) As it + is advantageous to use fixed-length keys in HBase, as well as keys that can support a + reasonable spread in the keyspace, similar options appear: + Composite Rowkey With Hashes: + + + [MD5 of customer number] = 16 bytes + + + [MD5 of order number] = 16 bytes + + + Composite Numeric/Hash Combo Rowkey: + + + [substituted long for customer number] = 8 bytes + + + [MD5 of order number] = 16 bytes + + +
+ Single Table? Multiple Tables? + A traditional design approach would have separate tables for CUSTOMER and SALES. + Another option is to pack multiple record types into a single table (e.g., CUSTOMER++). + Customer Record Type Rowkey: + + + [customer-id] + + + [type] = type indicating ‘1’ for customer record type + + + Order Record Type Rowkey: + + + [customer-id] + + + [type] = type indicating ‘2’ for order record type + + + [order] + + + The advantage of this particular CUSTOMER++ approach is that organizes many different + record-types by customer-id (e.g., a single scan could get you everything about that + customer). The disadvantage is that it’s not as easy to scan for a particular record-type. + +
+
+ Order Object Design + Now we need to address how to model the Order object. Assume that the class structure + is as follows: + + + Order + + (an Order can have multiple ShippingLocations + + + + LineItem + + (a ShippingLocation can have multiple LineItems + + + + ... there are multiple options on storing this data. +
+ Completely Normalized + With this approach, there would be separate tables for ORDER, SHIPPING_LOCATION, and + LINE_ITEM. + The ORDER table's rowkey was described above: + + The SHIPPING_LOCATION's composite rowkey would be something like this: + + + [order-rowkey] + + + [shipping location number] (e.g., 1st location, 2nd, etc.) + + + The LINE_ITEM table's composite rowkey would be something like this: + + + [order-rowkey] + + + [shipping location number] (e.g., 1st location, 2nd, etc.) + + + [line item number] (e.g., 1st lineitem, 2nd, etc.) + + + Such a normalized model is likely to be the approach with an RDBMS, but that's not + your only option with HBase. The cons of such an approach is that to retrieve + information about any Order, you will need: + + + Get on the ORDER table for the Order + + + Scan on the SHIPPING_LOCATION table for that order to get the ShippingLocation + instances + + + Scan on the LINE_ITEM for each ShippingLocation + + + ... granted, this is what an RDBMS would do under the covers anyway, but since there + are no joins in HBase you're just more aware of this fact.
-
- Order Object Design - Now we need to address how to model the Order object. Assume that the class structure is as follows: - -Order - ShippingLocation (an Order can have multiple ShippingLocations) - LineItem (a ShippingLocation can have multiple LineItems) - - ... there are multiple options on storing this data. - -
- Completely Normalized - With this approach, there would be separate tables for ORDER, SHIPPING_LOCATION, and LINE_ITEM. - - The ORDER table's rowkey was described above: - - The SHIPPING_LOCATION's composite rowkey would be something like this: - - [order-rowkey] - [shipping location number] (e.g., 1st location, 2nd, etc.) - - - The LINE_ITEM table's composite rowkey would be something like this: - - [order-rowkey] - [shipping location number] (e.g., 1st location, 2nd, etc.) - [line item number] (e.g., 1st lineitem, 2nd, etc.) - - - Such a normalized model is likely to be the approach with an RDBMS, but that's not your only option with HBase. - The cons of such an approach is that to retrieve information about any Order, you will need: - - Get on the ORDER table for the Order - Scan on the SHIPPING_LOCATION table for that order to get the ShippingLocation instances - Scan on the LINE_ITEM for each ShippingLocation - - ... granted, this is what an RDBMS would do under the covers anyway, but since there are no joins in HBase - you're just more aware of this fact. - -
-
- Single Table With Record Types - With this approach, there would exist a single table ORDER that would contain - - The Order rowkey was described above: - - [order-rowkey] - [ORDER record type] - - - The ShippingLocation composite rowkey would be something like this: - - [order-rowkey] - [SHIPPING record type] - [shipping location number] (e.g., 1st location, 2nd, etc.) - - - The LineItem composite rowkey would be something like this: - - [order-rowkey] - [LINE record type] - [shipping location number] (e.g., 1st location, 2nd, etc.) - [line item number] (e.g., 1st lineitem, 2nd, etc.) - - -
-
- Denormalized - A variant of the Single Table With Record Types approach is to denormalize and flatten some of the object - hierarchy, such as collapsing the ShippingLocation attributes onto each LineItem instance. - - The LineItem composite rowkey would be something like this: - - [order-rowkey] - [LINE record type] - [line item number] (e.g., 1st lineitem, 2nd, etc. - care must be taken that there are unique across the entire order) - - - ... and the LineItem columns would be something like this: - - itemNumber - quantity - price - shipToLine1 (denormalized from ShippingLocation) - shipToLine2 (denormalized from ShippingLocation) - shipToCity (denormalized from ShippingLocation) - shipToState (denormalized from ShippingLocation) - shipToZip (denormalized from ShippingLocation) - - - The pros of this approach include a less complex object heirarchy, but one of the cons is that updating gets more - complicated in case any of this information changes. - -
-
- Object BLOB - With this approach, the entire Order object graph is treated, in one way or another, as a BLOB. For example, the - ORDER table's rowkey was described above: , and a - single column called "order" would contain an object that could be deserialized that contained a container Order, - ShippingLocations, and LineItems. - - There are many options here: JSON, XML, Java Serialization, Avro, Hadoop Writables, etc. All of them are variants - of the same approach: encode the object graph to a byte-array. Care should be taken with this approach to ensure backward - compatibilty in case the object model changes such that older persisted structures can still be read back out of HBase. - - Pros are being able to manage complex object graphs with minimal I/O (e.g., a single HBase Get per - Order in this example), but the cons include the aforementioned warning about backward compatiblity of serialization, - language dependencies of serialization (e.g., Java Serialization only works with Java clients), the fact that - you have to deserialize the entire object to get any piece of information inside the BLOB, and the difficulty in - getting frameworks like Hive to work with custom objects like this. - -
-
-
- -
Case Study - "Tall/Wide/Middle" Schema Design Smackdown - This section will describe additional schema design questions that appear on the dist-list, specifically about - tall and wide tables. These are general guidelines and not laws - each application must consider its own needs. - -
Rows vs. Versions - A common question is whether one should prefer rows or HBase's built-in-versioning. The - context is typically where there are "a lot" of versions of a row to be retained (e.g., - where it is significantly above the HBase default of 1 max versions). The rows-approach - would require storing a timestamp in some portion of the rowkey so that they would not - overwite with each successive update. - Preference: Rows (generally speaking). - -
-
Rows vs. Columns - Another common question is whether one should prefer rows or columns. The context is typically in extreme cases of wide - tables, such as having 1 row with 1 million attributes, or 1 million rows with 1 columns apiece. - - Preference: Rows (generally speaking). To be clear, this guideline is in the context is in extremely wide cases, not in the - standard use-case where one needs to store a few dozen or hundred columns. But there is also a middle path between these two - options, and that is "Rows as Columns." - -
-
Rows as Columns - The middle path between Rows vs. Columns is packing data that would be a separate row into columns, for certain rows. - OpenTSDB is the best example of this case where a single row represents a defined time-range, and then discrete events are treated as - columns. This approach is often more complex, and may require the additional complexity of re-writing your data, but has the - advantage of being I/O efficient. For an overview of this approach, see - . - -
-
- +
+ + +
+ Case Study - "Tall/Wide/Middle" Schema Design Smackdown + This section will describe additional schema design questions that appear on the + dist-list, specifically about tall and wide tables. These are general guidelines and not + laws - each application must consider its own needs. +
+ Rows vs. Versions + A common question is whether one should prefer rows or HBase's built-in-versioning. + The context is typically where there are "a lot" of versions of a row to be retained + (e.g., where it is significantly above the HBase default of 1 max versions). The + rows-approach would require storing a timestamp in some portion of the rowkey so that they + would not overwite with each successive update. + Preference: Rows (generally speaking). +
+
+ Rows vs. Columns + Another common question is whether one should prefer rows or columns. The context is + typically in extreme cases of wide tables, such as having 1 row with 1 million attributes, + or 1 million rows with 1 columns apiece. + Preference: Rows (generally speaking). To be clear, this guideline is in the context + is in extremely wide cases, not in the standard use-case where one needs to store a few + dozen or hundred columns. But there is also a middle path between these two options, and + that is "Rows as Columns." +
+
+ Rows as Columns + The middle path between Rows vs. Columns is packing data that would be a separate row + into columns, for certain rows. OpenTSDB is the best example of this case where a single + row represents a defined time-range, and then discrete events are treated as columns. This + approach is often more complex, and may require the additional complexity of re-writing + your data, but has the advantage of being I/O efficient. For an overview of this approach, + see . +
+
+ -
- Case Study - List Data - The following is an exchange from the user dist-list regarding a fairly common question: - how to handle per-user list data in Apache HBase. - - *** QUESTION *** - - We're looking at how to store a large amount of (per-user) list data in -HBase, and we were trying to figure out what kind of access pattern made -the most sense. One option is store the majority of the data in a key, so -we could have something like: - +
+ Case Study - List Data + The following is an exchange from the user dist-list regarding a fairly common question: + how to handle per-user list data in Apache HBase. + *** QUESTION *** + We're looking at how to store a large amount of (per-user) list data in HBase, and we + were trying to figure out what kind of access pattern made the most sense. One option is + store the majority of the data in a key, so we could have something like: - -<FixedWidthUserName><FixedWidthValueId1>:"" (no value) -<FixedWidthUserName><FixedWidthValueId2>:"" (no value) -<FixedWidthUserName><FixedWidthValueId3>:"" (no value) - + :"" (no value) +:"" (no value) +:"" (no value) +]]> -The other option we had was to do this entirely using: - -<FixedWidthUserName><FixedWidthPageNum0>:<FixedWidthLength><FixedIdNextPageNum><ValueId1><ValueId2><ValueId3>... -<FixedWidthUserName><FixedWidthPageNum1>:<FixedWidthLength><FixedIdNextPageNum><ValueId1><ValueId2><ValueId3>... - - -where each row would contain multiple values. -So in one case reading the first thirty values would be: - - -scan { STARTROW => 'FixedWidthUsername' LIMIT => 30} - -And in the second case it would be - + The other option we had was to do this entirely using: + :... +:... + ]]> + where each row would contain multiple values. So in one case reading the first thirty + values would be: + 'FixedWidthUsername' LIMIT => 30} + ]]> + And in the second case it would be + get 'FixedWidthUserName\x00\x00\x00\x00' - -The general usage pattern would be to read only the first 30 values of -these lists, with infrequent access reading deeper into the lists. Some -users would have <= 30 total values in these lists, and some users would -have millions (i.e. power-law distribution) - - - The single-value format seems like it would take up more space on HBase, -but would offer some improved retrieval / pagination flexibility. Would -there be any significant performance advantages to be able to paginate via -gets vs paginating with scans? - - - My initial understanding was that doing a scan should be faster if our -paging size is unknown (and caching is set appropriately), but that gets -should be faster if we'll always need the same page size. I've ended up -hearing different people tell me opposite things about performance. I -assume the page sizes would be relatively consistent, so for most use cases -we could guarantee that we only wanted one page of data in the -fixed-page-length case. I would also assume that we would have infrequent -updates, but may have inserts into the middle of these lists (meaning we'd -need to update all subsequent rows). - - -Thanks for help / suggestions / follow-up questions. - - *** ANSWER *** - -If I understand you correctly, you're ultimately trying to store -triples in the form "user, valueid, value", right? E.g., something -like: - - + The general usage pattern would be to read only the first 30 values of these lists, + with infrequent access reading deeper into the lists. Some users would have <= 30 total + values in these lists, and some users would have millions (i.e. power-law distribution) + The single-value format seems like it would take up more space on HBase, but would + offer some improved retrieval / pagination flexibility. Would there be any significant + performance advantages to be able to paginate via gets vs paginating with scans? + My initial understanding was that doing a scan should be faster if our paging size is + unknown (and caching is set appropriately), but that gets should be faster if we'll always + need the same page size. I've ended up hearing different people tell me opposite things + about performance. I assume the page sizes would be relatively consistent, so for most use + cases we could guarantee that we only wanted one page of data in the fixed-page-length case. + I would also assume that we would have infrequent updates, but may have inserts into the + middle of these lists (meaning we'd need to update all subsequent rows). + Thanks for help / suggestions / follow-up questions. + *** ANSWER *** + If I understand you correctly, you're ultimately trying to store triples in the form + "user, valueid, value", right? E.g., something like: + "user123, firstname, Paul", "user234, lastname, Smith" - -(But the usernames are fixed width, and the valueids are fixed width). - - -And, your access pattern is along the lines of: "for user X, list the -next 30 values, starting with valueid Y". Is that right? And these -values should be returned sorted by valueid? - - -The tl;dr version is that you should probably go with one row per -user+value, and not build a complicated intra-row pagination scheme on -your own unless you're really sure it is needed. - - -Your two options mirror a common question people have when designing -HBase schemas: should I go "tall" or "wide"? Your first schema is -"tall": each row represents one value for one user, and so there are -many rows in the table for each user; the row key is user + valueid, -and there would be (presumably) a single column qualifier that means -"the value". This is great if you want to scan over rows in sorted -order by row key (thus my question above, about whether these ids are -sorted correctly). You can start a scan at any user+valueid, read the -next 30, and be done. What you're giving up is the ability to have -transactional guarantees around all the rows for one user, but it -doesn't sound like you need that. Doing it this way is generally -recommended (see -here http://hbase.apache.org/book.html#schema.smackdown). - - -Your second option is "wide": you store a bunch of values in one row, -using different qualifiers (where the qualifier is the valueid). The -simple way to do that would be to just store ALL values for one user -in a single row. I'm guessing you jumped to the "paginated" version -because you're assuming that storing millions of columns in a single -row would be bad for performance, which may or may not be true; as -long as you're not trying to do too much in a single request, or do -things like scanning over and returning all of the cells in the row, -it shouldn't be fundamentally worse. The client has methods that allow -you to get specific slices of columns. - - -Note that neither case fundamentally uses more disk space than the -other; you're just "shifting" part of the identifying information for -a value either to the left (into the row key, in option one) or to the -right (into the column qualifiers in option 2). Under the covers, -every key/value still stores the whole row key, and column family -name. (If this is a bit confusing, take an hour and watch Lars -George's excellent video about understanding HBase schema design: -http://www.youtube.com/watch?v=_HLoH_PgrLk). - - -A manually paginated version has lots more complexities, as you note, -like having to keep track of how many things are in each page, -re-shuffling if new values are inserted, etc. That seems significantly -more complex. It might have some slight speed advantages (or -disadvantages!) at extremely high throughput, and the only way to -really know that would be to try it out. If you don't have time to -build it both ways and compare, my advice would be to start with the -simplest option (one row per user+value). Start simple and iterate! :) - -
+ (But the usernames are fixed width, and the valueids are fixed width). + And, your access pattern is along the lines of: "for user X, list the next 30 values, + starting with valueid Y". Is that right? And these values should be returned sorted by + valueid? + The tl;dr version is that you should probably go with one row per user+value, and not + build a complicated intra-row pagination scheme on your own unless you're really sure it is + needed. + Your two options mirror a common question people have when designing HBase schemas: + should I go "tall" or "wide"? Your first schema is "tall": each row represents one value for + one user, and so there are many rows in the table for each user; the row key is user + + valueid, and there would be (presumably) a single column qualifier that means "the value". + This is great if you want to scan over rows in sorted order by row key (thus my question + above, about whether these ids are sorted correctly). You can start a scan at any + user+valueid, read the next 30, and be done. What you're giving up is the ability to have + transactional guarantees around all the rows for one user, but it doesn't sound like you + need that. Doing it this way is generally recommended (see here http://hbase.apache.org/book.html#schema.smackdown). + Your second option is "wide": you store a bunch of values in one row, using different + qualifiers (where the qualifier is the valueid). The simple way to do that would be to just + store ALL values for one user in a single row. I'm guessing you jumped to the "paginated" + version because you're assuming that storing millions of columns in a single row would be + bad for performance, which may or may not be true; as long as you're not trying to do too + much in a single request, or do things like scanning over and returning all of the cells in + the row, it shouldn't be fundamentally worse. The client has methods that allow you to get + specific slices of columns. + Note that neither case fundamentally uses more disk space than the other; you're just + "shifting" part of the identifying information for a value either to the left (into the row + key, in option one) or to the right (into the column qualifiers in option 2). Under the + covers, every key/value still stores the whole row key, and column family name. (If this is + a bit confusing, take an hour and watch Lars George's excellent video about understanding + HBase schema design: http://www.youtube.com/watch?v=_HLoH_PgrLk). + A manually paginated version has lots more complexities, as you note, like having to + keep track of how many things are in each page, re-shuffling if new values are inserted, + etc. That seems significantly more complex. It might have some slight speed advantages (or + disadvantages!) at extremely high throughput, and the only way to really know that would be + to try it out. If you don't have time to build it both ways and compare, my advice would be + to start with the simplest option (one row per user+value). Start simple and iterate! :) + +
+ -
-
Operational and Performance Configuration Options - See the Performance section for more information operational and performance - schema design options, such as Bloom Filters, Table-configured regionsizes, compression, and blocksizes. +
+ +
+ Operational and Performance Configuration Options + See the Performance section for more information operational and performance schema design + options, such as Bloom Filters, Table-configured regionsizes, compression, and blocksizes.
- + + diff --git a/src/main/docbkx/security.xml b/src/main/docbkx/security.xml index 1bac920e455..f0e327dd17a 100644 --- a/src/main/docbkx/security.xml +++ b/src/main/docbkx/security.xml @@ -1,13 +1,15 @@ - - -Secure Apache HBase -
+ Secure Apache HBase +
Secure Client Access to Apache HBase - Newer releases of Apache HBase (>= 0.92) support optional SASL authentication of clientsSee - also Matteo Bertozzi's article on Understanding User Authentication and Authorization in Apache HBase.. - This describes how to set up Apache HBase and clients for connection to secure HBase resources. + Newer releases of Apache HBase (>= 0.92) support optional SASL authentication of clients + See also Matteo Bertozzi's article on Understanding + User Authentication and Authorization in Apache HBase. + . + This describes how to set up Apache HBase and clients for connection to secure HBase + resources. -
Prerequisites - - You need to have a working Kerberos KDC. - - - A HBase configured for secure client access is expected to be running - on top of a secured HDFS cluster. HBase must be able to authenticate - to HDFS services. HBase needs Kerberos credentials to interact with - the Kerberos-enabled HDFS daemons. Authenticating a service should be - done using a keytab file. The procedure for creating keytabs for HBase - service is the same as for creating keytabs for Hadoop. Those steps - are omitted here. Copy the resulting keytab files to wherever HBase - Master and RegionServer processes are deployed and make them readable - only to the user account under which the HBase daemons will run. - - - A Kerberos principal has three parts, with the form - username/fully.qualified.domain.name@YOUR-REALM.COM. We - recommend using hbase as the username portion. - - - The following is an example of the configuration properties for - Kerberos operation that must be added to the - hbase-site.xml file on every server machine in the - cluster. Required for even the most basic interactions with a - secure Hadoop configuration, independent of HBase security. - - - hbase.regionserver.kerberos.principal - hbase/_HOST@YOUR-REALM.COM - - - hbase.regionserver.keytab.file - /etc/hbase/conf/keytab.krb5 - - - hbase.master.kerberos.principal - hbase/_HOST@YOUR-REALM.COM - - - hbase.master.keytab.file - /etc/hbase/conf/keytab.krb5 - +
+ Prerequisites + You need to have a working Kerberos KDC. + A HBase configured for secure client access is expected to be running on top of a + secured HDFS cluster. HBase must be able to authenticate to HDFS services. HBase needs + Kerberos credentials to interact with the Kerberos-enabled HDFS daemons. Authenticating a + service should be done using a keytab file. The procedure for creating keytabs for HBase + service is the same as for creating keytabs for Hadoop. Those steps are omitted here. Copy + the resulting keytab files to wherever HBase Master and RegionServer processes are deployed + and make them readable only to the user account under which the HBase daemons will run. + A Kerberos principal has three parts, with the form + username/fully.qualified.domain.name@YOUR-REALM.COM. We recommend using + hbase as the username portion. + The following is an example of the configuration properties for Kerberos operation that + must be added to the hbase-site.xml file on every server machine in the + cluster. Required for even the most basic interactions with a secure Hadoop configuration, + independent of HBase security. + + hbase.regionserver.kerberos.principal + hbase/_HOST@YOUR-REALM.COM + + + hbase.regionserver.keytab.file + /etc/hbase/conf/keytab.krb5 + + + hbase.master.kerberos.principal + hbase/_HOST@YOUR-REALM.COM + + + hbase.master.keytab.file + /etc/hbase/conf/keytab.krb5 + ]]> - - Each HBase client user should also be given a Kerberos principal. This - principal should have a password assigned to it (as opposed to a - keytab file). The client principal's maxrenewlife should - be set so that it can be renewed enough times for the HBase client - process to complete. For example, if a user runs a long-running HBase - client process that takes at most 3 days, we might create this user's - principal within kadmin with: addprinc -maxrenewlife - 3days - - - Long running daemons with indefinite lifetimes that require client - access to HBase can instead be configured to log in from a keytab. For - each host running such daemons, create a keytab with - kadmin or kadmin.local. The procedure for - creating keytabs for HBase service is the same as for creating - keytabs for Hadoop. Those steps are omitted here. Copy the resulting - keytab files to where the client daemon will execute and make them - readable only to the user account under which the daemon will run. - + Each HBase client user should also be given a Kerberos principal. This principal should + have a password assigned to it (as opposed to a keytab file). The client principal's + maxrenewlife should be set so that it can be renewed enough times for the + HBase client process to complete. For example, if a user runs a long-running HBase client + process that takes at most 3 days, we might create this user's principal within + kadmin with: addprinc -maxrenewlife 3days + + Long running daemons with indefinite lifetimes that require client access to HBase can + instead be configured to log in from a keytab. For each host running such daemons, create a + keytab with kadmin or kadmin.local. The procedure for creating + keytabs for HBase service is the same as for creating keytabs for Hadoop. Those steps are + omitted here. Copy the resulting keytab files to where the client daemon will execute and + make them readable only to the user account under which the daemon will run.
-
Server-side Configuration for Secure Operation - - Add the following to the hbase-site.xml file on every server machine in the cluster: - - - hbase.security.authentication - kerberos - - - hbase.security.authorization - true - - - hbase.coprocessor.region.classes - org.apache.hadoop.hbase.security.token.TokenProvider - +
+ Server-side Configuration for Secure Operation + Add the following to the hbase-site.xml file on every server machine in + the cluster: + + hbase.security.authentication + kerberos + + + hbase.security.authorization + true + + +hbase.coprocessor.region.classes + org.apache.hadoop.hbase.security.token.TokenProvider + ]]> - - A full shutdown and restart of HBase service is required when deploying - these configuration changes. - + A full shutdown and restart of HBase service is required when deploying these + configuration changes.
-
Client-side Configuration for Secure Operation - - Add the following to the hbase-site.xml file on every client: - - - hbase.security.authentication - kerberos - +
+ Client-side Configuration for Secure Operation + Add the following to the hbase-site.xml file on every client: + + hbase.security.authentication + kerberos + ]]> - - The client environment must be logged in to Kerberos from KDC or - keytab via the kinit command before communication with - the HBase cluster will be possible. - - - Be advised that if the hbase.security.authentication - in the client- and server-side site files do not match, the client will - not be able to communicate with the cluster. - - - Once HBase is configured for secure RPC it is possible to optionally - configure encrypted communication. To do so, add the following to the - hbase-site.xml file on every client: - - - hbase.rpc.protection - privacy - + The client environment must be logged in to Kerberos from KDC or keytab via the + kinit command before communication with the HBase cluster will be possible. + Be advised that if the hbase.security.authentication in the client- and + server-side site files do not match, the client will not be able to communicate with the + cluster. + Once HBase is configured for secure RPC it is possible to optionally configure + encrypted communication. To do so, add the following to the hbase-site.xml file + on every client: + + hbase.rpc.protection + privacy + ]]> - - This configuration property can also be set on a per connection basis. - Set it in the Configuration supplied to - HTable: - - - Configuration conf = HBaseConfiguration.create(); - conf.set("hbase.rpc.protection", "privacy"); - HTable table = new HTable(conf, tablename); + This configuration property can also be set on a per connection basis. Set it in the + Configuration supplied to HTable: + +Configuration conf = HBaseConfiguration.create(); +conf.set("hbase.rpc.protection", "privacy"); +HTable table = new HTable(conf, tablename); - - Expect a ~10% performance penalty for encrypted communication. - + Expect a ~10% performance penalty for encrypted communication.
-
Client-side Configuration for Secure Operation - Thrift Gateway - - Add the following to the hbase-site.xml file for every Thrift gateway: - - hbase.thrift.keytab.file - /etc/hbase/conf/hbase.keytab - - - hbase.thrift.kerberos.principal - $USER/_HOST@HADOOP.LOCALDOMAIN - - +
+ Client-side Configuration for Secure Operation - Thrift Gateway + Add the following to the hbase-site.xml file for every Thrift gateway: + hbase.thrift.keytab.file + /etc/hbase/conf/hbase.keytab + + + hbase.thrift.kerberos.principal + $USER/_HOST@HADOOP.LOCALDOMAIN + + ]]> - - - Substitute the appropriate credential and keytab for $USER and $KEYTAB - respectively. - - In order to use the Thrift API principal to interact with HBase, it is also necessary to add the hbase.thrift.kerberos.principal to the _acl_ table. For example, to give the Thrift API principal, thrift_server, administrative access, a command such as this one will suffice: - For more information about ACLs, please see the Access Control section - + + Substitute the appropriate credential and keytab for $USER and $KEYTAB respectively. + In order to use the Thrift API principal to interact with HBase, it is also necessary to + add the hbase.thrift.kerberos.principal to the _acl_ table. For + example, to give the Thrift API principal, thrift_server, administrative + access, a command such as this one will suffice: + + For more information about ACLs, please see the Access Control section - - The Thrift gateway will authenticate with HBase using the supplied - credential. No authentication will be performed by the Thrift gateway - itself. All client access via the Thrift gateway will use the Thrift - gateway's credential and have its privilege. - + The Thrift gateway will authenticate with HBase using the supplied credential. No + authentication will be performed by the Thrift gateway itself. All client access via the + Thrift gateway will use the Thrift gateway's credential and have its privilege.
-
Client-side Configuration for Secure Operation - REST Gateway - - Add the following to the hbase-site.xml file for every REST gateway: - - hbase.rest.keytab.file - $KEYTAB - - - hbase.rest.kerberos.principal - $USER/_HOST@HADOOP.LOCALDOMAIN - +
+ Client-side Configuration for Secure Operation - REST Gateway + Add the following to the hbase-site.xml file for every REST gateway: + + hbase.rest.keytab.file + $KEYTAB + + + hbase.rest.kerberos.principal + $USER/_HOST@HADOOP.LOCALDOMAIN + ]]> - - - Substitute the appropriate credential and keytab for $USER and $KEYTAB - respectively. - - - The REST gateway will authenticate with HBase using the supplied - credential. No authentication will be performed by the REST gateway - itself. All client access via the REST gateway will use the REST - gateway's credential and have its privilege. - - In order to use the REST API principal to interact with HBase, it is also necessary to add the hbase.rest.kerberos.principal to the _acl_ table. For example, to give the REST API principal, rest_server, administrative access, a command such as this one will suffice: - For more information about ACLs, please see the Access Control section - - - It should be possible for clients to authenticate with the HBase - cluster through the REST gateway in a pass-through manner via SPEGNO - HTTP authentication. This is future work. - -
- -
REST Gateway Impersonation Configuration - - By default, the REST gateway doesn't support impersonation. It accesses - the HBase on behalf of clients as the user configured as in the previous - section. To the HBase server, all requests are from the REST gateway user. - The actual users are unknown. You can turn on the impersonation support. - With impersonation, the REST gateway user is a proxy user. The HBase server - knows the acutal/real user of each request. So it can apply proper - authorizations. - - - To turn on REST gateway impersonation, we need to configure HBase servers - (masters and region servers) to allow proxy users; configure REST gateway - to enable impersonation. - - - To allow proxy users, add the following to the hbase-site.xml - file for every HBase server: - - hadoop.security.authorization - true - - - hadoop.proxyuser.$USER.groups - $GROUPS - - - hadoop.proxyuser.$USER.hosts - $GROUPS - + Substitute the appropriate credential and keytab for $USER and $KEYTAB respectively. + The REST gateway will authenticate with HBase using the supplied credential. No + authentication will be performed by the REST gateway itself. All client access via the REST + gateway will use the REST gateway's credential and have its privilege. + In order to use the REST API principal to interact with HBase, it is also necessary to + add the hbase.rest.kerberos.principal to the _acl_ table. For + example, to give the REST API principal, rest_server, administrative access, a + command such as this one will suffice: + - - - Substitute the REST gateway proxy user for $USER, and the allowed - group list for $GROUPS. - - - To enable REST gateway impersonation, add the following to the - hbase-site.xml file for every REST gateway. - - hbase.rest.authentication.type - kerberos - - - hbase.rest.authentication.kerberos.principal - HTTP/_HOST@HADOOP.LOCALDOMAIN - - - hbase.rest.authentication.kerberos.keytab - $KEYTAB - + For more information about ACLs, please see the Access Control section + It should be possible for clients to authenticate with the HBase cluster through the + REST gateway in a pass-through manner via SPEGNO HTTP authentication. This is future work. + +
+ +
+ REST Gateway Impersonation Configuration + By default, the REST gateway doesn't support impersonation. It accesses the HBase on + behalf of clients as the user configured as in the previous section. To the HBase server, + all requests are from the REST gateway user. The actual users are unknown. You can turn on + the impersonation support. With impersonation, the REST gateway user is a proxy user. The + HBase server knows the acutal/real user of each request. So it can apply proper + authorizations. + To turn on REST gateway impersonation, we need to configure HBase servers (masters and + region servers) to allow proxy users; configure REST gateway to enable impersonation. + To allow proxy users, add the following to the hbase-site.xml file for + every HBase server: + + hadoop.security.authorization + true + + + hadoop.proxyuser.$USER.groups + $GROUPS + + + hadoop.proxyuser.$USER.hosts + $GROUPS + ]]> - - - Substitute the keytab for HTTP for $KEYTAB. - -
+ Substitute the REST gateway proxy user for $USER, and the allowed group list for + $GROUPS. + To enable REST gateway impersonation, add the following to the + hbase-site.xml file for every REST gateway. + + hbase.rest.authentication.type + kerberos + + + hbase.rest.authentication.kerberos.principal + HTTP/_HOST@HADOOP.LOCALDOMAIN + + + hbase.rest.authentication.kerberos.keytab + $KEYTAB + + ]]> + Substitute the keytab for HTTP for $KEYTAB. +
-
+
+ -
+
Simple User Access to Apache HBase - Newer releases of Apache HBase (>= 0.92) support optional SASL authentication of clientsSee - also Matteo Bertozzi's article on Understanding User Authentication and Authorization in Apache HBase.. - This describes how to set up Apache HBase and clients for simple user access to HBase resources. + Newer releases of Apache HBase (>= 0.92) support optional SASL authentication of clients + See also Matteo Bertozzi's article on Understanding + User Authentication and Authorization in Apache HBase. + . + This describes how to set up Apache HBase and clients for simple user access to HBase + resources. -
Simple Versus Secure Access - - The following section shows how to set up simple user access. Simple user access is - not a secure method of operating HBase. This method is used to prevent users from making - mistakes. It can be used to mimic the Access Control using on a development system without having to - set up Kerberos. - - - This method is not used to prevent malicious or hacking attempts. To make HBase secure against these - types of attacks, you must configure HBase for secure operation. Refer to the section - Secure Client Access to HBase and complete all of the steps described - there. - +
+ Simple Versus Secure Access + The following section shows how to set up simple user access. Simple user access is not + a secure method of operating HBase. This method is used to prevent users from making + mistakes. It can be used to mimic the Access Control using on a development system without + having to set up Kerberos. + This method is not used to prevent malicious or hacking attempts. To make HBase secure + against these types of attacks, you must configure HBase for secure operation. Refer to the + section Secure Client Access to HBase and + complete all of the steps described there. -
Prerequisites - - None - +
+ Prerequisites + None -
Server-side Configuration for Simple User Access Operation - - Add the following to the hbase-site.xml file on every server machine in the cluster: - - - hbase.security.authentication - simple - - - hbase.security.authorization - true - - - hbase.coprocessor.master.classes - org.apache.hadoop.hbase.security.access.AccessController - - - hbase.coprocessor.region.classes - org.apache.hadoop.hbase.security.access.AccessController - +
+ Server-side Configuration for Simple User Access Operation + Add the following to the hbase-site.xml file on every server machine + in the cluster: + + hbase.security.authentication + simple + + + hbase.security.authorization + true + + + hbase.coprocessor.master.classes + org.apache.hadoop.hbase.security.access.AccessController + + + hbase.coprocessor.region.classes + org.apache.hadoop.hbase.security.access.AccessController + ]]> - - For 0.94, add the following to the hbase-site.xml file on every server machine in the cluster: - - - hbase.rpc.engine - org.apache.hadoop.hbase.ipc.SecureRpcEngine - - - hbase.coprocessor.master.classes - org.apache.hadoop.hbase.security.access.AccessController - - - hbase.coprocessor.region.classes - org.apache.hadoop.hbase.security.access.AccessController - + For 0.94, add the following to the hbase-site.xml file on every server + machine in the cluster: + + hbase.rpc.engine + org.apache.hadoop.hbase.ipc.SecureRpcEngine + + + hbase.coprocessor.master.classes + org.apache.hadoop.hbase.security.access.AccessController + + + hbase.coprocessor.region.classes + org.apache.hadoop.hbase.security.access.AccessController + ]]> - - A full shutdown and restart of HBase service is required when deploying - these configuration changes. - + A full shutdown and restart of HBase service is required when deploying these + configuration changes. +
+ +
+ Client-side Configuration for Simple User Access Operation + Add the following to the hbase-site.xml file on every client: + + hbase.security.authentication + simple + + ]]> + For 0.94, add the following to the hbase-site.xml file on every server + machine in the cluster: + + hbase.rpc.engine + org.apache.hadoop.hbase.ipc.SecureRpcEngine + + ]]> + Be advised that if the hbase.security.authentication in the client- + and server-side site files do not match, the client will not be able to communicate with + the cluster. +
+ +
+ Client-side Configuration for Simple User Access Operation - Thrift Gateway + The Thrift gateway user will need access. For example, to give the Thrift API user, + thrift_server, administrative access, a command such as this one will + suffice: + + For more information about ACLs, please see the Access Control section + + The Thrift gateway will authenticate with HBase using the supplied credential. No + authentication will be performed by the Thrift gateway itself. All client access via the + Thrift gateway will use the Thrift gateway's credential and have its privilege. +
+ +
+ Client-side Configuration for Simple User Access Operation - REST Gateway + + The REST gateway will authenticate with HBase using the supplied credential. No + authentication will be performed by the REST gateway itself. All client access via the + REST gateway will use the REST gateway's credential and have its privilege. + The REST gateway user will need access. For example, to give the REST API user, + rest_server, administrative access, a command such as this one will + suffice: + + For more information about ACLs, please see the Access Control section + It should be possible for clients to authenticate with the HBase cluster through + the REST gateway in a pass-through manner via SPEGNO HTTP authentication. This is future + work. +
+
-
Client-side Configuration for Simple User Access Operation - - Add the following to the hbase-site.xml file on every client: - +
+ + +
+ Tags + Every cell can have metadata associated with it. Adding metadata in the data part of + every cell would make things difficult. + The 0.98 version of HBase solves this problem by providing Tags along with the cell + format. Some of the usecases that uses the tags are Visibility labels, Cell level ACLs, etc. + HFile V3 version from 0.98 onwards supports tags and this feature can be turned on using + the following configuration - hbase.security.authentication - simple - + + hfile.format.version + 3 + ]]> - - For 0.94, add the following to the hbase-site.xml file on every server machine in the cluster: - + Every cell can have zero or more tags. Every tag has a type and the actual tag byte + array. The types 0-31 are reserved for System tags. For example ‘1’ is + reserved for ACL and ‘2’ is reserved for Visibility tags. + The way rowkeys, column families, qualifiers and values are encoded using different + Encoding Algos, similarly the tags can also be encoded. Tag encoding can be turned on per CF. + Default is always turn ON. To turn on the tag encoding on the HFiles use - hbase.rpc.engine - org.apache.hadoop.hbase.ipc.SecureRpcEngine - +HColumnDescriptor#setCompressTags(boolean compressTags) ]]> - - Be advised that if the hbase.security.authentication - in the client- and server-side site files do not match, the client will - not be able to communicate with the cluster. - -
- -
Client-side Configuration for Simple User Access Operation - Thrift Gateway - The Thrift gateway user will need access. For example, to give the Thrift API user, thrift_server, administrative access, a command such as this one will suffice: + Note that encoding of tags takes place only if the DataBlockEncoder is enabled for the + CF. + As we compress the WAL entries using Dictionary the tags present in the WAL can also be + compressed using Dictionary. Every tag is compressed individually using WAL Dictionary. To + turn ON tag compression in WAL dictionary enable the property For more information about ACLs, please see the Access Control section - - - - The Thrift gateway will authenticate with HBase using the supplied - credential. No authentication will be performed by the Thrift gateway - itself. All client access via the Thrift gateway will use the Thrift - gateway's credential and have its privilege. - -
- -
Client-side Configuration for Simple User Access Operation - REST Gateway - - - The REST gateway will authenticate with HBase using the supplied - credential. No authentication will be performed by the REST gateway - itself. All client access via the REST gateway will use the REST - gateway's credential and have its privilege. - - The REST gateway user will need access. For example, to give the REST API user, rest_server, administrative access, a command such as this one will suffice: + + hbase.regionserver.wal.tags.enablecompression + true + + ]]> + To add tags to every cell during Puts, the following apis are provided For more information about ACLs, please see the Access Control section - +Put#add(byte[] family, byte [] qualifier, byte [] value, Tag[] tag) +Put#add(byte[] family, byte[] qualifier, long ts, byte[] value, Tag[] tag) + ]]> + Some of the feature developed using tags are Cell level ACLs and Visibility labels. These + are some features that use tags framework and allows users to gain better security features on + cell level. + For details, see: - It should be possible for clients to authenticate with the HBase - cluster through the REST gateway in a pass-through manner via SPEGNO - HTTP authentication. This is future work. + Access Control + Visibility labels -
-
-
- -
- -
-Tags - - Every cell can have metadata associated with it. Adding metadata in the data part of every cell would make things difficult. - - - The 0.98 version of HBase solves this problem by providing Tags along with the cell format. - Some of the usecases that uses the tags are Visibility labels, Cell level ACLs, etc. - - - HFile V3 version from 0.98 onwards supports tags and this feature can be turned on using the following configuration - - - hfile.format.version - 3 - - ]]> - - Every cell can have zero or more tags. Every tag has a type and the actual tag byte array. - The types 0-31 are reserved for System tags. For example ‘1’ is reserved for ACL and ‘2’ is reserved for Visibility tags. - - - The way rowkeys, column families, qualifiers and values are encoded using different Encoding Algos, similarly the tags can also be encoded. - Tag encoding can be turned on per CF. Default is always turn ON. - To turn on the tag encoding on the HFiles use - - - - Note that encoding of tags takes place only if the DataBlockEncoder is enabled for the CF. - - - As we compress the WAL entries using Dictionary the tags present in the WAL can also be compressed using Dictionary. - Every tag is compressed individually using WAL Dictionary. To turn ON tag compression in WAL dictionary enable the property - - - hbase.regionserver.wal.tags.enablecompression - true - - ]]> - - To add tags to every cell during Puts, the following apis are provided - - - - Some of the feature developed using tags are Cell level ACLs and Visibility labels. - These are some features that use tags framework and allows users to gain better security features on cell level. - - - For details checkout - - - Access Control - Visibility labels - -
-
+
+
Access Control - - Newer releases of Apache HBase (>= 0.92) support optional access control - list (ACL-) based protection of resources on a column family and/or - table basis. - - - This describes how to set up Secure HBase for access control, with an - example of granting and revoking user permission on table resources - provided. - + Newer releases of Apache HBase (>= 0.92) support optional access control list (ACL-) + based protection of resources on a column family and/or table basis. + This describes how to set up Secure HBase for access control, with an example of granting + and revoking user permission on table resources provided. -
Prerequisites - - You must configure HBase for secure or simple user access operation. Refer to the - Secure Client Access to HBase or - Simple User Access to HBase - sections and complete all of the steps described - there. - - - For secure access, you must also configure ZooKeeper for secure operation. Changes to ACLs - are synchronized throughout the cluster using ZooKeeper. Secure - authentication to ZooKeeper must be enabled or otherwise it will be - possible to subvert HBase access control via direct client access to - ZooKeeper. Refer to the section on secure ZooKeeper configuration and - complete all of the steps described there. - +
+ Prerequisites + You must configure HBase for secure or simple user access operation. Refer to the Secure Client Access to HBase or Simple User Access to HBase sections and + complete all of the steps described there. + For secure access, you must also configure ZooKeeper for secure operation. Changes to + ACLs are synchronized throughout the cluster using ZooKeeper. Secure authentication to + ZooKeeper must be enabled or otherwise it will be possible to subvert HBase access control + via direct client access to ZooKeeper. Refer to the section on secure ZooKeeper + configuration and complete all of the steps described there.
-
Overview - - With Secure RPC and Access Control enabled, client access to HBase is - authenticated and user data is private unless access has been - explicitly granted. Access to data can be granted at a table or per - column family basis. - - - However, the following items have been left out of the initial - implementation for simplicity: - - - - Row-level or per value (cell): Using Tags in HFile V3 - - - Push down of file ownership to HDFS: HBase is not designed for the case where files may have different permissions than the HBase system principal. Pushing file ownership down into HDFS would necessitate changes to core code. Also, while HDFS file ownership would make applying quotas easy, and possibly make bulk imports more straightforward, it is not clear that it would offer a more secure setup. - - - HBase managed "roles" as collections of permissions: We will not model "roles" internally in HBase to begin with. We instead allow group names to be granted permissions, which allows external modeling of roles via group membership. Groups are created and manipulated externally to HBase, via the Hadoop group mapping service. - - - -Access control mechanisms are mature and fairly standardized in the relational database world. The HBase implementation approximates current convention, but HBase has a simpler feature set than relational databases, especially in terms of client operations. We don't distinguish between an insert (new record) and update (of existing record), for example, as both collapse down into a Put. Accordingly, the important operations condense to four permissions: READ, WRITE, CREATE, and ADMIN. - - - Operation To Permission Mapping - - - - - - Permission - Operation - - - - - - Read - Get - - - - Exists - - - - Scan - - - - Write - Put - - - - Delete - - - - Lock/UnlockRow - - - - IncrementColumnValue - - - - CheckAndDelete/Put - - - - Create - Create - - - - Alter - - - - Drop - - - - Bulk Load - - - - Admin - Enable/Disable - - - - Snapshot/Restore/Clone - - - - Split - - - - Flush - - - - Compact - - - - Major Compact - - - - Grant - - - - Revoke - - - - Shutdown - - - -
- - Permissions can be granted in any of the following scopes, though - CREATE and ADMIN permissions are effective only at table scope. - - - - - Table - - - Read: User can read from any column family in table - Write: User can write to any column family in table - Create: User can alter table attributes; add, alter, or drop column families; and drop the table. - Admin: User can alter table attributes; add, alter, or drop column families; and enable, disable, or drop the table. User can also trigger region (re)assignments or relocation. - - - - - Column Family - - - Read: User can read from the column family - Write: User can write to the column family - - - - - - - There is also an implicit global scope for the superuser. - - - The superuser is a principal, specified in the HBase site configuration - file, that has equivalent access to HBase as the 'root' user would on a - UNIX derived system. Normally this is the principal that the HBase - processes themselves authenticate as. Although future versions of HBase - Access Control may support multiple superusers, the superuser privilege - will always include the principal used to run the HMaster process. Only - the superuser is allowed to create tables, switch the balancer on or - off, or take other actions with global consequence. Furthermore, the - superuser has an implicit grant of all permissions to all resources. - - - Tables have a new metadata attribute: OWNER, the user principal who owns - the table. By default this will be set to the user principal who creates - the table, though it may be changed at table creation time or during an - alter operation by setting or changing the OWNER table attribute. Only a - single user principal can own a table at a given time. A table owner will - have all permissions over a given table. - +
+ Overview + With Secure RPC and Access Control enabled, client access to HBase is authenticated and + user data is private unless access has been explicitly granted. Access to data can be + granted at a table or per column family basis. + However, the following items have been left out of the initial implementation for + simplicity: + + + Row-level or per value (cell): Using Tags in HFile V3 + + + Push down of file ownership to HDFS: HBase is not designed for the case where files + may have different permissions than the HBase system principal. Pushing file ownership + down into HDFS would necessitate changes to core code. Also, while HDFS file ownership + would make applying quotas easy, and possibly make bulk imports more straightforward, it + is not clear that it would offer a more secure setup. + + + HBase managed "roles" as collections of permissions: We will not model "roles" + internally in HBase to begin with. We instead allow group names to be granted + permissions, which allows external modeling of roles via group membership. Groups are + created and manipulated externally to HBase, via the Hadoop group mapping + service. + + + Access control mechanisms are mature and fairly standardized in the relational database + world. The HBase implementation approximates current convention, but HBase has a simpler + feature set than relational databases, especially in terms of client operations. We don't + distinguish between an insert (new record) and update (of existing record), for example, as + both collapse down into a Put. Accordingly, the important operations condense to four + permissions: READ, WRITE, CREATE, and ADMIN. + + Operation To Permission Mapping + + + + + + Permission + Operation + + + + + + Read + Get + + + + Exists + + + + Scan + + + + Write + Put + + + + Delete + + + + Lock/UnlockRow + + + + IncrementColumnValue + + + + CheckAndDelete/Put + + + + Create + Create + + + + Alter + + + + Drop + + + + Bulk Load + + + + Admin + Enable/Disable + + + + Snapshot/Restore/Clone + + + + Split + + + + Flush + + + + Compact + + + + Major Compact + + + + Grant + + + + Revoke + + + + Shutdown + + + +
+ Permissions can be granted in any of the following scopes, though CREATE and ADMIN + permissions are effective only at table scope. + + + Table + + + + Read: User can read from any column family in table + + + Write: User can write to any column family in table + + + Create: User can alter table attributes; add, alter, or drop column families; + and drop the table. + + + Admin: User can alter table attributes; add, alter, or drop column families; + and enable, disable, or drop the table. User can also trigger region + (re)assignments or relocation. + + + + + + Column Family + + + + Read: User can read from the column family + + + Write: User can write to the column family + + + + + + + There is also an implicit global scope for the superuser. + The superuser is a principal, specified in the HBase site configuration file, that has + equivalent access to HBase as the 'root' user would on a UNIX derived system. Normally this + is the principal that the HBase processes themselves authenticate as. Although future + versions of HBase Access Control may support multiple superusers, the superuser privilege + will always include the principal used to run the HMaster process. Only the superuser is + allowed to create tables, switch the balancer on or off, or take other actions with global + consequence. Furthermore, the superuser has an implicit grant of all permissions to all + resources. + Tables have a new metadata attribute: OWNER, the user principal who owns the table. By + default this will be set to the user principal who creates the table, though it may be + changed at table creation time or during an alter operation by setting or changing the OWNER + table attribute. Only a single user principal can own a table at a given time. A table owner + will have all permissions over a given table.
-
Server-side Configuration for Access Control - - Enable the AccessController coprocessor in the cluster configuration - and restart HBase. The restart can be a rolling one. Complete the - restart of all Master and RegionServer processes before setting up - ACLs. - - - To enable the AccessController, modify the hbase-site.xml file on every server machine in the cluster to look like: - - - hbase.coprocessor.master.classes - org.apache.hadoop.hbase.security.access.AccessController - - - hbase.coprocessor.region.classes - org.apache.hadoop.hbase.security.token.TokenProvider, - org.apache.hadoop.hbase.security.access.AccessController - +
+ Server-side Configuration for Access Control + Enable the AccessController coprocessor in the cluster configuration and restart HBase. + The restart can be a rolling one. Complete the restart of all Master and RegionServer + processes before setting up ACLs. + To enable the AccessController, modify the hbase-site.xml file on every + server machine in the cluster to look like: + + hbase.coprocessor.master.classes + org.apache.hadoop.hbase.security.access.AccessController + + +hbase.coprocessor.region.classes + org.apache.hadoop.hbase.security.token.TokenProvider, + org.apache.hadoop.hbase.security.access.AccessController + ]]>
- Cell level Access Control using Tags - - Prior to HBase 0.98 access control was restricted to table and column family level. Thanks to tags feature in 0.98 that allows Access control on a cell level. - The existing Access Controller coprocessor helps in achieving cell level access control also. - For details on configuring it refer to Access Control section. - - - The ACLs can be specified for every mutation using the APIs - - perms) + Cell level Access Control using Tags + Prior to HBase 0.98 access control was restricted to table and column family level. + Thanks to tags feature in 0.98 that allows Access control on a cell level. The existing + Access Controller coprocessor helps in achieving cell level access control also. For details + on configuring it refer to Access Control section. + The ACLs can be specified for every mutation using the APIs + perms) ]]> - - For example, to provide read permission to an user ‘user1’ then - - For example, to provide read permission to an user ‘user1’ then + - - Generally the ACL applied on the table and CF takes precedence over Cell level ACL. In order to make the cell level ACL to take precedence use the following API, - - Generally the ACL applied on the table and CF takes precedence over Cell level ACL. In + order to make the cell level ACL to take precedence use the following API, + - - Please note that inorder to use this feature, HFile V3 version should be turned on. - - - hfile.format.version - 3 - + Please note that inorder to use this feature, HFile V3 version should be turned on. + + hfile.format.version + 3 + ]]> - - Note that deletes with ACLs do not have any effect. - To keep things simple the ACLs applied on the current Put does not change the ACL of any previous Put in the sense - that the ACL on the current put does not affect older versions of Put for the same row. - + Note that deletes with ACLs do not have any effect. To keep things simple the ACLs + applied on the current Put does not change the ACL of any previous Put in the sense that the + ACL on the current put does not affect older versions of Put for the same row.
-
Shell Enhancements for Access Control - -The HBase shell has been extended to provide simple commands for editing and updating user permissions. The following commands have been added for access control list management: - +
+ Shell Enhancements for Access Control + The HBase shell has been extended to provide simple commands for editing and updating + user permissions. The following commands have been added for access control list management: - - Grant - - grant <user|@group> <permissions> [ <table> [ <column family> [ <column qualifier> ] ] ] - - - - <user|@group> is user or group (start with character '@'), Groups are created and manipulated via the Hadoop group mapping service. - - - <permissions> is zero or more letters from the set "RWCA": READ('R'), WRITE('W'), CREATE('C'), ADMIN('A'). - - - Note: Grants and revocations of individual permissions on a resource are both accomplished using the grant command. A separate revoke command is also provided by the shell, but this is for fast revocation of all of a user's access rights to a given resource only. - - - Revoke + + Grant + [ [ [ ] ] ] + ]]> + - - revoke <user|@group> [ <table> [ <column family> [ <column qualifier> ] ] ] - - - - Alter + + <user|@group> is user or group (start with character '@'), Groups are + created and manipulated via the Hadoop group mapping service. + + <permissions> is zero or more letters from the set "RWCA": READ('R'), + WRITE('W'), CREATE('C'), ADMIN('A'). + Note: Grants and revocations of individual permissions on a resource are both + accomplished using the grant command. A separate revoke command is + also provided by the shell, but this is for fast revocation of all of a user's access rights + to a given resource only. + + Revoke - - The alter command has been extended to allow ownership assignment: - - alter 'tablename', {OWNER => 'username|@group'} - - - - - User Permission - - - The user_permission command shows all access permissions for the current user for a given table: - - user_permission <table> - - - - - - -
- Secure Bulk Load - - Bulk loading in secure mode is a bit more involved than normal setup, since the client has to transfer the ownership of the files generated from the mapreduce job to HBase. Secure bulk loading is implemented by a coprocessor, named SecureBulkLoadEndpoint. SecureBulkLoadEndpoint uses a staging directory "hbase.bulkload.staging.dir", which defaults to /tmp/hbase-staging/. The algorithm is as follows. - - Create an hbase owned staging directory which is world traversable (-rwx--x--x, 711) /tmp/hbase-staging. - A user writes out data to his secure output directory: /user/foo/data - A call is made to hbase to create a secret staging directory - which is globally readable/writable (-rwxrwxrwx, 777): /tmp/hbase-staging/averylongandrandomdirectoryname - The user makes the data world readable and writable, then moves it - into the random staging directory, then calls bulkLoadHFiles() - - - - Like delegation tokens the strength of the security lies in the length - and randomness of the secret directory. - - - - You have to enable the secure bulk load to work properly. You can modify the hbase-site.xml file on every server machine in the cluster and add the SecureBulkLoadEndpoint class to the list of regionserver coprocessors: - - - hbase.bulkload.staging.dir - /tmp/hbase-staging - - - hbase.coprocessor.region.classes - org.apache.hadoop.hbase.security.token.TokenProvider, - org.apache.hadoop.hbase.security.access.AccessController,org.apache.hadoop.hbase.security.access.SecureBulkLoadEndpoint - + [
[ [ ] ] ] ]]> - + + + Alter -
+ The alter command has been extended to allow ownership + assignment: + 'username|@group'} +]]> + + + + User Permission + + The user_permission command shows all access permissions for the current + user for a given table: + + ]]> + +
+ + + + +
+ Secure Bulk Load + Bulk loading in secure mode is a bit more involved than normal setup, since the client + has to transfer the ownership of the files generated from the mapreduce job to HBase. Secure + bulk loading is implemented by a coprocessor, named SecureBulkLoadEndpoint. + SecureBulkLoadEndpoint uses a staging directory "hbase.bulkload.staging.dir", + which defaults to /tmp/hbase-staging/. The algorithm is as follows. + + + Create an hbase owned staging directory which is world traversable (-rwx--x--x, + 711) /tmp/hbase-staging. + + + A user writes out data to his secure output directory: /user/foo/data + + + A call is made to hbase to create a secret staging directory which is globally + readable/writable (-rwxrwxrwx, 777): + /tmp/hbase-staging/averylongandrandomdirectoryname + + + The user makes the data world readable and writable, then moves it into the random + staging directory, then calls bulkLoadHFiles() + + + Like delegation tokens the strength of the security lies in the length and randomness of + the secret directory. + + You have to enable the secure bulk load to work properly. You can modify the + hbase-site.xml file on every server machine in the cluster and add the + SecureBulkLoadEndpoint class to the list of regionserver coprocessors: + + hbase.bulkload.staging.dir + /tmp/hbase-staging + + + hbase.coprocessor.region.classes + org.apache.hadoop.hbase.security.token.TokenProvider, + org.apache.hadoop.hbase.security.access.AccessController,org.apache.hadoop.hbase.security.access.SecureBulkLoadEndpoint + + ]]> +
+ + +
Visibility Labels - - This feature provides cell level security with labeled visibility for the cells. Cells can be associated with a visibility expression. The visibility expression can contain labels joined with logical expressions '&', '|' and '!'. Also using '(', ')' one can specify the precedence order. For example, consider the label set { confidential, secret, topsecret, probationary }, where the first three are sensitivity classifications and the last describes if an employee is probationary or not. If a cell is stored with this visibility expression: - ( secret | topsecret ) & !probationary - - - Then any user associated with the secret or topsecret label will be able to view the cell, as long as the user is not also associated with the probationary label. Furthermore, any user only associated with the confidential label, whether probationary or not, will not see the cell or even know of its existence. - - - Visibility expressions like the above can be added when storing or mutating a cell using the API, - - Mutation#setCellVisibility(new CellVisibility(String labelExpession)); - Where the labelExpression could be '( secret | topsecret ) & !probationary' - - - We build the user's label set in the RPC context when a request is first received by the HBase RegionServer. How users are associated with labels is pluggable. The default plugin passes through labels specified in Authorizations added to the Get or Scan and checks those against the calling user's authenticated labels list. When client passes some labels for which the user is not authenticated, this default algorithm will drop those. One can pass a subset of user authenticated labels via the Scan/Get authorizations. - - Get#setAuthorizations(new Authorizations(String,...)); - Scan#setAuthorizations(new Authorizations(String,...)); + This feature provides cell level security with labeled visibility for the cells. Cells + can be associated with a visibility expression. The visibility expression can contain labels + joined with logical expressions '&', '|' and '!'. Also using + '(', ')' one can specify the precedence order. For example, consider the label + set { confidential, secret, topsecret, probationary }, where the first three are sensitivity + classifications and the last describes if an employee is probationary or not. If a cell is + stored with this visibility expression: ( secret | topsecret ) & !probationary + Then any user associated with the secret or topsecret label will be able to view the + cell, as long as the user is not also associated with the probationary label. Furthermore, any + user only associated with the confidential label, whether probationary or not, will not see + the cell or even know of its existence. + Visibility expressions like the above can be added when storing or mutating a cell using + the API, + Mutation#setCellVisibility(new CellVisibility(String labelExpession)); + Where the labelExpression could be '( secret | topsecret ) & !probationary' + We build the user's label set in the RPC context when a request is first received by + the HBase RegionServer. How users are associated with labels is pluggable. The default plugin + passes through labels specified in Authorizations added to the Get or Scan and checks those + against the calling user's authenticated labels list. When client passes some labels for + which the user is not authenticated, this default algorithm will drop those. One can pass a + subset of user authenticated labels via the Scan/Get authorizations. + Get#setAuthorizations(new Authorizations(String,...)); + Scan#setAuthorizations(new Authorizations(String,...)); -
- Visibility Label Administration - - There are new client side Java APIs and shell commands for performing visibility labels administrative actions. Only the HBase super user is authorized to perform these operations. - +
+ Visibility Label Administration + There are new client side Java APIs and shell commands for performing visibility labels + administrative actions. Only the HBase super user is authorized to perform these operations. -
- Adding Labels - A set of labels can be added to the system either by using the Java API - VisibilityClient#addLabels(Configuration conf, final String[] labels) - Or by using the shell command - add_labels [label1, label2] - - Valid label can include alphanumeric characters and characters '-', '_', ':', '.' and '/' - -
+
+ Adding Labels + A set of labels can be added to the system either by using the Java API + VisibilityClient#addLabels(Configuration conf, final String[] + labels) + Or by using the shell command + add_labels [label1, label2] + Valid label can include alphanumeric characters and characters '-', + '_', ':', '.' and '/' +
-
- User Label Association - A set of labels can be associated with a user by using the API - VisibilityClient#setAuths(Configuration conf, final String[] auths, final String user) - Or by using the shell command - set_auths user,[label1, label2]. - Labels can be disassociated from a user using API - VisibilityClient#clearAuths(Configuration conf, final String[] auths, final String user) - Or by using shell command - clear_auths user,[label1, label2] - - One can use the API VisibilityClient#getAuths(Configuration conf, final String user) or get_auths shell command to get the list of labels associated for a given user. The labels and user auths information will be stored in the system table "labels". - -
-
+
+ User Label Association + A set of labels can be associated with a user by using the API + VisibilityClient#setAuths(Configuration conf, final String[] auths, final String + user) + Or by using the shell command + set_auths user,[label1, label2]. + Labels can be disassociated from a user using API + VisibilityClient#clearAuths(Configuration conf, final String[] auths, final + String user) + Or by using shell command + clear_auths user,[label1, label2] + One can use the API VisibilityClient#getAuths(Configuration conf, final String + user) or get_auths shell command to get the list of labels + associated for a given user. The labels and user auths information will be stored in the + system table "labels". +
+
-
- Server Side Configuration - - HBase stores cell level labels as cell tags. HFile version 3 adds the cell tags support. Be sure to use HFile version 3 by setting this property in every server site configuration file: - - + Server Side Configuration + HBase stores cell level labels as cell tags. HFile version 3 adds the cell tags + support. Be sure to use HFile version 3 by setting this property in every server site + configuration file: + hfile.format.version 3 ]]> - - You will also need to make sure the VisibilityController coprocessor is active on every table to protect by adding it to the list of system coprocessors in the server site configuration files: - - - hbase.coprocessor.master.classes - org.apache.hadoop.hbase.security.visibility.VisibilityController - - - hbase.coprocessor.region.classes - org.apache.hadoop.hbase.security.visibility.VisibilityController - + You will also need to make sure the VisibilityController coprocessor is active on every + table to protect by adding it to the list of system coprocessors in the server site + configuration files: + + hbase.coprocessor.master.classes +org.apache.hadoop.hbase.security.visibility.VisibilityController + + + hbase.coprocessor.region.classes +org.apache.hadoop.hbase.security.visibility.VisibilityController + ]]> - - As said above, finding out labels authenticated for a given get/scan request is a pluggable algorithm. A custom implementation can be plugged in using the property hbase.regionserver.scan.visibility.label.generator.class. The default implementation class is org.apache.hadoop.hbase.security.visibility.DefaultScanLabelGenerator. One can configure a set of ScanLabelGenerators to be used by the system. For this, a comma separated set of implementation class names to be configured. - -
-
+ As said above, finding out labels authenticated for a given get/scan request is a + pluggable algorithm. A custom implementation can be plugged in using the property + hbase.regionserver.scan.visibility.label.generator.class. The default + implementation class is + org.apache.hadoop.hbase.security.visibility.DefaultScanLabelGenerator. One + can configure a set of ScanLabelGenerators to be used by the system. For this, a comma + separated set of implementation class names to be configured. + + -
+
Transparent Server Side Encryption - -This feature provides transparent encryption for protecting HFile and WAL data at rest, using a two-tier key architecture for flexible and non-intrusive key rotation. - - -First, the administrator provisions a cluster master key, stored into a key provider accessable to every trusted HBase process: the Master, the RegionServers, and clients (e.g. the shell) on administrative workstations. The default key provider integrates with the Java KeyStore API and any key management system with support for it. How HBase retrieves key material is configurable via the site file. The master key may be stored on the cluster servers, protected by a secure KeyStore file, or on an external keyserver, or in a hardware security module. This master key is resolved as needed by HBase processes through the configured key provider. - - -Then, encryption keys can be specified in schema on a per column family basis, by creating or modifying a column descriptor to include two additional attributes: the name of the encryption algorithm to use (currently only "AES" is supported), and, optionally, a data key wrapped (encrypted) with the cluster master key. Per CF keys facilitates low impact incremental key rotation and reduces the scope of any external leak of key material. The wrapped data key is stored in the CF schema metadata, and in each HFile for the CF, encrypted with the cluster master key. Once the CF is configured for encryption, any new HFiles will be written encrypted. To insure encryption of all HFiles, trigger a major compaction after first enabling this feature. The key for decryption, encrypted with the cluster master key, is stored in the HFiles in a new meta block. At file open time the data key will be extracted from the HFile, decrypted with the cluster master key, and used for decryption of the remainder of the HFile. The HFile will be unreadable if the master key is not available. Should remote users somehow acquire access to the HFile data because of some lapse in HDFS permissions or from inappropriately discarded media, there will be no means to decrypt either the data key or the file data. - - -Specifying a data key in the CF schema is optional. If one is not present, a random data key will be created for each HFile. - - -A new configuration option for encrypting the WAL is also introduced. Even though WALs are transient, it is necessary to encrypt the WALEdits to avoid circumventing HFile protections for encrypted column families. - -
- Configuration - -Create a secret key of appropriate length for AES. - - \ - -genseckey -keyalg AES -keysize 128 \ - -alias - ]]> - -where <password> is the password for the KeyStore file and <alias>is the user name of the HBase service account, typically "hbase". Simply press RETURN to store the key with the same password as the store. The resulting file should be distributed to all nodes running HBase daemons, with file ownership and permissions set to be readable only by the HBase service account. - - -Configure HBase daemons to use a key provider backed by the KeyStore files for retrieving the cluster master key as needed. - - - hbase.crypto.keyprovider - org.apache.hadoop.hbase.io.crypto.KeyStoreKeyProvider - - - hbase.crypto.keyprovider.parameters - jceks:///path/to/hbase/conf/hbase.jks?password= - + This feature provides transparent encryption for protecting HFile and WAL data at rest, + using a two-tier key architecture for flexible and non-intrusive key rotation. + First, the administrator provisions a cluster master key, stored into a key provider + accessable to every trusted HBase process: the Master, the RegionServers, and clients (e.g. + the shell) on administrative workstations. The default key provider integrates with the Java + KeyStore API and any key management system with support for it. How HBase retrieves key + material is configurable via the site file. The master key may be stored on the cluster + servers, protected by a secure KeyStore file, or on an external keyserver, or in a hardware + security module. This master key is resolved as needed by HBase processes through the + configured key provider. + Then, encryption keys can be specified in schema on a per column family basis, by + creating or modifying a column descriptor to include two additional attributes: the name of + the encryption algorithm to use (currently only "AES" is supported), and, optionally, a data + key wrapped (encrypted) with the cluster master key. Per CF keys facilitates low impact + incremental key rotation and reduces the scope of any external leak of key material. The + wrapped data key is stored in the CF schema metadata, and in each HFile for the CF, encrypted + with the cluster master key. Once the CF is configured for encryption, any new HFiles will be + written encrypted. To insure encryption of all HFiles, trigger a major compaction after first + enabling this feature. The key for decryption, encrypted with the cluster master key, is + stored in the HFiles in a new meta block. At file open time the data key will be extracted + from the HFile, decrypted with the cluster master key, and used for decryption of the + remainder of the HFile. The HFile will be unreadable if the master key is not available. + Should remote users somehow acquire access to the HFile data because of some lapse in HDFS + permissions or from inappropriately discarded media, there will be no means to decrypt either + the data key or the file data. + Specifying a data key in the CF schema is optional. If one is not present, a random data + key will be created for each HFile. + A new configuration option for encrypting the WAL is also introduced. Even though WALs + are transient, it is necessary to encrypt the WALEdits to avoid circumventing HFile + protections for encrypted column families. +
+ Configuration + Create a secret key of appropriate length for AES. + \ + -genseckey -keyalg AES -keysize 128 \ + -alias + ]]> + where <password> is the password for the KeyStore file and <alias>is the + user name of the HBase service account, typically "hbase". Simply press RETURN to store the + key with the same password as the store. The resulting file should be distributed to all + nodes running HBase daemons, with file ownership and permissions set to be readable only by + the HBase service account. + Configure HBase daemons to use a key provider backed by the KeyStore files for + retrieving the cluster master key as needed. + + hbase.crypto.keyprovider + org.apache.hadoop.hbase.io.crypto.KeyStoreKeyProvider + + + hbase.crypto.keyprovider.parameters + jceks:///path/to/hbase/conf/hbase.jks?password= + ]]> - -By default the HBase service account name will be used to resolve the cluster master key, but you can store it with any arbitrary alias and configure HBase appropriately: - - - hbase.crypto.master.key.name - hbase - + By default the HBase service account name will be used to resolve the cluster master + key, but you can store it with any arbitrary alias and configure HBase appropriately: + + hbase.crypto.master.key.name + hbase + ]]> - -Because the password to the key store is sensitive information, the HBase site XML file should also have its permissions set to be readable only by the HBase service account. - - -Transparent encryption is a feature of HFile version 3. Be sure to use HFile version 3 by setting this property in every server site configuration file: - - - hfile.format.version - 3 - + Because the password to the key store is sensitive information, the HBase site XML file + should also have its permissions set to be readable only by the HBase service account. + Transparent encryption is a feature of HFile version 3. Be sure to use HFile version 3 + by setting this property in every server site configuration file: + + hfile.format.version + 3 + ]]> - -Finally, configure the secure WAL in every server site configuration file: - - - hbase.regionserver.hlog.reader.impl - org.apache.hadoop.hbase.regionserver.wal.SecureProtobufLogReader - - - hbase.regionserver.hlog.writer.impl - org.apache.hadoop.hbase.regionserver.wal.SecureProtobufLogWriter - - - hbase.regionserver.wal.encryption - true - + Finally, configure the secure WAL in every server site configuration file: + + hbase.regionserver.hlog.reader.impl + org.apache.hadoop.hbase.regionserver.wal.SecureProtobufLogReader + + + hbase.regionserver.hlog.writer.impl + org.apache.hadoop.hbase.regionserver.wal.SecureProtobufLogWriter + + + hbase.regionserver.wal.encryption + true + ]]>
-
- Setting Encryption on a CF - -To enable encryption on a CF, use HBaseAdmin#modifyColumn or the HBase shell to modify the column descriptor. The attribute 'ENCRYPTION' specifies the encryption algorithm to use. Currently only "AES" is supported. If creating a new table, simply set this attribute; no subsequent table modification will be necessary. - - -If setting a specific data key, the attribute 'ENCRYPTION_KEY' should contain the data key wrapped by the cluster master key. The static methods wrapKey and unwrapKey in org.apache.hadoop.hbase.security.EncryptionUtil can be used in conjunction with HColumnDescriptor#setEncryptionKey for this purpose. Because this must be done programatically, setting a data key with the shell is not supported. - - -To disable encryption on a CF, simply remove the 'ENCRYPTION' (and 'ENCRYPTION_KEY', if it was set) attributes from the column schema, using HBaseAdmin#modifyColumn or the HBase shell. All new HFiles for the CF will be written without encryption. Trigger a major compaction to rewrite all files. - +
+ Setting Encryption on a CF + To enable encryption on a CF, use HBaseAdmin#modifyColumn or the HBase + shell to modify the column descriptor. The attribute 'ENCRYPTION' specifies the encryption + algorithm to use. Currently only "AES" is supported. If creating a new table, simply set + this attribute; no subsequent table modification will be necessary. + If setting a specific data key, the attribute 'ENCRYPTION_KEY' should contain the data + key wrapped by the cluster master key. The static methods wrapKey and + unwrapKey in org.apache.hadoop.hbase.security.EncryptionUtil can + be used in conjunction with HColumnDescriptor#setEncryptionKey for this + purpose. Because this must be done programatically, setting a data key with the shell is not + supported. + To disable encryption on a CF, simply remove the 'ENCRYPTION' (and 'ENCRYPTION_KEY', if + it was set) attributes from the column schema, using HBaseAdmin#modifyColumn or + the HBase shell. All new HFiles for the CF will be written without encryption. Trigger a + major compaction to rewrite all files.
-
- Data Key Rotation - -Data key rotation is made simple by this design. First, change the CF key in the column descriptor. Then, trigger major compaction. Once compaction has completed, all files will be (re)encrypted with the new key material. While this process is ongoing, HFiles encrypted with old key material will still be readable. - +
+ Data Key Rotation + Data key rotation is made simple by this design. First, change the CF key in the column + descriptor. Then, trigger major compaction. Once compaction has completed, all files will be + (re)encrypted with the new key material. While this process is ongoing, HFiles encrypted + with old key material will still be readable.
-
- Master Key Rotation - -Master key rotation can be achieved by updating the KeyStore to contain a new master key, as described above, with also the old master key added to the KeyStore under a different alias. Then, configure fallback to the old master key in the HBase site file: - - - hbase.crypto.master.alternate.key.name - hbase.old - +
+ Master Key Rotation + Master key rotation can be achieved by updating the KeyStore to contain a new master + key, as described above, with also the old master key added to the KeyStore under a + different alias. Then, configure fallback to the old master key in the HBase site file: + + hbase.crypto.master.alternate.key.name + hbase.old + ]]> - -This will require a rolling restart of the HBase daemons to take effect. As with data key rotation, trigger a major compaction and wait for it to complete. Once compaction has completed, all files will be (re)encrypted with data keys wrapped by the new cluster master key. The old master key, and its associated site file configuration, can then be removed, and all trace of the old master key will be gone after the next rolling restart. A second rolling restart is not immediately necessary. - + This will require a rolling restart of the HBase daemons to take effect. As with data + key rotation, trigger a major compaction and wait for it to complete. Once compaction has + completed, all files will be (re)encrypted with data keys wrapped by the new cluster master + key. The old master key, and its associated site file configuration, can then be removed, + and all trace of the old master key will be gone after the next rolling restart. A second + rolling restart is not immediately necessary.
-
+
diff --git a/src/main/docbkx/shell.xml b/src/main/docbkx/shell.xml index aaddc8d636e..deca139ec8e 100644 --- a/src/main/docbkx/shell.xml +++ b/src/main/docbkx/shell.xml @@ -1,13 +1,15 @@ - - The Apache HBase Shell - - The Apache HBase Shell is (J)Ruby's - IRB with some HBase particular commands added. Anything you can do in - IRB, you should be able to do in the HBase Shell. - To run the HBase shell, - do as follows: - $ ./bin/hbase shell - - Type help and then <RETURN> - to see a listing of shell - commands and options. Browse at least the paragraphs at the end of - the help emission for the gist of how variables and command - arguments are entered into the - HBase shell; in particular note how table names, rows, and - columns, etc., must be quoted. - See - for example basic shell operation. - - Here is a nicely formatted listing of all shell commands by Rajeshbabu Chintaguntla. - + The Apache HBase Shell is (J)Ruby's IRB with some HBase particular commands + added. Anything you can do in IRB, you should be able to do in the HBase Shell. + To run the HBase shell, do as follows: + $ ./bin/hbase shell + Type help and then <RETURN> to see a listing + of shell commands and options. Browse at least the paragraphs at the end of the help + emission for the gist of how variables and command arguments are entered into the HBase + shell; in particular note how table names, rows, and columns, etc., must be quoted. + See for example basic shell operation. + Here is a nicely formatted listing of all shell + commands by Rajeshbabu Chintaguntla. -
Scripting - For examples scripting Apache HBase, look in the - HBase bin directory. Look at the files - that end in *.rb. To run one of these - files, do as follows: - $ ./bin/hbase org.jruby.Main PATH_TO_SCRIPT - +
+ Scripting + For examples scripting Apache HBase, look in the HBase bin + directory. Look at the files that end in *.rb. To run one of these + files, do as follows: + $ ./bin/hbase org.jruby.Main PATH_TO_SCRIPT
-
Shell Tricks -
Table variables +
+ Shell Tricks +
+ Table variables - - HBase 0.95 adds shell commands that provide a jruby-style - object-oriented references for tables. Previously all of - the shell commands that act upon a table have a procedural - style that always took the name of the table as an - argument. HBase 0.95 introduces the ability to assign a - table to a jruby variable. The table reference can be used - to perform data read write operations such as puts, scans, - and gets well as admin functionality such as disabling, - dropping, describing tables. - - - - For example, previously you would always specify a table name: - + HBase 0.95 adds shell commands that provide a jruby-style object-oriented + references for tables. Previously all of the shell commands that act upon a table + have a procedural style that always took the name of the table as an argument. HBase + 0.95 introduces the ability to assign a table to a jruby variable. The table + reference can be used to perform data read write operations such as puts, scans, and + gets well as admin functionality such as disabling, dropping, describing tables. + + For example, previously you would always specify a table name: + hbase(main):000:0> create ‘t’, ‘f’ 0 row(s) in 1.0970 seconds hbase(main):001:0> put 't', 'rold', 'f', 'v' @@ -101,12 +95,11 @@ hbase(main):005:0> drop 't' 0 row(s) in 23.1670 seconds hbase(main):006:0> - - - - - Now you can assign the table to a variable and use the results in jruby shell code. - + + + Now you can assign the table to a variable and use the results in jruby shell + code. + hbase(main):007 > t = create 't', 'f' 0 row(s) in 1.0970 seconds @@ -128,13 +121,11 @@ hbase(main):038:0> t.disable 0 row(s) in 6.2350 seconds hbase(main):039:0> t.drop 0 row(s) in 0.2340 seconds - - + - - If the table has already been created, you can assign a - Table to a variable by using the get_table method: - + If the table has already been created, you can assign a Table to a variable by + using the get_table method: + hbase(main):011 > create 't','f' 0 row(s) in 1.2500 seconds @@ -150,15 +141,12 @@ ROW COLUMN+CELL r1 column=f:, timestamp=1378473876949, value=v 1 row(s) in 0.0240 seconds hbase(main):015:0> - - + - - The list functionality has also been extended so that it - returns a list of table names as strings. You can then use - jruby to script table operations based on these names. The - list_snapshots command also acts similarly. - + The list functionality has also been extended so that it returns a list of table + names as strings. You can then use jruby to script table operations based on these + names. The list_snapshots command also acts similarly. + hbase(main):016 > tables = list(‘t.*’) TABLE t @@ -170,66 +158,66 @@ hbase(main):017:0> tables.map { |t| disable t ; drop t} => [nil] hbase(main):018:0> - - +
-
<filename>irbrc</filename> - Create an .irbrc file for yourself in your home - directory. Add customizations. A useful one is command history so commands are save - across Shell invocations: - - $ more .irbrc - require 'irb/ext/save-history' - IRB.conf[:SAVE_HISTORY] = 100 - IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" - See the ruby documentation of .irbrc - to learn about other possible configurations. -
-
LOG data to timestamp - - To convert the date '08/08/16 20:56:29' from an hbase log into a timestamp, do: - - hbase(main):021:0> import java.text.SimpleDateFormat - hbase(main):022:0> import java.text.ParsePosition - hbase(main):023:0> SimpleDateFormat.new("yy/MM/dd HH:mm:ss").parse("08/08/16 20:56:29", ParsePosition.new(0)).getTime() => 1218920189000 - - - To go the other direction: - - hbase(main):021:0> import java.util.Date - hbase(main):022:0> Date.new(1218920189000).toString() => "Sat Aug 16 20:56:29 UTC 2008" - - - To output in a format that is exactly like that of the HBase log format will take a little messing with - SimpleDateFormat. +
+ <filename>irbrc</filename> + Create an .irbrc file for yourself in your home directory. + Add customizations. A useful one is command history so commands are save across + Shell invocations: + +$ more .irbrc +require 'irb/ext/save-history' +IRB.conf[:SAVE_HISTORY] = 100 +IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" + See the ruby documentation of + .irbrc to learn about other possible configurations.
-
Debug -
Shell debug switch - You can set a debug switch in the shell to see more output - -- e.g. more of the stack trace on exception -- - when you run a command: - hbase> debug <RETURN> - +
+ LOG data to timestamp + To convert the date '08/08/16 20:56:29' from an hbase log into a timestamp, + do: + +hbase(main):021:0> import java.text.SimpleDateFormat +hbase(main):022:0> import java.text.ParsePosition +hbase(main):023:0> SimpleDateFormat.new("yy/MM/dd HH:mm:ss").parse("08/08/16 20:56:29", ParsePosition.new(0)).getTime() => 1218920189000 + To go the other direction: + +hbase(main):021:0> import java.util.Date +hbase(main):022:0> Date.new(1218920189000).toString() => "Sat Aug 16 20:56:29 UTC 2008" + To output in a format that is exactly like that of the HBase log format will take + a little messing with SimpleDateFormat. + +
+
+ Debug +
+ Shell debug switch + You can set a debug switch in the shell to see more output -- e.g. more of the + stack trace on exception -- when you run a command: + hbase> debug <RETURN>
-
DEBUG log level - To enable DEBUG level logging in the shell, - launch it with the -d option. - $ ./bin/hbase shell -d - +
+ DEBUG log level + To enable DEBUG level logging in the shell, launch it with the + -d option. + $ ./bin/hbase shell -d
-
-
Commands -
count - Count command returns the number of rows in a table. - It's quite fast when configured with the right CACHE - hbase> count '<tablename>', CACHE => 1000 - The above count fetches 1000 rows at a time. Set CACHE lower if your rows are big. - Default is to fetch one row at a time. - +
+
+ Commands +
+ count + Count command returns the number of rows in a table. It's quite fast when + configured with the right CACHE + hbase> count '<tablename>', CACHE => 1000 + The above count fetches 1000 rows at a time. Set CACHE lower if your rows are + big. Default is to fetch one row at a time.
-
+
- + diff --git a/src/main/docbkx/tracing.xml b/src/main/docbkx/tracing.xml index cdece20daf9..220cc79c17c 100644 --- a/src/main/docbkx/tracing.xml +++ b/src/main/docbkx/tracing.xml @@ -1,12 +1,14 @@ - + Troubleshooting and Debugging Apache HBase -
- General Guidelines - - Always start with the master log (TODO: Which lines?). - Normally it’s just printing the same lines over and over again. - If not, then there’s an issue. - Google or search-hadoop.com - should return some hits for those exceptions you’re seeing. - - - An error rarely comes alone in Apache HBase, usually when something gets screwed up what will - follow may be hundreds of exceptions and stack traces coming from all over the place. - The best way to approach this type of problem is to walk the log up to where it all - began, for example one trick with RegionServers is that they will print some - metrics when aborting so grepping for Dump - should get you around the start of the problem. - - - RegionServer suicides are “normal”, as this is what they do when something goes wrong. - For example, if ulimit and xcievers (the two most important initial settings, see ) - aren’t changed, it will make it impossible at some point for DataNodes to create new threads - that from the HBase point of view is seen as if HDFS was gone. Think about what would happen if your - MySQL database was suddenly unable to access files on your local file system, well it’s the same with - HBase and HDFS. Another very common reason to see RegionServers committing seppuku is when they enter - prolonged garbage collection pauses that last longer than the default ZooKeeper session timeout. - For more information on GC pauses, see the - 3 part blog post by Todd Lipcon - and above. - +
+ General Guidelines + Always start with the master log (TODO: Which lines?). Normally it’s just printing the + same lines over and over again. If not, then there’s an issue. Google or search-hadoop.com should return some hits for + those exceptions you’re seeing. + An error rarely comes alone in Apache HBase, usually when something gets screwed up what + will follow may be hundreds of exceptions and stack traces coming from all over the place. The + best way to approach this type of problem is to walk the log up to where it all began, for + example one trick with RegionServers is that they will print some metrics when aborting so + grepping for Dump should get you around the start of the problem. + RegionServer suicides are “normal”, as this is what they do when something goes wrong. + For example, if ulimit and xcievers (the two most important initial settings, see ) aren’t changed, it will make it impossible at some point for DataNodes + to create new threads that from the HBase point of view is seen as if HDFS was gone. Think + about what would happen if your MySQL database was suddenly unable to access files on your + local file system, well it’s the same with HBase and HDFS. Another very common reason to see + RegionServers committing seppuku is when they enter prolonged garbage collection pauses that + last longer than the default ZooKeeper session timeout. For more information on GC pauses, see + the 3 + part blog post by Todd Lipcon and above. +
+
+ Logs + The key process logs are as follows... (replace <user> with the user that started + the service, and <hostname> for the machine name) + NameNode: + $HADOOP_HOME/logs/hadoop-<user>-namenode-<hostname>.log + + DataNode: + $HADOOP_HOME/logs/hadoop-<user>-datanode-<hostname>.log + + JobTracker: + $HADOOP_HOME/logs/hadoop-<user>-jobtracker-<hostname>.log + + TaskTracker: + $HADOOP_HOME/logs/hadoop-<user>-tasktracker-<hostname>.log + + HMaster: + $HBASE_HOME/logs/hbase-<user>-master-<hostname>.log + + RegionServer: + $HBASE_HOME/logs/hbase-<user>-regionserver-<hostname>.log + + ZooKeeper: TODO + +
+ Log Locations + For stand-alone deployments the logs are obviously going to be on a single machine, + however this is a development configuration only. Production deployments need to run on a + cluster. +
+ NameNode + The NameNode log is on the NameNode server. The HBase Master is typically run on the + NameNode server, and well as ZooKeeper. + For smaller clusters the JobTracker is typically run on the NameNode server as + well. +
+
+ DataNode + Each DataNode server will have a DataNode log for HDFS, as well as a RegionServer log + for HBase. + Additionally, each DataNode server will also have a TaskTracker log for MapReduce task + execution. +
-
- Logs - - The key process logs are as follows... (replace <user> with the user that started the service, and <hostname> for the machine name) - - - NameNode: $HADOOP_HOME/logs/hadoop-<user>-namenode-<hostname>.log - - - DataNode: $HADOOP_HOME/logs/hadoop-<user>-datanode-<hostname>.log - - - JobTracker: $HADOOP_HOME/logs/hadoop-<user>-jobtracker-<hostname>.log - - - TaskTracker: $HADOOP_HOME/logs/hadoop-<user>-tasktracker-<hostname>.log - - - HMaster: $HBASE_HOME/logs/hbase-<user>-master-<hostname>.log - - - RegionServer: $HBASE_HOME/logs/hbase-<user>-regionserver-<hostname>.log - - - ZooKeeper: TODO - -
- Log Locations - For stand-alone deployments the logs are obviously going to be on a single machine, however this is a development configuration only. - Production deployments need to run on a cluster. -
- NameNode - The NameNode log is on the NameNode server. The HBase Master is typically run on the NameNode server, and well as ZooKeeper. - For smaller clusters the JobTracker is typically run on the NameNode server as well. -
-
- DataNode - Each DataNode server will have a DataNode log for HDFS, as well as a RegionServer log for HBase. - Additionally, each DataNode server will also have a TaskTracker log for MapReduce task execution. -
-
-
- Log Levels -
Enabling RPC-level logging - Enabling the RPC-level logging on a RegionServer can often given - insight on timings at the server. Once enabled, the amount of log - spewed is voluminous. It is not recommended that you leave this - logging on for more than short bursts of time. To enable RPC-level - logging, browse to the RegionServer UI and click on - Log Level. Set the log level to DEBUG for the package - org.apache.hadoop.ipc (Thats right, for - hadoop.ipc, NOT, hbase.ipc). Then tail the RegionServers log. Analyze. - To disable, set the logging level back to INFO level. - -
-
-
- JVM Garbage Collection Logs - HBase is memory intensive, and using the default GC you can see long pauses in all threads including the Juliet Pause aka "GC of Death". - To help debug this or confirm this is happening GC logging can be turned on in the Java virtual machine. - - - To enable, in hbase-env.sh, uncomment one of the below lines : - +
+ Log Levels +
+ Enabling RPC-level logging + Enabling the RPC-level logging on a RegionServer can often given insight on timings at + the server. Once enabled, the amount of log spewed is voluminous. It is not recommended + that you leave this logging on for more than short bursts of time. To enable RPC-level + logging, browse to the RegionServer UI and click on Log Level. Set + the log level to DEBUG for the package + org.apache.hadoop.ipc (Thats right, for + hadoop.ipc, NOT, hbase.ipc). Then tail the + RegionServers log. Analyze. + To disable, set the logging level back to INFO level. +
+
+
+ JVM Garbage Collection Logs + HBase is memory intensive, and using the default GC you can see long pauses in all + threads including the Juliet Pause aka "GC of Death". To help debug + this or confirm this is happening GC logging can be turned on in the Java virtual machine. + To enable, in hbase-env.sh, uncomment one of the below lines + : + # This enables basic gc logging to the .out file. # export SERVER_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps" @@ -132,22 +139,18 @@ # If <FILE-PATH> is not replaced, the log file(.gc) would be generated in the HBASE_LOG_DIR. - - - At this point you should see logs like so: - + At this point you should see logs like so: + 64898.952: [GC [1 CMS-initial-mark: 2811538K(3055704K)] 2812179K(3061272K), 0.0007360 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 64898.953: [CMS-concurrent-mark-start] 64898.971: [GC 64898.971: [ParNew: 5567K->576K(5568K), 0.0101110 secs] 2817105K->2812715K(3061272K), 0.0102200 secs] [Times: user=0.07 sys=0.00, real=0.01 secs] - - - In this section, the first line indicates a 0.0007360 second pause for the CMS to initially mark. This pauses the entire VM, all threads for that period of time. - - - The third line indicates a "minor GC", which pauses the VM for 0.0101110 seconds - aka 10 milliseconds. It has reduced the "ParNew" from about 5.5m to 576k. - Later on in this cycle we see: - + In this section, the first line indicates a 0.0007360 second pause for the CMS to + initially mark. This pauses the entire VM, all threads for that period of time. + The third line indicates a "minor GC", which pauses the VM for 0.0101110 seconds - aka + 10 milliseconds. It has reduced the "ParNew" from about 5.5m to 576k. Later on in this cycle + we see: + 64901.445: [CMS-concurrent-mark: 1.542/2.492 secs] [Times: user=10.49 sys=0.33, real=2.49 secs] 64901.445: [CMS-concurrent-preclean-start] 64901.453: [GC 64901.453: [ParNew: 5505K->573K(5568K), 0.0062440 secs] 2868746K->2864292K(3061272K), 0.0063360 secs] [Times: user=0.05 sys=0.00, real=0.01 secs] @@ -163,44 +166,40 @@ 64901.616: [GC[YG occupancy: 645 K (5568 K)]64901.616: [Rescan (parallel) , 0.0020210 secs]64901.618: [weak refs processing, 0.0027950 secs] [1 CMS-remark: 2866753K(3055704K)] 2867399K(3061272K), 0.0049380 secs] [Times: user=0.00 sys=0.01, real=0.01 secs] 64901.621: [CMS-concurrent-sweep-start] - - - The first line indicates that the CMS concurrent mark (finding garbage) has taken 2.4 seconds. But this is a _concurrent_ 2.4 seconds, Java has not been paused at any point in time. - - - There are a few more minor GCs, then there is a pause at the 2nd last line: - + The first line indicates that the CMS concurrent mark (finding garbage) has taken 2.4 + seconds. But this is a _concurrent_ 2.4 seconds, Java has not been paused at any point in + time. + There are a few more minor GCs, then there is a pause at the 2nd last line: + 64901.616: [GC[YG occupancy: 645 K (5568 K)]64901.616: [Rescan (parallel) , 0.0020210 secs]64901.618: [weak refs processing, 0.0027950 secs] [1 CMS-remark: 2866753K(3055704K)] 2867399K(3061272K), 0.0049380 secs] [Times: user=0.00 sys=0.01, real=0.01 secs] - - - The pause here is 0.0049380 seconds (aka 4.9 milliseconds) to 'remark' the heap. - - - At this point the sweep starts, and you can watch the heap size go down: - + + The pause here is 0.0049380 seconds (aka 4.9 milliseconds) to 'remark' the heap. + At this point the sweep starts, and you can watch the heap size go down: + 64901.637: [GC 64901.637: [ParNew: 5501K->569K(5568K), 0.0097350 secs] 2871958K->2867441K(3061272K), 0.0098370 secs] [Times: user=0.05 sys=0.00, real=0.01 secs] ... lines removed ... 64904.936: [GC 64904.936: [ParNew: 5532K->568K(5568K), 0.0070720 secs] 1365024K->1360689K(3061272K), 0.0071930 secs] [Times: user=0.05 sys=0.00, real=0.01 secs] 64904.953: [CMS-concurrent-sweep: 2.030/3.332 secs] [Times: user=9.57 sys=0.26, real=3.33 secs] - At this point, the CMS sweep took 3.332 seconds, and heap went from about ~ 2.8 GB to 1.3 GB (approximate). - - - The key points here is to keep all these pauses low. CMS pauses are always low, but if your ParNew starts growing, you can see minor GC pauses approach 100ms, exceed 100ms and hit as high at 400ms. - - - This can be due to the size of the ParNew, which should be relatively small. If your ParNew is very large after running HBase for a while, in one example a ParNew was about 150MB, then you might have to constrain the size of ParNew (The larger it is, the longer the collections take but if its too small, objects are promoted to old gen too quickly). In the below we constrain new gen size to 64m. - - - Add the below line in hbase-env.sh: - + At this point, the CMS sweep took 3.332 seconds, and heap went from about ~ 2.8 GB to + 1.3 GB (approximate). + The key points here is to keep all these pauses low. CMS pauses are always low, but if + your ParNew starts growing, you can see minor GC pauses approach 100ms, exceed 100ms and hit + as high at 400ms. + This can be due to the size of the ParNew, which should be relatively small. If your + ParNew is very large after running HBase for a while, in one example a ParNew was about + 150MB, then you might have to constrain the size of ParNew (The larger it is, the longer the + collections take but if its too small, objects are promoted to old gen too quickly). In the + below we constrain new gen size to 64m. + Add the below line in hbase-env.sh: + export SERVER_GC_OPTS="$SERVER_GC_OPTS -XX:NewSize=64m -XX:MaxNewSize=64m" - - - Similarly, to enable GC logging for client processes, uncomment one of the below lines in hbase-env.sh: - + + Similarly, to enable GC logging for client processes, uncomment one of the below lines + in hbase-env.sh: + # This enables basic gc logging to the .out file. # export CLIENT_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps" @@ -212,77 +211,92 @@ export SERVER_GC_OPTS="$SERVER_GC_OPTS -XX:NewSize=64m -XX:MaxNewSize=64m" # If <FILE-PATH> is not replaced, the log file(.gc) would be generated in the HBASE_LOG_DIR . - - - For more information on GC pauses, see the 3 part blog post by Todd Lipcon - and above. - -
+ For more information on GC pauses, see the 3 + part blog post by Todd Lipcon and above.
-
- Resources -
- search-hadoop.com - - search-hadoop.com indexes all the mailing lists and is great for historical searches. - Search here first when you have an issue as its more than likely someone has already had your problem. - -
-
- Mailing Lists - Ask a question on the Apache HBase mailing lists. - The 'dev' mailing list is aimed at the community of developers actually building Apache HBase and for features currently under development, and 'user' - is generally used for questions on released versions of Apache HBase. Before going to the mailing list, make sure your - question has not already been answered by searching the mailing list archives first. Use - . - Take some time crafting your questionSee Getting Answers; a quality question that includes all context and - exhibits evidence the author has tried to find answers in the manual and out on lists - is more likely to get a prompt response. - -
-
- IRC - #hbase on irc.freenode.net -
-
- JIRA - - JIRA is also really helpful when looking for Hadoop/HBase-specific issues. - -
+
+
+ Resources +
+ search-hadoop.com + + search-hadoop.com indexes all the mailing + lists and is great for historical searches. Search here first when you have an issue as its + more than likely someone has already had your problem.
-
- Tools -
- Builtin Tools -
- Master Web Interface - The Master starts a web-interface on port 16010 by default. - (Up to and including 0.98 this was port 60010) - - The Master web UI lists created tables and their definition (e.g., ColumnFamilies, blocksize, etc.). Additionally, - the available RegionServers in the cluster are listed along with selected high-level metrics (requests, number of regions, usedHeap, maxHeap). - The Master web UI allows navigation to each RegionServer's web UI. - -
-
- RegionServer Web Interface - RegionServers starts a web-interface on port 16030 by default. - (Up to an including 0.98 this was port 60030) - - The RegionServer web UI lists online regions and their start/end keys, as well as point-in-time RegionServer metrics (requests, regions, storeFileIndexSize, compactionQueueSize, etc.). - - See for more information in metric definitions. - -
-
- zkcli - zkcli is a very useful tool for investigating ZooKeeper-related issues. To invoke: - +
+ Mailing Lists + Ask a question on the Apache HBase mailing lists. + The 'dev' mailing list is aimed at the community of developers actually building Apache + HBase and for features currently under development, and 'user' is generally used for + questions on released versions of Apache HBase. Before going to the mailing list, make sure + your question has not already been answered by searching the mailing list archives first. + Use . Take some time crafting your question + See Getting Answers + ; a quality question that includes all context and exhibits evidence the author + has tried to find answers in the manual and out on lists is more likely to get a prompt + response. +
+
+ IRC + #hbase on irc.freenode.net +
+
+ JIRA + + JIRA is also really + helpful when looking for Hadoop/HBase-specific issues. +
+
+
+ Tools +
+ Builtin Tools +
+ Master Web Interface + The Master starts a web-interface on port 16010 by default. (Up to and including 0.98 + this was port 60010) + The Master web UI lists created tables and their definition (e.g., ColumnFamilies, + blocksize, etc.). Additionally, the available RegionServers in the cluster are listed + along with selected high-level metrics (requests, number of regions, usedHeap, maxHeap). + The Master web UI allows navigation to each RegionServer's web UI. +
+
+ RegionServer Web Interface + RegionServers starts a web-interface on port 16030 by default. (Up to an including + 0.98 this was port 60030) + The RegionServer web UI lists online regions and their start/end keys, as well as + point-in-time RegionServer metrics (requests, regions, storeFileIndexSize, + compactionQueueSize, etc.). + See for more information in metric definitions. +
+
+ zkcli + zkcli is a very useful tool for investigating ZooKeeper-related issues. + To invoke: + ./hbase zkcli -server host:port <cmd> <args> - The commands (and arguments) are: - + The commands (and arguments) are: + connect host:port get path [watch] ls path [watch] @@ -304,21 +318,28 @@ export SERVER_GC_OPTS="$SERVER_GC_OPTS -XX:NewSize=64m -XX:MaxNewSize=64m" delete path [version] setquota -n|-b val path - -
-
-
- External Tools -
+
+
+
+ External Tools +
tail - tail is the command line tool that lets you look at the end of a file. Add the “-f” option and it will refresh when new data is available. It’s useful when you are wondering what’s happening, for example, when a cluster is taking a long time to shutdown or startup as you can just fire a new terminal and tail the master log (and maybe a few RegionServers). - + tail is the command line tool that lets you look at the end of a file. Add + the “-f” option and it will refresh when new data is available. It’s useful when you are + wondering what’s happening, for example, when a cluster is taking a long time to shutdown + or startup as you can just fire a new terminal and tail the master log (and maybe a few + RegionServers).
-
+
top - top is probably one of the most important tool when first trying to see what’s running on a machine and how the resources are consumed. Here’s an example from production system: + top is probably one of the most important tool when first trying to see + what’s running on a machine and how the resources are consumed. Here’s an example from + production system: top - 14:46:59 up 39 days, 11:55, 1 user, load average: 3.75, 3.57, 3.84 Tasks: 309 total, 1 running, 308 sleeping, 0 stopped, 0 zombie @@ -332,21 +353,29 @@ Swap: 16008732k total, 14348k used, 15994384k free, 11106908k cached 8895 hadoop 18 -2 1581m 497m 3420 S 11 2.1 4002:32 java … - - - Here we can see that the system load average during the last five minutes is 3.75, which very roughly means that on average 3.75 threads were waiting for CPU time during these 5 minutes. In general, the “perfect” utilization equals to the number of cores, under that number the machine is under utilized and over that the machine is over utilized. This is an important concept, see this article to understand it more: http://www.linuxjournal.com/article/9001. - - - Apart from load, we can see that the system is using almost all its available RAM but most of it is used for the OS cache (which is good). The swap only has a few KBs in it and this is wanted, high numbers would indicate swapping activity which is the nemesis of performance of Java systems. Another way to detect swapping is when the load average goes through the roof (although this could also be caused by things like a dying disk, among others). - - - The list of processes isn’t super useful by default, all we know is that 3 java processes are using about 111% of the CPUs. To know which is which, simply type “c” and each line will be expanded. Typing “1” will give you the detail of how each CPU is used instead of the average for all of them like shown here. - + Here we can see that the system load average during the last five minutes is 3.75, + which very roughly means that on average 3.75 threads were waiting for CPU time during + these 5 minutes. In general, the “perfect” utilization equals to the number of cores, + under that number the machine is under utilized and over that the machine is over + utilized. This is an important concept, see this article to understand it more: http://www.linuxjournal.com/article/9001. + Apart from load, we can see that the system is using almost all its available RAM but + most of it is used for the OS cache (which is good). The swap only has a few KBs in it and + this is wanted, high numbers would indicate swapping activity which is the nemesis of + performance of Java systems. Another way to detect swapping is when the load average goes + through the roof (although this could also be caused by things like a dying disk, among + others). + The list of processes isn’t super useful by default, all we know is that 3 java + processes are using about 111% of the CPUs. To know which is which, simply type “c” and + each line will be expanded. Typing “1” will give you the detail of how each CPU is used + instead of the average for all of them like shown here.
-
+
jps - jps is shipped with every JDK and gives the java process ids for the current user (if root, then it gives the ids for all users). Example: + jps is shipped with every JDK and gives the java process ids for the current + user (if root, then it gives the ids for all users). Example: hadoop@sv4borg12:~$ jps 1322 TaskTracker @@ -358,82 +387,101 @@ hadoop@sv4borg12:~$ jps 19750 ThriftServer 18776 jmx - In order, we see a: + In order, we see a: - Hadoop TaskTracker, manages the local Childs - HBase RegionServer, serves regions - Child, its MapReduce task, cannot tell which type exactly - Hadoop TaskTracker, manages the local Childs - Hadoop DataNode, serves blocks - HQuorumPeer, a ZooKeeper ensemble member - Jps, well… it’s the current process - ThriftServer, it’s a special one will be running only if thrift was started - jmx, this is a local process that’s part of our monitoring platform ( poorly named maybe). You probably don’t have that. + + Hadoop TaskTracker, manages the local Childs + + + HBase RegionServer, serves regions + + + Child, its MapReduce task, cannot tell which type exactly + + + Hadoop TaskTracker, manages the local Childs + + + Hadoop DataNode, serves blocks + + + HQuorumPeer, a ZooKeeper ensemble member + + + Jps, well… it’s the current process + + + ThriftServer, it’s a special one will be running only if thrift was started + + + jmx, this is a local process that’s part of our monitoring platform ( poorly named + maybe). You probably don’t have that. + - - - You can then do stuff like checking out the full command line that started the process: + You can then do stuff like checking out the full command line that started the + process: hadoop@sv4borg12:~$ ps aux | grep HRegionServer hadoop 17789 155 35.2 9067824 8604364 ? S<l Mar04 9855:48 /usr/java/jdk1.6.0_14/bin/java -Xmx8000m -XX:+DoEscapeAnalysis -XX:+AggressiveOpts -XX:+UseConcMarkSweepGC -XX:NewSize=64m -XX:MaxNewSize=64m -XX:CMSInitiatingOccupancyFraction=88 -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/export1/hadoop/logs/gc-hbase.log -Dcom.sun.management.jmxremote.port=10102 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=/home/hadoop/hbase/conf/jmxremote.password -Dcom.sun.management.jmxremote -Dhbase.log.dir=/export1/hadoop/logs -Dhbase.log.file=hbase-hadoop-regionserver-sv4borg12.log -Dhbase.home.dir=/home/hadoop/hbase -Dhbase.id.str=hadoop -Dhbase.root.logger=INFO,DRFA -Djava.library.path=/home/hadoop/hbase/lib/native/Linux-amd64-64 -classpath /home/hadoop/hbase/bin/../conf:[many jars]:/home/hadoop/hadoop/conf org.apache.hadoop.hbase.regionserver.HRegionServer start -
-
+
jstack - jstack is one of the most important tools when trying to figure out what a java process is doing apart from looking at the logs. It has to be used in conjunction with jps in order to give it a process id. It shows a list of threads, each one has a name, and they appear in the order that they were created (so the top ones are the most recent threads). Here’s a few example: - - - The main thread of a RegionServer that’s waiting for something to do from the master: + jstack is one of the most important tools when trying to figure out what a + java process is doing apart from looking at the logs. It has to be used in conjunction + with jps in order to give it a process id. It shows a list of threads, each one has a + name, and they appear in the order that they were created (so the top ones are the most + recent threads). Here’s a few example: + The main thread of a RegionServer that’s waiting for something to do from the + master: - "regionserver60020" prio=10 tid=0x0000000040ab4000 nid=0x45cf waiting on condition [0x00007f16b6a96000..0x00007f16b6a96a70] - java.lang.Thread.State: TIMED_WAITING (parking) - at sun.misc.Unsafe.park(Native Method) - - parking to wait for <0x00007f16cd5c2f30> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) - at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198) - at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1963) - at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:395) - at org.apache.hadoop.hbase.regionserver.HRegionServer.run(HRegionServer.java:647) - at java.lang.Thread.run(Thread.java:619) +"regionserver60020" prio=10 tid=0x0000000040ab4000 nid=0x45cf waiting on condition [0x00007f16b6a96000..0x00007f16b6a96a70] +java.lang.Thread.State: TIMED_WAITING (parking) + at sun.misc.Unsafe.park(Native Method) + - parking to wait for <0x00007f16cd5c2f30> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) + at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198) + at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1963) + at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:395) + at org.apache.hadoop.hbase.regionserver.HRegionServer.run(HRegionServer.java:647) + at java.lang.Thread.run(Thread.java:619) - The MemStore flusher thread that is currently flushing to a file: + The MemStore flusher thread that is currently flushing to a file: "regionserver60020.cacheFlusher" daemon prio=10 tid=0x0000000040f4e000 nid=0x45eb in Object.wait() [0x00007f16b5b86000..0x00007f16b5b87af0] - java.lang.Thread.State: WAITING (on object monitor) - at java.lang.Object.wait(Native Method) - at java.lang.Object.wait(Object.java:485) - at org.apache.hadoop.ipc.Client.call(Client.java:803) - - locked <0x00007f16cb14b3a8> (a org.apache.hadoop.ipc.Client$Call) - at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:221) - at $Proxy1.complete(Unknown Source) - at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) - at java.lang.reflect.Method.invoke(Method.java:597) - at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82) - at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59) - at $Proxy1.complete(Unknown Source) - at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.closeInternal(DFSClient.java:3390) - - locked <0x00007f16cb14b470> (a org.apache.hadoop.hdfs.DFSClient$DFSOutputStream) - at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.close(DFSClient.java:3304) - at org.apache.hadoop.fs.FSDataOutputStream$PositionCache.close(FSDataOutputStream.java:61) - at org.apache.hadoop.fs.FSDataOutputStream.close(FSDataOutputStream.java:86) - at org.apache.hadoop.hbase.io.hfile.HFile$Writer.close(HFile.java:650) - at org.apache.hadoop.hbase.regionserver.StoreFile$Writer.close(StoreFile.java:853) - at org.apache.hadoop.hbase.regionserver.Store.internalFlushCache(Store.java:467) - - locked <0x00007f16d00e6f08> (a java.lang.Object) - at org.apache.hadoop.hbase.regionserver.Store.flushCache(Store.java:427) - at org.apache.hadoop.hbase.regionserver.Store.access$100(Store.java:80) - at org.apache.hadoop.hbase.regionserver.Store$StoreFlusherImpl.flushCache(Store.java:1359) - at org.apache.hadoop.hbase.regionserver.HRegion.internalFlushcache(HRegion.java:907) - at org.apache.hadoop.hbase.regionserver.HRegion.internalFlushcache(HRegion.java:834) - at org.apache.hadoop.hbase.regionserver.HRegion.flushcache(HRegion.java:786) - at org.apache.hadoop.hbase.regionserver.MemStoreFlusher.flushRegion(MemStoreFlusher.java:250) - at org.apache.hadoop.hbase.regionserver.MemStoreFlusher.flushRegion(MemStoreFlusher.java:224) - at org.apache.hadoop.hbase.regionserver.MemStoreFlusher.run(MemStoreFlusher.java:146) +java.lang.Thread.State: WAITING (on object monitor) + at java.lang.Object.wait(Native Method) + at java.lang.Object.wait(Object.java:485) + at org.apache.hadoop.ipc.Client.call(Client.java:803) + - locked <0x00007f16cb14b3a8> (a org.apache.hadoop.ipc.Client$Call) + at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:221) + at $Proxy1.complete(Unknown Source) + at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) + at java.lang.reflect.Method.invoke(Method.java:597) + at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82) + at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59) + at $Proxy1.complete(Unknown Source) + at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.closeInternal(DFSClient.java:3390) + - locked <0x00007f16cb14b470> (a org.apache.hadoop.hdfs.DFSClient$DFSOutputStream) + at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.close(DFSClient.java:3304) + at org.apache.hadoop.fs.FSDataOutputStream$PositionCache.close(FSDataOutputStream.java:61) + at org.apache.hadoop.fs.FSDataOutputStream.close(FSDataOutputStream.java:86) + at org.apache.hadoop.hbase.io.hfile.HFile$Writer.close(HFile.java:650) + at org.apache.hadoop.hbase.regionserver.StoreFile$Writer.close(StoreFile.java:853) + at org.apache.hadoop.hbase.regionserver.Store.internalFlushCache(Store.java:467) + - locked <0x00007f16d00e6f08> (a java.lang.Object) + at org.apache.hadoop.hbase.regionserver.Store.flushCache(Store.java:427) + at org.apache.hadoop.hbase.regionserver.Store.access$100(Store.java:80) + at org.apache.hadoop.hbase.regionserver.Store$StoreFlusherImpl.flushCache(Store.java:1359) + at org.apache.hadoop.hbase.regionserver.HRegion.internalFlushcache(HRegion.java:907) + at org.apache.hadoop.hbase.regionserver.HRegion.internalFlushcache(HRegion.java:834) + at org.apache.hadoop.hbase.regionserver.HRegion.flushcache(HRegion.java:786) + at org.apache.hadoop.hbase.regionserver.MemStoreFlusher.flushRegion(MemStoreFlusher.java:250) + at org.apache.hadoop.hbase.regionserver.MemStoreFlusher.flushRegion(MemStoreFlusher.java:224) + at org.apache.hadoop.hbase.regionserver.MemStoreFlusher.run(MemStoreFlusher.java:146) - - - A handler thread that’s waiting for stuff to do (like put, delete, scan, etc): + A handler thread that’s waiting for stuff to do (like put, delete, scan, etc): "IPC Server handler 16 on 60020" daemon prio=10 tid=0x00007f16b011d800 nid=0x4a5e waiting on condition [0x00007f16afefd000..0x00007f16afefd9f0] java.lang.Thread.State: WAITING (parking) @@ -444,9 +492,8 @@ hadoop 17789 155 35.2 9067824 8604364 ? S<l Mar04 9855:48 /usr/java/j at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:358) at org.apache.hadoop.hbase.ipc.HBaseServer$Handler.run(HBaseServer.java:1013) - - - And one that’s busy doing an increment of a counter (it’s in the phase where it’s trying to create a scanner in order to read the last value): + And one that’s busy doing an increment of a counter (it’s in the phase where it’s + trying to create a scanner in order to read the last value): "IPC Server handler 66 on 60020" daemon prio=10 tid=0x00007f16b006e800 nid=0x4a90 runnable [0x00007f16acb77000..0x00007f16acb77cf0] java.lang.Thread.State: RUNNABLE @@ -466,9 +513,7 @@ hadoop 17789 155 35.2 9067824 8604364 ? S<l Mar04 9855:48 /usr/java/j at org.apache.hadoop.hbase.ipc.HBaseRPC$Server.call(HBaseRPC.java:560) at org.apache.hadoop.hbase.ipc.HBaseServer$Handler.run(HBaseServer.java:1027) - - - A thread that receives data from HDFS: + A thread that receives data from HDFS: "IPC Client (47) connection to sv4borg9/10.4.24.40:9000 from hadoop" daemon prio=10 tid=0x00007f16a02d0000 nid=0x4fa3 runnable [0x00007f16b517d000..0x00007f16b517dbf0] java.lang.Thread.State: RUNNABLE @@ -493,10 +538,8 @@ hadoop 17789 155 35.2 9067824 8604364 ? S<l Mar04 9855:48 /usr/java/j at org.apache.hadoop.ipc.Client$Connection.receiveResponse(Client.java:569) at org.apache.hadoop.ipc.Client$Connection.run(Client.java:477) - - - And here is a master trying to recover a lease after a RegionServer died: - + And here is a master trying to recover a lease after a RegionServer died: + "LeaseChecker" daemon prio=10 tid=0x00000000407ef800 nid=0x76cd waiting on condition [0x00007f6d0eae2000..0x00007f6d0eae2a70] -- java.lang.Thread.State: WAITING (on object monitor) @@ -518,84 +561,116 @@ hadoop 17789 155 35.2 9067824 8604364 ? S<l Mar04 9855:48 /usr/java/j at org.apache.hadoop.hbase.master.HMaster.joinCluster(HMaster.java:572) at org.apache.hadoop.hbase.master.HMaster.run(HMaster.java:503) - -
-
- OpenTSDB - - OpenTSDB is an excellent alternative to Ganglia as it uses Apache HBase to store all the time series and doesn’t have to downsample. Monitoring your own HBase cluster that hosts OpenTSDB is a good exercise. - - - Here’s an example of a cluster that’s suffering from hundreds of compactions launched almost all around the same time, which severely affects the IO performance: (TODO: insert graph plotting compactionQueueSize) - - - It’s a good practice to build dashboards with all the important graphs per machine and per cluster so that debugging issues can be done with a single quick look. For example, at StumbleUpon there’s one dashboard per cluster with the most important metrics from both the OS and Apache HBase. You can then go down at the machine level and get even more detailed metrics. - -
-
+
+
+ OpenTSDB + + OpenTSDB is an excellent alternative to Ganglia + as it uses Apache HBase to store all the time series and doesn’t have to downsample. + Monitoring your own HBase cluster that hosts OpenTSDB is a good exercise. + Here’s an example of a cluster that’s suffering from hundreds of compactions launched + almost all around the same time, which severely affects the IO performance: (TODO: insert + graph plotting compactionQueueSize) + It’s a good practice to build dashboards with all the important graphs per machine + and per cluster so that debugging issues can be done with a single quick look. For + example, at StumbleUpon there’s one dashboard per cluster with the most important metrics + from both the OS and Apache HBase. You can then go down at the machine level and get even + more detailed metrics. +
+
clusterssh+top - - clusterssh+top, it’s like a poor man’s monitoring system and it can be quite useful when you have only a few machines as it’s very easy to setup. Starting clusterssh will give you one terminal per machine and another terminal in which whatever you type will be retyped in every window. This means that you can type “top” once and it will start it for all of your machines at the same time giving you full view of the current state of your cluster. You can also tail all the logs at the same time, edit files, etc. - -
+ clusterssh+top, it’s like a poor man’s monitoring system and it can be quite useful + when you have only a few machines as it’s very easy to setup. Starting clusterssh will + give you one terminal per machine and another terminal in which whatever you type will be + retyped in every window. This means that you can type “top” once and it will start it for + all of your machines at the same time giving you full view of the current state of your + cluster. You can also tail all the logs at the same time, edit files, etc. +
+
+ +
+ Client + For more information on the HBase client, see . +
+ ScannerTimeoutException or UnknownScannerException + This is thrown if the time between RPC calls from the client to RegionServer exceeds the + scan timeout. For example, if Scan.setCaching is set to 500, then there will be + an RPC call to fetch the next batch of rows every 500 .next() calls on the + ResultScanner because data is being transferred in blocks of 500 rows to the client. + Reducing the setCaching value may be an option, but setting this value too low makes for + inefficient processing on numbers of rows. + See .
+
+ <classname>LeaseException</classname> when calling + <classname>Scanner.next</classname> + In some situations clients that fetch data from a RegionServer get a LeaseException + instead of the usual . Usually the source of the exception is + org.apache.hadoop.hbase.regionserver.Leases.removeLease(Leases.java:230) + (line number may vary). It tends to happen in the context of a slow/freezing + RegionServer#next call. It can be prevented by having hbase.rpc.timeout > + hbase.regionserver.lease.period. Harsh J investigated the issue as part + of the mailing list thread HBase, + mail # user - Lease does not exist exceptions + +
+
+ Shell or client application throws lots of scary exceptions during normal + operation + Since 0.20.0 the default log level for org.apache.hadoop.hbase.*is DEBUG. + On your clients, edit $HBASE_HOME/conf/log4j.properties and change + this: log4j.logger.org.apache.hadoop.hbase=DEBUG to this: + log4j.logger.org.apache.hadoop.hbase=INFO, or even + log4j.logger.org.apache.hadoop.hbase=WARN. +
+
+ Long Client Pauses With Compression + This is a fairly frequent question on the Apache HBase dist-list. The scenario is that a + client is typically inserting a lot of data into a relatively un-optimized HBase cluster. + Compression can exacerbate the pauses, although it is not the source of the problem. + See on the pattern for pre-creating regions and confirm that + the table isn't starting with a single region. + See for cluster configuration, particularly + hbase.hstore.blockingStoreFiles, + hbase.hregion.memstore.block.multiplier, MAX_FILESIZE (region + size), and MEMSTORE_FLUSHSIZE. + + A slightly longer explanation of why pauses can happen is as follows: Puts are sometimes + blocked on the MemStores which are blocked by the flusher thread which is blocked because + there are too many files to compact because the compactor is given too many small files to + compact and has to compact the same data repeatedly. This situation can occur even with + minor compactions. Compounding this situation, Apache HBase doesn't compress data in memory. + Thus, the 64MB that lives in the MemStore could become a 6MB file after compression - which + results in a smaller StoreFile. The upside is that more data is packed into the same region, + but performance is achieved by being able to write larger files - which is why HBase waits + until the flushize before writing a new StoreFile. And smaller StoreFiles become targets for + compaction. Without compression the files are much bigger and don't need as much compaction, + however this is at the expense of I/O. + For additional information, see this thread on Long + client pauses with compression. -
- Client - For more information on the HBase client, see . - -
- ScannerTimeoutException or UnknownScannerException - This is thrown if the time between RPC calls from the client to RegionServer exceeds the scan timeout. - For example, if Scan.setCaching is set to 500, then there will be an RPC call to fetch the next batch of rows every 500 .next() calls on the ResultScanner - because data is being transferred in blocks of 500 rows to the client. Reducing the setCaching value may be an option, but setting this value too low makes for inefficient - processing on numbers of rows. - - See . - -
-
- <classname>LeaseException</classname> when calling <classname>Scanner.next</classname> - -In some situations clients that fetch data from a RegionServer get a LeaseException instead of the usual -. Usually the source of the exception is -org.apache.hadoop.hbase.regionserver.Leases.removeLease(Leases.java:230) (line number may vary). -It tends to happen in the context of a slow/freezing RegionServer#next call. -It can be prevented by having hbase.rpc.timeout > hbase.regionserver.lease.period. -Harsh J investigated the issue as part of the mailing list thread -HBase, mail # user - Lease does not exist exceptions - -
-
- Shell or client application throws lots of scary exceptions during normal operation - Since 0.20.0 the default log level for org.apache.hadoop.hbase.*is DEBUG. - - On your clients, edit $HBASE_HOME/conf/log4j.properties and change this: log4j.logger.org.apache.hadoop.hbase=DEBUG to this: log4j.logger.org.apache.hadoop.hbase=INFO, or even log4j.logger.org.apache.hadoop.hbase=WARN. - -
-
- Long Client Pauses With Compression - This is a fairly frequent question on the Apache HBase dist-list. The scenario is that a client is typically inserting a lot of data into a - relatively un-optimized HBase cluster. Compression can exacerbate the pauses, although it is not the source of the problem. - See on the pattern for pre-creating regions and confirm that the table isn't starting with a single region. - See for cluster configuration, particularly hbase.hstore.blockingStoreFiles, hbase.hregion.memstore.block.multiplier, - MAX_FILESIZE (region size), and MEMSTORE_FLUSHSIZE. - A slightly longer explanation of why pauses can happen is as follows: Puts are sometimes blocked on the MemStores which are blocked by the flusher thread which is blocked because there are - too many files to compact because the compactor is given too many small files to compact and has to compact the same data repeatedly. This situation can occur even with minor compactions. - Compounding this situation, Apache HBase doesn't compress data in memory. Thus, the 64MB that lives in the MemStore could become a 6MB file after compression - which results in a smaller StoreFile. The upside is that - more data is packed into the same region, but performance is achieved by being able to write larger files - which is why HBase waits until the flushize before writing a new StoreFile. And smaller StoreFiles - become targets for compaction. Without compression the files are much bigger and don't need as much compaction, however this is at the expense of I/O. - - - For additional information, see this thread on Long client pauses with compression. - - -
-
- ZooKeeper Client Connection Errors - Errors like this... - +
+
+ ZooKeeper Client Connection Errors + Errors like this... + 11/07/05 11:26:41 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.ConnectException: Connection refused: no further information @@ -613,67 +688,81 @@ Harsh J investigated the issue as part of the mailing list thread 11/07/05 11:26:45 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181 - ... are either due to ZooKeeper being down, or unreachable due to network issues. - - The utility may help investigate ZooKeeper issues. - -
-
- Client running out of memory though heap size seems to be stable (but the off-heap/direct heap keeps growing) - -You are likely running into the issue that is described and worked through in -the mail thread HBase, mail # user - Suspected memory leak -and continued over in HBase, mail # dev - FeedbackRe: Suspected memory leak. -A workaround is passing your client-side JVM a reasonable value for -XX:MaxDirectMemorySize. By default, -the MaxDirectMemorySize is equal to your -Xmx max heapsize setting (if -Xmx is set). -Try seting it to something smaller (for example, one user had success setting it to 1g when -they had a client-side heap of 12g). If you set it too small, it will bring on FullGCs so keep -it a bit hefty. You want to make this setting client-side only especially if you are running the new experiemental -server-side off-heap cache since this feature depends on being able to use big direct buffers (You may have to keep -separate client-side and server-side config dirs). - - -
-
- Client Slowdown When Calling Admin Methods (flush, compact, etc.) - -This is a client issue fixed by HBASE-5073 in 0.90.6. -There was a ZooKeeper leak in the client and the client was getting pummeled by ZooKeeper events with each additional -invocation of the admin API. - -
- -
- Secure Client Cannot Connect ([Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)]) - -There can be several causes that produce this symptom. - - -First, check that you have a valid Kerberos ticket. One is required in order to set up communication with a secure Apache HBase cluster. Examine the ticket currently in the credential cache, if any, by running the klist command line utility. If no ticket is listed, you must obtain a ticket by running the kinit command with either a keytab specified, or by interactively entering a password for the desired principal. - - -Then, consult the Java Security Guide troubleshooting section. The most common problem addressed there is resolved by setting javax.security.auth.useSubjectCredsOnly system property value to false. - - -Because of a change in the format in which MIT Kerberos writes its credentials cache, there is a bug in the Oracle JDK 6 Update 26 and earlier that causes Java to be unable to read the Kerberos credentials cache created by versions of MIT Kerberos 1.8.1 or higher. If you have this problematic combination of components in your environment, to work around this problem, first log in with kinit and then immediately refresh the credential cache with kinit -R. The refresh will rewrite the credential cache without the problematic formatting. - - -Finally, depending on your Kerberos configuration, you may need to install the Java Cryptography Extension, or JCE. Insure the JCE jars are on the classpath on both server and client systems. - - -You may also need to download the unlimited strength JCE policy files. Uncompress and extract the downloaded file, and install the policy jars into <java-home>/lib/security. - -
+ ... are either due to ZooKeeper being down, or unreachable due to network issues. + The utility may help investigate ZooKeeper issues. +
+
+ Client running out of memory though heap size seems to be stable (but the + off-heap/direct heap keeps growing) + You are likely running into the issue that is described and worked through in the mail + thread HBase, + mail # user - Suspected memory leak and continued over in HBase, + mail # dev - FeedbackRe: Suspected memory leak. A workaround is passing your + client-side JVM a reasonable value for -XX:MaxDirectMemorySize. By default, the + MaxDirectMemorySize is equal to your -Xmx max heapsize + setting (if -Xmx is set). Try seting it to something smaller (for example, one + user had success setting it to 1g when they had a client-side heap of + 12g). If you set it too small, it will bring on FullGCs so keep + it a bit hefty. You want to make this setting client-side only especially if you are running + the new experiemental server-side off-heap cache since this feature depends on being able to + use big direct buffers (You may have to keep separate client-side and server-side config + dirs).
+
+ Client Slowdown When Calling Admin Methods (flush, compact, etc.) + This is a client issue fixed by HBASE-5073 in 0.90.6. + There was a ZooKeeper leak in the client and the client was getting pummeled by ZooKeeper + events with each additional invocation of the admin API. +
-
- MapReduce -
- You Think You're On The Cluster, But You're Actually Local - This following stacktrace happened using ImportTsv, but things like this - can happen on any job with a mis-configuration. - +
+ Secure Client Cannot Connect ([Caused by GSSException: No valid credentials provided + (Mechanism level: Failed to find any Kerberos tgt)]) + There can be several causes that produce this symptom. + First, check that you have a valid Kerberos ticket. One is required in order to set up + communication with a secure Apache HBase cluster. Examine the ticket currently in the + credential cache, if any, by running the klist command line utility. If no ticket is listed, + you must obtain a ticket by running the kinit command with either a keytab specified, or by + interactively entering a password for the desired principal. + Then, consult the Java + Security Guide troubleshooting section. The most common problem addressed there is + resolved by setting javax.security.auth.useSubjectCredsOnly system property value to false. + Because of a change in the format in which MIT Kerberos writes its credentials cache, + there is a bug in the Oracle JDK 6 Update 26 and earlier that causes Java to be unable to + read the Kerberos credentials cache created by versions of MIT Kerberos 1.8.1 or higher. If + you have this problematic combination of components in your environment, to work around this + problem, first log in with kinit and then immediately refresh the credential cache with + kinit -R. The refresh will rewrite the credential cache without the problematic formatting. + Finally, depending on your Kerberos configuration, you may need to install the Java + Cryptography Extension, or JCE. Insure the JCE jars are on the classpath on both + server and client systems. + You may also need to download the unlimited + strength JCE policy files. Uncompress and extract the downloaded file, and install + the policy jars into <java-home>/lib/security. +
+ +
+ +
+ MapReduce +
+ You Think You're On The Cluster, But You're Actually Local + This following stacktrace happened using ImportTsv, but things like this + can happen on any job with a mis-configuration. + WARN mapred.LocalJobRunner: job_local_0001 java.lang.IllegalArgumentException: Can't read partitions file at org.apache.hadoop.hbase.mapreduce.hadoopbackport.TotalOrderPartitioner.setConf(TotalOrderPartitioner.java:111) @@ -691,219 +780,238 @@ Caused by: java.io.FileNotFoundException: File _partition.lst does not exist. at org.apache.hadoop.io.SequenceFile$Reader.<init>(SequenceFile.java:1419) at org.apache.hadoop.hbase.mapreduce.hadoopbackport.TotalOrderPartitioner.readPartitions(TotalOrderPartitioner.java:296) - .. see the critical portion of the stack? It's... - - at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:210) + .. see the critical portion of the stack? It's... + +at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:210) - LocalJobRunner means the job is running locally, not on the cluster. - + LocalJobRunner means the job is running locally, not on the cluster. To solve this problem, you should run your MR job with your - HADOOP_CLASSPATH set to include the HBase dependencies. - The "hbase classpath" utility can be used to do this easily. - For example (substitute VERSION with your HBase version): + HADOOP_CLASSPATH set to include the HBase dependencies. The "hbase classpath" + utility can be used to do this easily. For example (substitute VERSION with your HBase + version): HADOOP_CLASSPATH=`hbase classpath` hadoop jar $HBASE_HOME/hbase-VERSION.jar rowcounter usertable - - See - - http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/package-summary.html#classpath for more - information on HBase MapReduce jobs and classpaths. - -
+ See + http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/package-summary.html#classpath + for more information on HBase MapReduce jobs and classpaths.
+
-
- NameNode - For more information on the NameNode, see . - -
- HDFS Utilization of Tables and Regions - To determine how much space HBase is using on HDFS use the hadoop shell commands from the NameNode. For example... - hadoop fs -dus /hbase/ ...returns the summarized disk utilization for all HBase objects. - hadoop fs -dus /hbase/myTable ...returns the summarized disk utilization for the HBase table 'myTable'. - hadoop fs -du /hbase/myTable ...returns a list of the regions under the HBase table 'myTable' and their disk utilization. - For more information on HDFS shell commands, see the HDFS FileSystem Shell documentation. - -
-
- Browsing HDFS for HBase Objects - Sometimes it will be necessary to explore the HBase objects that exist on HDFS. - These objects could include the WALs (Write Ahead Logs), tables, regions, StoreFiles, etc. - The easiest way to do this is with the NameNode web application that runs on port 50070. The +
+ NameNode + For more information on the NameNode, see . +
+ HDFS Utilization of Tables and Regions + To determine how much space HBase is using on HDFS use the hadoop shell + commands from the NameNode. For example... + hadoop fs -dus /hbase/ ...returns the summarized disk + utilization for all HBase objects. + hadoop fs -dus /hbase/myTable ...returns the summarized + disk utilization for the HBase table 'myTable'. + hadoop fs -du /hbase/myTable ...returns a list of the + regions under the HBase table 'myTable' and their disk utilization. + For more information on HDFS shell commands, see the HDFS + FileSystem Shell documentation. +
+
+ Browsing HDFS for HBase Objects + Sometimes it will be necessary to explore the HBase objects that exist on HDFS. These + objects could include the WALs (Write Ahead Logs), tables, regions, StoreFiles, etc. The + easiest way to do this is with the NameNode web application that runs on port 50070. The NameNode web application will provide links to the all the DataNodes in the cluster so that they can be browsed seamlessly. - The HDFS directory structure of HBase tables in the cluster is... - + The HDFS directory structure of HBase tables in the cluster is... + /hbase /<Table> (Tables in the cluster) /<Region> (Regions for the table) /<ColumnFamily> (ColumnFamilies for the Region for the table) /<StoreFile> (StoreFiles for the ColumnFamily for the Regions for the table) - - The HDFS directory structure of HBase WAL is.. - + + The HDFS directory structure of HBase WAL is.. + /hbase /.logs /<RegionServer> (RegionServers) /<HLog> (WAL HLog files for the RegionServer) - - See the HDFS User Guide for other non-shell diagnostic - utilities like fsck. - -
- Zero size HLogs with data in them - Problem: when getting a listing of all the files in a region server's .logs directory, one file has a size of 0 but it contains data. - Answer: It's an HDFS quirk. A file that's currently being to will appear to have a size of 0 but once it's closed it will show its true size -
-
- Use Cases - Two common use-cases for querying HDFS for HBase objects is research the degree of uncompaction of a table. If there are a large number of StoreFiles for each ColumnFamily it could - indicate the need for a major compaction. Additionally, after a major compaction if the resulting StoreFile is "small" it could indicate the need for a reduction of ColumnFamilies for - the table. - -
- -
-
- -
- Network -
- Network Spikes - If you are seeing periodic network spikes you might want to check the compactionQueues to see if major - compactions are happening. - - See for more information on managing compactions. - + + See the HDFS User + Guide for other non-shell diagnostic utilities like fsck. +
+ Zero size HLogs with data in them + Problem: when getting a listing of all the files in a region server's .logs directory, + one file has a size of 0 but it contains data. + Answer: It's an HDFS quirk. A file that's currently being to will appear to have a + size of 0 but once it's closed it will show its true size
-
- Loopback IP - HBase expects the loopback IP Address to be 127.0.0.1. See the Getting Started section on . - -
-
- Network Interfaces - Are all the network interfaces functioning correctly? Are you sure? See the Troubleshooting Case Study in . - +
+ Use Cases + Two common use-cases for querying HDFS for HBase objects is research the degree of + uncompaction of a table. If there are a large number of StoreFiles for each ColumnFamily + it could indicate the need for a major compaction. Additionally, after a major compaction + if the resulting StoreFile is "small" it could indicate the need for a reduction of + ColumnFamilies for the table.
+
-
- RegionServer - For more information on the RegionServers, see . - -
- Startup Errors -
- Master Starts, But RegionServers Do Not - The Master believes the RegionServers have the IP of 127.0.0.1 - which is localhost and resolves to the master's own localhost. - - The RegionServers are erroneously informing the Master that their IP addresses are 127.0.0.1. - - Modify /etc/hosts on the region servers, from... - +
+ Network +
+ Network Spikes + If you are seeing periodic network spikes you might want to check the + compactionQueues to see if major compactions are happening. + See for more information on managing compactions. +
+
+ Loopback IP + HBase expects the loopback IP Address to be 127.0.0.1. See the Getting Started section + on . +
+
+ Network Interfaces + Are all the network interfaces functioning correctly? Are you sure? See the + Troubleshooting Case Study in . +
+ +
+ +
+ RegionServer + For more information on the RegionServers, see . +
+ Startup Errors +
+ Master Starts, But RegionServers Do Not + The Master believes the RegionServers have the IP of 127.0.0.1 - which is localhost + and resolves to the master's own localhost. + The RegionServers are erroneously informing the Master that their IP addresses are + 127.0.0.1. + Modify /etc/hosts on the region servers, from... + # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 fully.qualified.regionservername regionservername localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 - ... to (removing the master node's name from localhost)... - + ... to (removing the master node's name from localhost)... + # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 - -
+
-
- Compression Link Errors - - Since compression algorithms such as LZO need to be installed and configured on each cluster this is a frequent source of startup error. If you see messages like this... - +
+ Compression Link Errors + Since compression algorithms such as LZO need to be installed and configured on each + cluster this is a frequent source of startup error. If you see messages like + this... + 11/02/20 01:32:15 ERROR lzo.GPLNativeCodeLoader: Could not load native gpl library java.lang.UnsatisfiedLinkError: no gplcompression in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734) at java.lang.Runtime.loadLibrary0(Runtime.java:823) at java.lang.System.loadLibrary(System.java:1028) - .. then there is a path issue with the compression libraries. See the Configuration section on LZO compression configuration. - -
+ .. then there is a path issue with the compression libraries. See the Configuration + section on LZO compression configuration.
-
- Runtime Errors +
+
+ Runtime Errors -
- RegionServer Hanging - - Are you running an old JVM (< 1.6.0_u21?)? When you look at a thread dump, - does it look like threads are BLOCKED but no one holds the lock all are - blocked on? See HBASE 3622 Deadlock in HBaseServer (JVM bug?). - Adding -XX:+UseMembar to the HBase HBASE_OPTS in conf/hbase-env.sh - may fix it. - -
-
- java.io.IOException...(Too many open files) - - If you see log messages like this... - +
+ RegionServer Hanging + Are you running an old JVM (< 1.6.0_u21?)? When you look at a thread dump, does it + look like threads are BLOCKED but no one holds the lock all are blocked on? See HBASE 3622 Deadlock in + HBaseServer (JVM bug?). Adding -XX:+UseMembar to the HBase + HBASE_OPTS in conf/hbase-env.sh may fix it. + +
+
+ java.io.IOException...(Too many open files) + If you see log messages like this... + 2010-09-13 01:24:17,336 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Disk-related IOException in BlockReceiver constructor. Cause is java.io.IOException: Too many open files at java.io.UnixFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(File.java:883) - ... see the Getting Started section on ulimit and nproc configuration. - -
-
- xceiverCount 258 exceeds the limit of concurrent xcievers 256 - - This typically shows up in the DataNode logs. - - - See the Getting Started section on xceivers configuration. - -
-
- System instability, and the presence of "java.lang.OutOfMemoryError: unable to create new native thread in exceptions" HDFS DataNode logs or that of any system daemon - - See the Getting Started section on ulimit and nproc configuration. The default on recent Linux - distributions is 1024 - which is far too low for HBase. - -
-
- DFS instability and/or RegionServer lease timeouts - - If you see warning messages like this... - + ... see the Getting Started section on ulimit and nproc configuration. +
+
+ xceiverCount 258 exceeds the limit of concurrent xcievers 256 + This typically shows up in the DataNode logs. + See the Getting Started section on xceivers configuration. +
+
+ System instability, and the presence of "java.lang.OutOfMemoryError: unable to create + new native thread in exceptions" HDFS DataNode logs or that of any system daemon + See the Getting Started section on ulimit and nproc configuration. The default on recent Linux + distributions is 1024 - which is far too low for HBase. +
+
+ DFS instability and/or RegionServer lease timeouts + If you see warning messages like this... + 2009-02-24 10:01:33,516 WARN org.apache.hadoop.hbase.util.Sleeper: We slept xxx ms, ten times longer than scheduled: 10000 2009-02-24 10:01:33,516 WARN org.apache.hadoop.hbase.util.Sleeper: We slept xxx ms, ten times longer than scheduled: 15000 2009-02-24 10:01:36,472 WARN org.apache.hadoop.hbase.regionserver.HRegionServer: unable to report to master for xxx milliseconds - retrying - ... or see full GC compactions then you may be experiencing full GC's. - -
-
- "No live nodes contain current block" and/or YouAreDeadException - - These errors can happen either when running out of OS file handles or in periods of severe network problems where the nodes are unreachable. - - - See the Getting Started section on ulimit and nproc configuration and check your network. - -
-
- ZooKeeper SessionExpired events - Master or RegionServers shutting down with messages like those in the logs: - + ... or see full GC compactions then you may be experiencing full GC's. +
+
+ "No live nodes contain current block" and/or YouAreDeadException + These errors can happen either when running out of OS file handles or in periods of + severe network problems where the nodes are unreachable. + See the Getting Started section on ulimit and nproc configuration and check your network. +
+
+ ZooKeeper SessionExpired events + Master or RegionServers shutting down with messages like those in the logs: + WARN org.apache.zookeeper.ClientCnxn: Exception closing session 0x278bd16a96000f to sun.nio.ch.SelectionKeyImpl@355811ec java.io.IOException: TIMED OUT @@ -919,21 +1027,34 @@ java.io.IOException: Session Expired at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:945) ERROR org.apache.hadoop.hbase.regionserver.HRegionServer: ZooKeeper session expired - - The JVM is doing a long running garbage collecting which is pausing every threads (aka "stop the world"). - Since the RegionServer's local ZooKeeper client cannot send heartbeats, the session times out. - By design, we shut down any node that isn't able to contact the ZooKeeper ensemble after getting a timeout so that it stops serving data that may already be assigned elsewhere. - + The JVM is doing a long running garbage collecting which is pausing every threads + (aka "stop the world"). Since the RegionServer's local ZooKeeper client cannot send + heartbeats, the session times out. By design, we shut down any node that isn't able to + contact the ZooKeeper ensemble after getting a timeout so that it stops serving data that + may already be assigned elsewhere. - - Make sure you give plenty of RAM (in hbase-env.sh), the default of 1GB won't be able to sustain long running imports. - Make sure you don't swap, the JVM never behaves well under swapping. - Make sure you are not CPU starving the RegionServer thread. For example, if you are running a MapReduce job using 6 CPU-intensive tasks on a machine with 4 cores, you are probably starving the RegionServer enough to create longer garbage collection pauses. - Increase the ZooKeeper session timeout - - If you wish to increase the session timeout, add the following to your hbase-site.xml to increase the timeout from the default of 60 seconds to 120 seconds. - - + + + Make sure you give plenty of RAM (in hbase-env.sh), the + default of 1GB won't be able to sustain long running imports. + + + Make sure you don't swap, the JVM never behaves well under swapping. + + + Make sure you are not CPU starving the RegionServer thread. For example, if you + are running a MapReduce job using 6 CPU-intensive tasks on a machine with 4 cores, you + are probably starving the RegionServer enough to create longer garbage collection + pauses. + + + Increase the ZooKeeper session timeout + + + If you wish to increase the session timeout, add the following to your + hbase-site.xml to increase the timeout from the default of 60 + seconds to 120 seconds. + zookeeper.session.timeout 1200000 @@ -1088,7 +1209,7 @@ ERROR org.apache.hadoop.hbase.regionserver.HRegionServer: ZooKeeper session expi <code>NoClassDefFoundError</code> when trying to run 0.90.x on hadoop-0.20.205.x (or hadoop-1.0.x) Apache HBase 0.90.x does not ship with hadoop-0.20.205.x, etc. To make it run, you need to replace the hadoop jars that Apache HBase shipped with in its lib directory with those of the Hadoop you want to - run HBase on. If even after replacing Hadoop jars you get the below exception: + run HBase on. If even after replacing Hadoop jars you get the below exception: sv4r6s38: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/configuration/Configuration sv4r6s38: at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:37) @@ -1101,33 +1222,35 @@ sv4r6s38: at org.apache.hadoop.security.KerberosName.<clinit>(KerberosN sv4r6s38: at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:202) sv4r6s38: at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:177) -you need to copy under hbase/lib, the commons-configuration-X.jar you find -in your Hadoop's lib directory. That should fix the above complaint. - -
+ you need to copy under hbase/lib, the + commons-configuration-X.jar you find in your Hadoop's + lib directory. That should fix the above complaint. +
-
- ...cannot communicate with client version... -If you see something like the following in your logs -... -2012-09-24 10:20:52,168 FATAL org.apache.hadoop.hbase.master.HMaster: Unhandled exception. Starting shutdown. -org.apache.hadoop.ipc.RemoteException: Server IPC version 7 cannot communicate with client version 4 -... -...are you trying to talk to an Hadoop 2.0.x from an HBase that has an Hadoop 1.0.x client? -Use the HBase built against Hadoop 2.0 or rebuild your HBase passing the -Dhadoop.profile=2.0 -attribute to Maven (See for more). - +
+ ...cannot communicate with client version... + If you see something like the following in your logs ... 2012-09-24 + 10:20:52,168 FATAL org.apache.hadoop.hbase.master.HMaster: Unhandled exception. Starting + shutdown. org.apache.hadoop.ipc.RemoteException: Server IPC version 7 cannot communicate + with client version 4 ... ...are you trying to talk to an Hadoop 2.0.x + from an HBase that has an Hadoop 1.0.x client? Use the HBase built against Hadoop 2.0 or + rebuild your HBase passing the -Dhadoop.profile=2.0 attribute to Maven + (See for more). -
+
-
+
-
- Running unit or integration tests -
- Runtime exceptions from MiniDFSCluster when running tests -If you see something like the following -... +
+ Running unit or integration tests +
+ Runtime exceptions from MiniDFSCluster when running tests + If you see something like the following + ... java.lang.NullPointerException: null at org.apache.hadoop.hdfs.MiniDFSCluster.startDataNodes at org.apache.hadoop.hdfs.MiniDFSCluster.<init> @@ -1135,8 +1258,8 @@ at org.apache.hadoop.hbase.MiniHBaseCluster.<init> at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniDFSCluster at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster ... -or -... + or + ... java.io.IOException: Shutting down at org.apache.hadoop.hbase.MiniHBaseCluster.init at org.apache.hadoop.hbase.MiniHBaseCluster.<init> @@ -1144,42 +1267,44 @@ at org.apache.hadoop.hbase.MiniHBaseCluster.<init> at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniHBaseCluster at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster ... -... then try issuing the command umask 022 before launching tests. This is a workaround for -HDFS-2556 - -
- -
- -
- Case Studies - For Performance and Troubleshooting Case Studies, see . + ... then try issuing the command umask 022 before launching tests. + This is a workaround for HDFS-2556
-
- Cryptographic Features -
- sun.security.pkcs11.wrapper.PKCS11Exception: CKR_ARGUMENTS_BAD -This problem manifests as exceptions ultimately caused by: - +
+ +
+ Case Studies + For Performance and Troubleshooting Case Studies, see . +
+ +
+ Cryptographic Features +
+ sun.security.pkcs11.wrapper.PKCS11Exception: CKR_ARGUMENTS_BAD + This problem manifests as exceptions ultimately caused by: + Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_ARGUMENTS_BAD at sun.security.pkcs11.wrapper.PKCS11.C_DecryptUpdate(Native Method) at sun.security.pkcs11.P11Cipher.implDoFinal(P11Cipher.java:795) - -This problem appears to affect some versions of OpenJDK 7 shipped by some Linux vendors. NSS is configured as the default provider. If the host has an x86_64 architecture, depending on if the vendor packages contain the defect, the NSS provider will not function correctly. - - -To work around this problem, find the JRE home directory and edit the file lib/security/java.security. Edit the file to comment out the line: - - + This problem appears to affect some versions of OpenJDK 7 shipped by some Linux + vendors. NSS is configured as the default provider. If the host has an x86_64 architecture, + depending on if the vendor packages contain the defect, the NSS provider will not function + correctly. + To work around this problem, find the JRE home directory and edit the file + lib/security/java.security. Edit the file to comment out the line: + security.provider.1=sun.security.pkcs11.SunPKCS11 ${java.home}/lib/security/nss.cfg - -Then renumber the remaining providers accordingly. - -
+ Then renumber the remaining providers accordingly.
+
- + diff --git a/src/main/docbkx/upgrading.xml b/src/main/docbkx/upgrading.xml index 758d6d4317c..33b68d87d6e 100644 --- a/src/main/docbkx/upgrading.xml +++ b/src/main/docbkx/upgrading.xml @@ -1,13 +1,15 @@ - - - ZooKeeper<indexterm> - <primary>ZooKeeper</primary> - </indexterm> + ZooKeeper<indexterm> + <primary>ZooKeeper</primary> + </indexterm> - A distributed Apache HBase installation depends on a running ZooKeeper cluster. - All participating nodes and clients need to be able to access the - running ZooKeeper ensemble. Apache HBase by default manages a ZooKeeper - "cluster" for you. It will start and stop the ZooKeeper ensemble - as part of the HBase start/stop process. You can also manage the - ZooKeeper ensemble independent of HBase and just point HBase at - the cluster it should use. To toggle HBase management of - ZooKeeper, use the HBASE_MANAGES_ZK variable in - conf/hbase-env.sh. This variable, which - defaults to true, tells HBase whether to - start/stop the ZooKeeper ensemble servers as part of HBase - start/stop. + A distributed Apache HBase installation depends on a running ZooKeeper cluster. All + participating nodes and clients need to be able to access the running ZooKeeper ensemble. Apache + HBase by default manages a ZooKeeper "cluster" for you. It will start and stop the ZooKeeper + ensemble as part of the HBase start/stop process. You can also manage the ZooKeeper ensemble + independent of HBase and just point HBase at the cluster it should use. To toggle HBase + management of ZooKeeper, use the HBASE_MANAGES_ZK variable in + conf/hbase-env.sh. This variable, which defaults to + true, tells HBase whether to start/stop the ZooKeeper ensemble servers as + part of HBase start/stop. - When HBase manages the ZooKeeper ensemble, you can specify - ZooKeeper configuration using its native - zoo.cfg file, or, the easier option is to - just specify ZooKeeper options directly in - conf/hbase-site.xml. A ZooKeeper - configuration option can be set as a property in the HBase - hbase-site.xml XML configuration file by - prefacing the ZooKeeper option name with - hbase.zookeeper.property. For example, the - clientPort setting in ZooKeeper can be changed - by setting the - hbase.zookeeper.property.clientPort property. - For all default values used by HBase, including ZooKeeper - configuration, see . Look for the - hbase.zookeeper.property prefix - For the full list of ZooKeeper configurations, see - ZooKeeper's zoo.cfg. HBase does not ship - with a zoo.cfg so you will need to browse - the conf directory in an appropriate - ZooKeeper download. - + When HBase manages the ZooKeeper ensemble, you can specify ZooKeeper configuration using its + native zoo.cfg file, or, the easier option is to just specify ZooKeeper + options directly in conf/hbase-site.xml. A ZooKeeper configuration option + can be set as a property in the HBase hbase-site.xml XML configuration file + by prefacing the ZooKeeper option name with hbase.zookeeper.property. For + example, the clientPort setting in ZooKeeper can be changed by setting the + hbase.zookeeper.property.clientPort property. For all default values used + by HBase, including ZooKeeper configuration, see . Look for the + hbase.zookeeper.property prefix + For the full list of ZooKeeper configurations, see ZooKeeper's + zoo.cfg. HBase does not ship with a zoo.cfg so + you will need to browse the conf directory in an appropriate ZooKeeper + download. + - You must at least list the ensemble servers in - hbase-site.xml using the - hbase.zookeeper.quorum property. This property - defaults to a single ensemble member at - localhost which is not suitable for a fully - distributed HBase. (It binds to the local machine only and remote - clients will not be able to connect). - How many ZooKeepers should I run? + You must at least list the ensemble servers in hbase-site.xml using the + hbase.zookeeper.quorum property. This property defaults to a single + ensemble member at localhost which is not suitable for a fully distributed + HBase. (It binds to the local machine only and remote clients will not be able to connect). + + How many ZooKeepers should I run? - You can run a ZooKeeper ensemble that comprises 1 node - only but in production it is recommended that you run a - ZooKeeper ensemble of 3, 5 or 7 machines; the more members an - ensemble has, the more tolerant the ensemble is of host - failures. Also, run an odd number of machines. In ZooKeeper, - an even number of peers is supported, but it is normally not used - because an even sized ensemble requires, proportionally, more peers - to form a quorum than an odd sized ensemble requires. For example, an - ensemble with 4 peers requires 3 to form a quorum, while an ensemble with - 5 also requires 3 to form a quorum. Thus, an ensemble of 5 allows 2 peers to - fail, and thus is more fault tolerant than the ensemble of 4, which allows - only 1 down peer. - - Give each ZooKeeper server around 1GB of RAM, and if possible, its own - dedicated disk (A dedicated disk is the best thing you can do - to ensure a performant ZooKeeper ensemble). For very heavily - loaded clusters, run ZooKeeper servers on separate machines - from RegionServers (DataNodes and TaskTrackers). - + You can run a ZooKeeper ensemble that comprises 1 node only but in production it is + recommended that you run a ZooKeeper ensemble of 3, 5 or 7 machines; the more members an + ensemble has, the more tolerant the ensemble is of host failures. Also, run an odd number of + machines. In ZooKeeper, an even number of peers is supported, but it is normally not used + because an even sized ensemble requires, proportionally, more peers to form a quorum than an + odd sized ensemble requires. For example, an ensemble with 4 peers requires 3 to form a + quorum, while an ensemble with 5 also requires 3 to form a quorum. Thus, an ensemble of 5 + allows 2 peers to fail, and thus is more fault tolerant than the ensemble of 4, which allows + only 1 down peer. + Give each ZooKeeper server around 1GB of RAM, and if possible, its own dedicated disk (A + dedicated disk is the best thing you can do to ensure a performant ZooKeeper ensemble). For + very heavily loaded clusters, run ZooKeeper servers on separate machines from RegionServers + (DataNodes and TaskTrackers). + - For example, to have HBase manage a ZooKeeper quorum on - nodes rs{1,2,3,4,5}.example.com, bound to - port 2222 (the default is 2181) ensure - HBASE_MANAGE_ZK is commented out or set to - true in conf/hbase-env.sh - and then edit conf/hbase-site.xml and set - hbase.zookeeper.property.clientPort and - hbase.zookeeper.quorum. You should also set - hbase.zookeeper.property.dataDir to other than - the default as the default has ZooKeeper persist data under - /tmp which is often cleared on system - restart. In the example below we have ZooKeeper persist to - /user/local/zookeeper. - <configuration> + For example, to have HBase manage a ZooKeeper quorum on nodes + rs{1,2,3,4,5}.example.com, bound to port 2222 (the default is 2181) + ensure HBASE_MANAGE_ZK is commented out or set to true in + conf/hbase-env.sh and then edit conf/hbase-site.xml + and set hbase.zookeeper.property.clientPort and + hbase.zookeeper.quorum. You should also set + hbase.zookeeper.property.dataDir to other than the default as the default + has ZooKeeper persist data under /tmp which is often cleared on system + restart. In the example below we have ZooKeeper persist to + /user/local/zookeeper. + ... - <property> - <name>hbase.zookeeper.property.clientPort</name> - <value>2222</value> - <description>Property from ZooKeeper's config zoo.cfg. + + hbase.zookeeper.property.clientPort + 2222 + Property from ZooKeeper's config zoo.cfg. The port at which the clients will connect. - </description> - </property> - <property> - <name>hbase.zookeeper.quorum</name> - <value>rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com</value> - <description>Comma separated list of servers in the ZooKeeper Quorum. + + + + hbase.zookeeper.quorum + rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com + Comma separated list of servers in the ZooKeeper Quorum. For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com". By default this is set to localhost for local and pseudo-distributed modes of operation. For a fully-distributed setup, this should be set to a full list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh this is the list of servers which we will start/stop ZooKeeper on. - </description> - </property> - <property> - <name>hbase.zookeeper.property.dataDir</name> - <value>/usr/local/zookeeper</value> - <description>Property from ZooKeeper's config zoo.cfg. + + + + hbase.zookeeper.property.dataDir + /usr/local/zookeeper + Property from ZooKeeper's config zoo.cfg. The directory where the snapshot is stored. - </description> - </property> + + ... - </configuration> - - What verion of ZooKeeper should I use? - The newer version, the better. For example, some folks have been bitten by - ZOOKEEPER-1277. - If running zookeeper 3.5+, you can ask hbase to make use of the new multi operation by - enabling " in your hbase-site.xml. - + ]]>
+ + What verion of ZooKeeper should I use? + The newer version, the better. For example, some folks have been bitten by ZOOKEEPER-1277. If + running zookeeper 3.5+, you can ask hbase to make use of the new multi operation by enabling " in your hbase-site.xml. - ZooKeeper Maintenance - Be sure to set up the data dir cleaner described under - Zookeeper Maintenance else you could - have 'interesting' problems a couple of months in; i.e. zookeeper could start - dropping sessions if it has to run through a directory of hundreds of thousands of - logs which is wont to do around leader reelection time -- a process rare but run on - occasion whether because a machine is dropped or happens to hiccup. + ZooKeeper Maintenance + Be sure to set up the data dir cleaner described under Zookeeper + Maintenance else you could have 'interesting' problems a couple of months in; i.e. + zookeeper could start dropping sessions if it has to run through a directory of hundreds of + thousands of logs which is wont to do around leader reelection time -- a process rare but run + on occasion whether because a machine is dropped or happens to hiccup. -
- Using existing ZooKeeper ensemble +
+ Using existing ZooKeeper ensemble - To point HBase at an existing ZooKeeper cluster, one that - is not managed by HBase, set HBASE_MANAGES_ZK - in conf/hbase-env.sh to false - + To point HBase at an existing ZooKeeper cluster, one that is not managed by HBase, set + HBASE_MANAGES_ZK in conf/hbase-env.sh to + false + ... # Tell HBase whether it should manage its own instance of Zookeeper or not. - export HBASE_MANAGES_ZK=false Next set ensemble locations - and client port, if non-standard, in - hbase-site.xml, or add a suitably - configured zoo.cfg to HBase's - CLASSPATH. HBase will prefer the - configuration found in zoo.cfg over any - settings in hbase-site.xml. + export HBASE_MANAGES_ZK=false + Next set ensemble locations and client port, if non-standard, in + hbase-site.xml, or add a suitably configured + zoo.cfg to HBase's CLASSPATH. HBase will prefer + the configuration found in zoo.cfg over any settings in + hbase-site.xml. - When HBase manages ZooKeeper, it will start/stop the - ZooKeeper servers as a part of the regular start/stop scripts. - If you would like to run ZooKeeper yourself, independent of - HBase start/stop, you would do the following + When HBase manages ZooKeeper, it will start/stop the ZooKeeper servers as a part of the + regular start/stop scripts. If you would like to run ZooKeeper yourself, independent of HBase + start/stop, you would do the following - + ${HBASE_HOME}/bin/hbase-daemons.sh {start,stop} zookeeper - + - Note that you can use HBase in this manner to spin up a - ZooKeeper cluster, unrelated to HBase. Just make sure to set - HBASE_MANAGES_ZK to false - if you want it to stay up across HBase restarts so that when - HBase shuts down, it doesn't take ZooKeeper down with it. + Note that you can use HBase in this manner to spin up a ZooKeeper cluster, unrelated to + HBase. Just make sure to set HBASE_MANAGES_ZK to false + if you want it to stay up across HBase restarts so that when HBase shuts down, it doesn't take + ZooKeeper down with it. - For more information about running a distinct ZooKeeper - cluster, see the ZooKeeper Getting - Started Guide. Additionally, see the ZooKeeper Wiki or the - ZooKeeper documentation - for more information on ZooKeeper sizing. - -
+ For more information about running a distinct ZooKeeper cluster, see the ZooKeeper Getting + Started Guide. Additionally, see the ZooKeeper Wiki or the ZooKeeper + documentation for more information on ZooKeeper sizing. +
-
- SASL Authentication with ZooKeeper - Newer releases of Apache HBase (>= 0.92) will - support connecting to a ZooKeeper Quorum that supports - SASL authentication (which is available in Zookeeper - versions 3.4.0 or later). +
+ SASL Authentication with ZooKeeper + Newer releases of Apache HBase (>= 0.92) will support connecting to a ZooKeeper Quorum + that supports SASL authentication (which is available in Zookeeper versions 3.4.0 or + later). - This describes how to set up HBase to mutually - authenticate with a ZooKeeper Quorum. ZooKeeper/HBase - mutual authentication (HBASE-2418) - is required as part of a complete secure HBase configuration - (HBASE-3025). + This describes how to set up HBase to mutually authenticate with a ZooKeeper Quorum. + ZooKeeper/HBase mutual authentication (HBASE-2418) is required + as part of a complete secure HBase configuration (HBASE-3025). For + simplicity of explication, this section ignores additional configuration required (Secure HDFS + and Coprocessor configuration). It's recommended to begin with an HBase-managed Zookeeper + configuration (as opposed to a standalone Zookeeper quorum) for ease of learning. - For simplicity of explication, this section ignores - additional configuration required (Secure HDFS and Coprocessor - configuration). It's recommended to begin with an - HBase-managed Zookeeper configuration (as opposed to a - standalone Zookeeper quorum) for ease of learning. - +
+ Operating System Prerequisites -
Operating System Prerequisites + You need to have a working Kerberos KDC setup. For each $HOST that will + run a ZooKeeper server, you should have a principle zookeeper/$HOST. For each + such host, add a service key (using the kadmin or kadmin.local + tool's ktadd command) for zookeeper/$HOST and copy this file to + $HOST, and make it readable only to the user that will run zookeeper on + $HOST. Note the location of this file, which we will use below as + $PATH_TO_ZOOKEEPER_KEYTAB. - - You need to have a working Kerberos KDC setup. For - each $HOST that will run a ZooKeeper - server, you should have a principle - zookeeper/$HOST. For each such host, - add a service key (using the kadmin or - kadmin.local tool's ktadd - command) for zookeeper/$HOST and copy - this file to $HOST, and make it - readable only to the user that will run zookeeper on - $HOST. Note the location of this file, - which we will use below as - $PATH_TO_ZOOKEEPER_KEYTAB. - + Similarly, for each $HOST that will run an HBase server (master or + regionserver), you should have a principle: hbase/$HOST. For each host, add a + keytab file called hbase.keytab containing a service key for + hbase/$HOST, copy this file to $HOST, and make it readable only + to the user that will run an HBase service on $HOST. Note the location of this + file, which we will use below as $PATH_TO_HBASE_KEYTAB. - - Similarly, for each $HOST that will run - an HBase server (master or regionserver), you should - have a principle: hbase/$HOST. For each - host, add a keytab file called - hbase.keytab containing a service - key for hbase/$HOST, copy this file to - $HOST, and make it readable only to the - user that will run an HBase service on - $HOST. Note the location of this file, - which we will use below as - $PATH_TO_HBASE_KEYTAB. - + Each user who will be an HBase client should also be given a Kerberos principal. This + principal should usually have a password assigned to it (as opposed to, as with the HBase + servers, a keytab file) which only this user knows. The client's principal's + maxrenewlife should be set so that it can be renewed enough so that the user + can complete their HBase client processes. For example, if a user runs a long-running HBase + client process that takes at most 3 days, we might create this user's principal within + kadmin with: addprinc -maxrenewlife 3days. The Zookeeper client + and server libraries manage their own ticket refreshment by running threads that wake up + periodically to do the refreshment. - - Each user who will be an HBase client should also be - given a Kerberos principal. This principal should - usually have a password assigned to it (as opposed to, - as with the HBase servers, a keytab file) which only - this user knows. The client's principal's - maxrenewlife should be set so that it can - be renewed enough so that the user can complete their - HBase client processes. For example, if a user runs a - long-running HBase client process that takes at most 3 - days, we might create this user's principal within - kadmin with: addprinc -maxrenewlife - 3days. The Zookeeper client and server - libraries manage their own ticket refreshment by - running threads that wake up periodically to do the - refreshment. - + On each host that will run an HBase client (e.g. hbase shell), add the + following file to the HBase home directory's conf directory: - On each host that will run an HBase client - (e.g. hbase shell), add the following - file to the HBase home directory's conf - directory: - - - Client { - com.sun.security.auth.module.Krb5LoginModule required - useKeyTab=false - useTicketCache=true; - }; + +Client { + com.sun.security.auth.module.Krb5LoginModule required + useKeyTab=false + useTicketCache=true; +}; - We'll refer to this JAAS configuration file as - $CLIENT_CONF below. -
-
- HBase-managed Zookeeper Configuration + We'll refer to this JAAS configuration file as $CLIENT_CONF + below. +
+
+ HBase-managed Zookeeper Configuration - On each node that will run a zookeeper, a - master, or a regionserver, create a JAAS - configuration file in the conf directory of the node's - HBASE_HOME directory that looks like the - following: + On each node that will run a zookeeper, a master, or a regionserver, create a JAAS + configuration file in the conf directory of the node's HBASE_HOME + directory that looks like the following: - - Server { - com.sun.security.auth.module.Krb5LoginModule required - useKeyTab=true - keyTab="$PATH_TO_ZOOKEEPER_KEYTAB" - storeKey=true - useTicketCache=false - principal="zookeeper/$HOST"; - }; - Client { - com.sun.security.auth.module.Krb5LoginModule required - useKeyTab=true - useTicketCache=false - keyTab="$PATH_TO_HBASE_KEYTAB" - principal="hbase/$HOST"; - }; + +Server { + com.sun.security.auth.module.Krb5LoginModule required + useKeyTab=true + keyTab="$PATH_TO_ZOOKEEPER_KEYTAB" + storeKey=true + useTicketCache=false + principal="zookeeper/$HOST"; +}; +Client { + com.sun.security.auth.module.Krb5LoginModule required + useKeyTab=true + useTicketCache=false + keyTab="$PATH_TO_HBASE_KEYTAB" + principal="hbase/$HOST"; +}; - where the $PATH_TO_HBASE_KEYTAB and - $PATH_TO_ZOOKEEPER_KEYTAB files are what - you created above, and $HOST is the hostname for that - node. + where the $PATH_TO_HBASE_KEYTAB and + $PATH_TO_ZOOKEEPER_KEYTAB files are what you created above, and + $HOST is the hostname for that node. - The Server section will be used by - the Zookeeper quorum server, while the - Client section will be used by the HBase - master and regionservers. The path to this file should - be substituted for the text $HBASE_SERVER_CONF - in the hbase-env.sh - listing below. + The Server section will be used by the Zookeeper quorum server, while the + Client section will be used by the HBase master and regionservers. The path + to this file should be substituted for the text $HBASE_SERVER_CONF in + the hbase-env.sh listing below. - - The path to this file should be substituted for the - text $CLIENT_CONF in the - hbase-env.sh listing below. - + The path to this file should be substituted for the text + $CLIENT_CONF in the hbase-env.sh listing below. - Modify your hbase-env.sh to include the - following: + Modify your hbase-env.sh to include the following: - - export HBASE_OPTS="-Djava.security.auth.login.config=$CLIENT_CONF" - export HBASE_MANAGES_ZK=true - export HBASE_ZOOKEEPER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" - export HBASE_MASTER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" - export HBASE_REGIONSERVER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" + +export HBASE_OPTS="-Djava.security.auth.login.config=$CLIENT_CONF" +export HBASE_MANAGES_ZK=true +export HBASE_ZOOKEEPER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" +export HBASE_MASTER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" +export HBASE_REGIONSERVER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" - where $HBASE_SERVER_CONF and - $CLIENT_CONF are the full paths to the - JAAS configuration files created above. + where $HBASE_SERVER_CONF and $CLIENT_CONF are + the full paths to the JAAS configuration files created above. - Modify your hbase-site.xml on each node - that will run zookeeper, master or regionserver to contain: + Modify your hbase-site.xml on each node that will run zookeeper, + master or regionserver to contain: - - - hbase.zookeeper.quorum - $ZK_NODES - - - hbase.cluster.distributed - true - - - hbase.zookeeper.property.authProvider.1 - org.apache.zookeeper.server.auth.SASLAuthenticationProvider - - - hbase.zookeeper.property.kerberos.removeHostFromPrincipal - true - - - hbase.zookeeper.property.kerberos.removeRealmFromPrincipal - true - - + + + hbase.zookeeper.quorum + $ZK_NODES + + + hbase.cluster.distributed + true + + + hbase.zookeeper.property.authProvider.1 + org.apache.zookeeper.server.auth.SASLAuthenticationProvider + + + hbase.zookeeper.property.kerberos.removeHostFromPrincipal + true + + + hbase.zookeeper.property.kerberos.removeRealmFromPrincipal + true + + ]]> - where $ZK_NODES is the - comma-separated list of hostnames of the Zookeeper - Quorum hosts. + where $ZK_NODES is the comma-separated list of hostnames of the Zookeeper + Quorum hosts. - Start your hbase cluster by running one or more - of the following set of commands on the appropriate - hosts: - + Start your hbase cluster by running one or more of the following set of commands on the + appropriate hosts: - - bin/hbase zookeeper start - bin/hbase master start - bin/hbase regionserver start + +bin/hbase zookeeper start +bin/hbase master start +bin/hbase regionserver start + + +
+ +
+ External Zookeeper Configuration + Add a JAAS configuration file that looks like: + +Client { + com.sun.security.auth.module.Krb5LoginModule required + useKeyTab=true + useTicketCache=false + keyTab="$PATH_TO_HBASE_KEYTAB" + principal="hbase/$HOST"; +}; + where the $PATH_TO_HBASE_KEYTAB is the keytab created above for + HBase services to run on this host, and $HOST is the hostname for that node. + Put this in the HBase home's configuration directory. We'll refer to this file's full + pathname as $HBASE_SERVER_CONF below. -
+ Modify your hbase-env.sh to include the following: -
External Zookeeper Configuration - Add a JAAS configuration file that looks like: - - - Client { - com.sun.security.auth.module.Krb5LoginModule required - useKeyTab=true - useTicketCache=false - keyTab="$PATH_TO_HBASE_KEYTAB" - principal="hbase/$HOST"; - }; - - - where the $PATH_TO_HBASE_KEYTAB is the keytab - created above for HBase services to run on this host, and $HOST is the - hostname for that node. Put this in the HBase home's - configuration directory. We'll refer to this file's - full pathname as $HBASE_SERVER_CONF below. - - Modify your hbase-env.sh to include the following: - - - export HBASE_OPTS="-Djava.security.auth.login.config=$CLIENT_CONF" - export HBASE_MANAGES_ZK=false - export HBASE_MASTER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" - export HBASE_REGIONSERVER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" + +export HBASE_OPTS="-Djava.security.auth.login.config=$CLIENT_CONF" +export HBASE_MANAGES_ZK=false +export HBASE_MASTER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" +export HBASE_REGIONSERVER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF" - Modify your hbase-site.xml on each node - that will run a master or regionserver to contain: + Modify your hbase-site.xml on each node that will run a master or + regionserver to contain: - - - hbase.zookeeper.quorum - $ZK_NODES - - - hbase.cluster.distributed - true - - + + + hbase.zookeeper.quorum + $ZK_NODES + + + hbase.cluster.distributed + true + + ]]> - where $ZK_NODES is the - comma-separated list of hostnames of the Zookeeper - Quorum hosts. + where $ZK_NODES is the comma-separated list of hostnames of the Zookeeper + Quorum hosts. - - Add a zoo.cfg for each Zookeeper Quorum host containing: - - authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider - kerberos.removeHostFromPrincipal=true - kerberos.removeRealmFromPrincipal=true + Add a zoo.cfg for each Zookeeper Quorum host containing: + +authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider +kerberos.removeHostFromPrincipal=true +kerberos.removeRealmFromPrincipal=true + + Also on each of these hosts, create a JAAS configuration file containing: + +Server { + com.sun.security.auth.module.Krb5LoginModule required + useKeyTab=true + keyTab="$PATH_TO_ZOOKEEPER_KEYTAB" + storeKey=true + useTicketCache=false + principal="zookeeper/$HOST"; +}; + + where $HOST is the hostname of each Quorum host. We will refer to the full + pathname of this file as $ZK_SERVER_CONF below. + + Start your Zookeepers on each Zookeeper Quorum host with: + +SERVER_JVMFLAGS="-Djava.security.auth.login.config=$ZK_SERVER_CONF" bin/zkServer start - Also on each of these hosts, create a JAAS configuration file containing: + Start your HBase cluster by running one or more of the following set of commands on the + appropriate nodes: - - Server { - com.sun.security.auth.module.Krb5LoginModule required - useKeyTab=true - keyTab="$PATH_TO_ZOOKEEPER_KEYTAB" - storeKey=true - useTicketCache=false - principal="zookeeper/$HOST"; - }; - - - where $HOST is the hostname of each - Quorum host. We will refer to the full pathname of - this file as $ZK_SERVER_CONF below. - - - - - Start your Zookeepers on each Zookeeper Quorum host with: - - - SERVER_JVMFLAGS="-Djava.security.auth.login.config=$ZK_SERVER_CONF" bin/zkServer start - - - - - - Start your HBase cluster by running one or more of the following set of commands on the appropriate nodes: - - - - bin/hbase master start - bin/hbase regionserver start - + +bin/hbase master start +bin/hbase regionserver start + -
+
-
- Zookeeper Server Authentication Log Output - If the configuration above is successful, - you should see something similar to the following in - your Zookeeper server logs: - +
+ Zookeeper Server Authentication Log Output + If the configuration above is successful, you should see something similar to the + following in your Zookeeper server logs: + 11/12/05 22:43:39 INFO zookeeper.Login: successfully logged in. 11/12/05 22:43:39 INFO server.NIOServerCnxnFactory: binding to port 0.0.0.0/0.0.0.0:2181 11/12/05 22:43:39 INFO zookeeper.Login: TGT refresh thread started. @@ -507,18 +429,15 @@ ${HBASE_HOME}/bin/hbase-daemons.sh {start,stop} zookeeper authorizationID=hbase/ip-10-166-175-249.us-west-1.compute.internal@HADOOP.LOCALDOMAIN. 11/12/05 22:43:59 INFO auth.SaslServerCallbackHandler: Setting authorizedID: hbase 11/12/05 22:43:59 INFO server.ZooKeeperServer: adding SASL authorization for authorizationID: hbase - + - +
-
- -
- Zookeeper Client Authentication Log Output - On the Zookeeper client side (HBase master or regionserver), - you should see something similar to the following: - - +
+ Zookeeper Client Authentication Log Output + On the Zookeeper client side (HBase master or regionserver), you should see something + similar to the following: + 11/12/05 22:43:59 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=ip-10-166-175-249.us-west-1.compute.internal:2181 sessionTimeout=180000 watcher=master:60000 11/12/05 22:43:59 INFO zookeeper.ClientCnxn: Opening socket connection to server /10.166.175.249:2181 11/12/05 22:43:59 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 14851@ip-10-166-175-249 @@ -530,76 +449,67 @@ ${HBASE_HOME}/bin/hbase-daemons.sh {start,stop} zookeeper 11/12/05 22:43:59 INFO zookeeper.Login: TGT expires: Tue Dec 06 22:43:59 UTC 2011 11/12/05 22:43:59 INFO zookeeper.Login: TGT refresh sleeping until: Tue Dec 06 18:30:37 UTC 2011 11/12/05 22:43:59 INFO zookeeper.ClientCnxn: Session establishment complete on server ip-10-166-175-249.us-west-1.compute.internal/10.166.175.249:2181, sessionid = 0x134106594320000, negotiated timeout = 180000 - - -
+ +
-
- Configuration from Scratch +
+ Configuration from Scratch - This has been tested on the current standard Amazon - Linux AMI. First setup KDC and principals as - described above. Next checkout code and run a sanity - check. + This has been tested on the current standard Amazon Linux AMI. First setup KDC and + principals as described above. Next checkout code and run a sanity check. - - git clone git://git.apache.org/hbase.git - cd hbase - mvn clean test -Dtest=TestZooKeeperACL - + +git clone git://git.apache.org/hbase.git +cd hbase +mvn clean test -Dtest=TestZooKeeperACL + - Then configure HBase as described above. - Manually edit target/cached_classpath.txt (see below): - - - bin/hbase zookeeper & - bin/hbase master & - bin/hbase regionserver & - -
+ Then configure HBase as described above. Manually edit target/cached_classpath.txt (see + below): + +bin/hbase zookeeper & +bin/hbase master & +bin/hbase regionserver & + +
-
- Future improvements +
+ Future improvements -
Fix target/cached_classpath.txt - - You must override the standard hadoop-core jar file from the - target/cached_classpath.txt - file with the version containing the HADOOP-7070 fix. You can use the following script to do this: +
+ Fix target/cached_classpath.txt + You must override the standard hadoop-core jar file from the + target/cached_classpath.txt file with the version containing the + HADOOP-7070 fix. You can use the following script to do this: + +echo `find ~/.m2 -name "*hadoop-core*7070*SNAPSHOT.jar"` ':' `cat target/cached_classpath.txt` | sed 's/ //g' > target/tmp.txt +mv target/tmp.txt target/cached_classpath.txt + +
- - echo `find ~/.m2 -name "*hadoop-core*7070*SNAPSHOT.jar"` ':' `cat target/cached_classpath.txt` | sed 's/ //g' > target/tmp.txt - mv target/tmp.txt target/cached_classpath.txt - - -
- -
- -
- Set JAAS configuration - programmatically +
+ Set JAAS configuration programmatically - This would avoid the need for a separate Hadoop jar - that fixes HADOOP-7070. - -
+ This would avoid the need for a separate Hadoop jar that fixes HADOOP-7070. + +
-
- Elimination of - <code>kerberos.removeHostFromPrincipal</code> and - <code>kerberos.removeRealmFromPrincipal</code> - -
+
+ Elimination of <code>kerberos.removeHostFromPrincipal</code> and + <code>kerberos.removeRealmFromPrincipal</code> + +
-
+
-
+
+ - +