
Installing Elasticsearch 7.x on Ubuntu and Debian: A Step-by-Step Guide
Elasticsearch has become an incredibly popular open-source distributed search and analytics engine, powering everything from website search bars to complex log analysis platforms. Its speed, scalability, and flexible schema make it a go-to choice for handling large volumes of data. If you’re running a server on Ubuntu 18.04 or Debian 9.8 and need to leverage the power of Elasticsearch 7.x, this guide will walk you through the installation process.
Before you begin, ensure you have root privileges or can use sudo on your server. A stable internet connection is also necessary to download the required packages. Elasticsearch also requires Java, so make sure a compatible Java Development Kit (JDK) is installed (OpenJDK 11 or later is recommended for Elasticsearch 7.x).
Here are the key steps to get Elasticsearch 7.x up and running on your system:
Import the Elasticsearch GPG Key:
To ensure the packages you download are authentic, you need to add the Elasticsearch signing key to your system’s keyring. This is a crucial security step. You’ll use a command likewgetto retrieve the key andapt-key addto import it.Add the Elasticsearch Repository:
Elasticsearch is not typically available in the default Ubuntu or Debian repositories. You need to add the official Elasticsearch repository to your system’s list of sources. This involves creating a new file in/etc/apt/sources.list.d/that points to the Elasticsearch package source for your distribution.Update Your Package List:
After adding the new repository, you must update your system’s package index to recognize the available packages from the Elasticsearch source. This is done with the standardapt updatecommand.Install Elasticsearch:
Now that your system knows where to find the package, you can install Elasticsearch using theapt install elasticsearchcommand. The package manager will download and install the necessary files and dependencies.Configure Elasticsearch:
Configuration is vital for performance and stability. The main configuration file is located at/etc/elasticsearch/elasticsearch.yml. Key settings to review include:network.host: By default, Elasticsearch binds tolocalhost. For production environments or if you need external access (with proper firewall rules!), you should change this. Setting it to0.0.0.0makes it accessible externally (caution: secure appropriately!), or specify a specific IP address.http.port: The default HTTP port is 9200.- Memory Allocation: Elasticsearch is a memory-intensive application. It’s highly recommended to configure the JVM heap size. This is done by editing the
/etc/elasticsearch/jvm.optionsfile. SetXmsandXmxto the same value, typically no more than half of your system’s total RAM, leaving sufficient memory for the operating system and other processes.
Reload systemd and Start the Service:
After installation and configuration, you need to manage the Elasticsearch service using systemd. First, reload the systemd daemon withsystemctl daemon-reloadto recognize the new service unit. Then, start the Elasticsearch service usingsystemctl start elasticsearch.Enable Elasticsearch on Boot:
To ensure Elasticsearch starts automatically every time your server reboots, enable the service withsystemctl enable elasticsearch.Verify the Installation:
Confirm that Elasticsearch is running and accessible. You can do this by usingcurlto query the Elasticsearch API, typically atlocalhost:9200(or the IP/hostname you configured). A successful response will return information about the Elasticsearch node.
Following these steps will provide you with a working Elasticsearch 7.x instance on your Ubuntu 18.04 or Debian 9.8 server, ready for indexing and searching your data. Remember that securing your Elasticsearch instance, especially if exposed to a network, is paramount after the initial installation. Always refer to the official Elasticsearch documentation for detailed security configurations.
Source: https://kifarunix.com/install-elasticsearch-7-x-on-ubuntu-18-04-debian-9-8/


