0

elasticsearch version : elasticsearch-5.2.0

elasticsearch-head version : latest version

Start service successfully:

#### node1 ####
deMacBook-Pro:bin yyq$ ./elasticsearch
[2017-02-15T13:08:57,174][INFO ][o.e.n.Node               ] [yml-es-node-1] initializing ...
[2017-02-15T13:08:57,303][INFO ][o.e.e.NodeEnvironment    ] [yml-es-node-1] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [21.4gb], net total_space [232.6gb], spins? [unknown], types [hfs]
[2017-02-15T13:08:57,304][INFO ][o.e.e.NodeEnvironment    ] [yml-es-node-1] heap size [1.9gb], compressed ordinary object pointers [true]
[2017-02-15T13:08:57,355][INFO ][o.e.n.Node               ] [yml-es-node-1] node name [yml-es-node-1], node ID [hqVAcDOdRu-LXuAgUEX9oQ]
[2017-02-15T13:08:57,358][INFO ][o.e.n.Node               ] [yml-es-node-1] version[5.2.0], pid[93922], build[24e05b9/2017-01-24T19:52:35.800Z], OS[Mac OS X/10.11.6/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_25/25.25-b02]
[2017-02-15T13:08:58,802][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [aggs-matrix-stats]
[2017-02-15T13:08:58,803][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [ingest-common]
[2017-02-15T13:08:58,803][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [lang-expression]
[2017-02-15T13:08:58,803][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [lang-groovy]
[2017-02-15T13:08:58,803][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [lang-mustache]
[2017-02-15T13:08:58,803][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [lang-painless]
[2017-02-15T13:08:58,803][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [percolator]
[2017-02-15T13:08:58,804][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [reindex]
[2017-02-15T13:08:58,804][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [transport-netty3]
[2017-02-15T13:08:58,804][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] loaded module [transport-netty4]
[2017-02-15T13:08:58,805][INFO ][o.e.p.PluginsService     ] [yml-es-node-1] no plugins loaded
[2017-02-15T13:09:02,610][INFO ][o.e.n.Node               ] [yml-es-node-1] initialized
[2017-02-15T13:09:02,610][INFO ][o.e.n.Node               ] [yml-es-node-1] starting ...
[2017-02-15T13:09:02,953][INFO ][o.e.t.TransportService   ] [yml-es-node-1] publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}
[2017-02-15T13:09:06,125][INFO ][o.e.c.s.ClusterService   ] [yml-es-node-1] detected_master {yml-es-node-2}{FWhiCkI7TV6hJOlmT_fgQg}{URIaxsK2T0aP7jRRe6TDfg}{127.0.0.1}{127.0.0.1:9301}, added {{yml-es-node-2}{FWhiCkI7TV6hJOlmT_fgQg}{URIaxsK2T0aP7jRRe6TDfg}{127.0.0.1}{127.0.0.1:9301},}, reason: zen-disco-receive(from master [master {yml-es-node-2}{FWhiCkI7TV6hJOlmT_fgQg}{URIaxsK2T0aP7jRRe6TDfg}{127.0.0.1}{127.0.0.1:9301} committed version [385]])
[2017-02-15T13:09:06,175][INFO ][o.e.h.HttpServer         ] [yml-es-node-1] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}
[2017-02-15T13:09:06,175][INFO ][o.e.n.Node               ] [yml-es-node-1] started

#### node2 ####
deMacBook-Pro:bin yyq$ ./elasticsearch
[2017-02-15T10:31:03,936][INFO ][o.e.n.Node               ] [yml-es-node-2] initializing ...
[2017-02-15T10:31:04,087][INFO ][o.e.e.NodeEnvironment    ] [yml-es-node-2] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [19.3gb], net total_space [232.6gb], spins? [unknown], types [hfs]
[2017-02-15T10:31:04,087][INFO ][o.e.e.NodeEnvironment    ] [yml-es-node-2] heap size [1.9gb], compressed ordinary object pointers [true]
[2017-02-15T10:31:04,104][INFO ][o.e.n.Node               ] [yml-es-node-2] node name [yml-es-node-2], node ID [FWhiCkI7TV6hJOlmT_fgQg]
[2017-02-15T10:31:04,112][INFO ][o.e.n.Node               ] [yml-es-node-2] version[5.2.0], pid[85158], build[24e05b9/2017-01-24T19:52:35.800Z], OS[Mac OS X/10.11.6/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_25/25.25-b02]
[2017-02-15T10:31:05,830][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [aggs-matrix-stats]
[2017-02-15T10:31:05,830][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [ingest-common]
[2017-02-15T10:31:05,830][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [lang-expression]
[2017-02-15T10:31:05,830][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [lang-groovy]
[2017-02-15T10:31:05,830][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [lang-mustache]
[2017-02-15T10:31:05,830][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [lang-painless]
[2017-02-15T10:31:05,831][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [percolator]
[2017-02-15T10:31:05,831][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [reindex]
[2017-02-15T10:31:05,831][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [transport-netty3]
[2017-02-15T10:31:05,831][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] loaded module [transport-netty4]
[2017-02-15T10:31:05,832][INFO ][o.e.p.PluginsService     ] [yml-es-node-2] no plugins loaded
[2017-02-15T10:31:09,871][INFO ][o.e.n.Node               ] [yml-es-node-2] initialized
[2017-02-15T10:31:09,871][INFO ][o.e.n.Node               ] [yml-es-node-2] starting ...
[2017-02-15T10:31:10,171][INFO ][o.e.t.TransportService   ] [yml-es-node-2] publish_address {127.0.0.1:9301}, bound_addresses {[fe80::1]:9301}, {[::1]:9301}, {127.0.0.1:9301}
[2017-02-15T10:31:13,327][INFO ][o.e.c.s.ClusterService   ] [yml-es-node-2] detected_master {yml-es-node-1}{hqVAcDOdRu-LXuAgUEX9oQ}{VrY6MUvhQNetUmbzcRnKMg}{127.0.0.1}{127.0.0.1:9300}, added {{yml-es-node-1}{hqVAcDOdRu-LXuAgUEX9oQ}{VrY6MUvhQNetUmbzcRnKMg}{127.0.0.1}{127.0.0.1:9300},}, reason: zen-disco-receive(from master [master {yml-es-node-1}{hqVAcDOdRu-LXuAgUEX9oQ}{VrY6MUvhQNetUmbzcRnKMg}{127.0.0.1}{127.0.0.1:9300} committed version [223]])
[2017-02-15T10:31:13,388][INFO ][o.e.h.HttpServer         ] [yml-es-node-2] publish_address {127.0.0.1:9201}, bound_addresses {[fe80::1]:9201}, {[::1]:9201}, {127.0.0.1:9201}
[2017-02-15T10:31:13,388][INFO ][o.e.n.Node               ] [yml-es-node-2] started

deMacBook-Pro:elasticsearch-head-master yyq$ grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

When I opened the url:http://localhost:9100 and clicked [connect] button, but I'm unable to connect to elasticsearch. Could anyone help me? This is the screenshot

Alex
  • 19
  • 2
  • 8

2 Answers2

0

In your elasticsearch.yml configuration, you probably have the following setting:

http.port: 9201

This is also visible in your logs:

[...] publish_address {127.0.0.1:9201}, bound_addresses {[fe80::1]:9201}, {[::1]:9201}, {127.0.0.1:9201}
                                  ^
                                  |
                            your HTTP port 

So in your elasticsearch-head interface, you need to connect to localhost:9201 not localhost:9200.

UPDATE

You also need to add http.cors.enabled: true in your elasticsearch.yml configuration and restart your ES server

Val
  • 207,596
  • 13
  • 358
  • 360
  • In my computer, there are two instance,[yml-es-node-1]'s port is 9200,[yml-es-node-2]'s port is 9201. when i changed to http://localhost:9201, also can't connection. – Alex Feb 15 '17 at 05:12
  • Is yml-es-node-1 running? – Val Feb 15 '17 at 05:14
  • If you open the Developer console of your browser, what do you see in the Network pane? – Val Feb 15 '17 at 05:15
  • XMLHttpRequest cannot load http://localhost:9200/_cluster/health. Origin http://localhost:9100 is not allowed by Access-Control-Allow-Origin. – Alex Feb 15 '17 at 05:20
  • Then you need to add `http.cors.enabled: true` in your `elasticsearch.yml` configuration and restart your ES server – Val Feb 15 '17 at 05:21
  • thanks for your reminding,when i setting [http.cors.enabled: true] and [http.cors.allow-origin: /http?:\/\/localhost(:[0-9]+)?/] in my elasticsearch.yml, and restart service, i can access the http://localhost:9200. thanks a lot... – Alex Feb 15 '17 at 05:35
0

As mentioned in the previous post, to be able to run the head plugin to check the health status of the ElastiSearch cluster, you need to enable the CORS's environmental variables. One way is to mount the config file for ES as described here. Alternatively, you can define the environmental variables directly in your docker-compose as documented in this GitHub issue. I am adding the code below for completeness, which worked for me:

version: '3'
services:
    # search engine
    elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.1
        container_name: elasticsearch
        environment:
            - discovery.type=single-node
            - http.port=9200
            - http.cors.enabled=true
            - http.cors.allow-origin=http://localhost:1358,http://127.0.0.1:1358
            - http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
            - http.cors.allow-credentials=true
            - bootstrap.memory_lock=true
            - 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
        ports:
            - '9200:9200'
            - '9300:9300'
    # elasticsearch browser
    dejavu:
        image: appbaseio/dejavu:3.2.3
        container_name: dejavu
        ports:
            - '1358:1358'
        links:
            - elasticsearch

Note that using - http.cors.allow-origin=* works and it could be handy for certain development setups.

K F
  • 1,368
  • 13
  • 20