Server rental store

Elasticsearch

Elasticsearch Server Configuration

Elasticsearch is a powerful, distributed, RESTful search and analytics engine capable of solving a growing number of use cases. This article provides a comprehensive guide to configuring an Elasticsearch server for use with your MediaWiki installation, enhancing search capabilities significantly beyond the default database search. This guide assumes a Linux-based server environment.

Introduction to Elasticsearch and MediaWiki Integration

Elasticsearch excels at full-text search, making it ideal for improving the speed and relevance of searches within a large wiki like ours. Integrating Elasticsearch with MediaWiki requires configuring both systems to communicate effectively. We'll cover the installation, configuration, and connection process. Prior to beginning, ensure you have a functioning MediaWiki installation and administrative access to your server. Understanding System administration basics is also recommended. See also Extension installation for general extension guidance.

Prerequisites

Before installing Elasticsearch, ensure your system meets the following requirements:

Requirement Details
Operating System Linux (CentOS, Ubuntu, Debian recommended)
Java Java 8 or later (OpenJDK or Oracle JDK) is required.
Memory Minimum 2GB RAM, 4GB+ recommended for production.
Disk Space Sufficient disk space for Elasticsearch data (size depends on wiki content).

You also need `curl` installed for testing the Elasticsearch connection. This can usually be installed with your distribution's package manager (e.g., `sudo apt-get install curl` on Debian/Ubuntu). Consult your Operating System documentation for specifics.

Installation

The installation process varies slightly depending on your Linux distribution. Here's a common method using APT (Debian/Ubuntu):

1. Download the Elasticsearch Debian package from the [Elasticsearch Downloads page](https://www.elastic.co/downloads/elasticsearch). 2. Install the package: `sudo dpkg -i elasticsearch-*.deb` 3. Resolve dependencies: `sudo apt-get install -f`

On CentOS/RHEL, you'll typically use YUM or DNF. Refer to the official Elasticsearch documentation for detailed instructions for your specific distribution: [Elasticsearch Installation Guide](https://www.elastic.co/guide/en/elasticsearch/reference/current/install-on-linux.html).

Elasticsearch Configuration

The primary Elasticsearch configuration file is `elasticsearch.yml`, located in `/etc/elasticsearch/`. Here are some crucial settings:

Setting Description Example
`cluster.name` The name of your Elasticsearch cluster. Must be consistent across all nodes. `my-mediawiki-cluster`
`node.name` A unique name for this node in the cluster. `mediawiki-es-node-1`
`network.host` The network interface Elasticsearch will bind to. Set to `0.0.0.0` for all interfaces, or a specific IP address. `0.0.0.0`
`http.port` The port Elasticsearch listens on for HTTP requests. `9200`
`discovery.seed_hosts` A list of hostnames or IP addresses of other Elasticsearch nodes in the cluster. `["192.168.1.10", "192.168.1.11"]`

After modifying `elasticsearch.yml`, restart the Elasticsearch service: `sudo systemctl restart elasticsearch`.

MediaWiki Configuration

1. **Install the `Elasticsearch` extension:** Download the `Elasticsearch` extension from the [MediaWiki Extensions page](https://www.mediawiki.org/wiki/Extension:Elasticsearch) and install it following the Extension installation instructions. 2. **Configure `LocalSettings.php`:** Add the following lines to your `LocalSettings.php` file:

```php require_once "$IP/extensions/Elasticsearch/Elasticsearch.php";

$wgElasticsearchConfig = array( 'hosts' => array( array( 'host' => 'localhost', // Replace with your Elasticsearch server's hostname or IP address 'port' => 9200, // Elasticsearch HTTP port 'scheme' => 'http', // Use 'https' if Elasticsearch is configured with SSL ), ), 'index' => 'mediawiki', // The name of the Elasticsearch index. ); ```

3. **Rebuild the index**: Navigate to `Special:Elasticsearch` within your wiki and click "Rebuild Index." This process may take a significant amount of time depending on the size of your wiki. See the Special pages for more information.

Verification and Troubleshooting

⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️