20

I installed elasticsearch.90.7 with a deb file in ubuntu. I tried to uninstall elasticsearch.90.7 with this command:

sudo apt-get --purge autoremove elasticsearch

And then I downloaded elasticsearch-1.6.0.deb to install elasticsearch 1.6.

When I run this command to install elasticsearch 1.6 by deb file:

dpkg -i elasticsearch-1.6.0.deb

It shows me this:

Selecting previously unselected package elasticsearch.
(Reading database ... 89826 files and directories currently installed.)
Preparing to unpack elasticsearch-1.6.0.deb ...
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Unpacking elasticsearch (1.6.0) ...
Setting up elasticsearch (1.6.0) ...
Processing triggers for ureadahead (0.100.0-16) ...

When I start elasticsearch with service elasticsearch start it's starting, but when i run this command: curl http://localhost:9200

It shows this error:

curl: (7) Failed to connect to localhost port 9200: Connection refused

I think elasticsearch is not installed properly. I want know what I should do to install elasticsearch properly.

Oldskool
  • 2,005
  • 1
  • 16
  • 26
alireza
  • 303
  • 1
  • 2
  • 5

4 Answers4

51

(1) Remove previous versions of ElasticSearch:

sudo apt-get --purge autoremove elasticsearch

(2) Remove the ElasticSearch directories:

sudo rm -rf /var/lib/elasticsearch/
sudo rm -rf /etc/elasticsearch

(3) Install ElasticSearch 1.6:

sudo dpkg -i elasticsearch-1.6.0.deb

(4) Start the service:

sudo service elasticsearch start

(5) Test if it works:

sudo service elasticsearch status
curl -XGET "http://localhost:9200/_cluster/health?pretty=true"
curl "localhost:9200/_nodes/settings?pretty=true"
  • I get `elasticsearch: unrecognized service` after installing the `.deb` file and trying to run `sudo service elasticsearch start`. – Vadorequest Mar 05 '16 at 14:49
  • Try ``` sudo /etc/init.d/elasticsearch start ``` – Artur Barseghyan Aug 18 '16 at 22:00
  • I am using elasticsearch version 5.2.0. And I follow your steps and now when I check log I am getting the error. Active: failed (Result: exit-code) since Wed 2018-09-19 20:39:29 Docs: http://www.elastic.co Process: 16709 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet -Edefault.path.logs=${LOG_DIR} -Edefault.path.data=${DATA_DIR} -Edefault.path.conf=${CONF_DIR} Process: 16708 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS) Main PID: 16709 (code=exited, status=1/FAILURE) – Abbas Sep 19 '18 at 11:40
  • @Abbas: How did you install Elasticsearch 5.2.0? – Artur Barseghyan Sep 19 '18 at 11:46
  • I download the 5.2.0 deb file from https://www.elastic.co/downloads/past-releases/elasticsearch-5-2-0 and then follow the steps you mentioned in the post. – Abbas Sep 19 '18 at 11:47
  • I have set the JAVA_HOME at /etc/environment like this JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64. Do you think is it ok or not? – Abbas Sep 19 '18 at 11:52
  • When I check my log file at /var/log/elasticsearh/elasticsearch.log I found [o.e.b.Bootstrap ] Exception java.lang.IllegalStateException: No match found at java.util.regex.Matcher.group(Matcher.java:645) ~[?:?] – Abbas Sep 19 '18 at 12:01
  • 1
    @Abbas: Try Oracle Java installation (no OpenJDK). – Artur Barseghyan Sep 19 '18 at 12:03
  • 1
    @ArturBarseghyan Thank You very much. It solve the issue. Now I install the java by following http://ubuntuhandbook.org/index.php/2018/05/install-oracle-java-jdk-8-10-ubuntu-18-04/ and it is working. – Abbas Sep 19 '18 at 12:17
  • You are and angel Artur. Thanks for the help – PRashant PUrohit Aug 21 '21 at 02:37
3

Instead of starting elasticsearch with service elasticsearch start, try to start it with the following command:

sudo /usr/share/elasticsearch/bin/elasticsearch --default.config=/etc/elasticsearch/elasticsearch.yml --default.path.home=/usr/share/elasticsearch --default.path.logs=/var/log/elasticsearch --default.path.data=/var/lib/elasticsearch --default.path.work=/tmp/elasticsearch --default.path.conf=/etc/elasticsearch

And see if the output of the application is giving you any advice on what's going wrong ...

Posting the output here may help us to find the origin of the problem.

Vadorequest
  • 103
  • 4
SylvainB
  • 135
  • 7
3

It appears you have installed/updated ElasticSearch correctly and it appears to be running. You needn't re-install it.

It may be your CURL command is incomplete. Try this instead:

curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'

You should receive a json response which reads like this:

{
  "cluster_name" : "your_clusters_name",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0
}
Deer Hunter
  • 1,070
  • 7
  • 17
  • 25
JG Coding
  • 39
  • 2
0

"sudo service elastic search start

elasticsearch: unrecognised service"

I had a corrupt ElasticSearch installation.

I deleted and re-installed ElasticSearch as mentioned in (Remove previous versions of ElasticSearch:)

Problem solved, good luck