跳过正文
  1. en/
  2. Posts/

Docker Big Data Cluster HA Deployment

作者
John Lee
Building things with code. Writing about tech, projects, and ideas.

Docker Big Data Cluster HA Deployment
#

Docker Compose orchestrated 32-container full-stack HA big data cluster for local testing and learning.

Architecture Overview
#

                    ┌─────────────────────────────────────────────────┐
                    │            Docker Bridge: bigdata-net            │
                    │              172.25.0.0/16                      │
                    ├─────────────────────────────────────────────────┤
                    │  Layer 0 (base): MySQL + ZooKeeper x3           │
                    │  Layer 1 (storage): JournalNode x3              │
                    │  Layer 2 (storage): NameNode x2 + ZKFC x2       │
                    │  Layer 3 (storage): DataNode x3                 │
                    │  Layer 4 (compute): ResourceManager x2 + NM x3  │
                    │  Layer 5 (analytics): Hive Metastore/Server2    │
                    │  Layer 6 (analytics): HBase x5 + Kafka x3       │
                    │  Layer 7 (analytics): Spark + Flink History     │
                    └─────────────────────────────────────────────────┘
ComponentVersionHA StrategyContainers
HDFS3.3.6Dual NameNode + 3 JN + ZKFC10
YARN3.3.6Dual RM + ZK State Store6
ZooKeeper3.7.13-node quorum3
HBase2.6.4Dual Master + ZK discovery5
Hive3.1.3Metastore + Server2 (separate)2
Kafka2.8.03 Broker + ZK coordination3
Spark3.5.8History Server (YARN on-demand)1
Flink1.19.1History Server (YARN on-demand)1
MySQL5.71

Total: 32 containers, ~10-11GB RAM

Prerequisites
#

  • Docker Desktop 24+ (Windows/Mac/Linux)
  • 16GB+ RAM (close other heavy apps recommended)
  • 50GB+ disk space
  • Component binaries cached in ansible/files/cache/

Quick Start
#

cd docker

# 1. Build the unified image (~10-20 min first time)
make build

# 2. Start by layer (or make all for everything)
make base        # Layer 0: MySQL + ZKx3
make storage     # Layer 1-3: HDFS HA
make compute     # Layer 4: YARN HA
make analytics   # Layer 5-7: Hive + HBase + Kafka + Spark/Flink

# Or one-shot
make all

# 3. First-time deployment: initialize HDFS
make init-hdfs

# 4. Verification
make verify          # Level 1 Smoke Test
make verify-spark    # Level 2a Spark
make verify-flink    # Level 2b Flink
make verify-ha       # Level 3 HA Failover

Layered Startup
#

Start on demand — low-memory environments don’t need everything:

LayerCommandServicesMemory
Layer 0make baseMySQL, ZKx3~1.5GB
Layer 1-3make storageJNx3, NNx2, ZKFCx2, DNx3~3.5GB
Layer 4make computeRMx2, NMx3, JobHistory~2.5GB
Layer 5-7make analyticsHivex2, HBasex5, Kafkax3, Spark/Flinkx2~3.5GB

Command Reference
#

CommandDescription
make buildBuild unified image
make allStart all 32 containers
make baseStart infrastructure layer
make storageStart HDFS HA storage layer
make computeStart YARN HA compute layer
make analyticsStart analytics layer
make statusContainer resource usage
make psContainer list
make verifyLevel 1 Smoke Test (7 items)
make verify-sparkLevel 2a Spark verification
make verify-flinkLevel 2b Flink verification
make verify-haLevel 3 HA failover test (10 items)
make init-hdfsFirst-time HDFS format + init
make stopStop all services (reverse order)
make restartRestart all
make cleanRemove containers and network
make logsView all logs
make logs-<name>View specific container logs
make shell-<name>Enter container shell

Verification Tests
#

Level 1: Smoke Test (7 items)
#

#TestWhat it verifies
S1HDFS read/writeWrite → Read → Delete
S2YARN nodes>=3 NM RUNNING
S3ZK cluster1 leader + 2 follower
S4Hive MetastorePort 9083 reachable
S5HiveServer2Port 10000 reachable
S6HBase Shellstatus command works
S7Kafka E2ECreate → Produce → Consume → Delete

Level 2: Spark/Flink Functional (6 items)#

#Test
SP1Spark Pi (YARN cluster mode)
SP2Spark SQL query
SP3Spark History Server HTTP
FL1Flink YARN Session creation
FL2Flink WordCount batch job
FL3Flink History Server HTTP

Level 3: HA Failover (10 items)
#

#TestFault Injection
HA1NN failoverStop namenode-active
HA2NN recoveryStart namenode-active
HA3HDFS fault toleranceRead/write after NN switch
HA4RM failoverStop resourcemanager-1
HA5Spark on HASubmit after RM switch
HA6Flink on HASession after RM switch
HA7HMaster failoverStop hbase-master-1
HA8JN fault toleranceStop 1/3 JN
HA9ZK fault toleranceStop 1/3 ZK
HA10Kafka fault toleranceStop 1/3 Broker

Web UI Access
#

ServiceURL
NameNode Activehttp://localhost:9870
NameNode Standbyhttp://localhost:9871
YARN RM1http://localhost:8088
YARN RM2http://localhost:8089
JobHistoryhttp://localhost:19888
HBase Master1http://localhost:16010
HBase Master2http://localhost:16011
Spark Historyhttp://localhost:18080
Flink Historyhttp://localhost:8082

Troubleshooting
#

Container fails to start
#

docker compose --profile <name> logs     # View layer logs
make logs-<container>                    # View specific container
make shell-<container>                   # Enter container for debugging

Out of memory
#

  • Reduce JVM heap in .env (e.g., NAMENODE_HEAP=128m)
  • Start by layer instead of all at once
  • Close other heavy apps on Windows

HDFS not healthy
#

make init-hdfs                           # Re-format (destroys data)
docker compose --profile storage restart # Restart storage layer

Port conflicts
#

Edit ports mappings in docker-compose.yml (host port is on the left).

Comparison with Bare-Metal/Ansible
#

FeatureDockerAnsible
PurposeLocal testing/learningProduction bare-metal
Memory10-11GB12GB+
HAFull production-gradeFull production-grade
ConfigStandalone config/ dirJinja2 templates
ManagementMakefile + docker composeansible-playbook
NetworkBridge (172.25.0.0/16)Physical NIC