Top Banner
HBase Operations: Best Practices Yaniv Yancovich Data Group Leader @ Gigya
37
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: HBase operations

HBase Operations:Best Practices

Yaniv YancovichData Group Leader @ Gigya

Page 2: HBase operations

Agenda

● HBase internals● Replication● Backup and Recovery● Monitoring & Diagnostic ● Deploy● Useful tools● Hardware recommendations● The future

Page 3: HBase operations

HBase Internals - Quick overview● A sparse multi dimensional sorted map● Supports random reads and random writes● Table is split to regions (partitions) - Auto sharding ● Region: Contiguous set of sorted keys● Each region assigned to single RegionServer● ZooKeeper cluster coordination

Page 4: HBase operations

HBase Internals - Quick Overview● Table contains rows● Each row contains cells:

o row key, column family, column qualifier, timestamp● Rows are sorted lexicographically based on row key

Page 5: HBase operations

HBase Internals - Client <-> server

● Client “talks” directly to the corresponding RS

Page 6: HBase operations

● Meet Mr. E, our Operation Director● A very calm person until...

Page 7: HBase operations

Problem #1: “The entire cluster went down!!!”

● The service is down!● “Well, we have another cluster but it isn’t

up to date”● “Maybe move to DR?”

o “DR? Who needs it?”

Page 8: HBase operations

The Solution: Replication

● Why do we need it?o Replicate data between DCso Keep DR up to dateo Easy to manage a cluster

● Three modes:o Master <-> mastero Master -> Slave o Cyclic

Page 9: HBase operations

Replication: Design

● Push in favor of Pull (MySQL)● Async● Cluster can be distinct (# clusters, security, etc)● .Meta isn’t replicated● ZooKeeper as a key player● Replaying WALEdits from the WALs (Write Ahead

Log) ● TS of replicated HLog are being kept intact● Per column family

Page 10: HBase operations

Replication: In Practise

Page 11: HBase operations

Replication: Issues, Best Practices

● Not so good over bad network● Monitor, Monitor, Monitor● Problems with recovery● Master and slave should be sync by NTP● Avoid loops in cyclic replication

Page 12: HBase operations

● So now when we have replication we can sleep like...

Well...

Page 13: HBase operations

The Problem: “I see half of my DATA!!!”

● “The “smart” guys from R&D wrote a very sophisticated tool to clean unnecessary records.”

● “Well... They did a “great” job and deleted 50% of the records! “

● “They said they are sorry...”● “We thought replication is enough...”

Page 14: HBase operations

The Solution: Backup

● Why do we need it?o Prevent Data losso Recover to point in timeo Use for offline processing

Page 15: HBase operations

Backup (Method #1) - CopyTable

● MapReduce (MR) job● Copy part or all table● Incremental copies (StartTime -> EndTime)● Limitations:

o Can only copy to an HBase tableo Newly rows won’t be includedo High latency

Page 16: HBase operations

● Not production friendly...● Affects production latency

Page 17: HBase operations

The Solution (Method #2): Backup by Export

● MR job● Dump the data to HDFS● Copy data without going through Hbase● Pros: Simple, point in time, heavily tested● Cons: Slow, have impact on running

server

Page 18: HBase operations

● "There is not enough memory or disk space to complete the operation"

● You are killing our HDFS!

Page 19: HBase operations

The Solution: Backup by Snapshots

● Recover to point-in-time● Inexpensive way to freeze a table state● Recover from user error● Compliance (monthly snapshot)● Pros:

o Point in timeo Fasto Quick recovery: table from SnapShot

Page 20: HBase operations

Backup - Snapshots

● Not a copy of a table, but set of operations on Table’s metadata and the data

● A snapshot manifest contains references to files in the original table

● On HDFS level (without cache hits)● What happens in compactions? splits?

o Archiving - HFile archiver● Offline and online snapshots

Page 21: HBase operations

Snapshots - Offline Vs Online● Offline:

o Disabled table -> all data is flushed on disko Fully consistento Atomicy, Fasto Master takes the snapshot

● Online:o Master asks each RS to take for its regionso Two phase commit using ZooKeepero Pluggable snapshots: Currently “Flush snapshot”o Few seconds

Page 22: HBase operations

Another Scenario:● So our data analyst just wanted to run a

“SMALL” HIVE query to check something

● Unfortunately it was on production cluster

Page 23: HBase operations

The Solution: Export\Clone Snapshots

● Clone Snapshot - New table from Snapshot. No data copy!

● Export snapshot - copy snapshot to remote cluster - faster than CopyTable

● Restore Snapshot - rollback● Full support in shell● No incremental snapshots● Little impact on production

Page 24: HBase operations

Backup - SummaryPerformance impact

Data footprint

Downtime Incremental backups

Easy of implementation

MTTR

Snapshots Minimal Tiny Brief (only on restore)

No Easy Seconds

Replication Minimal Large None Intrinsic Medium Seconds

Export High Large None Yes Easy High

CopyTable High Large None Yes Easy High

Page 25: HBase operations

● Something seems to bother these people

● But what???

● If just we had a decent monitoring system...

● “When nothing is sure, everything is possible” (Margaret Atwood)

Page 26: HBase operations

Monitoring● JMX based on few levels:

o Mastero Regionso Replicationo OSo GC

● Web UI renewed at 0.98o Block cache

● Zabbix, Ganglia, Nagios, Graphite● SemaText

Page 27: HBase operations

● It seems they also have a problem

● Look on the man in the middle - He was told that he need to change a single setting on all of them...

● After doing it, they figured out they need to upgrade each one...

● They just were asked to install 100 HBase nodes one after another

● But what???

Page 28: HBase operations

The Solution: Automation● Puppet

o Can build a cluster very fasto Hadoop, ZooKeeper, HBaseo Userso Carefull!!!

Page 29: HBase operations

Meet Mr. Slow our production manager

● “We have all backups and replication in place but...● Production is so SLOW!”● High latency

Page 30: HBase operations

We might call him for help!

Or...

Page 31: HBase operations

Solution: Hardware and OS Recommendations

● SSD - Not cost effective yet● Virtual storage isn’t recommended● Recommended RAM between 24-72● Min dual 1G network● Raid\JBOD on masters● No swap● NTP

Page 32: HBase operations

Useful Tools

● HBase web interface (master, regions)

● rowCount\CellCount● VerifyReplication● hbck for inconsistency● HFile - examine HFile file content● HLog - examine content of HLog file

Page 33: HBase operations

General Operational Best Practices

● Upgrades● Built in web tools for quick checks● Monitoring (JMX, JSON)● Alerting system● Configuration: Block size, Block cache,

comparison● Optimize to read\write

Page 34: HBase operations

The Future

● Upcoming: HDFS snapshots● Major compaction timing ● New pluggable snapshots

Page 36: HBase operations

Open discussion

● Tell us about your experience in production:o Replicationo Hardwareo Backupso DRo Anything else?

Page 37: HBase operations

Open discussion 2

● Any suggestions for next meetups?