Elasticsearch

From Server rental store
Jump to navigation Jump to search

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

  • **Elasticsearch Status:** Verify Elasticsearch is running using: `sudo systemctl status elasticsearch`.
  • **Connection Test:** Use `curl` to test the connection: `curl -X GET "http://localhost:9200/"`. You should see a JSON response with information about your Elasticsearch cluster.
  • **MediaWiki Search:** After rebuilding the index, perform a search in your MediaWiki. The results should be significantly faster and more relevant.
  • **Logs:** Check the Elasticsearch logs (`/var/log/elasticsearch/`) and the MediaWiki error logs for any errors. See Error reporting for details on MediaWiki logging.
  • **Firewall:** Ensure your firewall allows communication between the MediaWiki server and the Elasticsearch server on port 9200 (or the configured port). Review your Firewall configuration.

Advanced Configuration

  • **SSL/TLS:** For production environments, configure Elasticsearch with SSL/TLS for secure communication. Refer to the Elasticsearch documentation for instructions.
  • **Sharding and Replication:** For large wikis, consider configuring sharding and replication in Elasticsearch to improve performance and availability. See Cluster architecture.
  • **Analysis:** Customize the Elasticsearch analysis settings to optimize search results for your specific content. Text indexing provides further details.

Security Considerations

  • **Authentication:** Implement authentication for Elasticsearch to restrict access to authorized users only.
  • **Firewall:** Restrict access to the Elasticsearch port (9200) to only the MediaWiki server.
  • **Regular Updates:** Keep both Elasticsearch and MediaWiki updated with the latest security patches. See Security updates.

Further Resources


Intel-Based Server Configurations

Configuration Specifications Benchmark
Core i7-6700K/7700 Server 64 GB DDR4, NVMe SSD 2 x 512 GB CPU Benchmark: 8046
Core i7-8700 Server 64 GB DDR4, NVMe SSD 2x1 TB CPU Benchmark: 13124
Core i9-9900K Server 128 GB DDR4, NVMe SSD 2 x 1 TB CPU Benchmark: 49969
Core i9-13900 Server (64GB) 64 GB RAM, 2x2 TB NVMe SSD
Core i9-13900 Server (128GB) 128 GB RAM, 2x2 TB NVMe SSD
Core i5-13500 Server (64GB) 64 GB RAM, 2x500 GB NVMe SSD
Core i5-13500 Server (128GB) 128 GB RAM, 2x500 GB NVMe SSD
Core i5-13500 Workstation 64 GB DDR5 RAM, 2 NVMe SSD, NVIDIA RTX 4000

AMD-Based Server Configurations

Configuration Specifications Benchmark
Ryzen 5 3600 Server 64 GB RAM, 2x480 GB NVMe CPU Benchmark: 17849
Ryzen 7 7700 Server 64 GB DDR5 RAM, 2x1 TB NVMe CPU Benchmark: 35224
Ryzen 9 5950X Server 128 GB RAM, 2x4 TB NVMe CPU Benchmark: 46045
Ryzen 9 7950X Server 128 GB DDR5 ECC, 2x2 TB NVMe CPU Benchmark: 63561
EPYC 7502P Server (128GB/1TB) 128 GB RAM, 1 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (128GB/2TB) 128 GB RAM, 2 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (128GB/4TB) 128 GB RAM, 2x2 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (256GB/1TB) 256 GB RAM, 1 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (256GB/4TB) 256 GB RAM, 2x2 TB NVMe CPU Benchmark: 48021
EPYC 9454P Server 256 GB RAM, 2x2 TB NVMe

Order Your Dedicated Server

Configure and order your ideal server configuration

Need Assistance?

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