使用elasticsearch 5.0启动新容器时失败

时间:2016-10-31 23:41:21

标签: elasticsearch docker

我跑:

$ docker run --rm -ti -p 9200:9200 -p 9300:9300 elasticsearch

但我无法启动elasticsearch 5.0,这里是日志:

Unable to find image 'elasticsearch:latest' locally
latest: Pulling from library/elasticsearch

43c265008fae: Already exists 
af36d2c7a148: Already exists 
2b7b4d10e1c1: Already exists 
9f7579daddb2: Already exists 
a985511f2468: Already exists 
6c2b485fcc3e: Already exists 
00b73c83b440: Already exists 
a38975861823: Pull complete 
b9d0b4aaf934: Pull complete 
f5f25bb3de04: Pull complete 
93426e1e8953: Pull complete 
590c2ab9b639: Pull complete 
31bf48850601: Pull complete 
21aad7ce70fa: Pull complete 
Digest: sha256:29205bca045c8d083f777dfc453f4f1ff3d2c08ea4f529f88795166c58e5607e
Status: Downloaded newer image for elasticsearch:latest
[2016-10-31T20:56:22,023][INFO ][o.e.n.Node               ] [] initializing ...
[2016-10-31T20:56:22,129][INFO ][o.e.e.NodeEnvironment    ] [N-vpIo0] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda8)]], net usable_space [48.7gb], net total_space [98.3gb], spins? [possibly], types [ext4]
[2016-10-31T20:56:22,130][INFO ][o.e.e.NodeEnvironment    ] [N-vpIo0] heap size [1.9gb], compressed ordinary object pointers [true]
[2016-10-31T20:56:22,130][INFO ][o.e.n.Node               ] [N-vpIo0] node name [N-vpIo0] derived from node ID; set [node.name] to override
[2016-10-31T20:56:22,132][INFO ][o.e.n.Node               ] [N-vpIo0] version[5.0.0], pid[1], build[253032b/2016-10-26T05:11:34.737Z], OS[Linux/3.16.0-4-amd64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_102/25.102-b14]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [aggs-matrix-stats]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [ingest-common]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [lang-expression]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [lang-groovy]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [lang-mustache]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [lang-painless]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [percolator]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [reindex]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [transport-netty3]
[2016-10-31T20:56:22,785][INFO ][o.e.p.PluginsService     ] [N-vpIo0] loaded module [transport-netty4]
[2016-10-31T20:56:22,786][INFO ][o.e.p.PluginsService     ] [N-vpIo0] no plugins loaded
[2016-10-31T20:56:22,875][WARN ][o.e.d.s.g.GroovyScriptEngineService] [groovy] scripts are deprecated, use [painless] scripts instead
[2016-10-31T20:56:24,241][INFO ][o.e.n.Node               ] [N-vpIo0] initialized
[2016-10-31T20:56:24,241][INFO ][o.e.n.Node               ] [N-vpIo0] starting ...
[2016-10-31T20:56:24,380][INFO ][o.e.t.TransportService   ] [N-vpIo0] publish_address {172.17.0.4:9300}, bound_addresses {[::]:9300}
[2016-10-31T20:56:24,389][INFO ][o.e.b.BootstrapCheck     ] [N-vpIo0] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: bootstrap checks failed
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
[2016-10-31T20:56:24,400][INFO ][o.e.n.Node               ] [N-vpIo0] stopping ...
[2016-10-31T20:56:24,426][INFO ][o.e.n.Node               ] [N-vpIo0] stopped
[2016-10-31T20:56:24,426][INFO ][o.e.n.Node               ] [N-vpIo0] closing ...
[2016-10-31T20:56:24,433][INFO ][o.e.n.Node               ] [N-vpIo0] closed

请问,我该如何解决这个问题?

2 个答案:

答案 0 :(得分:6)

主机设置部分中的Docker image documentation所述:

  

注意:自5.0以来,Elasticsearch默认只侦听localhost,   所以这个图像将network.host设置为0.0.0.0(假设localhost是   在Docker上下文中并不十分有用。)

     

因此,Elasticsearch对引导程序检查更加严格   它执行,特别是在检查值时   vm.max_map_count,它不是命名空间,因此必须设置为   主机上可接受的值(而不是简单地使用--sysctl on   docker run)。

所以你只需要在主机上执行它:

sysctl -w vm.max_map_count=262144

你很高兴使用5.0.0版本

要永久设置此值,请更新vm.max_map_count中的/etc/sysctl.conf设置。要在重新启动后进行验证,请运行sysctl vm.max_map_count

More information here

答案 1 :(得分:1)

这是与虚拟内存设置相关的问题,以下命令应该有效:

sysctl -w vm.max_map_count=262144

更多细节可以在https://www.elastic.co/guide/en/elasticsearch/reference/5.0/vm-max-map-count.html

找到