Introduction
Running Solr in production requires careful management of collections, backups, and performance tuning. This guide covers essential operations for maintaining healthy Solr deployments.
Collection Management
Creating Collections
# Create collection (SolrCloud)
curl "http://localhost:8983/solr/admin/collections?action=CREATE&name=products&numShards=3&replicationFactor=2&collection.configName=myconfig"
Collection Aliases
# Create alias
curl "http://localhost:8983/solr/admin/collections?action=CREATEALIAS&name=latest_products&router.field=prod_date"
# List collections
curl "http://localhost:8983/solr/admin/collections?action=LIST"
Collection API
# Reload collection
curl "http://localhost:8983/solr/admin/collections?action=RELOAD&name=products"
# Delete collection
curl "http://localhost:8983/solr/admin/collections?action=DELETE&name=old_products"
Backup and Restore
Backup
# Backup collection
curl "http://localhost:8983/solr/admin/collections?action=BACKUP&name=products_backup&collection=products&location=/backup/solr"
# List backups
curl "http://localhost:8983/solr/admin/collections?action=LISTBACKUP&location=/backup/solr"
Restore
# Restore collection
curl "http://localhost:8983/solr/admin/collections?action=RESTORE&name=products_backup&collection=products_restored&location=/backup/solr"
Security
Authentication
# Enable basic auth
curl -X POST --header "Content-Type: application/json" \
--data '{"set-user": {"admin": "admin123"}}' \
"http://localhost:8983/solr/admin/authentication"
Authorization
# Set permissions
curl -X POST --header "Content-Type: application/json" \
--data '{"set-permission": {"name": "read", "role": "readers"}}' \
"http://localhost:8983/solr/admin/authorization"
Monitoring
Metrics API
# Get metrics
curl "http://localhost:8983/solr/admin/metrics?group=core"
# Get JVM metrics
curl "http://localhost:8983/solr/admin/metrics?group=jvm"
Admin UI
# Access Solr Admin UI
http://localhost:8983/solr
# View:
# - Collection overview
# - Query distribution
# - Cache hit rates
# - Index size
Performance Tuning
Cache Configuration
// solrconfig.xml
<query>
<filterCache class="solr.LRUCache" size="10000" initialSize="5120"/>
<queryResultCache class="solr.LRUCache" size="10000" initialSize="5120"/>
<documentCache class="solr.LRUCache" size="10000" initialSize="5120"/>
</query>
JVM Settings
# Set heap size
export SOLR_HEAP=4g
# In solr.in.sh
SOLR_HEAP=4g
GC_TUNE="-XX:+UseG1GC -XX:MaxGCPauseMillis=100"
Index Management
Commit Types
# Soft commit (near real-time)
curl -X POST "http://localhost:8983/solr/gettingstarted/update?softCommit=true"
# Hard commit (durable)
curl -X POST "http://localhost:8983/solr/gettingstarted/update?commit=true"
Merge Policy
// Configure merge policy
<mergePolicyFactory class="solr.TieredMergePolicyFactory">
<int name="maxMergeAtOnce">10</int>
<int name="segmentsPerTier">10</int>
</mergePolicyFactory>
Conclusion
Solr operations require attention to collections, backups, security, and monitoring. With proper management, Solr can handle enterprise-scale search workloads reliably.
Comments