run Elasticsearch<\/a>, we need Java. Let’s install it from the default Debian 11 repository.<\/p>\n\n\n\n# apt install default-jre<\/pre>\n\n\n\nDebian 11 ships with Java 11 by default; it can be verified by running this command below.<\/p>\n\n\n\n
# java --version<\/pre>\n\n\n\nYou will get an output like this:<\/p>\n\n\n\n
openjdk 11.0.18 2023-01-17\nOpenJDK Runtime Environment (build 11.0.18+10-post-Debian-1deb11u1)\nOpenJDK 64-Bit Server VM (build 11.0.18+10-post-Debian-1deb11u1, mixed mode, sharing)<\/pre>\n\n\n\n<\/span>Step 4. Add Elasticsearch Repository<\/span><\/h2>\n\n\n\nTo ensure the download source is secure and from the official source, we need to import the GPG key by downloading it using wget.<\/p>\n\n\n\n
# wget -qO - https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch | gpg --dearmor | tee \/usr\/share\/keyrings\/elasticsearch.gpg<\/pre>\n\n\n\nDebian 11 does not ship with a package for Elasticsearch. Fortunately, the Elasticsearch developer team has provided its own repository packages for Debian. We can add the Elasticsearch repository by executing the command below.<\/p>\n\n\n\n
# echo \"deb [signed-by=\/usr\/share\/keyrings\/elasticsearch.gpg] https:\/\/artifacts.elastic.co\/packages\/8.x\/apt stable main\" | tee \/etc\/apt\/sources.list.d\/elastic-8.list<\/pre>\n\n\n\nTo refresh the system packages index and update the list of available packages after adding a new repository, we should run apt update.<\/p>\n\n\n\n
# apt update -y<\/pre>\n\n\n\n<\/span>Step 5. Install Elasticsearch<\/span><\/h2>\n\n\n\nWe added the Elasticsearch repository in the previous step, and the package metadata list has also been updated. We can now install Elasticsearch by invoking this command:<\/p>\n\n\n\n
# apt install elasticsearch<\/pre>\n\n\n\nOn the Debian 11 system, once Elasticsearch is installed, it is not automatically running. Execute the following command to run Elasticsearch and enable it on boot.<\/p>\n\n\n\n
# systemctl enable --now elasticsearch<\/pre>\n\n\n\nThat’s it, Elasticsearch is now running, and you can verify with this command<\/p>\n\n\n\n
# systemctl status elasticsearch<\/pre>\n\n\n\nIt will return an output like this:<\/p>\n\n\n\n
\u25cf elasticsearch.service - Elasticsearch\nLoaded: loaded (\/lib\/systemd\/system\/elasticsearch.service; enabled; vendor preset: enabled)\nActive: active (running) since Tue 2023-04-18 08:59:54 EDT; 1min 14s ago\nDocs: https:\/\/www.elastic.co\nMain PID: 8236 (java)\nTasks: 71 (limit: 2294)\nMemory: 1.3G\nCPU: 44.403s\nCGroup: \/system.slice\/elasticsearch.service\n\u251c\u25008236 \/usr\/share\/elasticsearch\/jdk\/bin\/java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=\/usr\/share\/elasticsearch\/bin\/elasticsearch -Dcli.libs=lib\/tools>\n\u251c\u25008295 \/usr\/share\/elasticsearch\/jdk\/bin\/java -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -Djava.security.manager=allow -XX:+AlwaysPreTouch ->\n\u2514\u25008315 \/usr\/share\/elasticsearch\/modules\/x-pack-ml\/platform\/linux-x86_64\/bin\/controller\n\nApr 18 08:59:13 debian11 systemd[1]: Starting Elasticsearch...\nApr 18 08:59:54 debian11 systemd[1]: Started Elasticsearch.<\/pre>\n\n\n\n