其实这个问题没有真正解决,只是迫不得已的方法。

问题描述

  • 首先是笔者的系统信息

    $ uname -a
    Linux XPS 4.8.0-46-generic #49-Ubuntu SMP Fri Mar 31 13:57:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    
  • 接下来下载apt自带的elasticsearch

    $ sudo apt install elasticsearch
    
  • 下载非常的顺利,但是访问http://localhost:9200是拒绝访问的

  • 接下来我们看看这时候elasticsearch的服务状态,大致是这样的

elasticsearch.service - LSB: Starts elasticsearch
Loaded: loaded (/etc/init.d/elasticsearch; bad; vendor preset: enabled)
Active: active (exited) since Thu 2017-04-21 12:03:54 EDT; 32min ago
Docs: man:systemd-sysv-generator(8)
Process: 1192 ExecStart=/etc/init.d/elasticsearch start (code=exited, status=0
Tasks: 0 (limit: 512)

Apr 21 12:03:54 rubix2 systemd[1]: Starting LSB: Starts elasticsearch…
Apr 21 12:03:54 rubix2 systemd[1]: Started LSB: Starts elasticsearch.
Apr 21 12:36:19 rubix2 systemd[1]: Started LSB: Starts elasticsearch.

可以看到这里其实是active的,但是就是不能访问,并且所有的日志文件夹都是空的。

  • 然后笔者看到了一个回答,测试了一下
It seems that to get Elasticsearch to run on 16.04 you have to set START_DAEMON to true on /etc/default/elasticsearch. It comes commented out by default, and uncommenting it makes Elasticsearch start again just fine.

Be sure to use systemctl restart instead of just start because the service is started right after installation, and apparently there’s some socket/pidfile/something that systemd keeps that must be released before being able to start the service again — I didn’t bother to track that down, feel free to look for it .

大致的意思就是去把/etc/default/elasticsearch中的START_DAEMON前的#号删除,并且重启服务,好像很多人都是通过这个方式解决的,但是笔者试验后并没有解决问题。

最后的不能称为解决方法的解决方法

去官网根据手册下载了最新的版本的elasticsearch

sudo apt-get install openjdk-8-jre
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.1.deb
sudo dpkg -i elasticsearch-5.3.1.deb
sudo /etc/init.d/elasticsearch start

解决了….