Skip to content

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.

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 versions

Naming 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

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: stable
roles:
- component: tsdb
version: auto # OK for dev, resolve before prod

Save resolved versions:

Terminal window
apex validate -f deployment.yaml --manifests ~/.apex/manifests/ \
> deployment-resolved-$(date +%Y%m%d).yaml

Before every deployment, especially production:

  • Target nodes accessible (SSH or local)
  • Required ports available (check with ss, lsof, or netstat)
  • 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
  • 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
  • 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.)
  • Existing data backed up
  • Configuration files backed up
  • Docker volumes backed up (if applicable)
  • Rollback plan documented

Always run stages in order, with validation between:

Terminal window
# 1. Check connectivity and basic YAML
apex check -f deployment.yaml
# 2. Validate manifests, versions, dependencies
apex 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 deployment
apex apply -f deployment.yaml --yes

Or use the combined command:

Terminal window
apex deploy -f deployment.yaml --yes

For initial production deployments, add extra verification:

Terminal window
# 1. Test in staging first with identical versions
apex deploy -f staging.yaml --yes
# Verify staging thoroughly before production
# 2. Prepare production without deploying
apex check -f production.yaml
apex validate -f production.yaml --manifests ~/.apex/manifests/
apex prepare -f production.yaml --manifests ~/.apex/manifests/
# 3. Schedule maintenance window
# 4. Review plan one final time
apex apply -f production.yaml --dry-run
# 5. Deploy during maintenance window
apex apply -f production.yaml --yes
# 6. Verify deployment
apex-component-status.sh # Linux
apex-component-status.ps1 # Windows
# 7. Run health checks (component-specific)
  • Use the official installer: TDengineSetup-x64.exe for 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:

