Database Guide

    Self-Hosted InfluxDB Time-Series Database

    Deploy InfluxDB, the leading open-source time-series database, on RamNode VPS. Perfect for metrics, IoT, and real-time analytics.

    Ubuntu 20.04+
    InfluxDB 2.7
    ⏱️ 15-20 minutes

    Why InfluxDB?

    InfluxDB is purpose-built for time-series data, offering high-performance writes, efficient storage with compression, and powerful query capabilities through Flux. Ideal for DevOps monitoring, IoT, and real-time analytics.

    High-performance time-series storage
    Flux query language for analytics
    Built-in retention policies
    Native Telegraf integration

    Prerequisites

    Minimum Requirements

    • • 2 CPU cores
    • • 2 GB RAM
    • • 20 GB SSD storage
    • • Ubuntu 20.04+ / Debian 11+

    Recommended for Production

    • • 4+ CPU cores
    • • 8+ GB RAM
    • • 100+ GB NVMe SSD
    • • Dedicated data disk

    Installation

    1

    Add InfluxDB Repository

    Add the official InfluxData repository:

    Add Repository
    # Install prerequisites
    sudo apt update
    sudo apt install -y curl gnupg2
    
    # Add InfluxData GPG key
    curl -s https://repos.influxdata.com/influxdata-archive.key | \
      gpg --dearmor | sudo tee /usr/share/keyrings/influxdb-archive-keyring.gpg > /dev/null
    
    # Add repository (Ubuntu/Debian)
    echo "deb [signed-by=/usr/share/keyrings/influxdb-archive-keyring.gpg] \
      https://repos.influxdata.com/debian stable main" | \
      sudo tee /etc/apt/sources.list.d/influxdb.list
    2

    Install InfluxDB 2.x

    Install the latest InfluxDB 2.x version:

    Install InfluxDB
    # Update package list
    sudo apt update
    
    # Install InfluxDB
    sudo apt install -y influxdb2
    
    # Start and enable service
    sudo systemctl start influxdb
    sudo systemctl enable influxdb
    
    # Verify installation
    influx version
    Expected Output
    InfluxDB v2.7.x
    3

    Initial Setup

    Configure InfluxDB with initial user, organization, and bucket:

    Setup InfluxDB
    # Run initial setup (interactive)
    influx setup
    
    # Or use non-interactive setup
    influx setup \
      --username admin \
      --password YourSecurePassword123! \
      --org my-organization \
      --bucket my-bucket \
      --retention 30d \
      --force

    Important: Save the generated API token - you will need it for authentication.

    Docker Installation

    1

    Deploy with Docker

    Run InfluxDB in a Docker container:

    Docker Run
    # Create data directory
    mkdir -p ~/influxdb2/{data,config}
    
    # Run InfluxDB container
    docker run -d \
      --name influxdb \
      -p 8086:8086 \
      -v ~/influxdb2/data:/var/lib/influxdb2 \
      -v ~/influxdb2/config:/etc/influxdb2 \
      -e DOCKER_INFLUXDB_INIT_MODE=setup \
      -e DOCKER_INFLUXDB_INIT_USERNAME=admin \
      -e DOCKER_INFLUXDB_INIT_PASSWORD=YourSecurePassword123! \
      -e DOCKER_INFLUXDB_INIT_ORG=my-organization \
      -e DOCKER_INFLUXDB_INIT_BUCKET=my-bucket \
      -e DOCKER_INFLUXDB_INIT_RETENTION=30d \
      -e DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-token \
      influxdb:2.7

    Configuration

    1

    Main Configuration

    Edit the main configuration file:

    /etc/influxdb/config.toml
    # InfluxDB 2.x Configuration
    
    # Bolt path for metadata storage
    bolt-path = "/var/lib/influxdb/influxd.bolt"
    
    # Engine path for time-series data
    engine-path = "/var/lib/influxdb/engine"
    
    # HTTP configuration
    [http]
      bind-address = ":8086"
      flux-enabled = true
      
    # Logging configuration
    [logging]
      level = "info"
      format = "auto"
    
    # Storage configuration
    [storage-cache]
      max-memory-size = "1g"
      snapshot-memory-size = "25m"
      
    # Query configuration
    [query]
      concurrency = 10
      queue-size = 10
    2

    Performance Tuning

    Optimize for production workloads:

    Performance Settings
    # Increase memory limits for high-throughput
    [storage-cache]
      max-memory-size = "4g"
      snapshot-memory-size = "100m"
    
    # WAL configuration
    [storage-wal]
      max-concurrent-writes = 256
      max-write-delay = "10m"
    
    # Query limits
    [query]
      concurrency = 20
      queue-size = 20
    3

    Retention Policies

    Configure data retention for buckets:

    Bucket Management
    # Create bucket with retention
    influx bucket create \
      --name metrics \
      --org my-organization \
      --retention 7d
    
    # Create bucket for long-term storage
    influx bucket create \
      --name metrics-archive \
      --org my-organization \
      --retention 365d
    
    # List buckets
    influx bucket list
    
    # Update retention policy
    influx bucket update \
      --id <bucket-id> \
      --retention 90d

    Security Hardening

    1

    API Token Management

    Create tokens with appropriate permissions:

    Token Management
    # Create read-only token
    influx auth create \
      --org my-organization \
      --read-bucket my-bucket \
      --description "Read-only access"
    
    # Create write-only token
    influx auth create \
      --org my-organization \
      --write-bucket my-bucket \
      --description "Write-only access"
    
    # List tokens
    influx auth list
    
    # Delete token
    influx auth delete --id <token-id>
    2

    Enable TLS/SSL

    Configure HTTPS for secure communication:

    Generate Certificate
    # Generate self-signed certificate
    sudo mkdir -p /etc/influxdb/ssl
    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
      -keyout /etc/influxdb/ssl/influxdb.key \
      -out /etc/influxdb/ssl/influxdb.crt \
      -subj "/CN=influxdb.example.com"
    
    # Set permissions
    sudo chown influxdb:influxdb /etc/influxdb/ssl/*
    sudo chmod 600 /etc/influxdb/ssl/*
    TLS Configuration
    [http]
      bind-address = ":8086"
      tls-cert = "/etc/influxdb/ssl/influxdb.crt"
      tls-key = "/etc/influxdb/ssl/influxdb.key"
      tls-min-version = "1.2"
    3

    Firewall Configuration

    Restrict network access:

    UFW Rules
    # Allow InfluxDB port from specific IPs only
    sudo ufw allow from 10.0.0.0/8 to any port 8086
    
    # Or from specific hosts
    sudo ufw allow from 192.168.1.100 to any port 8086
    
    # Deny public access
    sudo ufw deny 8086
    
    # Enable firewall
    sudo ufw enable

    Basic Operations

    1

    Writing Data

    Write time-series data using various methods:

    Write Data
    # Write using CLI (Line Protocol)
    influx write \
      --bucket my-bucket \
      --org my-organization \
      'cpu,host=server1,region=us-west usage=45.2 1625000000000000000'
    
    # Write from file
    influx write \
      --bucket my-bucket \
      --org my-organization \
      --file data.lp
    
    # Write using API
    curl -XPOST "http://localhost:8086/api/v2/write?org=my-organization&bucket=my-bucket" \
      --header "Authorization: Token $INFLUX_TOKEN" \
      --header "Content-Type: text/plain" \
      --data-binary 'cpu,host=server1 usage=45.2'
    2

    Querying Data (Flux)

    Query data using Flux query language:

    Flux Queries
    # Basic query
    influx query 'from(bucket: "my-bucket")
      |> range(start: -1h)
      |> filter(fn: (r) => r._measurement == "cpu")'
    
    # Query with aggregation
    influx query 'from(bucket: "my-bucket")
      |> range(start: -24h)
      |> filter(fn: (r) => r._measurement == "cpu")
      |> aggregateWindow(every: 1h, fn: mean)
      |> yield(name: "hourly_avg")'
    3

    Managing Resources

    Manage buckets and organizations:

    Resource Management
    # List organizations
    influx org list
    
    # Create organization
    influx org create --name production
    
    # List buckets
    influx bucket list
    
    # Delete bucket
    influx bucket delete --id <bucket-id>
    
    # Create user
    influx user create --name grafana --org my-organization
    
    # Set user password
    influx user password --name grafana

    Backup & Recovery

    1

    Full Backup

    Create a complete backup:

    Backup Commands
    # Create backup directory
    mkdir -p /backup/influxdb
    
    # Full backup
    influx backup /backup/influxdb/$(date +%Y%m%d) \
      --host http://localhost:8086 \
      --token $INFLUX_TOKEN
    
    # Backup specific bucket
    influx backup /backup/influxdb/metrics-$(date +%Y%m%d) \
      --bucket metrics \
      --host http://localhost:8086 \
      --token $INFLUX_TOKEN
    2

    Restore from Backup

    Restore data from backup:

    Restore Commands
    # Full restore (new instance)
    influx restore /backup/influxdb/20240101 \
      --host http://localhost:8086 \
      --token $INFLUX_TOKEN \
      --full
    
    # Restore specific bucket
    influx restore /backup/influxdb/20240101 \
      --bucket metrics \
      --new-bucket metrics-restored \
      --host http://localhost:8086 \
      --token $INFLUX_TOKEN

    Monitoring

    1

    Health Checks

    Monitor InfluxDB health:

    Health Endpoints
    # Check health endpoint
    curl http://localhost:8086/health
    
    # Check readiness
    curl http://localhost:8086/ready
    
    # Get server status
    influx ping
    Health Response
    {
      "name": "influxdb",
      "message": "ready for queries and writes",
      "status": "pass",
      "version": "2.7.1"
    }
    2

    Telegraf Integration

    Use Telegraf to collect system metrics:

    Telegraf Configuration
    # Output to InfluxDB 2.x
    [[outputs.influxdb_v2]]
      urls = ["http://localhost:8086"]
      token = "$INFLUX_TOKEN"
      organization = "my-organization"
      bucket = "telegraf"
    
    # Collect CPU metrics
    [[inputs.cpu]]
      percpu = true
      totalcpu = true
    
    # Collect memory metrics
    [[inputs.mem]]
    
    # Collect disk metrics
    [[inputs.disk]]
      ignore_fs = ["tmpfs", "devtmpfs"]

    Troubleshooting

    High Memory Usage

    Memory Troubleshooting
    # Check current memory usage
    influx query 'from(bucket: "_monitoring")
      |> range(start: -1h)
      |> filter(fn: (r) => r._measurement == "go_memstats")'
    
    # Reduce cache size in config and restart
    sudo systemctl restart influxdb

    Write Failures

    Debug Writes
    # Check logs for errors
    sudo journalctl -u influxdb -f
    
    # Verify token permissions
    influx auth list
    
    # Check disk space
    df -h /var/lib/influxdb
    
    # Test write
    influx write --bucket my-bucket 'test value=1'

    Service Issues

    Service Troubleshooting
    # Check service status
    sudo systemctl status influxdb
    
    # View detailed logs
    sudo journalctl -u influxdb --no-pager -n 100
    
    # Check config syntax
    influxd print-config
    
    # Check file permissions
    ls -la /var/lib/influxdb/
    sudo chown -R influxdb:influxdb /var/lib/influxdb/

    Quick Reference

    Default Ports

    • • HTTP API: 8086

    Important Paths

    • • Config: /etc/influxdb/config.toml
    • • Data: /var/lib/influxdb/
    • • Logs: journalctl -u influxdb

    Common Commands

    • • influx bucket list
    • • influx write
    • • influx query
    • • influx backup/restore

    Key Concepts

    • • Organization → Workspace
    • • Bucket → Database with retention
    • • Measurement → Table
    • • Tags → Indexed metadata