LoginSignup
3
1

More than 5 years have passed since last update.

コマンドライン2行:ElasticSearch + Kibana 環境を Docker on Mac で作る(2018年5月時点)

Last updated at Posted at 2018-05-29

TL;DR

既に Docker はインストールされている前提ですが、以下のコマンド2行で行けます。

$ docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.2.4
$ docker run -p 5601:5601 -e ELASTICSEARCH_URL=http://docker.for.mac.host.internal:9200/ docker.elastic.co/kibana/kibana:6.2.4

以下詳細

ElasticSearch について

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.2.4

このコマンドで、ElasticSearch が起動してドキュメントを Index 可能な状態になります。

ローカルマシーンの 9200 ポートに、コンテナ内の ElasticSearch がバインドされるので、何かしたいときには localhost:9200 に投げれば OK です。

ログ

[2018-05-29T04:52:33,705][INFO ][o.e.n.Node               ] [] initializing ...
[2018-05-29T04:52:33,801][INFO ][o.e.e.NodeEnvironment    ] [XkZJKRm] using [1] data paths, mounts [[/ (overlay)]], net usable_space [52gb], net total_space [58.4gb], types [overlay]
[2018-05-29T04:52:33,802][INFO ][o.e.e.NodeEnvironment    ] [XkZJKRm] heap size [1007.3mb], compressed ordinary object pointers [true]
[2018-05-29T04:52:33,804][INFO ][o.e.n.Node               ] node name [XkZJKRm] derived from node ID [XkZJKRmkQuiBNo27F98H_Q]; set [node.name] to override
[2018-05-29T04:52:33,804][INFO ][o.e.n.Node               ] version[6.2.4], pid[1], build[ccec39f/2018-04-12T20:37:28.497551Z], OS[Linux/4.9.87-linuxkit-aufs/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_161/25.161-b14]
[2018-05-29T04:52:33,805][INFO ][o.e.n.Node               ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.k4dX3j1T, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.cgroups.hierarchy.override=/, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config]
[2018-05-29T04:52:36,461][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [aggs-matrix-stats]
[2018-05-29T04:52:36,461][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [analysis-common]
[2018-05-29T04:52:36,462][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [ingest-common]
[2018-05-29T04:52:36,462][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [lang-expression]
[2018-05-29T04:52:36,462][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [lang-mustache]
[2018-05-29T04:52:36,462][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [lang-painless]
[2018-05-29T04:52:36,463][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [mapper-extras]
[2018-05-29T04:52:36,463][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [parent-join]
[2018-05-29T04:52:36,463][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [percolator]
[2018-05-29T04:52:36,463][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [rank-eval]
[2018-05-29T04:52:36,464][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [reindex]
[2018-05-29T04:52:36,464][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [repository-url]
[2018-05-29T04:52:36,464][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [transport-netty4]
[2018-05-29T04:52:36,464][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded module [tribe]
[2018-05-29T04:52:36,465][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [ingest-geoip]
[2018-05-29T04:52:36,465][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [ingest-user-agent]
[2018-05-29T04:52:36,465][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [x-pack-core]
[2018-05-29T04:52:36,465][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [x-pack-deprecation]
[2018-05-29T04:52:36,466][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [x-pack-graph]
[2018-05-29T04:52:36,467][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [x-pack-logstash]
[2018-05-29T04:52:36,467][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [x-pack-ml]
[2018-05-29T04:52:36,468][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [x-pack-monitoring]
[2018-05-29T04:52:36,468][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [x-pack-security]
[2018-05-29T04:52:36,468][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [x-pack-upgrade]
[2018-05-29T04:52:36,468][INFO ][o.e.p.PluginsService     ] [XkZJKRm] loaded plugin [x-pack-watcher]
[2018-05-29T04:52:40,799][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/103] [Main.cc@128] controller (64 bit): Version 6.2.4 (Build 524e7fe231abc1) Copyright (c) 2018 Elasticsearch BV
[2018-05-29T04:52:42,373][INFO ][o.e.d.DiscoveryModule    ] [XkZJKRm] using discovery type [single-node]
[2018-05-29T04:52:43,690][INFO ][o.e.n.Node               ] initialized
[2018-05-29T04:52:43,690][INFO ][o.e.n.Node               ] [XkZJKRm] starting ...
[2018-05-29T04:52:43,939][INFO ][o.e.t.TransportService   ] [XkZJKRm] publish_address {172.17.0.2:9300}, bound_addresses {0.0.0.0:9300}
[2018-05-29T04:52:43,997][INFO ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [XkZJKRm] publish_address {172.17.0.2:9200}, bound_addresses {0.0.0.0:9200}
[2018-05-29T04:52:43,998][INFO ][o.e.n.Node               ] [XkZJKRm] started
[2018-05-29T04:52:44,215][INFO ][o.e.g.GatewayService     ] [XkZJKRm] recovered [0] indices into cluster_state
[2018-05-29T04:52:44,804][INFO ][o.e.l.LicenseService     ] [XkZJKRm] license [7d2821ee-bdf1-46d1-bce0-7e374f6e7e2e] mode [basic] - valid
[2018-05-29T04:52:53,850][INFO ][o.e.c.m.MetaDataCreateIndexService] [XkZJKRm] [.monitoring-es-6-2018.05.29] creating index, cause [auto(bulk api)], templates [.monitoring-es], shards [1]/[0], mappings [doc]
[2018-05-29T04:52:54,113][INFO ][o.e.c.r.a.AllocationService] [XkZJKRm] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[.monitoring-es-6-2018.05.29][0]] ...]).

起動確認

% curl -S -v localhost:9200                                                                                                                                 [master>] /Users/JP20217
* Rebuilt URL to: localhost:9200/
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9200 (#0)
> GET / HTTP/1.1
> Host: localhost:9200
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< content-type: application/json; charset=UTF-8
< content-length: 436
<
{
  "name" : "XkZJKRm",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "crBVi6wRSqGBbanzRgQQEQ",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

Kibana について

docker run -p 5601:5601 -e "ELASTICSEARCH_URL=http://docker.for.mac.host.internal:9200/" docker.elastic.co/kibana/kibana:6.2.4

同じく docker.elastic.co/kibana/kibana:6.2.4 をとってきて起動するだけですが、ElasticSearch と繋ぐための設定が必要です。

-e ELASTICSEARCH_URL=http://docker.for.mac.host.internal:9200/ とやると、環境変数を起動して Kibana が http://docker.for.mac.host.internal:9200/ の ElasticSearch に接続しに行きます。

docker.for.mac.host.internal は Docker Container の中で見える、ホスト(Mac)を示す名前です。

Docker の中から localhost とやっても、それはコンテナの中の localhost なので、隣の ElasticSearch は見えない。

起動ログ

{"type":"log","@timestamp":"2018-05-29T05:03:12Z","tags":["status","plugin:kibana@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:12Z","tags":["status","plugin:elasticsearch@6.2.4","info"],"pid":1,"state":"yellow","message":"Status changed from uninitialized to yellow - Waiting for Elasticsearch","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:12Z","tags":["status","plugin:xpack_main@6.2.4","info"],"pid":1,"state":"yellow","message":"Status changed from uninitialized to yellow - Waiting for Elasticsearch","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:12Z","tags":["status","plugin:searchprofiler@6.2.4","info"],"pid":1,"state":"yellow","message":"Status changed from uninitialized to yellow - Waiting for Elasticsearch","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:12Z","tags":["status","plugin:ml@6.2.4","info"],"pid":1,"state":"yellow","message":"Status changed from uninitialized to yellow - Waiting for Elasticsearch","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:12Z","tags":["status","plugin:tilemap@6.2.4","info"],"pid":1,"state":"yellow","message":"Status changed from uninitialized to yellow - Waiting for Elasticsearch","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:12Z","tags":["status","plugin:watcher@6.2.4","info"],"pid":1,"state":"yellow","message":"Status changed from uninitialized to yellow - Waiting for Elasticsearch","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:12Z","tags":["status","plugin:license_management@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:13Z","tags":["status","plugin:timelion@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:13Z","tags":["status","plugin:graph@6.2.4","info"],"pid":1,"state":"yellow","message":"Status changed from uninitialized to yellow - Waiting for Elasticsearch","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:13Z","tags":["status","plugin:monitoring@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["reporting","warning"],"pid":1,"message":"Generating a random key for xpack.reporting.encryptionKey. To prevent pending reports from failing on restart, please set xpack.reporting.encryptionKey in kibana.yml"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:reporting@6.2.4","info"],"pid":1,"state":"yellow","message":"Status changed from uninitialized to yellow - Waiting for Elasticsearch","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:xpack_main@6.2.4","error"],"pid":1,"state":"red","message":"Status changed from yellow to red - Request Timeout after 3000ms","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:searchprofiler@6.2.4","error"],"pid":1,"state":"red","message":"Status changed from yellow to red - Request Timeout after 3000ms","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:ml@6.2.4","error"],"pid":1,"state":"red","message":"Status changed from yellow to red - Request Timeout after 3000ms","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:tilemap@6.2.4","error"],"pid":1,"state":"red","message":"Status changed from yellow to red - Request Timeout after 3000ms","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:watcher@6.2.4","error"],"pid":1,"state":"red","message":"Status changed from yellow to red - Request Timeout after 3000ms","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:graph@6.2.4","error"],"pid":1,"state":"red","message":"Status changed from yellow to red - Request Timeout after 3000ms","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:reporting@6.2.4","error"],"pid":1,"state":"red","message":"Status changed from yellow to red - Request Timeout after 3000ms","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:elasticsearch@6.2.4","error"],"pid":1,"state":"red","message":"Status changed from yellow to red - Request Timeout after 3000ms","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["license","info","xpack"],"pid":1,"message":"Imported license information from Elasticsearch for the [data] cluster: mode: basic | status: active | expiry date: 2018-06-28T04:52:44+00:00"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:xpack_main@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Request Timeout after 3000ms"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:searchprofiler@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Request Timeout after 3000ms"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:ml@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Request Timeout after 3000ms"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:tilemap@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Request Timeout after 3000ms"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:watcher@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Request Timeout after 3000ms"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:graph@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Request Timeout after 3000ms"}
{"type":"log","@timestamp":"2018-05-29T05:03:16Z","tags":["status","plugin:reporting@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Request Timeout after 3000ms"}
{"type":"log","@timestamp":"2018-05-29T05:03:17Z","tags":["info","monitoring-ui","kibana-monitoring"],"pid":1,"message":"Stopping all Kibana monitoring collectors"}
{"type":"log","@timestamp":"2018-05-29T05:03:17Z","tags":["license","info","xpack"],"pid":1,"message":"Imported license information from Elasticsearch for the [monitoring] cluster: mode: basic | status: active | expiry date: 2018-06-28T04:52:44+00:00"}
{"type":"log","@timestamp":"2018-05-29T05:03:20Z","tags":["info","monitoring-ui","kibana-monitoring"],"pid":1,"message":"Starting all Kibana monitoring collectors"}
{"type":"log","@timestamp":"2018-05-29T05:03:20Z","tags":["status","plugin:elasticsearch@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Request Timeout after 3000ms"}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["status","plugin:security@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["security","warning"],"pid":1,"message":"Generating a random key for xpack.security.encryptionKey. To prevent sessions from being invalidated on restart, please set xpack.security.encryptionKey in kibana.yml"}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["security","warning"],"pid":1,"message":"Session cookies will be transmitted over insecure connections. This is not recommended."}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["status","plugin:grokdebugger@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["status","plugin:dashboard_mode@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["status","plugin:logstash@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["status","plugin:apm@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["status","plugin:console@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["status","plugin:metrics@6.2.4","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}
{"type":"log","@timestamp":"2018-05-29T05:03:33Z","tags":["listening","info"],"pid":1,"message":"Server running at http://0:5601"}
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1