Bulk loading is the process of preparing and loading HFiles (HBase’s own file format) directly into the RegionServers, thus bypassing the write path.
This obviates many issues, such as:
HBase already has a replication functionality called Cluster Replication (see official documentation here). Why isn’t that enough if you want to replicate the bulk loaded data as well?
The “standard” replication uses a source-push methodology. When the active cluster (source) receives an edit to a column family with replication enabled, that edit is propagated to all destination clusters using the WAL for that column family on the RegionServer managing the relevant region.
However, in the case of bulk load, only the event (the fact that there is bulk load happening) is captured in the WAL, with reference to the HFile. The data being loaded is not recorded.
By enabling BulkLoad Replication, the active HBase RegionServer will also send these WAL entries to the peer cluster. Peer cluster will read these WAL entries and copy the HFiles from the active source cluster in the peer cluster staging directory, and basically, from here it’s just a standard bulk load.
For more information on bulk loading, you can refer to a previous blog post or see the Apache documentation. A good function description on bulk loading can be found attached to the HBASE Jira.
Bulk load Replication is supported from CDH 6.3 (including CDP releases).
In order to copy the HFiles from the source cluster to the peer cluster, the peer cluster will need the active cluster’s FileSystem client configurations. FileSystem (FS) could be HDFS or any other file system supported by HBase.
There could be multiple active clusters, so the peer needs to be able to identify the client configurations. Each active cluster must configure a unique replication cluster id. This ID will be sent to the peer cluster as part of a replication request.
The default implementation (making a custom implementation is out of the scope of this post) for getting the source cluster’s FileSystem client configurations needs each peer cluster to have a replication configuration directory. This can be configured using the hbase.replication.conf.dir property. The directory will have a sub-directory for each one of the active source clusters. Sub-directory name must be the same as the active cluster unique replication id. So the path to the respective FS client configurations will be hbase.replication.conf.dir/hbase.replication.cluster.id.
Note: If there are any changes in FS client configurations in the replication configuration directory, all the RegionServers in the peer cluster must be restarted.
If compaction, merge or split happens, the HFile is moved to the archive folder. This HFile will be cleaned up by HFile cleaner periodically. To avoid this before replication completes, the replication module will maintain these bulk loaded HFile paths into ZooKeeper for each peer.
The HFile Cleaner will not clean the HFiles until its entry is found in ZooKeeper. Once the HFile is replicated successfully, the ZooKeeper entry will be deleted by the replication module for that particular peer.
Note: If you have Kerberos setup, please check this page on how to set up cross-realm authentication.
find ./ -name 'hbase-site.xml' -print0 | xargs -0 grep 'hbase.replication.bulkload.enabled'
scp core-site.xml hdfs-site.xml hbase-site.xml root@sink.cluster.com:/opt/cloudera/fs_conf/source/It is important to copy the configuration files to the correct path defined by the two configuration parameters:
chown -R hbase:hbase /opt/cloudera/fs_conf/source
add_peer '1', CLUSTER_KEY => 'cluster-sink-1.company.com:2181:/hbase'
enable_table_replication 'IntegrationTestBulkLoad'
disable ‘IntegrationTestBulkLoad’
alter‘IntegrationTestBulkLoad’, {NAME => ‘D’, REPLICATION_SCOPE => '1'}
enable ‘IntegrationTestBulkLoad’
You should be all set now.
If HBase encounters a BulkLoad entry for the associated tables in the WAL, it will initiate the bulk load replication by reading the configuration of the source cluster. There will be some info level logs like:
If there were no errors with the configuration files and connection, HBase copies over the HFile from the source cluster’s FS to local FS and you can see that in the FileSystem log.
There will be no information trace of this in the HBase logs unless the HFile has been archived (“Failed to copy hfile from sourceHFilePath to localHFilePath. Trying to copy from hfile archive directory.”).
If the HFile has been archived, HBase will look into the archive directory. If it’s also a miss, there will be an error log ("Failed to copy hfile from sourceHFilePath to localHFilePath. Hence ignoring this hfile from replication.”) and the bulkload replication for this HFile will be skipped.