以下是CentOS上HBase數據備份的常用方法:
hbase backup create 'backup_name' /backup/hbase --full
支持指定表名(如--tables 'table1,table2')。hbase backup create 'backup_name' /backup/hbase --incremental
需先有全量備份,僅備份變化數據。hbase snapshot 'snapshot_name' 'table_name'
hbase snapshot restore 'snapshot_name' 'table_name'
通過hadoop distcp命令備份HBase數據到HDFS:
hadoop distcp hdfs:///hbase /backup/hbase
hadoop distcp /backup/hbase hdfs:///hbase
需先停止HBase服務,確保數據一致性。
xtrabackup --backup --target-dir=/backup/hbase --hbase-home=/path/to/hbase
xtrabackup --prepare --target-dir=/backup/hbase
xtrabackup --copy-back --target-dir=/backup/hbase
根據業務需求選擇合適方案,全量備份適合關鍵數據,增量備份適合頻繁更新場景,快照適合快速回滾。