Magento 2 and Elasticsearch
Install prerequisites and Elasticsearch
Installing OpenJDK 8
Start by verifying that Java hasn't been installed yet on your system:
java -version
-bash: java: command not found
Java LTS version 8 is not available in the official Debian Buster repositories. You can still install it by enabling the AdoptOpenJDK repository which provides prebuilt OpenJDK packages (check alternatives):
apt update
apt install apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common
Import the repository’s GPG key using the following wget command:
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
Add the AdoptOpenJDK APT repository to your system:
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
Once the repository is enabled, update apt sources and install Java 8 using the following commands:
sudo apt update
sudo apt install adoptopenjdk-8-hotspot
Finally, verify the installation by checking the Java version. The output should look something like this::
java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)
Install Elasticsearch 6.x
Download and install the public signing key:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
Save the repository definition to /etc/apt/sources.list.d/elastic-6.x.list
:
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
You can install the Elasticsearch Debian package with:
apt update && sudo apt install elasticsearch
To configure Elasticsearch to start automatically when the system boots up, run the following commands:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
Elasticsearch can be started and stopped as follows:
systemctl start elasticsearch.service
systemctl stop elasticsearch.service
These commands provide no feedback as to whether Elasticsearch was started successfully or not. Instead, this information will be written in the log files located in /var/log/elasticsearch/. You can also check the service status:
systemctl status elasticsearch.service