Terminal window
# Check disk space
Get-PSDrive C | Select-Object Used,Free
# Check port availability
Test-NetConnection -ComputerName localhost -Port 6030
Test-NetConnection -ComputerName localhost -Port 6041
# Check administrator access
([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
  • 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:

Terminal window
# Backup before upgrade
$backupPath = "C:\Backups\TDengine-$(Get-Date -Format 'yyyyMMdd')"
Copy-Item "C:\ProgramData\TDengine" -Destination $backupPath -Recurse
Terminal window
# Check status
apex-component-status.ps1
# Start/stop components
apex-component-start.ps1 tsdb,idmp
apex-component-stop.ps1 tdgpt
# Uninstall (preserves data)
apex-component-uninstall.ps1 tsdb
# Purge (removes data)
apex-component-purge.ps1 tsdb
Terminal window
# Verify Docker is running
docker version
docker compose version
# Check resources
docker info | grep -E 'CPUs|Total Memory'
# Verify ports available
ss -tuln | grep -E '6030|6041|8030'

Use Apex-provided scripts (not docker compose directly):

Terminal window
# 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 status

These scripts handle environment setup and volume configuration correctly.

After Docker asset updates:

Terminal window
# 1. Stop services
./tdengine.sh stop
# 2. Compare configurations
diff .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 start

Protect volumes: Never delete volumes during updates:

Terminal window
# Good: restart with existing volumes
docker compose down
docker compose up -d
# BAD: destroys data
docker compose down -v # -v removes volumes!

Backup volumes:

Terminal window
# List volumes
docker volume ls | grep tdengine
# Backup a volume
docker run --rm \
-v tdengine_tsdb_data:/data \
-v $(pwd)/backup:/backup \
alpine tar czf /backup/tsdb-data-$(date +%Y%m%d).tar.gz /data

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-x64

Don’t use loopback SSH when local transport is appropriate.

When to use: Remote nodes or multi-node deployments

SSH key setup:

Terminal window
# Generate deployment key
ssh-keygen -t ed25519 -f ~/.ssh/apex-deploy -C "apex-deployment"
chmod 600 ~/.ssh/apex-deploy
# Deploy to target
ssh-copy-id -i ~/.ssh/apex-deploy.pub root@target-host
# Test connection
ssh -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 port
Terminal window
# 1. Backup everything
# - Configuration files
# - Data directories
# - Docker volumes
# - Current deployment YAML
# 2. Test in staging
apex deploy -f staging-new-version.yaml --yes
# Verify thoroughly
# 3. Document current state
apex version
apex-component-status.sh > pre-upgrade-status.txt
Terminal window
# 1. Update versions in deployment YAML
# 2. Schedule maintenance window
# 3. Stop workload (application-specific)
# 4. Deploy new versions
apex deploy -f deployment-new-version.yaml --yes
# 5. Verify components
apex-component-status.sh
# 6. Run health checks
# 7. Resume workload

Always have a rollback plan:

Terminal window
# Save pre-upgrade deployment
cp deployment.yaml deployment-backup-$(date +%Y%m%d).yaml
# If upgrade fails, rollback
apex deploy -f deployment-backup-20250115.yaml --yes

Daily:

Terminal window
# Check component status
apex-component-status.sh
# Check disk space
df -h
# Check logs for errors
grep -i error ~/.apex/logs/deploy-*/apex.log

Weekly:

  • 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

Retention strategy:

Terminal window
# Archive old logs
tar 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:

Terminal window
# Redact sensitive information
sed -i 's/password=.*/password=REDACTED/g' apex.log
sed -i 's|/home/[^/]\+|/home/USER|g' apex.log
sed -i 's/10\.[0-9]\+\.[0-9]\+\.[0-9]\+/X.X.X.X/g' apex.log

On a connected machine:

Terminal window
# 1. Download Apex release
curl -O https://downloads.tdengine.com/apex/v0.4.0/apex-linux-x64-v0.4.0.tar.gz
# 2. Extract and prepare
tar xzf apex-linux-x64-v0.4.0.tar.gz
cd apex-linux-x64-v0.4.0
./install.sh
# 3. Prepare artifacts for offline deployment
apex prepare -f deployment.yaml --manifests ~/.apex/manifests/
# 4. Bundle everything
mkdir offline-bundle
cp -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 checksums
cd offline-bundle
sha256sum * > checksums.txt
# 6. Transfer to air-gapped environment

On the air-gapped machine:

Terminal window
# 1. Verify checksums
sha256sum -c checksums.txt
# 2. Install Apex
tar xzf apex-linux-x64-v0.4.0.tar.gz
cd apex-linux-x64-v0.4.0
./install.sh -OfflineBundle .
# 3. Import artifacts
apex prepare -f deployment.yaml \
--manifests ./manifests/ \
--import-dir ./cache
# 4. Deploy
apex apply -f deployment.yaml --yes

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:

Terminal window
# Test restore in non-production environment
# Verify backup integrity regularly
tar tzf backup.tar.gz > /dev/null && echo "Backup valid"

Component failure:

Terminal window
# 1. Check status
apex-component-status.sh
# 2. Check logs
tail -100 /var/log/taos/taoslog.txt
# 3. Restart component
apex-component-restart.sh tsdb
# 4. If restart fails, reinstall
apex deploy -f deployment.yaml --yes

Complete node failure:

Terminal window
# 1. Provision replacement node
# 2. Deploy from backup configuration
apex deploy -f deployment-backup.yaml --yes
# 3. Restore data
# (Component-specific restore procedures)
# 4. Verify
apex-component-status.sh
  • 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

Follow component-specific tuning guides:

  • TSDB: Configure cache, WAL, and compression
  • IDMP: Adjust worker threads and memory limits
  • TDgpt: GPU allocation if available

Don’t:

  • ❌ Use version: auto in production without resolving
  • ❌ Skip --dry-run before 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 compose directly (use Apex scripts)
  • ❌ Skip backups before upgrades

Do:

  • ✅ Pin versions in production
  • ✅ Use SSH key authentication
  • ✅ Run check and validate before apply
  • ✅ 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