[box type="note" align="" class="" width=""]This article is an extract from the book, Mastering Elastic Stack co-authored by Ravi Kumar Gupta and Yuvraj Gupta.This book will brush you up with basic knowledge on implementing the Elastic Stack and then dives deep into complex and advanced implementations. [/box]
In today’s tutorial we aim to learn Elasticsearch v5.1.1 installation for Ubuntu and Windows.
In order to install Elasticsearch on Ubuntu, refer to the following steps:
wget https://artifacts.elastic.co
/downloads/elasticsearch/elasticsearch-5.1.1.deb
2. Install the debian package using following command:
sudo dpkg -i elasticsearch-5.1.1.deb
Elasticsearch will be installed in /usr/share/elasticsearch directory. The configuration files will be present at /etc/elasticsearch. The init script will be present at /etc/init.d/elasticsearch. The log files will be present within /var/log/elasticsearch directory.
3. Configure Elasticsearch to run automatically on bootup . If you are using SysV init distribution, then run the following command:
sudo update-rc.d elasticsearch defaults 95 10
The preceding command will print on screen:
Adding system startup for, /etc/init.d/elasticsearch
Check status of Elasticsearch using following command:
sudo service elasticsearch status
Run Elasticsearch as a service using following command:
sudo service elasticsearch start
Elasticsearch may not start if you have any plugin installed which is not supported in ES-5.0.x version onwards. As plugins have been deprecated, it is required to uninstall any plugin if exists in prior version of ES. Remove a plugin after going to ES Home using following command: bin/elasticsearch-plugin remove head Usage of Elasticsearch command:
sudo service elasticsearch {start|stop|restart|force- reload|status}
If you are using systemd distribution, then run following command:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
To verify elasticsearch installation open open http://localhost:9200 in browser or run the following command from command line:
curl -X GET http://localhost:9200
In order to install Elasticsearch on Windows, refer to the following steps:
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch
Upon opening the link, click on it and it will download the ZIP package.
2. Extract the downloaded ZIP package by unzipping it using WinRAR, 7-Zip, and other such extracting softwares (if you don't have one of these then download it).
This will extract the files and folders in the directory.
3. Then click on the extracted folder and navigate the folder to reach inside the bin folder.
4. Click on the elasticsearch.bat file to run Elasticsearch.
If this window is closed Elasticsearch will stop running, as the node will shut down.
5. To verify Elasticsearch installation, open http://localhost:9200 in the browser:
After installing Elasticsearch as previously mentioned, open Command Prompt after navigating to the bin folder and use the following command:
elasticsearch-service.bat install
Usage: elasticsearch-service.bat install | remove | start | stop | manager
To summarize, we learnt installation of Elasticsearch on Ubuntu and Windows. If you are keen to know more about how to work with the Elastic Stack in a production environment, you can grab our comprehensive guide Mastering Elastic Stack.