问题处理:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

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

问题复现:
通过 Docker 部署 Sonarqube 时,服务一直无法启动,查看 Docker 容器日志如下:

2019.12.18 15:06:12 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
2019.12.18 15:06:13 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2019.12.18 15:06:13 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch
2019.12.18 15:06:13 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
2019.12.18 15:06:14 INFO  app[][o.e.p.PluginsService] no modules loaded
2019.12.18 15:06:14 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
tail: './logs/es.log' has appeared;  following new file
2019.12.18 15:06:19 INFO  es[][o.e.e.NodeEnvironment] using [1] data paths, mounts [[/opt/sonarqube/data (/dev/mapper/centos-root)]], net usable_space [8.1gb], net total_space [16.9gb], types [xfs]
2019.12.18 15:06:19 INFO  es[][o.e.e.NodeEnvironment] heap size [494.9mb], compressed ordinary object pointers [true]
2019.12.18 15:06:19 INFO  es[][o.e.n.Node] node name [sonarqube], node ID [ZuBtsC2oQ4GvGSkl6JTDVA]
2019.12.18 15:06:19 INFO  es[][o.e.n.Node] version[6.8.0], pid[27], build[default/tar/65b6179/2019-05-15T20:06:13.172855Z], OS[Linux/3.10.0-1062.4.3.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/11.0.5/11.0.5+10]
2019.12.18 15:06:19 INFO  es[][o.e.n.Node] JVM arguments [-XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -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=/opt/sonarqube/temp, -XX:ErrorFile=../logs/es_hs_err_pid%p.log, -Des.enforce.bootstrap.checks=true, -Xms512m, -Xmx512m, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/opt/sonarqube/elasticsearch, -Des.path.conf=/opt/sonarqube/temp/conf/es, -Des.distribution.flavor=default, -Des.distribution.type=tar]
2019.12.18 15:06:20 INFO  es[][o.e.p.PluginsService] loaded module [analysis-common]
2019.12.18 15:06:20 INFO  es[][o.e.p.PluginsService] loaded module [lang-painless]
2019.12.18 15:06:20 INFO  es[][o.e.p.PluginsService] loaded module [mapper-extras]
2019.12.18 15:06:20 INFO  es[][o.e.p.PluginsService] loaded module [parent-join]
2019.12.18 15:06:20 INFO  es[][o.e.p.PluginsService] loaded module [percolator]
2019.12.18 15:06:20 INFO  es[][o.e.p.PluginsService] loaded module [reindex]
2019.12.18 15:06:20 INFO  es[][o.e.p.PluginsService] loaded module [repository-url]
2019.12.18 15:06:20 INFO  es[][o.e.p.PluginsService] loaded module [transport-netty4]
2019.12.18 15:06:20 INFO  es[][o.e.p.PluginsService] no plugins loaded
2019.12.18 15:06:21 WARN  es[][o.e.d.c.s.Settings] [http.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2019.12.18 15:06:23 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 78
2019.12.18 15:06:23 INFO  app[][o.s.a.SchedulerImpl] Process[es] is stopped
2019.12.18 15:06:23 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
2019.12.18 15:06:23 INFO  es[][o.e.n.Node] starting ...
2019.12.18 15:06:23 INFO  es[][o.e.t.TransportService] publish_address {127.0.0.1:9001}, bound_addresses {127.0.0.1:9001}
2019.12.18 15:06:23 INFO  es[][o.e.b.BootstrapChecks] explicitly enforcing bootstrap checks
2019.12.18 15:06:23 ERROR es[][o.e.b.Bootstrap] node validation exception
[1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2019.12.18 15:06:23 INFO  es[][o.e.n.Node] stopping ...
2019.12.18 15:06:23 INFO  es[][o.e.n.Node] stopped
2019.12.18 15:06:23 INFO  es[][o.e.n.Node] closing ...
2019.12.18 15:06:23 INFO  es[][o.e.n.Node] closed
2019.12.18 15:06:24 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
2019.12.18 15:06:24 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2019.12.18 15:06:24 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch
2019.12.18 15:06:24 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2019.12.18 15:06:24 INFO  app[][o.e.p.PluginsService] no modules loaded
2019.12.18 15:06:24 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
2019.12.18 15:06:26 INFO  es[][o.e.e.NodeEnvironment] using [1] data paths, mounts [[/opt/sonarqube/data (/dev/mapper/centos-root)]], net usable_space [8.1gb], net total_space [16.9gb], types [xfs]
2019.12.18 15:06:26 INFO  es[][o.e.e.NodeEnvironment] heap size [494.9mb], compressed ordinary object pointers [true]
2019.12.18 15:06:26 INFO  es[][o.e.n.Node] node name [sonarqube], node ID [ZuBtsC2oQ4GvGSkl6JTDVA]
2019.12.18 15:06:26 INFO  es[][o.e.n.Node] version[6.8.0], pid[27], build[default/tar/65b6179/2019-05-15T20:06:13.172855Z], OS[Linux/3.10.0-1062.4.3.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/11.0.5/11.0.5+10]
2019.12.18 15:06:26 INFO  es[][o.e.n.Node] JVM arguments [-XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -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=/opt/sonarqube/temp, -XX:ErrorFile=../logs/es_hs_err_pid%p.log, -Des.enforce.bootstrap.checks=true, -Xms512m, -Xmx512m, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/opt/sonarqube/elasticsearch, -Des.path.conf=/opt/sonarqube/temp/conf/es, -Des.distribution.flavor=default, -Des.distribution.type=tar]
2019.12.18 15:06:26 INFO  es[][o.e.p.PluginsService] loaded module [analysis-common]
2019.12.18 15:06:26 INFO  es[][o.e.p.PluginsService] loaded module [lang-painless]
2019.12.18 15:06:26 INFO  es[][o.e.p.PluginsService] loaded module [mapper-extras]
2019.12.18 15:06:26 INFO  es[][o.e.p.PluginsService] loaded module [parent-join]
2019.12.18 15:06:26 INFO  es[][o.e.p.PluginsService] loaded module [percolator]
2019.12.18 15:06:26 INFO  es[][o.e.p.PluginsService] loaded module [reindex]
2019.12.18 15:06:26 INFO  es[][o.e.p.PluginsService] loaded module [repository-url]
2019.12.18 15:06:26 INFO  es[][o.e.p.PluginsService] loaded module [transport-netty4]
2019.12.18 15:06:26 INFO  es[][o.e.p.PluginsService] no plugins loaded
2019.12.18 15:06:28 WARN  es[][o.e.d.c.s.Settings] [http.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.
2019.12.18 15:06:29 INFO  es[][o.e.d.DiscoveryModule] using discovery type [zen] and host providers [settings]
2019.12.18 15:06:29 INFO  es[][o.e.n.Node] initialized
2019.12.18 15:06:29 INFO  es[][o.e.n.Node] starting ...
2019.12.18 15:06:29 INFO  es[][o.e.t.TransportService] publish_address {127.0.0.1:9001}, bound_addresses {127.0.0.1:9001}
2019.12.18 15:06:29 INFO  es[][o.e.b.BootstrapChecks] explicitly enforcing bootstrap checks
2019.12.18 15:06:29 ERROR es[][o.e.b.Bootstrap] node validation exception
[1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2019.12.18 15:06:29 INFO  es[][o.e.n.Node] stopping ...
2019.12.18 15:06:29 INFO  es[][o.e.n.Node] stopped
2019.12.18 15:06:29 INFO  es[][o.e.n.Node] closing ...
2019.12.18 15:06:30 INFO  es[][o.e.n.Node] closed
2019.12.18 15:06:30 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 78
2019.12.18 15:06:30 INFO  app[][o.s.a.SchedulerImpl] Process[es] is stopped
2019.12.18 15:06:30 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
2019.12.18 15:06:29 INFO  es[][o.e.n.Node] starting ...
2019.12.18 15:06:29 INFO  es[][o.e.t.TransportService] publish_address {127.0.0.1:9001}, bound_addresses {127.0.0.1:9001}
2019.12.18 15:06:29 INFO  es[][o.e.b.BootstrapChecks] explicitly enforcing bootstrap checks
2019.12.18 15:06:29 ERROR es[][o.e.b.Bootstrap] node validation exception
[1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2019.12.18 15:06:29 INFO  es[][o.e.n.Node] stopping ...
2019.12.18 15:06:29 INFO  es[][o.e.n.Node] stopped
2019.12.18 15:06:29 INFO  es[][o.e.n.Node] closing ...
2019.12.18 15:06:30 INFO  es[][o.e.n.Node] closed

解决方法:

# sysctl -w vm.max_map_count=262144

这种方法会在服务器重启后失效,使用如下方法进行配置持久化:

# vim /etc/sysctl.conf
vm.max_map_count = 262144

重启之后检查配置是否生效:

# sysctl vm.max_map_count
bootstrap checks failed : max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] 这个错误是由于Elasticsearch启动时对系统进行了一系列的检查,而其中的一个检查是检查虚拟内存区域的最大数量(vm.max_map_count)是否足够高。在这个错误中,虚拟内存区域的最大数量被检测到太低了,需要至少增加到262144。 有两种解决方案可以解决这个问题。第一种是临时修改虚拟内存区域的最大数量,可以使用以下命令来修改: ``` sysctl -w vm.max_map_count=262144 ``` 第二种是永久修改虚拟内存区域的最大数量,可以使用以下命令来修改/etc/sysctl.conf文件: ``` echo vm.max_map_count=262144 >> /etc/sysctl.conf ``` 然后使用以下命令来使修改生效: ``` sysctl -p ``` 另外,如果你使用Docker运行Elasticsearch,可以在Docker run命令中添加以下参数来增加虚拟内存区域的最大数量: ``` docker run -d -p 9200:9200 -p 9300:9300 --name <自定义容器名字> -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -e "discovery.type=single-node" --sysctl vm.max_map_count=262144 <容器ID> ``` 这样就能够解决bootstrap checks failed : max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]这个错误了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ [1] bootstrap checks failed [1]: max virtual memory areas vm.max_map_count [65530] is too l](https://blog.csdn.net/qq_42704442/article/details/128000463)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [解决Docker启动Elasticsearch7.x报错的问题](https://download.csdn.net/download/weixin_38719475/14048015)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]](https://blog.csdn.net/jcmj123456/article/details/120477158)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值