{"id":1677,"date":"2023-03-25T22:30:52","date_gmt":"2023-03-25T14:30:52","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1677"},"modified":"2023-04-23T21:49:17","modified_gmt":"2023-04-23T13:49:17","slug":"elasticsearch-common-exceptions","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/elasticsearch-common-exceptions\/","title":{"rendered":"ElasticSearch \u5e38\u89c1\u5f02\u5e38"},"content":{"rendered":"<p><strong>1. Cannot open file logs\/gc.log due to Permission denied<\/strong><\/p>\n<p>\u4e0d\u80fd\u7528root\u8d26\u6237\u542f\u52a8ES\uff0c\u9700\u8981\u7528ES\u8d26\u6237\u542f\u52a8<code>su essearch .\/bin\/elasticsearch<\/code><\/p>\n<p>\u5982\u679c\u51fa\u73b0\u4ee5\u4e0a\u95ee\u9898\uff0c\u5219\u662f\u56e0\u4e3a\u7528root\u542f\u52a8\u8fc7\u5bfc\u81f4\u3002\u5230ElasticSearch\u4e2d\u7684log\u4e2d\u5220\u9664<code>gc.log<\/code>\u6587\u4ef6\u5373\u53ef<\/p>\n<p><!-- more --><\/p>\n<p><strong>2. ElasticSearch \u542f\u52a8\u4e0d\u8d77\u6765<\/strong><\/p>\n<p>\u5f53Logstash\u6b63\u5927\u91cf\u62e5\u5835\u8981\u5199\u5165\u7684\u6570\u636e\u65f6\uff0cES\u662f\u65e0\u6cd5\u542f\u52a8\u7684\uff0c\u8d1f\u8f7d\u592a\u9ad8\uff0c\u9700\u8981\u4e34\u65f6\u505c\u6b62Logstash\u4f5c\u4e1a<\/p>\n<p><strong>3. \u5065\u5eb7\u72b6\u6001\u4e00\u76f4\u5904\u4e8e\u8b66\u544a\uff0cES\u574f\u8282\u70b9\u8f83\u591a\uff0c\u65e0\u6cd5\u5206\u7247<\/strong><\/p>\n<pre><code class=\"language-bash\">#\u91cd\u65b0\u5206\u914d\nPOST \/_cluster\/reroute?retry_failed=true\n#\u67e5\u770b\u96c6\u7fa4\u72b6\u6001\nGET _cluster\/health?pretty<\/code><\/pre>\n<p><strong>4. logstash\u542f\u52a8<\/strong><\/p>\n<pre><code class=\"language-bash\">nohup bin\/logstash -f config\/kafka2es.conf &amp;&gt;\/dev\/null &amp;<\/code><\/pre>\n<p><strong>5. Validation Failed: 1: this action would add [1] total shards, but this cluster currently has [1000]<\/strong><\/p>\n<pre><code class=\"language-bash\">[2021-04-12T03:41:01,723][WARN ][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=&gt;400, :action=&gt;[&quot;index&quot;, {:_id=&gt;nil, :_index=&gt;&quot;appblog-2021.02.12&quot;, :_type=&gt;&quot;_doc&quot;, :routing=&gt;nil}, #&lt;LogStash::Event:0x53ee69a7&gt;], :response=&gt;{&quot;index&quot;=&gt;{&quot;_index&quot;=&gt;&quot;appblog-2021.02.12&quot;, &quot;_type&quot;=&gt;&quot;_doc&quot;, &quot;_id&quot;=&gt;nil, &quot;status&quot;=&gt;400, &quot;error&quot;=&gt;{&quot;type&quot;=&gt;&quot;validation_exception&quot;, &quot;reason&quot;=&gt;&quot;Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [1000]\/[1000] maximum shards open;&quot;}}}}<\/code><\/pre>\n<p>ES\u62a5\u9519\u65e0\u6cd5\u521b\u5efa\u591a\u4f59\u7684\u5206\u7247\uff0c\u53ef\u8c03\u6574\u5206\u7247\u6570<\/p>\n<p>\u539f\u56e0\uff1aES\u96c6\u7fa4\u9ed8\u8ba4\u6709\u6700\u5927\u5206\u7247\u65701000\u7684\u9650\u5236\uff0c\u8fbe\u5230\u6700\u5927\u6570\u4ee5\u540e\uff0c\u65e0\u6cd5\u6dfb\u52a0\u65b0\u7684\u5206\u7247\uff0c\u5bfc\u81f4\u65e0\u6cd5\u521b\u5efa\u7d22\u5f15\u5199\u5165\u65e5\u5fd7\u3002<\/p>\n<p>\u89e3\u51b3\uff1a\u5728Kibana\u4e0a\u7684<code>DEV TOOL<\/code>\u5de5\u5177\u91cc\u6267\u884c\u5982\u4e0b\u547d\u4ee4<\/p>\n<pre><code class=\"language-json\">PUT \/_cluster\/settings\n{\n  &quot;transient&quot;: {\n    &quot;cluster&quot;: {\n      &quot;max_shards_per_node&quot;:10000\n    }\n  }\n}<\/code><\/pre>\n<pre><code class=\"language-json\">{\n  &quot;acknowledged&quot; : true,\n  &quot;persistent&quot; : { },\n  &quot;transient&quot; : {\n    &quot;cluster&quot; : {\n      &quot;max_shards_per_node&quot; : &quot;10000&quot;\n    }\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. Cannot open file logs\/gc.log due to Permission denie [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[301,345],"tags":[180],"class_list":["post-1677","post","type-post","status-publish","format-standard","hentry","category-elasticsearch","category-elk","tag-elasticsearch"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1677"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1677\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}