I have Ubuntu 16.04 LTS on virtual box and I'd like to install elasticsearch
in order to use it with Ruby on Rails. I've done a search on google on how to do the installation, but I have found mutiple guides that have a few differences which got me a little bit confused, for instance:
Installing elasticsearch on Ubuntu 16.04
Digital Ocean: Install and Configure Elasticsearch on Ubuntu 16.04
(see @ Prerequisites)
How should I install elasticsearch safely, without messing up my development environment?
Elastic has their own guide to install elasticsearch with Debian packages. you can find it on their website.
https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html
I used this one and now everything works like a charm.
Elasticsearch requires Java 8 or later:
Install Elasticsearch
some remarks (from elastic website):
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:=> Delete the deb-src entry from the /etc/apt/sources.list file and the installation should work as expected.
=> Examine
/etc/apt/sources.list.d/elasticsearch-5.x.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
fileFor very basic installation of ElasticSearch 1.x or 2.x on Ubuntu 16.04
(the same goes for Ubuntu 14.04) do the next few steps on fresh install Ubuntu:
sudo apt-get update
sudo apt-get upgrade
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version
//For 2.x; elasticsearch 2.4.0
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.4.0/elasticsearch-2.4.0.deb
sudo dpkg -i elasticsearch-2.4.0.deb
service elasticsearch status
sudo apt-get install -y curl lynx links
lynx http : // localhost : 9200
OR
curl -X GET 'http : // localhost:9200'
Installing ElasticSearch 6.8.6 on Ubuntu 16
The latest version at the time of writing was 7 but we needed version 6 for compatibility reasons so using the typical
apt-get
package manager wouldn't work. Instead we opted to install the package directly.Download and install the debian package for version 6.8.6:
Setup elasticsearch to start automatically on boot.
Start the elasticsearch service.
Confirm elasticsearch is running:
NOTE: Sometimes it takes a few seconds to spin up.
Configure as necessary:
For example, uncomment this line,
#network.host: localhost
, and replacelocalhost
with your server's IP address so it looks someting like this:network.host: 123.123.123.123
.Elasticsearch 7.x installation on Ubuntu 20.04
Installing openjdk 11 (8th version also have been used without issues):
Elasticsearch installation
Configure elasticsearch configuration file
/etc/elasticsearch/elasticsearch.yml
Uncomment the above option and specify your IP address or just
localhost
if you do not desire to give access to it through your local network.If you desire to allow access to it from your local network, then specify only IP addresses of specific machine you want to grant access from:
Do not allow access from any host, because of it does not have restrictions.
Start elasticsearch service:
Test if your elasticsearch service is running using telnet from both machines (192.168.0.5 and 192.168.0.55):
You'll get the next
if elasticsearch service is not running
You'll get the next if it is running but blocked by firewall:
You'll get the next output if the service is running and it is allowed in firewall:
Test elasticsearch configuration by:
More details here