<\/span><\/h2>\r\n\r\n\r\n\r\nFirst, log in to your Ubuntu 20.04 server via SSH as the root user:<\/p>\r\n\r\n\r\n\r\n
ssh root@IP_Address -p Port_number<\/pre>\r\n\r\n\r\n\r\nYou will need to replace \u2018IP_Address\u2018 and \u2018Port_number\u2018 with your server\u2019s respective IP address and SSH port number. Additionally, replace \u2018root\u2019 with the username of the admin account if necessary.<\/p>\r\n\r\n\r\n\r\n
Before starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date. You can do this by running the following commands:<\/p>\r\n\r\n\r\n\r\n
apt-get update -y\r\napt-get upgrade -y<\/pre>\r\n\r\n\r\n\r\n<\/span>Install Required Dependencies<\/span><\/h2>\r\n\r\n\r\n\r\nBefore starting, you will need to install Java and other required dependencies in your server. You can install all of them using the following command:<\/p>\r\n\r\n\r\n\r\n
apt-get install openjdk-11-jdk wget apt-transport-https curl gnupg2 -y<\/pre>\r\n\r\n\r\n\r\nOnce all the packages are installed, verify the installed version of Java with the following command:<\/p>\r\n\r\n\r\n\r\n
java -version<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
openjdk version \"11.0.9.1\" 2020-11-04\r\nOpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)\r\nOpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)\r\n<\/pre>\r\n\r\n\r\n\r\n<\/span>Install Elasticsearch<\/span><\/h2>\r\n\r\n\r\n\r\nBy default, Elasticsearch is not available in the Ubuntu standard repository. So you will need to add the Elasticsearch repository to your system.<\/p>\r\n\r\n\r\n\r\n
First, add the Elasticsearch signing key with the following command:<\/p>\r\n\r\n\r\n\r\n
wget -qO - https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch | apt-key add -<\/pre>\r\n\r\n\r\n\r\nNext, add the repository with the following command:<\/p>\r\n\r\n\r\n\r\n
echo \"deb https:\/\/artifacts.elastic.co\/packages\/7.x\/apt stable main\" | tee -a \/etc\/apt\/sources.list.d\/elastic-7.x.list\r\n<\/pre>\r\n\r\n\r\n\r\nOnce the repository is added, update the repository and install the Elasticsearch package with the following command:<\/p>\r\n\r\n\r\n\r\n
apt-get update -y\r\napt-get install elasticsearch -y<\/pre>\r\n\r\n\r\n\r\nOnce the Elasticsearch is installed, start the Elasticsearch service and enable it to start at system reboot:<\/p>\r\n\r\n\r\n\r\n
systemctl start elasticsearch\r\nsystemctl enable elasticsearch<\/pre>\r\n\r\n\r\n\r\nAt this point, Elasticsearch is started and listening on port 9200. You can verify it with the following command:<\/p>\r\n\r\n\r\n\r\n
ss -antpl | grep 9200<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
LISTEN 0 4096 [::ffff:127.0.0.1]:9200 *:* users:((\"java\",pid=27757,fd=257)) \r\nLISTEN 0 4096 [::1]:9200 [::]:* users:((\"java\",pid=27757,fd=256)) \r\n<\/pre>\r\n\r\n\r\n\r\nYou can also check the Elasticsearch by sending an HTTP request:<\/p>\r\n\r\n\r\n\r\n
curl -X GET http:\/\/localhost:9200<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
{\r\n \"name\" : \"ubuntu2004\",\r\n \"cluster_name\" : \"elasticsearch\",\r\n \"cluster_uuid\" : \"LhG8-a_eQHyyoRAlQQXBTQ\",\r\n \"version\" : {\r\n \"number\" : \"7.10.0\",\r\n \"build_flavor\" : \"default\",\r\n \"build_type\" : \"deb\",\r\n \"build_hash\" : \"51e9d6f22758d0374a0f3f5c6e8f3a7997850f96\",\r\n \"build_date\" : \"2020-11-09T21:30:33.964949Z\",\r\n \"build_snapshot\" : false,\r\n \"lucene_version\" : \"8.7.0\",\r\n \"minimum_wire_compatibility_version\" : \"6.8.0\",\r\n \"minimum_index_compatibility_version\" : \"6.0.0-beta1\"\r\n },\r\n \"tagline\" : \"You Know, for Search\"\r\n}\r\n<\/pre>\r\n\r\n\r\n\r\n