From 93498ddc599fe15f4357acf742a2dcb8b2c84b9c Mon Sep 17 00:00:00 2001 From: meiyi Date: Mon, 9 Apr 2018 20:57:18 +0800 Subject: [PATCH] HBASE-17918 document serial replication Signed-off-by: zhangduo --- src/main/asciidoc/_chapters/ops_mgt.adoc | 34 +++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/asciidoc/_chapters/ops_mgt.adoc b/src/main/asciidoc/_chapters/ops_mgt.adoc index 6d332afe9d8..816773ec0c6 100644 --- a/src/main/asciidoc/_chapters/ops_mgt.adoc +++ b/src/main/asciidoc/_chapters/ops_mgt.adoc @@ -1407,9 +1407,12 @@ If a slave cluster does run out of room, or is inaccessible for other reasons, i .Consistency Across Replicated Clusters [WARNING] ==== -How your application builds on top of the HBase API matters when replication is in play. HBase's replication system provides at-least-once delivery of client edits for an enabled column family to each configured destination cluster. In the event of failure to reach a given destination, the replication system will retry sending edits in a way that might repeat a given message. Further more, there is not a guaranteed order of delivery for client edits. In the event of a RegionServer failing, recovery of the replication queue happens independent of recovery of the individual regions that server was previously handling. This means that it is possible for the not-yet-replicated edits to be serviced by a RegionServer that is currently slower to replicate than the one that handles edits from after the failure. +How your application builds on top of the HBase API matters when replication is in play. HBase's replication system provides at-least-once delivery of client edits for an enabled column family to each configured destination cluster. In the event of failure to reach a given destination, the replication system will retry sending edits in a way that might repeat a given message. HBase provides two ways of replication, one is the original replication and the other is serial replication. In the previous way of replication, there is not a guaranteed order of delivery for client edits. In the event of a RegionServer failing, recovery of the replication queue happens independent of recovery of the individual regions that server was previously handling. This means that it is possible for the not-yet-replicated edits to be serviced by a RegionServer that is currently slower to replicate than the one that handles edits from after the failure. The combination of these two properties (at-least-once delivery and the lack of message ordering) means that some destination clusters may end up in a different state if your application makes use of operations that are not idempotent, e.g. Increments. + +To solve the problem, HBase now supports serial replication, which sends edits to destination cluster as the order of requests from client. See <>. + ==== .Terminology Changes @@ -1450,6 +1453,9 @@ Instead of SQL statements, entire WALEdits (consisting of multiple cell inserts LOG.info("Replicating "+clusterId + " -> " + peerClusterId); ---- +.Serial Replication Configuration +See <> + .Cluster Management Commands add_peer :: Adds a replication relationship between two clusters. + @@ -1471,6 +1477,32 @@ enable_table_replication :: disable_table_replication :: Disable the table replication switch for all its column families. +=== Serial Replication + +Note: this feature is introduced in HBase 2.1 + +.Function of serial replication + +Serial replication supports to push logs to the destination cluster in the same order as logs reach to the source cluster. + +.Why need serial replication? +In replication of HBase, we push mutations to destination cluster by reading WAL in each region server. We have a queue for WAL files so we can read them in order of creation time. However, when region-move or RS failure occurs in source cluster, the hlog entries that are not pushed before region-move or RS-failure will be pushed by original RS(for region move) or another RS which takes over the remained hlog of dead RS(for RS failure), and the new entries for the same region(s) will be pushed by the RS which now serves the region(s), but they push the hlog entries of a same region concurrently without coordination. + +This treatment can possibly lead to data inconsistency between source and destination clusters: + +1. there are put and then delete written to source cluster. + +2. due to region-move / RS-failure, they are pushed by different replication-source threads to peer cluster. + +3. if delete is pushed to peer cluster before put, and flush and major-compact occurs in peer cluster before put is pushed to peer cluster, the delete is collected and the put remains in peer cluster, but in source cluster the put is masked by the delete, hence data inconsistency between source and destination clusters. + + +.Serial replication configuration + +. Set the serial flag to true for a repliation peer. You can either set it to true when creating a replication peer, or change it to true later. + +The serial replication feature had been done firstly in link:https://issues.apache.org/jira/browse/HBASE-9465[HBASE-9465] and then reverted and redone in link:https://issues.apache.org/jira/browse/HBASE-20046[HBASE-20046]. You can find more details in these issues. + === Verifying Replicated Data The `VerifyReplication` MapReduce job, which is included in HBase, performs a systematic comparison of replicated data between two different clusters. Run the VerifyReplication job on the master cluster, supplying it with the peer ID and table name to use for validation. You can limit the verification further by specifying a time range or specific families. The job's short name is `verifyrep`. To run the job, use a command like the following: