How to Install Meilisearch on Rocky Linux

Install Meilisearch on Rocky Linux

Meilisearch is a lightning-fast, open-source search engine that’s designed to provide instant search experiences for your applications. Think of it as Google’s search functionality, but for your own data. Whether you’re building an e-commerce site, a documentation portal, or any application that needs powerful search capabilities, Meilisearch delivers results in milliseconds.

Key Features of Meilisearch

Meilisearch stands out from other search engines with its impressive feature set:

  • Lightning-fast search responses – typically under 50ms
  • Typo tolerance – finds results even with spelling mistakes
  • Faceted search – filter results by categories, prices, or any attribute
  • Geo-search capabilities – location-based search functionality
  • Multi-language support – works with over 30 languages
  • RESTful API – easy integration with any programming language
  • Real-time indexing – updates search results instantly

Why Choose Meilisearch for Your Search Engine?

You might wonder why choose Meilisearch over alternatives like Elasticsearch or Solr. Here’s the thing – while those are powerful, they’re also complex beasts that require significant DevOps expertise. Meilisearch, on the other hand, is designed with simplicity in mind. You can have a fully functional search engine running in minutes, not hours or days.

Prerequisites for Installing Meilisearch on Rocky Linux

Before we dive into the installation process, let’s make sure your Rocky Linux system is ready for Meilisearch.

System Requirements

Your Rocky Linux server should meet these minimum requirements:

  • RAM: At least 1GB (2GB+ recommended for production)
  • CPU: Single core minimum (multi-core preferred)
  • Storage: 10GB free space minimum
  • Network: Internet connection for downloading packages
  • OS: Rocky Linux 8.x or 9.x

Required Packages and Dependencies

We’ll need several packages during the installation process:

  • curl or wget for downloading files
  • systemd for service management
  • firewalld for firewall configuration
  • Development tools if building from source

Setting Up Rocky Linux Environment

Let’s start by preparing your Rocky Linux system for the Meilisearch installation.

Updating Your System

First things first – always start with a fresh system update:

sudo dnf update -y

This ensures you have the latest security patches and package versions. It’s like giving your car a tune-up before a long road trip.

Installing Essential Development Tools

Install the basic tools we’ll need:

sudo dnf groupinstall "Development Tools" -y
sudo dnf install curl wget git -y

These tools will come in handy regardless of which installation method you choose.

Method 1: Installing Meilisearch Using Binary Release

This is the quickest and most straightforward method. Think of it as downloading a pre-built application rather than assembling it yourself.

Downloading the Latest Meilisearch Binary

Let’s grab the latest Meilisearch binary directly from their GitHub releases:

curl -L https://install.meilisearch.com | sh

This command downloads and installs the latest stable version automatically. If you prefer manual control, you can download a specific version:

wget https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-linux-amd64
chmod +x meilisearch-linux-amd64
sudo mv meilisearch-linux-amd64 /usr/local/bin/meilisearch

Setting Up Meilisearch Binary

Now let’s create a dedicated user for Meilisearch (security best practice):

sudo useradd --system --shell /bin/false --home /var/lib/meilisearch meilisearch
sudo mkdir -p /var/lib/meilisearch
sudo chown meilisearch:meilisearch /var/lib/meilisearch

Create the necessary directories:

sudo mkdir -p /etc/meilisearch
sudo mkdir -p /var/log/meilisearch
sudo chown meilisearch:meilisearch /var/log/meilisearch

Creating a Systemd Service

Let’s create a systemd service file for easy management:

sudo tee /etc/systemd/system/meilisearch.service > /dev/null <<EOF
[Unit]
Description=Meilisearch
After=network.target

[Service]
Type=simple
User=meilisearch
Group=meilisearch
ExecStart=/usr/local/bin/meilisearch --http-addr 127.0.0.1:7700 --db-path /var/lib/meilisearch
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

Method 2: Installing Meilisearch via Docker

Docker provides an isolated environment for Meilisearch, making it perfect for development and testing scenarios.

Installing Docker on Rocky Linux

First, let’s install Docker:

sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io -y
sudo systemctl start docker
sudo systemctl enable docker

Add your user to the docker group:

sudo usermod -aG docker $USER

Running Meilisearch Container

Now we can run Meilisearch in a Docker container:

docker run -it --rm \
  -p 7700:7700 \
  -v $(pwd)/meili_data:/meili_data \
  getmeili/meilisearch:latest

For production use, you’ll want to run it as a daemon:

docker run -d \
  --name meilisearch \
  -p 7700:7700 \
  -v $(pwd)/meili_data:/meili_data \
  getmeili/meilisearch:latest

Configuring Docker Compose

For easier management, create a docker-compose.yml file:

version: '3.8'
services:
  meilisearch:
    image: getmeili/meilisearch:latest
    ports:
      - "7700:7700"
    volumes:
      - ./meili_data:/meili_data
    restart: unless-stopped

Start with: docker-compose up -d

Method 3: Building Meilisearch from Source

This method gives you the most control but requires more steps. It’s like cooking from scratch instead of using a ready-made meal.

Installing Rust and Cargo

Meilisearch is written in Rust, so we need the Rust toolchain:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env

Cloning and Building Meilisearch

Clone the repository and build:

git clone https://github.com/meilisearch/meilisearch.git
cd meilisearch
cargo build --release

This process can take 15-30 minutes depending on your system specs. The compiled binary will be in target/release/meilisearch.

Configuring Meilisearch

Basic Configuration Settings

Create a configuration file at /etc/meilisearch/config.toml:

db_path = "/var/lib/meilisearch"
http_addr = "127.0.0.1:7700"
max_index_size = "100 GiB"
max_task_db_size = "1 GiB"

Security Configuration

For production environments, always set a master key:

export MEILI_MASTER_KEY="your-super-secret-master-key-here"

Add this to your systemd service file or environment configuration.

Performance Optimization

Adjust these settings based on your hardware:

  • Set max_indexing_memory to about 50% of available RAM
  • Configure max_indexing_threads to match your CPU cores
  • Enable schedule_period for batch indexing

Starting and Managing Meilisearch Service

Starting Meilisearch

If you used the binary installation with systemd:

sudo systemctl daemon-reload
sudo systemctl start meilisearch

Enabling Auto-start on Boot

Ensure Meilisearch starts automatically:

sudo systemctl enable meilisearch

Monitoring Meilisearch Status

Check if everything’s running smoothly:

sudo systemctl status meilisearch
sudo journalctl -u meilisearch -f

Testing Your Meilisearch Installation

Verifying the Installation

Test if Meilisearch is responding:

curl http://localhost:7700/health

You should see a response like: {"status":"available"}

Creating Your First Index

Let’s create a test index:

curl -X POST 'http://localhost:7700/indexes' \
-H 'Content-Type: application/json' \
--data-binary '{
  "uid": "movies",
  "primaryKey": "id"
}'

Adding Sample Data

Add some test documents:

curl -X POST 'http://localhost:7700/indexes/movies/documents' \
-H 'Content-Type: application/json' \
--data-binary '[
  {
    "id": 1,
    "title": "The Matrix",
    "genre": "Science Fiction"
  },
  {
    "id": 2,
    "title": "Pulp Fiction",
    "genre": "Crime"
  }
]'

Troubleshooting Common Issues

Port Binding Issues

If port 7700 is already in use, check what’s using it:

sudo netstat -tlnp | grep 7700

Change the port in your configuration if needed.

Permission Problems

Ensure the meilisearch user owns all necessary directories:

sudo chown -R meilisearch:meilisearch /var/lib/meilisearch
sudo chown -R meilisearch:meilisearch /var/log/meilisearch

Memory and Performance Issues

Monitor memory usage:

sudo systemctl status meilisearch
htop

Adjust memory limits in your configuration if experiencing OOM errors.

Best Practices for Production Deployment

Security Hardening

  • Always use HTTPS in production
  • Set up proper firewall rules
  • Use environment variables for sensitive configuration
  • Regularly update Meilisearch to the latest version

Backup and Recovery

Create regular backups of your database:

curl -X POST 'http://localhost:7700/dumps'

Store dumps in a secure, separate location.

Monitoring and Logging

Set up monitoring for:

  • Service availability
  • Response times
  • Memory and CPU usage
  • Index size growth

Consider using tools like Prometheus and Grafana for comprehensive monitoring.

Frequently Asked Questions

Q: Can I run multiple Meilisearch instances on the same Rocky Linux server?

A: Yes, you can run multiple instances by using different ports and data directories. Each instance should have its own configuration file and systemd service. This is useful for separating development and production environments or serving different applications.

Q: How much RAM does Meilisearch need for optimal performance?

A: While Meilisearch can run with as little as 1GB RAM, we recommend at least 2GB for production use. For large datasets (millions of documents), consider 8GB or more. Meilisearch is quite memory-efficient compared to alternatives like Elasticsearch.

Q: Is it safe to upgrade Meilisearch on a production server?

A: Yes, but always backup your database first using the dump feature. Meilisearch maintains backward compatibility, but it’s good practice to test upgrades in a staging environment first. Stop the service, replace the binary, and restart.

Q: Can I use Meilisearch with SSL/TLS encryption?

A: Meilisearch doesn’t handle SSL directly. In production, place it behind a reverse proxy like Nginx or Apache that handles SSL termination. This is actually a security best practice as it keeps your search engine isolated from direct internet access.

Q: What’s the difference between the master key and API keys in Meilisearch?

A: The master key is used for administrative tasks and creating other API keys. API keys are more granular and can be restricted to specific indexes or actions. In production, applications should use API keys with minimal required permissions, not the master key.

Marshall Anthony is a professional Linux DevOps writer with a passion for technology and innovation. With over 8 years of experience in the industry, he has become a go-to expert for anyone looking to learn more about Linux.

Related Posts