Best practices
This guide covers operational best practices for planning, deploying, monitoring, and maintaining TDengine All-in-One with Apex. Follow these recommendations to ensure reliable, secure, and maintainable deployments.
Planning and Design
Section titled “Planning and Design”Environment Strategy
Section titled “Environment Strategy”Separate environments: Maintain distinct development, staging, and production environments with different configurations:
~/.apex/deployments/├── dev-deployment.yaml # Development with auto versions├── staging-deployment.yaml # Staging with pinned versions└── prod-deployment.yaml # Production with pinned versionsNaming conventions: Use consistent, descriptive names:
- Nodes:
{env}-{function}-{number}(e.g.,prod-tsdb-01) - Deployments:
{env}-{purpose}(e.g.,prod-cluster) - SSH keys:
~/.ssh/apex-{env}(e.g.,~/.ssh/apex-prod)
Resource planning: Before deployment, verify:
- CPU: Check AVX2 requirement for x64 All-in-One
- Memory: Minimum per component requirements
- Disk: 20+ GB free space, plus data storage
- Network: Required ports available and reachable
- Dependencies: glibc 2.28+, curl, tar, SSH utilities
Version Management
Section titled “Version Management”Production: pin all versions:
roles: - component: tsdb version: "3.3.5.0" # Explicit version, not auto - component: idmp version: "1.2.3.0"Development: allow auto with resolution:
spec: release: profile: all-in-one channel: stableroles: - component: tsdb version: auto # OK for dev, resolve before prodSave resolved versions:
apex validate -f deployment.yaml --manifests ~/.apex/manifests/ \ > deployment-resolved-$(date +%Y%m%d).yamlPre-Deployment Checklist
Section titled “Pre-Deployment Checklist”Before every deployment, especially production:
Infrastructure
Section titled “Infrastructure”- Target nodes accessible (SSH or local)
- Required ports available (check with
ss,lsof, ornetstat) - Sufficient disk space (20+ GB free minimum)
- Adequate memory and CPU
- Network connectivity to download sources (or offline bundle ready)
- Firewall rules configured for component ports
Security
Section titled “Security”- SSH key authentication configured (prefer over passwords)
- File permissions correct (600 for keys, configs)
- No secrets in version control
- Deployment credentials secured (vault or environment variables)
- Non-standard SSH ports for production
- Bastion/jump host configured if required
Configuration
Section titled “Configuration”- Deployment YAML syntax valid
- Component versions appropriate (pinned for prod)
- Platform settings match target architecture
- Transport mode correct (local vs SSH)
- Custom paths configured if needed
- Profile matches intended deployment (all-in-one, TSDB-Enterprise, etc.)
Backups
Section titled “Backups”- Existing data backed up
- Configuration files backed up
- Docker volumes backed up (if applicable)
- Rollback plan documented
Deployment Workflow
Section titled “Deployment Workflow”Standard Deployment
Section titled “Standard Deployment”Always run stages in order, with validation between:
# 1. Check connectivity and basic YAMLapex check -f deployment.yaml
# 2. Validate manifests, versions, dependenciesapex validate -f deployment.yaml --manifests ~/.apex/manifests/
# 3. Review deployment plan (no changes made)apex apply -f deployment.yaml --dry-run
# 4. Prepare artifacts (download and verify)apex prepare -f deployment.yaml --manifests ~/.apex/manifests/
# 5. Execute deploymentapex apply -f deployment.yaml --yesOr use the combined command:
apex deploy -f deployment.yaml --yesFirst-Time Production Deployment
Section titled “First-Time Production Deployment”For initial production deployments, add extra verification:
# 1. Test in staging first with identical versionsapex deploy -f staging.yaml --yes
# Verify staging thoroughly before production
# 2. Prepare production without deployingapex check -f production.yamlapex validate -f production.yaml --manifests ~/.apex/manifests/apex prepare -f production.yaml --manifests ~/.apex/manifests/
# 3. Schedule maintenance window
# 4. Review plan one final timeapex apply -f production.yaml --dry-run
# 5. Deploy during maintenance windowapex apply -f production.yaml --yes
# 6. Verify deploymentapex-component-status.sh # Linuxapex-component-status.ps1 # Windows
# 7. Run health checks (component-specific)Windows Host Best Practices
Section titled “Windows Host Best Practices”Installation
Section titled “Installation”- Use the official installer:
TDengineSetup-x64.exefor Host deployments - Run as Administrator: Required for service installation
- Check prerequisites:
- Administrator access
- 20+ GB free disk space
- Required ports available
- Windows Defender/antivirus policy
- Computer name and user name validated
Pre-installation checks:
# Check disk spaceGet-PSDrive C | Select-Object Used,Free
# Check port availabilityTest-NetConnection -ComputerName localhost -Port 6030Test-NetConnection -ComputerName localhost -Port 6041
# Check administrator access([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)Data Management
Section titled “Data Management”- Program Files: Binaries in
C:\Program Files\TDengine\ - ProgramData: Runtime data in
C:\ProgramData\TDengine\ - Separation: Uninstalling the program does NOT delete ProgramData
- Before uninstall: Decide if data should be preserved or purged
Backup ProgramData:
# Backup before upgrade$backupPath = "C:\Backups\TDengine-$(Get-Date -Format 'yyyyMMdd')"Copy-Item "C:\ProgramData\TDengine" -Destination $backupPath -RecurseComponent Management
Section titled “Component Management”# Check statusapex-component-status.ps1
# Start/stop componentsapex-component-start.ps1 tsdb,idmpapex-component-stop.ps1 tdgpt
# Uninstall (preserves data)apex-component-uninstall.ps1 tsdb
# Purge (removes data)apex-component-purge.ps1 tsdbDocker Best Practices
Section titled “Docker Best Practices”Pre-Deployment
Section titled “Pre-Deployment”# Verify Docker is runningdocker versiondocker compose version
# Check resourcesdocker info | grep -E 'CPUs|Total Memory'
# Verify ports availabless -tuln | grep -E '6030|6041|8030'Service Management
Section titled “Service Management”Use Apex-provided scripts (not docker compose directly):
# Linux./tdengine.sh start./tdengine.sh stop./tdengine.sh restart./tdengine.sh status
# Windows.\tdengine.ps1 start.\tdengine.ps1 stop.\tdengine.ps1 restart.\tdengine.ps1 statusThese scripts handle environment setup and volume configuration correctly.
Configuration Updates
Section titled “Configuration Updates”After Docker asset updates:
# 1. Stop services./tdengine.sh stop
# 2. Compare configurationsdiff .env .env.example
# 3. Merge new settings into .env# Edit .env to incorporate changes from .env.example
# 4. Preserve persistent volumes (do NOT remove)
# 5. Restart services./tdengine.sh startPersistent Data
Section titled “Persistent Data”Protect volumes: Never delete volumes during updates:
# Good: restart with existing volumesdocker compose downdocker compose up -d
# BAD: destroys datadocker compose down -v # -v removes volumes!Backup volumes:
# List volumesdocker volume ls | grep tdengine
# Backup a volumedocker run --rm \ -v tdengine_tsdb_data:/data \ -v $(pwd)/backup:/backup \ alpine tar czf /backup/tsdb-data-$(date +%Y%m%d).tar.gz /dataTransport Best Practices
Section titled “Transport Best Practices”Local Transport
Section titled “Local Transport”When to use: Single-node deployments on the Apex host itself
Benefits:
- No SSH setup required
- Simpler configuration
- Direct filesystem access
Configuration:
nodes: - name: localhost transport: local host: localhost platform: linux-x64Don’t use loopback SSH when local transport is appropriate.
SSH Transport
Section titled “SSH Transport”When to use: Remote nodes or multi-node deployments
SSH key setup:
# Generate deployment keyssh-keygen -t ed25519 -f ~/.ssh/apex-deploy -C "apex-deployment"chmod 600 ~/.ssh/apex-deploy
# Deploy to targetssh-copy-id -i ~/.ssh/apex-deploy.pub root@target-host
# Test connectionssh -i ~/.ssh/apex-deploy root@target-host echo "Connected"Production SSH hardening:
spec: ssh: user: deploy-user # Non-root user keyPath: ~/.ssh/apex-prod port: 2222 # Non-standard portUpgrade Best Practices
Section titled “Upgrade Best Practices”Pre-Upgrade
Section titled “Pre-Upgrade”# 1. Backup everything# - Configuration files# - Data directories# - Docker volumes# - Current deployment YAML
# 2. Test in stagingapex deploy -f staging-new-version.yaml --yes# Verify thoroughly
# 3. Document current stateapex versionapex-component-status.sh > pre-upgrade-status.txtUpgrade Execution
Section titled “Upgrade Execution”# 1. Update versions in deployment YAML# 2. Schedule maintenance window# 3. Stop workload (application-specific)
# 4. Deploy new versionsapex deploy -f deployment-new-version.yaml --yes
# 5. Verify componentsapex-component-status.sh
# 6. Run health checks
# 7. Resume workloadRollback Plan
Section titled “Rollback Plan”Always have a rollback plan:
# Save pre-upgrade deploymentcp deployment.yaml deployment-backup-$(date +%Y%m%d).yaml
# If upgrade fails, rollbackapex deploy -f deployment-backup-20250115.yaml --yesMonitoring and Maintenance
Section titled “Monitoring and Maintenance”Regular Health Checks
Section titled “Regular Health Checks”Daily:
# Check component statusapex-component-status.sh
# Check disk spacedf -h
# Check logs for errorsgrep -i error ~/.apex/logs/deploy-*/apex.logWeekly:
- Review deployment reports
- Check for component updates
- Verify backups are current
- Review security logs
Monthly:
- Test rollback procedures
- Review and rotate logs
- Update documentation
- Security audit
Log Management
Section titled “Log Management”Retention strategy:
# Archive old logstar czf apex-logs-$(date +%Y%m).tar.gz ~/.apex/logs/deploy-*mv apex-logs-*.tar.gz /archive/
# Remove archived logs (keep reports)find ~/.apex/logs -type d -mtime +30 -exec rm -rf {} +Before sharing logs:
# Redact sensitive informationsed -i 's/password=.*/password=REDACTED/g' apex.logsed -i 's|/home/[^/]\+|/home/USER|g' apex.logsed -i 's/10\.[0-9]\+\.[0-9]\+\.[0-9]\+/X.X.X.X/g' apex.logOffline and Air-Gapped Deployments
Section titled “Offline and Air-Gapped Deployments”Bundle Preparation
Section titled “Bundle Preparation”On a connected machine:
# 1. Download Apex releasecurl -O https://downloads.tdengine.com/apex/v0.4.0/apex-linux-x64-v0.4.0.tar.gz
# 2. Extract and preparetar xzf apex-linux-x64-v0.4.0.tar.gzcd apex-linux-x64-v0.4.0./install.sh
# 3. Prepare artifacts for offline deploymentapex prepare -f deployment.yaml --manifests ~/.apex/manifests/
# 4. Bundle everythingmkdir offline-bundlecp -r ~/.apex/cache offline-bundle/cp -r ~/.apex/manifests offline-bundle/cp deployment.yaml offline-bundle/cp apex-linux-x64-v0.4.0.tar.gz offline-bundle/
# 5. Create checksumscd offline-bundlesha256sum * > checksums.txt
# 6. Transfer to air-gapped environmentOffline Deployment
Section titled “Offline Deployment”On the air-gapped machine:
# 1. Verify checksumssha256sum -c checksums.txt
# 2. Install Apextar xzf apex-linux-x64-v0.4.0.tar.gzcd apex-linux-x64-v0.4.0./install.sh -OfflineBundle .
# 3. Import artifactsapex prepare -f deployment.yaml \ --manifests ./manifests/ \ --import-dir ./cache
# 4. Deployapex apply -f deployment.yaml --yesDisaster Recovery
Section titled “Disaster Recovery”Backup Strategy
Section titled “Backup Strategy”What to backup:
- Apex configuration (
~/.apex/config.yaml) - Deployment YAMLs
- Component data directories
- Docker volumes
- Operation reports (for audit)
Backup frequency:
- Before every upgrade
- Daily for production data
- After significant configuration changes
Backup verification:
# Test restore in non-production environment# Verify backup integrity regularlytar tzf backup.tar.gz > /dev/null && echo "Backup valid"Recovery Procedures
Section titled “Recovery Procedures”Component failure:
# 1. Check statusapex-component-status.sh
# 2. Check logstail -100 /var/log/taos/taoslog.txt
# 3. Restart componentapex-component-restart.sh tsdb
# 4. If restart fails, reinstallapex deploy -f deployment.yaml --yesComplete node failure:
# 1. Provision replacement node# 2. Deploy from backup configurationapex deploy -f deployment-backup.yaml --yes
# 3. Restore data# (Component-specific restore procedures)
# 4. Verifyapex-component-status.shPerformance Tuning
Section titled “Performance Tuning”Resource Allocation
Section titled “Resource Allocation”- CPU: Ensure AVX2 for x64 All-in-One
- Memory: Allocate per component requirements
- Disk: Use SSD for database storage
- Network: Low-latency links for multi-node clusters
Component Optimization
Section titled “Component Optimization”Follow component-specific tuning guides:
- TSDB: Configure cache, WAL, and compression
- IDMP: Adjust worker threads and memory limits
- TDgpt: GPU allocation if available
Common Pitfalls to Avoid
Section titled “Common Pitfalls to Avoid”Don’t:
- ❌ Use
version: autoin production without resolving - ❌ Skip
--dry-runbefore production deployments - ❌ Use password authentication in production (use SSH keys)
- ❌ Commit secrets to version control
- ❌ Deploy to production without testing in staging
- ❌ Modify component files directly (use Apex)
- ❌ Delete ProgramData/volumes without backups
- ❌ Run deployment as root on the control host (unnecessary)
- ❌ Use
docker composedirectly (use Apex scripts) - ❌ Skip backups before upgrades
Do:
- ✅ Pin versions in production
- ✅ Use SSH key authentication
- ✅ Run
checkandvalidatebeforeapply - ✅ Maintain separate dev/staging/prod environments
- ✅ Back up before every upgrade
- ✅ Document deployment procedures
- ✅ Monitor component health
- ✅ Keep logs for audit and troubleshooting
- ✅ Test rollback procedures
- ✅ Follow security best practices
Related Topics
Section titled “Related Topics”- Security guide - Authentication, secrets, and hardening
- Examples and use cases - Real-world deployment patterns
- Troubleshooting - Common issues and solutions
- Architecture - Design decisions and trade-offs