Search Platform Guide

    Apache Solr on RamNode

    Deploy a powerful, open-source enterprise search platform on your RamNode VPS. Build scalable full-text search solutions with real-time indexing, advanced querying, and high availability.

    Ubuntu 22.04/24.04
    Solr 9.x
    ⏱️ 30-45 minutes
    1

    Introduction to Apache Solr

    Apache Solr is a powerful, open-source search platform built on Apache Lucene. It provides distributed indexing, replication, load-balanced querying, automated failover and recovery, and centralized configuration. Solr is highly reliable, scalable, and fault-tolerant, making it ideal for enterprise search applications.

    Key Features

    • • Full-text search with advanced query capabilities including faceted search, highlighting, and spell checking
    • • Real-time indexing for immediate searchability of new content
    • • Highly scalable distributed architecture with SolrCloud mode
    • • Rich document handling supporting JSON, XML, CSV, and binary formats
    • • Comprehensive REST-like API for easy integration
    • • Built-in admin interface for monitoring and management

    Common Use Cases

    E-commerce Search

    Product search and filtering

    CMS & Document Management

    Content and document search

    Log Analysis

    Log monitoring and analytics

    Knowledge Base

    Enterprise wiki search

    Prerequisites and VPS Requirements

    Before installing Solr, ensure your RamNode VPS meets the following requirements:

    ResourceRecommendation
    CPU2+ vCPU cores (4+ for production)
    RAM4GB minimum (8GB+ for larger indexes)
    StorageSSD, 20GB+ depending on data volume
    OSUbuntu 22.04 LTS or Ubuntu 24.04 LTS

    Recommended VPS

    Premium KVM VPS with 4GB RAM and SSD storage for development and small-to-medium workloads.

    Software Prerequisites

    • • Java 11+ (Java 17 LTS recommended)
    • • Root or sudo access
    • • Basic Linux command line
    • • Firewall access for ports
    3

    Installing Java (OpenJDK)

    Solr requires Java to run. We'll install OpenJDK 17, the current long-term support release.

    Update System Packages
    sudo apt update && sudo apt upgrade -y
    Install OpenJDK 17
    sudo apt install openjdk-17-jdk -y
    Verify Installation
    java -version
    Expected Output
    openjdk version "17.0.x" 2024-xx-xx
    OpenJDK Runtime Environment (build 17.0.x+x-Ubuntu-xxxxx)
    OpenJDK 64-Bit Server VM (build 17.0.x+x-Ubuntu-xxxxx, mixed mode)
    Set JAVA_HOME Environment Variable
    echo 'export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64' | sudo tee -a /etc/profile.d/java.sh
    echo 'export PATH=$PATH:$JAVA_HOME/bin' | sudo tee -a /etc/profile.d/java.sh
    source /etc/profile.d/java.sh
    4

    Installing Apache Solr

    We'll download and install Solr 9.x, the latest stable major version, using the official installation script.

    Download Solr
    cd /opt
    sudo wget https://dlcdn.apache.org/solr/solr/9.7.0/solr-9.7.0.tgz

    💡 Version Note: Check solr.apache.org/downloads for the latest version. Replace 9.7.0 with the current stable release if newer.

    Extract and Run Installation Script
    sudo tar xzf solr-9.7.0.tgz solr-9.7.0/bin/install_solr_service.sh --strip-components=2
    sudo bash ./install_solr_service.sh solr-9.7.0.tgz

    This script will create a dedicated 'solr' user, extract Solr to /opt/solr, configure data directory at /var/solr, and set up Solr as a systemd service.

    Verify Solr Service
    sudo systemctl status solr
    Start and Enable Solr (if not running)
    sudo systemctl start solr
    sudo systemctl enable solr

    ✅ Access the Solr Admin UI at http://YOUR_SERVER_IP:8983/solr

    5

    Configuring Solr

    Solr's main configuration is managed through several files. Understanding these will help you customize your deployment.

    FilePurpose
    solr.in.shEnvironment variables, JVM settings, memory
    solr.xmlGlobal settings, core discovery configuration
    solrconfig.xmlPer-core: request handlers, caching, indexing
    managed-schemaField definitions, field types, analyzers

    Adjusting Memory Settings

    Edit the Solr environment file to configure JVM heap size based on your VPS RAM:

    Edit Solr Environment
    sudo nano /etc/default/solr.in.sh
    Memory Configuration
    SOLR_HEAP="2g"
    # For a 4GB VPS, use 2GB heap
    # For an 8GB VPS, use 4GB heap
    # Leave at least 2GB for the OS and other processes

    Binding to Specific IP

    For security, bind Solr to localhost or a specific interface:

    IP Binding in /etc/default/solr.in.sh
    SOLR_HOST="127.0.0.1"
    # Or bind to all interfaces (not recommended for production)
    # SOLR_HOST="0.0.0.0"
    Restart Solr After Changes
    sudo systemctl restart solr
    6

    Creating Your First Core

    A Solr core is a single index with its own configuration. Let's create a core and index some data.

    Create a New Core
    sudo -u solr /opt/solr/bin/solr create -c mycore

    This creates a core named 'mycore' with the default schema-less configuration.

    Index Sample Data

    Using the Post Tool
    cd /opt/solr
    sudo -u solr bin/solr post -c mycore example/exampledocs/books.json
    Or Index via cURL
    curl -X POST -H 'Content-Type: application/json' \
      'http://localhost:8983/solr/mycore/update?commit=true' \
      --data-binary '[
        {"id": "1", "title": "Introduction to Solr", "author": "John Doe"},
        {"id": "2", "title": "Advanced Search Techniques", "author": "Jane Smith"}
      ]'

    Query Your Data

    Search All Documents
    curl 'http://localhost:8983/solr/mycore/select?q=*:*'
    Search with Specific Terms
    curl 'http://localhost:8983/solr/mycore/select?q=title:Solr'

    Managing Cores

    Core Management Commands
    # List all cores
    sudo -u solr /opt/solr/bin/solr status
    
    # Delete a core
    sudo -u solr /opt/solr/bin/solr delete -c mycore
    
    # Reload a core (after config changes)
    curl 'http://localhost:8983/solr/admin/cores?action=RELOAD&core=mycore'
    7

    Security Configuration

    Securing your Solr installation is critical for production environments. Implement these security measures before exposing Solr to the network.

    Enable Authentication

    Solr supports Basic Authentication. Create a security.json file:

    Create Security Configuration
    sudo -u solr nano /var/solr/data/security.json
    security.json Content
    {
      "authentication": {
        "class": "solr.BasicAuthPlugin",
        "credentials": {
          "admin": "IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="
        },
        "blockUnknown": true
      },
      "authorization": {
        "class": "solr.RuleBasedAuthorizationPlugin",
        "permissions": [
          { "name": "security-edit", "role": "admin" },
          { "name": "all", "role": "admin" }
        ],
        "user-role": { "admin": "admin" }
      }
    }

    ⚠️ Important: The password hash above is for 'SolrRocks'. Generate your own secure password hash using: echo -n 'yourpassword' | sha256sum

    Firewall Configuration

    Configure UFW to restrict access to Solr:

    Configure UFW Firewall
    # Allow SSH
    sudo ufw allow ssh
    
    # Allow Solr only from specific IPs (recommended)
    sudo ufw allow from YOUR_IP_ADDRESS to any port 8983
    
    # Or allow from anywhere (less secure)
    # sudo ufw allow 8983/tcp
    
    # Enable firewall
    sudo ufw enable

    Reverse Proxy with Nginx (Recommended)

    For production, use Nginx as a reverse proxy with SSL:

    Install Nginx and Create Config
    sudo apt install nginx -y
    sudo nano /etc/nginx/sites-available/solr
    Nginx Configuration
    server {
        listen 443 ssl;
        server_name solr.yourdomain.com;
    
        ssl_certificate /etc/letsencrypt/live/solr.yourdomain.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/solr.yourdomain.com/privkey.pem;
    
        location / {
            proxy_pass http://127.0.0.1:8983;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
    Enable Nginx Site
    sudo ln -s /etc/nginx/sites-available/solr /etc/nginx/sites-enabled/
    sudo nginx -t && sudo systemctl reload nginx
    8

    Performance Tuning

    Optimize Solr performance based on your workload and available resources.

    JVM Garbage Collection

    For Solr 9.x, G1GC is recommended. Add to /etc/default/solr.in.sh:

    GC Configuration
    GC_TUNE=("-XX:+UseG1GC" \
      "-XX:+PerfDisableSharedMem" \
      "-XX:+ParallelRefProcEnabled" \
      "-XX:MaxGCPauseMillis=250" \
      "-XX:+AlwaysPreTouch")

    Query Cache Configuration

    Edit solrconfig.xml for your core to tune caching:

    Cache Configuration in solrconfig.xml
    <query>
      <filterCache class="solr.CaffeineCache"
        size="512"
        initialSize="512"
        autowarmCount="256"/>
    
      <queryResultCache class="solr.CaffeineCache"
        size="512"
        initialSize="512"
        autowarmCount="256"/>
    
      <documentCache class="solr.CaffeineCache"
        size="512"
        initialSize="512"/>
    </query>

    OS-Level Optimizations

    Increase File Descriptor Limits
    sudo nano /etc/security/limits.conf
    
    # Add these lines:
    solr soft nofile 65535
    solr hard nofile 65535
    solr soft nproc 65535
    solr hard nproc 65535
    Optimize Virtual Memory
    sudo sysctl -w vm.max_map_count=262144
    echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.conf
    9

    Monitoring and Maintenance

    Regular monitoring and maintenance keeps your Solr instance healthy and performant.

    Checking Solr Status

    Status Commands
    # Service status
    sudo systemctl status solr
    
    # Solr admin status
    curl 'http://localhost:8983/solr/admin/info/system?wt=json'
    
    # Core status
    curl 'http://localhost:8983/solr/admin/cores?action=STATUS'

    Log Management

    Solr logs are located at /var/solr/logs/:

    View and Monitor Logs
    # View recent logs
    sudo tail -f /var/solr/logs/solr.log
    
    # Check for errors
    sudo grep -i error /var/solr/logs/solr.log | tail -20

    Backup and Recovery

    Backup Commands
    # Backup via API
    curl 'http://localhost:8983/solr/mycore/replication?command=backup&location=/var/solr/backups'
    
    # Manual backup of data directory
    sudo -u solr cp -r /var/solr/data/mycore /var/solr/backups/mycore-$(date +%Y%m%d)
    
    # Restore from backup
    curl 'http://localhost:8983/solr/mycore/replication?command=restore&location=/var/solr/backups'

    Index Optimization

    Index Maintenance
    # Optimize (merge segments)
    curl 'http://localhost:8983/solr/mycore/update?optimize=true&waitFlush=true'
    
    # Force commit
    curl 'http://localhost:8983/solr/mycore/update?commit=true'
    10

    Troubleshooting

    Common issues and their solutions.

    Solr Won't Start

    Diagnostic Commands
    # Check logs for errors
    sudo journalctl -u solr -n 50
    sudo cat /var/solr/logs/solr.log | tail -50
    
    # Verify Java is available
    java -version
    
    # Check port availability
    sudo netstat -tlnp | grep 8983

    Out of Memory Errors

    If you see OutOfMemoryError in logs:

    • 1. Increase SOLR_HEAP in /etc/default/solr.in.sh
    • 2. Reduce cache sizes in solrconfig.xml
    • 3. Consider upgrading to a VPS with more RAM
    • 4. Split large cores into multiple smaller ones

    Slow Query Performance

    • • Enable query logging to identify slow queries
    • • Review and optimize your schema field types
    • • Increase cache sizes for frequently accessed data
    • • Use filter queries (fq) for faceting and filtering
    • • Consider using SSD storage for improved I/O

    📚 Need Help? Consult the Apache Solr documentation or reach out to RamNode support for VPS-related issues.

    Recommended RamNode Plans for Solr

    Development / Small Index

    Premium KVM VPS with 4GB RAM and SSD storage.

    View Premium VPS

    Production / Large Index

    Premium KVM VPS with 8GB+ RAM for larger workloads.

    View Plans