Apache Ambari provides a web-based management interface for provisioning, managing, and monitoring Hadoop clusters. After deploying Ambari for clusters with hundreds of nodes, I appreciate how it simplifies operations tasks that would otherwise require dozens of custom scripts and manual configuration.
This tutorial covers Ambari's architecture, service management, alerting, stack definitions, and API-driven automation for managing production Hadoop clusters.
Ambari Architecture and Components
Ambari consists of an Ambari Server (manages cluster state), Ambari Agent (runs on each node), and Ambari Database (stores cluster topology and configuration). The Ambari Server coordinates agent communication, manages service configurations, and provides the web UI. Agents execute commands on their local nodes and report status back.
Ambari stores cluster topology, configurations, and metrics in its database (PostgreSQL or MySQL). The Ambari REST API provides programmatic access to all management operations β everything the UI does can be done via API.
# Ambari server setup
$ ambari-server setup
# Database: PostgreSQL
# Host: ambari-db
# Port: 5432
# Database: ambari
# User: ambari
# Start services
$ ambari-server start
$ ambari-agent start # on each agent node
# Access web UI
open http://ambari-server:8080
# Default credentials: admin/admin
# Verify cluster
$ curl -u admin:admin http://ambari-server:8080/api/v1/clusters/my-cluster
Service Management and Configuration
Ambari manages Hadoop services (HDFS, YARN, Hive, HBase, etc.) through service definitions (stacks). Each stack defines service components, configuration properties, and lifecycle commands. Ambari tracks service health, configuration versions, and dependency relationships.
Configuration changes are versioned β Ambari keeps a complete history of every configuration change and which user made it. Rollback to previous configurations is a single click or API call.
# Update configuration via API
curl -X PUT -H 'X-Requested-By: ambari' \
-u admin:admin \
-d '{
"Clusters": {
"desired_configs": {
"type": "hdfs-site",
"tag": "version2"
}
}
}' \
http://ambari-server:8080/api/v1/clusters/my-cluster
# Get current configuration
curl -u admin:admin \
http://ambari-server:8080/api/v1/clusters/my-cluster/configurations?type=hdfs-site
# Restart a service
curl -X POST -H 'X-Requested-By: ambari' \
-u admin:admin \
-d '{"RequestInfo":{"context":"Restart HDFS"}}' \
http://ambari-server:8080/api/v1/clusters/my-cluster/services/HDFS/restart
Stacks and Service Definitions
Ambari Stacks define available services and their versions. The HDP stack includes HDFS, YARN, Hive, HBase, and more. Custom stacks let you add proprietary services or custom versions. Each stack defines services, components, configurations, and lifecycle commands.
Upgrading Hadoop distributions is managed through Ambari's rolling upgrade process. Ambari handles component-by-component upgrade with automatic rollback on failure, reducing the risk of major version upgrades.
# Custom stack definition
# /var/lib/ambari-server/resources/stacks/CUSTOM/3.0/metainfo.xml
2.0
CUSTOM_SERVICE
Custom Service
1.0.0
CUSTOM_SERVICE_MASTER
Custom Service Master
MASTER