[[deb]] === Install Elasticsearch with Debian Package The Debian package for Elasticsearch can be <> or from our <>. It can be used to install Elasticsearch on any Debian-based system such as Debian and Ubuntu. The latest stable version of Elasticsearch can be found on the link:/downloads/elasticsearch[Download Elasticsearch] page. Other versions can be found on the link:/downloads/past-releases[Past Releases page]. NOTE: Elasticsearch requires Java 8 or later. Use the http://www.oracle.com/technetwork/java/javase/downloads/index.html[official Oracle distribution] or an open-source distribution such as http://openjdk.java.net[OpenJDK]. [[deb-key]] ==== Import the Elasticsearch PGP Key include::key.asciidoc[] [source,sh] ------------------------- wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - ------------------------- [[deb-repo]] ==== Installing from the APT repository ifeval::["{release-state}"=="unreleased"] Version {version} of Elasticsearch has not yet been released. endif::[] ifeval::["{release-state}"!="unreleased"] You may need to install the `apt-transport-https` package on Debian before proceeding: [source,sh] -------------------------------------------------- sudo apt-get install apt-transport-https -------------------------------------------------- Save the repository definition to +/etc/apt/sources.list.d/elastic-{major-version}.list+: ifeval::["{release-state}"=="released"] ["source","sh",subs="attributes,callouts"] -------------------------------------------------- echo "deb https://artifacts.elastic.co/packages/{major-version}-prerelease/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-{major-version}.list -------------------------------------------------- endif::[] ifeval::["{release-state}"=="prerelease"] ["source","sh",subs="attributes,callouts"] -------------------------------------------------- echo "deb https://artifacts.elastic.co/packages/{major-version}/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-{major-version}.list -------------------------------------------------- endif::[] [WARNING] ================================================== Do not use `add-apt-repository` as it will add a `deb-src` entry as well, but we do not provide a source package. If you have added the `deb-src` entry, you will see an error like the following: Unable to find expected entry 'main/source/Sources' in Release file (Wrong sources.list entry or malformed file) Delete the `deb-src` entry from the `/etc/apt/sources.list` file and the installation should work as expected. ================================================== You can install the Elasticsearch Debian package with: [source,sh] -------------------------------------------------- sudo apt-get update && sudo apt-get install elasticsearch -------------------------------------------------- [WARNING] ================================================== If two entries exist for the same Elasticsearch repository, you will see an error like this during `apt-get update`: ["literal",subs="attributes,callouts"] Duplicate sources.list entry https://artifacts.elastic.co/packages/{major-version}/apt/ ...` Examine +/etc/apt/sources.list.d/elasticsearch-{major-version}.list+ for the duplicate entry or locate the duplicate entry amongst the files in `/etc/apt/sources.list.d/` and the `/etc/apt/sources.list` file. ================================================== endif::[] [[install-deb]] ==== Download and install the Debian package manually ifeval::["{release-state}"=="unreleased"] Version {version} of Elasticsearch has not yet been released. endif::[] ifeval::["{release-state}"!="unreleased"] The Debian package for Elastisearch v{version} can be downloaded from the website and installed as follows: ["source","sh",subs="attributes"] -------------------------------------------- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}.deb sha1sum elasticsearch-{version}.deb <1> sudo dpkg -i elasticsearch-{version}.deb -------------------------------------------- <1> Compare the SHA produced by `sha1sum` or `shasum` with the https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}.deb.sha1[published SHA]. endif::[] include::init-systemd.asciidoc[] [[deb-running-init]] ==== Running Elasticsearch with SysV `init` Use the `update-rc.d` command to configure Elasticsearch to start automatically when the system boots up: [source,sh] -------------------------------------------------- sudo update-rc.d elasticsearch defaults 95 10 -------------------------------------------------- Elasticsearch can be started and stopped using the `service` command: [source,sh] -------------------------------------------- sudo -i service elasticsearch start sudo -i service elasticsearch stop -------------------------------------------- If Elasticsearch fails to start for any reason, it will print the reason for failure to STDOUT. Log files can be found in `/var/log/elasticsearch/`. [[deb-running-systemd]] include::systemd.asciidoc[] [[deb-check-running]] include::check-running.asciidoc[] [[deb-configuring]] ==== Configuring Elasticsearch Elasticsearch loads its configuration from the `/etc/elasticsearch/elasticsearch.yml` file by default. The format of this config file is explained in <>. The Debian package also has a system configuration file (`/etc/default/elasticsearch`), which allows you to set the following parameters: include::sysconfig-file.asciidoc[] NOTE: Distributions that use `systemd` require that system resource limits be configured via `systemd` rather than via the `/etc/sysconfig/elasticsearch` file. See <> for more information. [[deb-layout]] ==== Directory layout of Debian package The Debian package places config files, logs, and the data directory in the appropriate locations for a Debian-based system: [cols="