Production-grade ClickHouse Docker infrastructure with hot/warm storage tiering and intelligent resource management.
All settings are centralized in the .env-config
file for easy management:
# Quick configuration
cp .env-config .env-config.backup # Backup current config
nano .env-config # Edit configuration
./manage.sh restart # Apply changes
π Complete Configuration Guide β
- π’ HTTP Interface:
http://localhost:8123
- Working - π’ TCP Interface:
localhost:9000
- Working - π’ Health Status: Healthy container
- π’ Storage Policies: Hot/warm tiering active
- π’ Auto-Configuration: Dynamic memory (6.98 GiB) & threading (16 cores)
- Hot Storage:
~/Downloads/clickhouse-hot
(Fast access) - Warm Storage:
/Volumes/Extreme-Pro/clickhouse-warm
(Archival) - Backup Storage:
/Volumes/Extreme-Pro/clickhouse-backup
(Upgrade backups)
For CPU-optimized local development:
./start-optimized.sh # Start with optimized threading (6-12% CPU usage)
Standard management:
./manage.sh start # Start ClickHouse
./manage.sh stop # Stop ClickHouse
./manage.sh client # Connect to CLI
./manage.sh status # Check status
./manage.sh logs # View logs
This setup includes advanced CPU optimization that reduces resource usage by 87-92% while maintaining full functionality:
- Before Optimization: 82.03% CPU usage, 683 processes/threads
- After Optimization: 5-12% CPU usage (balanced profile)
- Memory Efficiency: Dynamic allocation based on available RAM
- Container Stability: Preserved during profile switches
Switch between performance profiles based on your needs:
./switch-performance-profile.sh [profile-name]
Available Profiles:
ultra-low
- 2-5% CPU usage (minimal resources)balanced
- 6-12% CPU usage (default, development)high-performance
- 15-30% CPU usage (testing/staging)production
- 20-50% CPU usage (server deployment)
Profile Management:
./switch-performance-profile.sh current # Show current profile
./switch-performance-profile.sh balanced # Switch to balanced
./switch-performance-profile.sh production # Switch to production
Monitor performance in real-time:
docker stats # Live container stats
docker exec clickhouse-server-hot-warm top # Process monitoring inside container
π Complete CPU Tuning Guide β
π Optimization Report β
- HTTP API: http://localhost:8123
- TCP Client: localhost:9000
- Interserver: localhost:9009
- Memory Management: Uses 90% of available RAM automatically
- Thread Scaling: Auto-scales from 1-16+ threads based on query complexity
- Cache Auto-Sizing: Mark and uncompressed caches size themselves
- Storage Tiering: Automatic hotβwarm data movement
hot_warm_policy
: Automatic tiering (starts hot, moves to warm at 80% capacity)hot_only_policy
: Keep data on fast storage onlywarm_only_policy
: Archive data directly to warm storage
# Test HTTP interface
curl "http://localhost:8123/?query=SELECT 1"
# Check auto-configured memory
curl "http://localhost:8123/?query=SELECT formatReadableSize(value::UInt64) FROM system.server_settings WHERE name='max_server_memory_usage'"
# View storage policies
curl "http://localhost:8123/?query=SELECT policy_name, volume_name FROM system.storage_policies FORMAT TabSeparated"
# Comprehensive test suite
echo "=== CLICKHOUSE CONNECTION TEST SUMMARY ===" && \
echo "1. Container Status:" && \
docker ps --filter name=clickhouse-server-hot-warm --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" && \
echo -e "\n2. HTTP Interface:" && \
curl -s "http://localhost:8123/?query=SELECT%20'HTTP%20OK'%20as%20status" && \
echo -e "\n3. Performance Test:" && \
curl -s "http://localhost:8123/?query=SELECT%20count()%20FROM%20numbers(100000)" && \
echo -e "\n4. Auto-Config Check:" && \
curl -s "http://localhost:8123/?query=SELECT%20formatReadableSize(value::UInt64)%20as%20auto_memory_limit%20FROM%20system.server_settings%20WHERE%20name='max_server_memory_usage'" && \
echo -e "\n5. Storage Policies:" && \
curl -s "http://localhost:8123/?query=SELECT%20count()%20as%20policy_count%20FROM%20system.storage_policies" && \
echo -e "\n=== ALL TESTS PASSED! ==="
# Check current version
./upgrade-manager.sh version
# Backup before upgrade
./upgrade-manager.sh backup
# Upgrade to new version (example: 25.8)
./upgrade-manager.sh upgrade 25.8
# Verify data integrity
./upgrade-manager.sh verify
# Rollback if needed
./upgrade-manager.sh rollback
./upgrade-manager.sh upgrade <version>
- Safe upgrade with backup./upgrade-manager.sh backup
- Manual backup creation./upgrade-manager.sh rollback
- Revert to previous version./upgrade-manager.sh verify
- Check data integrity./upgrade-manager.sh list-backups
- View available backups
- β Automatic backups before upgrades
- β Hot/warm storage preservation
- β Metadata export (schemas, policies)
- β Integrity verification after upgrades
- β One-click rollback capability
docker-compose.yml
- Container setup with environment variablesDockerfile
- Custom image with configurable build args.env-config
- Central configuration file for all settingsmanage.sh
- Infrastructure management scriptupgrade-manager.sh
- Version upgrade & backup managerconfig/
- ClickHouse configuration filesconfig.xml
- Server settings with auto-configurationusers.xml
- User authentication & profilesstorage.xml
- Hot/warm storage policies (partially configurable)
CONFIGURATION_GUIDE.md
- Complete configuration management guideBACKUP_RESTORE_GUIDE.md
- Backup and restore proceduresPRODUCTION_TEST_REPORT.md
- Infrastructure testing resultsENV_CONFIG_TEST_REPORT.md
- Environment configuration system test results
β Centralized Environment Configuration System Successfully Implemented
All infrastructure settings are now managed through a single .env-config
file with 75+ configurable parameters. The system has been comprehensively tested and validated for production use.