技术分享

ELK Deploy Problems and Solutions

2021/04/05

正文

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

[2021-04-04T13:41:26,580][INFO ][o.e.n.Node               ] [es01] initialized
[2021-04-04T13:41:26,580][INFO ][o.e.n.Node               ] [es01] starting ...
[2021-04-04T13:41:26,679][INFO ][o.e.t.TransportService   ] [es01] publish_address {172.20.0.2:9300}, bound_addresses {0.0.0.0:9300}
[2021-04-04T13:41:26,702][INFO ][o.e.b.BootstrapChecks    ] [es01] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2021-04-04T13:41:26,729][INFO ][o.e.n.Node               ] [es01] stopping ...
[2021-04-04T13:41:26,753][INFO ][o.e.n.Node               ] [es01] stopped
[2021-04-04T13:41:26,753][INFO ][o.e.n.Node               ] [es01] closing ...
[2021-04-04T13:41:26,760][INFO ][o.e.n.Node               ] [es01] closed
[2021-04-04T13:41:26,762][INFO ][o.e.x.m.p.NativeController] [es01] Native controller process has stopped - no new native processes can be started

According to the anwser from Stack Overflow , we should use sudo sysctl -w vm.max_map_count=262144.If we set memory limit in ~/.wslconfig, however, all limits in ~/.wslconfig setting will lose their function once we use the command. That is CPU and Memory will consume a lot.

图片:Vmmem overuse

We can just remove the memory limit in ~/.wslconfig and use sudo sysctl -w vm.max_map_count=262144. However, we should type the command once we restart wsl and the way of adding vm.max_map_count=262144 to /etc/sysctl.conf not work.

Here is the solution I found as I post it in vm.max_map_count in docker-desktop distro for WSL2 #5202

version: '2.2'
services:
  elasticsearch:
    image: elasticsearch:6.8.14
    privileged: true
    user: root
    command:
      - /bin/bash
      - -c
      - |
        sysctl -w vm.max_map_count=262144 &&
        su elasticsearch -c bin/elasticsearch
    container_name: elasticsearch

As you can see in the picture below, the max_map_count number change after we running the docker compose.

图片:It works fine after using that code

And the CPU usage also controls fine.

外部图片

failed to load SSL configuration [xpack.security.transport.ssl] error

elasticsearchSecurityException[failed to load SSL configuration [xpack.security.transport.ssl]];

nested: ElasticsearchException[failed to initialize SSL TrustManager];

nested: IOException[keystore password was incorrect];

nested: UnrecoverableKeyException[failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.

I googled and found a question in a similar situation to mine.