YugabyteDB Cluster
YugabyteDB distributed PostgreSQL-compatible database.
[i]Overview
YugabyteDB is a high-performance, cloud-native distributed SQL database that combines the best of traditional RDBMS and NoSQL systems. Built from the ground up to be geo-distributed, YugabyteDB offers PostgreSQL compatibility with automatic sharding, replication, and multi-region capabilities. Originally developed by former Facebook engineers who worked on HBase and Cassandra, YugabyteDB addresses the limitations of traditional databases in cloud-native environments by providing horizontal scalability without sacrificing ACID transactions or SQL capabilities.
This Docker configuration deploys a minimal YugabyteDB cluster consisting of one master server (yb-master) and one tablet server (yb-tserver). The master server handles cluster metadata, load balancing, and administrative operations, while the tablet server stores actual data and serves client requests. This architecture allows YugabyteDB to provide both PostgreSQL (YSQL) and Cassandra (YCQL) APIs simultaneously, enabling applications to use familiar SQL operations while benefiting from distributed database capabilities.
This setup is ideal for developers and database administrators who need to evaluate distributed PostgreSQL capabilities or prototype applications requiring horizontal scalability. While this single-node cluster configuration doesn't demonstrate YugabyteDB's full distributed capabilities, it provides an excellent foundation for understanding the system's dual API support and can be easily expanded to multi-node deployments for production workloads requiring high availability and geographic distribution.
[*]Key Features
- [+]PostgreSQL-compatible SQL API (YSQL) on port 5433 with full ACID transactions
- [+]Cassandra Query Language API (YCQL) on port 9042 for NoSQL workloads
- [+]Built-in web-based Master UI for cluster monitoring and administration
- [+]Tablet Server UI providing real-time metrics and query performance insights
- [+]Automatic data sharding and replication without application changes
- [+]Multi-version concurrency control with snapshot isolation
- [+]Support for distributed ACID transactions across multiple tablets
- [+]Native JSON and JSONB data types with advanced indexing capabilities
[#]Common Use Cases
- [1]Migrating from PostgreSQL while maintaining compatibility and adding horizontal scalability
- [2]Building cloud-native applications requiring multi-region data distribution
- [3]Developing microservices architectures with both SQL and NoSQL data access patterns
- [4]Creating financial applications requiring distributed ACID transactions
- [5]Prototyping IoT platforms with high-throughput ingestion and complex analytics
- [6]Building e-commerce platforms requiring global data consistency and low latency
- [7]Evaluating distributed SQL databases for enterprise modernization projects
[!]Prerequisites
- [!]Docker Engine 20.10+ with at least 4GB RAM allocated to containers
- [!]Minimum 8GB system RAM for optimal YugabyteDB performance
- [!]Available ports 5433, 7000, 7100, 9000, 9042, and 9100
- [!]Understanding of PostgreSQL concepts and SQL query optimization
- [!]Basic knowledge of distributed systems and CAP theorem principles
- [!]Familiarity with Docker volumes for persistent data storage management
[!]
WARNING: For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
[$]docker-compose.yml
[docker-compose.yml]
1services: 2 yb-master: 3 image: yugabytedb/yugabyte:latest4 container_name: yb-master5 restart: unless-stopped6 command: bash -c "7 /home/yugabyte/bin/yb-master8 --fs_data_dirs=/mnt/disk09 --master_addresses=yb-master: 710010 --rpc_bind_addresses=yb-master: 710011 "12 ports: 13 - "${MASTER_UI_PORT:-7000}:7000"14 volumes: 15 - yb_master_data:/mnt/disk01617 yb-tserver: 18 image: yugabytedb/yugabyte:latest19 container_name: yb-tserver20 restart: unless-stopped21 command: bash -c "22 /home/yugabyte/bin/yb-tserver23 --fs_data_dirs=/mnt/disk024 --tserver_master_addrs=yb-master: 710025 --rpc_bind_addresses=yb-tserver: 910026 "27 ports: 28 - "${YSQL_PORT:-5433}:5433"29 - "${YCQL_PORT:-9042}:9042"30 - "${TSERVER_UI_PORT:-9000}:9000"31 volumes: 32 - yb_tserver_data:/mnt/disk033 depends_on: 34 - yb-master3536volumes: 37 yb_master_data: 38 yb_tserver_data: [$].env Template
[.env]
1# YugabyteDB2MASTER_UI_PORT=70003YSQL_PORT=54334YCQL_PORT=90425TSERVER_UI_PORT=9000[i]Usage Notes
- [1]Master UI at http://localhost:7000
- [2]PostgreSQL at localhost:5433
- [3]Cassandra at localhost:9042
- [4]Distributed PostgreSQL
Individual Services(2 services)
Copy individual services to mix and match with your existing compose files.
yb-master
yb-master:
image: yugabytedb/yugabyte:latest
container_name: yb-master
restart: unless-stopped
command: bash -c " /home/yugabyte/bin/yb-master --fs_data_dirs=/mnt/disk0 --master_addresses=yb-master:7100 --rpc_bind_addresses=yb-master:7100 "
ports:
- ${MASTER_UI_PORT:-7000}:7000
volumes:
- yb_master_data:/mnt/disk0
yb-tserver
yb-tserver:
image: yugabytedb/yugabyte:latest
container_name: yb-tserver
restart: unless-stopped
command: bash -c " /home/yugabyte/bin/yb-tserver --fs_data_dirs=/mnt/disk0 --tserver_master_addrs=yb-master:7100 --rpc_bind_addresses=yb-tserver:9100 "
ports:
- ${YSQL_PORT:-5433}:5433
- ${YCQL_PORT:-9042}:9042
- ${TSERVER_UI_PORT:-9000}:9000
volumes:
- yb_tserver_data:/mnt/disk0
depends_on:
- yb-master
[>]Quick Start
[terminal]
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 yb-master:5 image: yugabytedb/yugabyte:latest6 container_name: yb-master7 restart: unless-stopped8 command: bash -c "9 /home/yugabyte/bin/yb-master10 --fs_data_dirs=/mnt/disk011 --master_addresses=yb-master:710012 --rpc_bind_addresses=yb-master:710013 "14 ports:15 - "${MASTER_UI_PORT:-7000}:7000"16 volumes:17 - yb_master_data:/mnt/disk01819 yb-tserver:20 image: yugabytedb/yugabyte:latest21 container_name: yb-tserver22 restart: unless-stopped23 command: bash -c "24 /home/yugabyte/bin/yb-tserver25 --fs_data_dirs=/mnt/disk026 --tserver_master_addrs=yb-master:710027 --rpc_bind_addresses=yb-tserver:910028 "29 ports:30 - "${YSQL_PORT:-5433}:5433"31 - "${YCQL_PORT:-9042}:9042"32 - "${TSERVER_UI_PORT:-9000}:9000"33 volumes:34 - yb_tserver_data:/mnt/disk035 depends_on:36 - yb-master3738volumes:39 yb_master_data:40 yb_tserver_data:41EOF4243# 2. Create the .env file44cat > .env << 'EOF'45# YugabyteDB46MASTER_UI_PORT=700047YSQL_PORT=543348YCQL_PORT=904249TSERVER_UI_PORT=900050EOF5152# 3. Start the services53docker compose up -d5455# 4. View logs56docker compose logs -f[>]One-Liner
Run this command to download and set up the recipe in one step:
[terminal]
1curl -fsSL https://docker.recipes/api/recipes/yugabytedb-cluster/run | bash[?]Troubleshooting
- [!]yb-master fails to start with 'address already in use': Check if port 7100 is occupied by another service or previous YugabyteDB instance
- [!]Connection refused on PostgreSQL port 5433: Wait 60-90 seconds after startup for tablet server initialization to complete
- [!]Web UI shows 'Under-replicated tablets': Normal behavior in single-node setup, add more tablet servers for proper replication
- [!]High memory usage warnings in logs: Increase Docker memory limits or reduce yb-tserver cache sizes using --db_block_cache_size_bytes flag
- [!]YSQL queries timeout or fail: Verify tablet server is healthy via port 9000 UI and check for resource constraints
- [!]Data persistence issues after container restart: Ensure Docker volumes are properly mounted and have sufficient disk space
Community Notes
Loading...
Loading notes...
## Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Shortcuts: C CopyF FavoriteD Download