Sometimes you need to completely reset OpenSearch and OpenSearch Dashboards to start fresh - whether you’re dealing with corrupted data, testing configurations, or simply want a clean slate. This guide walks you through the process of completely resetting both services.
Table of contents
When to Reset OpenSearch
You might want to reset OpenSearch in these scenarios:
- Corrupted indices that can’t be recovered
- Testing purposes where you need a clean environment
- Configuration issues that are easier to reset than fix
- Learning environments where you want to start over
- Development setups that accumulated too much test data
⚠️ Warning: This process will permanently delete ALL your data, including:
- All indices and documents
- All dashboards and visualizations
- All saved searches and filters
- All user configurations and settings
Prerequisites
Before proceeding, ensure you have:
- Root or sudo access to the server
- Backed up any data you need to preserve
- Documented any custom configurations you want to recreate
- Stopped any applications that depend on OpenSearch
Step-by-Step Reset Process
Step 1: Stop the Services
First, stop both OpenSearch and OpenSearch Dashboards services:
sudo systemctl stop opensearchsudo systemctl stop opensearch-dashboards
Verify the services have stopped:
sudo systemctl status opensearchsudo systemctl status opensearch-dashboards
Step 2: Remove OpenSearch Data
Delete all OpenSearch data directories:
# Default OpenSearch data directorysudo rm -rf /var/lib/opensearch/*
# Also remove logs if you want them freshsudo rm -rf /var/log/opensearch/*
If your installation uses custom paths, adjust accordingly. You can find your data path in /etc/opensearch/opensearch.yml
under the path.data
setting.
Step 3: Remove OpenSearch Dashboards Data
Clear OpenSearch Dashboards data:
# Default OpenSearch Dashboards data directorysudo rm -rf /var/lib/opensearch-dashboards/*
# Remove logssudo rm -rf /var/log/opensearch-dashboards/*
Step 4: Reset Configuration (Optional)
If you want to reset configurations to defaults:
# Backup current configs firstsudo cp -r /etc/opensearch /etc/opensearch.backupsudo cp -r /etc/opensearch-dashboards /etc/opensearch-dashboards.backup
# Remove configs (they'll be recreated with defaults)sudo rm -rf /etc/opensearch/*sudo rm -rf /etc/opensearch-dashboards/*
⚠️ Note: Only do this if you want default configurations. If you have custom settings you want to keep, skip this step.
Step 5: Restart Services
Start OpenSearch first, then OpenSearch Dashboards:
# Start OpenSearchsudo systemctl start opensearch
# Wait for OpenSearch to fully start (important!)sleep 30
# Start OpenSearch Dashboardssudo systemctl start opensearch-dashboards
Step 6: Verify Services are Running
Check that both services started successfully:
# Check service statussudo systemctl status opensearchsudo systemctl status opensearch-dashboards
# Verify OpenSearch is respondingcurl -X GET "localhost:9200"
# Check cluster healthcurl -X GET "localhost:9200/_cluster/health?pretty"
You should see a response indicating the cluster is healthy (likely with “yellow” status initially for a single-node setup).
Alternative Reset Methods
Method 1: Using Delete API (Less Destructive)
If you only want to delete indices but keep configurations:
# Delete all indicescurl -X DELETE "localhost:9200/*"
# Delete specific indicescurl -X DELETE "localhost:9200/index_name"
Method 2: Docker Reset
If using Docker, simply remove and recreate containers:
# Stop and remove containersdocker-compose down -v
# Start fresh containersdocker-compose up -d
Common Issues and Troubleshooting
Service Won’t Start After Reset
- Check permissions on data directories:
sudo chown -R opensearch:opensearch /var/lib/opensearchsudo chown -R opensearch-dashboards:opensearch-dashboards /var/lib/opensearch-dashboards
- Check for port conflicts:
sudo netstat -tulpn | grep -E '9200|5601'
Configuration Errors
If you deleted configurations and services won’t start:
- Reinstall the packages to restore default configs:
sudo apt-get install --reinstall opensearch opensearch-dashboards
Disk Space Issues
Ensure you have sufficient disk space after deletion:
df -h /var/lib/opensearch
Post-Reset Tasks
After resetting, you’ll need to:
- Reconfigure security settings if you had custom authentication
- Recreate index templates and mappings
- Restore any backed-up data if needed
- Reconfigure OpenSearch Dashboards index patterns
- Set up users and roles again
Best Practices
- Always backup first - Even if you think you don’t need the data
- Document your configurations - Keep track of custom settings
- Test in development first - Never reset production without testing
- Use snapshots - Consider using OpenSearch snapshots for easier recovery
- Monitor after reset - Check logs for any issues after restarting
Conclusion
Resetting OpenSearch and OpenSearch Dashboards gives you a clean slate but comes with the cost of losing all data and configurations. Always ensure you have proper backups and understand the implications before proceeding. This process is best suited for development environments or situations where data recovery is not possible or needed.
Remember: with great power comes great responsibility - use the reset process wisely!