{"id":1488,"date":"2021-10-19T12:29:58","date_gmt":"2021-10-19T04:29:58","guid":{"rendered":"https:\/\/www.siediyer.cn\/?p=1488"},"modified":"2021-10-19T12:29:58","modified_gmt":"2021-10-19T04:29:58","slug":"elasticsearch-bootstrap-memory_lock","status":"publish","type":"post","link":"https:\/\/www.siediyer.cn\/?p=1488","title":{"rendered":"elasticsearch bootstrap.memory_lock"},"content":{"rendered":"<p>\u7531\u4e8e\u5f53jvm\u5f00\u59cbswapping\u65f6es\u7684\u6548\u7387\u4f1a\u964d\u4f4e\uff0c\u6240\u4ee5\u8981\u4fdd\u8bc1\u5b83\u4e0dswap\uff0c\u8fd9\u5bf9\u8282\u70b9\u5065\u5eb7\u6781\u5176\u91cd\u8981\u3002\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u7684\u4e00\u79cd\u65b9\u6cd5\u662f\u5c06\u00a0bootstrap.memory_lock\u00a0\u8bbe\u7f6e\u4e3atrue\u3002<br \/>\n\u8981\u4f7f\u6b64\u8bbe\u7f6e\u6709\u6548\uff0c\u9996\u5148\u9700\u8981\u914d\u7f6e\u5176\u4ed6\u7cfb\u7edf\u8bbe\u7f6e\u3002\u6709\u5173\u5982\u4f55\u6b63\u786e\u8bbe\u7f6e\u5185\u5b58\u9501\u5b9a\u7684\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u542f\u7528bootstrap.memory_lock\u3002<\/p>\n<p>bootstrap.memory_lock: \u662f\u5426\u9501\u4f4f\u5185\u5b58\uff0c\u907f\u514d\u4ea4\u6362(swapped)\u5e26\u6765\u7684\u6027\u80fd\u635f\u5931,\u9ed8\u8ba4\u503c\u662f: false<br \/>\nbootstrap.system_call_filter: \u662f\u5426\u652f\u6301\u8fc7\u6ee4\u6389\u7cfb\u7edf\u8c03\u7528\u3002elasticsearch 5.2\u4ee5\u540e\u5f15\u5165\u7684\u529f\u80fd\uff0c\u5728bootstrap\u7684\u65f6\u5019check\u662f\u5426\u652f\u6301seccomp\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\u68c0\u67e5bootstrap.memory_lock\u8bbe\u7f6e\u662f\u5426\u751f\u6548:\r\ncurl http:\/\/127.0.0.1:9200\/_nodes?filter_path=**.mlockall\r\n\r\n\u54cd\u5e94\uff1a\r\n{\r\n    \"nodes\": {\r\n        \"9giihmDNRdS136KT52Gl5g\": {\r\n            \"process\": {\r\n                \"mlockall\": true\r\n            }\r\n        },\r\n        \"X0zQESeeT8uJ9kVXvHpl-w\": {\r\n            \"process\": {\r\n                \"mlockall\": true\r\n            }\r\n        },\r\n        \"w4hYw86rQhqL1ayGyUK1Kw\": {\r\n            \"process\": {\r\n                \"mlockall\": true\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u5982\u679c\u770b\u5230mlockall\u4e3afalse\uff0c\u5219\u8868\u793amlockall\u8bf7\u6c42\u5931\u8d25\u3002\u8fd8\u5c06\u5728\u65e5\u5fd7\u4e2d\u770b\u5230\u4e00\u884c\u201dUnable to lock JVM Memory\u201d\u3002<\/p>\n<h5 id=\"elasticsearch\u62a5\u9519\u4e4b-memory-locking-requested-for-elasticsearch-process-but-memory-is-not-locked\">elasticsearch\u62a5\u9519\u4e4b memory locking requested for elasticsearch process but memory is not locked:<\/h5>\n<p>\u5b89\u88c5elasticsearch\u62a5\u9519\u5982\u4e0b\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">[2019-01-14T03:57:16,453][ERROR][o.e.b.Bootstrap          ] [ip-172-31-30-62.ec2.internal] node validation exception\r\n[1] bootstrap checks failed\r\n[1]: memory locking requested for elasticsearch process but memory is not locked<\/pre>\n<p>\u7f51\u4e0a\u67e5\u627e\u8d44\u6599\uff0c\u53d1\u73b0\u90fd\u4e0d\u662f\u9002\u5e94\u81ea\u5df1\u7684\u73af\u5883\u3002\u6700\u540e\u5728\u5b98\u7f51\u627e\u5230\u4e86\u65b9\u6cd5\uff1a<\/p>\n<p>\u4e0d\u8fc7\u5148\u8ddf\u5927\u5bb6\u58f0\u660e\u4e00\u70b9\u5c31\u662f\uff1a\u73af\u5883\u4e0d\u4e00\u6837\u89e3\u51b3\u7684\u65b9\u6cd5\u4e5f\u4e0d\u4e00\u6837\uff0c\u8fd9\u91cc\u662fCentos7.5\u7248\u672c\u7684\u7cfb\u7edf\uff0c\u6240\u6709\u7684\u670d\u52a1\u90fd\u7531systemd\u6765\u7ba1\u7406\u3002elasticsearch\u662f6.5.4\u7248\u672c\uff0c\u4f7f\u7528RPM\u5305\u7684\u65b9\u5f0f\u5b89\u88c5\u7684\u3002<\/p>\n<p>\u73b0\u5728\u6211\u4eec\u5f00\u59cb\u89e3\u51b3\u95ee\u9898\uff1a<\/p>\n<h6 id=\"1\u3001\u4fee\u6539-etc-sysconfig-elasticsearch\u6587\u4ef6\u8c03\u6574JVM\u5185\u5b58\u5927\u5c0f\">1\u3001\u4fee\u6539\/etc\/sysconfig\/elasticsearch\u6587\u4ef6\u8c03\u6574JVM\u5185\u5b58\u5927\u5c0f<\/h6>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#ES_JAVA_OPTS=\"-Xms16g -Xmx16g\" (\u5185\u5b58\u5927\u5c0f\u4e5f\u53ef\u4ee5\u5728\/etc\/elasticsearch\/jvm.options\u914d\u7f6e\u6587\u4ef6\u4e2d\u5b9a\u4e49\uff0c\u6216\u8005ES_HEAP_SIZE=16g)\r\nJAVA_HOME=\/usr\/java\/jdk1.8.0_51\r\nES_HEAP_SIZE=16g\r\nMAX_OPEN_FILES=655350\r\nMAX_LOCKED_MEMORY=unlimited<\/pre>\n<p>\u66ff\u636216g\u4e3a\u603b\u5185\u5b58\u7684\u4e00\u534a\uff08Elasticsearch\u5b98\u65b9\u5efa\u8bae\u662f\u4e3b\u673a\u603b\u5185\u5b58\u7684\u4e00\u534a\uff09<\/p>\n<h6 id=\"2\u3001\u4fee\u6539-etc-security-limits-conf\u6587\u4ef6\u5185\u5bb9\">2\u3001\u4fee\u6539\/etc\/security\/limits.conf\u6587\u4ef6\u5185\u5bb9<\/h6>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">elasticsearch soft memlock unlimited\r\nelasticsearch hard memlock unlimited<\/pre>\n<p>\u9700\u8981\u5c06elasticsearch\u66ff\u6362\u4e3a\u8fd0\u884cElasticsearch\u7a0b\u5e8f\u7684\u7528\u6237,\u4f7f\u7528root\u6267\u884c\uff1aservice elasticsearch start\u5b9e\u9645\u4e0a\u662f\u4ee5elasticsearch\u7528\u6237\u6765\u6267\u884c<\/p>\n<h6 id=\"3\u3001\u5728-etc-systemd-system-elasticsearch-service-d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6override-conf\uff0c\u5e76\u6dfb\u52a0\u4e0b\u5217\u5185\u5bb9\">3\u3001\u5728\/etc\/systemd\/system\/elasticsearch.service.d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6override.conf\uff0c\u5e76\u6dfb\u52a0\u4e0b\u5217\u5185\u5bb9<\/h6>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">[Service]\r\nLimitMEMLOCK=infinity\r\n\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003\uff1ahttps:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/setting-system-settings.html#systemd<\/pre>\n<h6 id=\"4\u3001\u6700\u540e\u91cd\u65b0\u8f7d\u5165\u914d\u7f6e\u6587\u4ef6\u66f4\u65b0\u670d\u52a1\">4\u3001\u6700\u540e\u91cd\u65b0\u8f7d\u5165\u914d\u7f6e\u6587\u4ef6\u66f4\u65b0\u670d\u52a1<\/h6>\n<p>systemctl daemon-reload<\/p>\n<h6 id=\"5\u3001\u91cd\u542felasticsearch\">5\u3001\u91cd\u542felasticsearch<\/h6>\n<p>service elasticsearch restart<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7531\u4e8e\u5f53jvm\u5f00\u59cbswapping\u65f6es\u7684\u6548\u7387\u4f1a\u964d\u4f4e\uff0c\u6240\u4ee5\u8981\u4fdd\u8bc1\u5b83\u4e0dswap\uff0c\u8fd9\u5bf9\u8282\u70b9\u5065\u5eb7\u6781\u5176\u91cd\u8981\u3002\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[108,109],"class_list":["post-1488","post","type-post","status-publish","format-standard","hentry","category-linux","tag-elasticsearch","tag-memory_lock"],"_links":{"self":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/1488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1488"}],"version-history":[{"count":1,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/1488\/revisions"}],"predecessor-version":[{"id":1489,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/1488\/revisions\/1489"}],"wp:attachment":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}