{"id":6379,"date":"2018-01-17T11:10:09","date_gmt":"2018-01-17T03:10:09","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=6379"},"modified":"2018-01-17T11:10:09","modified_gmt":"2018-01-17T03:10:09","slug":"elasticsearch%e5%a4%87%e4%bb%bd%e5%92%8c%e8%bf%98%e5%8e%9f","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/6379.html","title":{"rendered":"Elasticsearch\u5907\u4efd\u548c\u8fd8\u539f"},"content":{"rendered":"<p>Elasticsearch\u7ecf\u5e38\u7528\u6765\u5b58\u50a8\u6570\u636e\uff0c\u5982\u679c\u4f60\u5728\u91cc\u9762\u5b58\u50a8\u4e86\u91cd\u8981\u7684\u6570\u636e\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u8fdb\u884c\u5907\u4efd\uff0c\u7136\u540e\u5728\u51fa\u73b0\u95ee\u9898\u7684\u65f6\u5019\u9700\u8981\u8fdb\u884c\u8fd8\u539f\u3002<\/p>\n<h1>\u7ba1\u7406repositories<\/h1>\n<p>Elasticsearch\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5185\u7f6e\u7684\u7cfb\u7edf\u6765\u5feb\u901f\u5907\u4efd\u548c\u6062\u590d\u60a8\u7684\u6570\u636e\u3002 \u5728\u4f7f\u7528\u5b9e\u65f6\u6570\u636e\u65f6\uff0c\u4fdd\u6301\u5907\u4efd\u662f\u590d\u6742\u7684\uff0c\u56e0\u4e3a\u4f1a\u6709\u5927\u91cf\u7684\u5e76\u53d1\u95ee\u9898\u3002<br \/>\nElasticsearch\u5feb\u7167\u5141\u8bb8\u5c06\u5355\u4e2a\u7d22\u5f15\uff08\u6216\u522b\u540d\uff09\u6216\u6574\u4e2a\u96c6\u7fa4\u7684\u5feb\u7167\u521b\u5efa\u5230\u8fdc\u7a0b\u5b58\u50a8\u5e93\u4e2d\u3002\u5728\u5f00\u59cb\u6267\u884c\u5feb\u7167\u4e4b\u524d\uff0c\u5fc5\u987b\u521b\u5efa\u5b58\u50a8\u5e93 \u2013 \u8fd9\u662f\u60a8\u7684\u5907\u4efd\/\u5feb\u7167\u5c06\u88ab\u5b58\u50a8\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u6211\u4eec\u9700\u8981\u7f16\u8f91config\/elasticsearch.yml\u6587\u4ef6\u589e\u52a0\u5907\u4efd\u5b58\u50a8\u5e93\u7684\u4f4d\u7f6e\uff0c\u6bd4\u5982\uff1apath.repo: \/tmp\/\uff0c\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u6211\u4eec\u4f7f\u7528\/tmp\u76ee\u5f55\u6765\u4f5c\u4e3a\u5b58\u50a8\u5e93\u7684\u4f4d\u7f6e\uff0c\u7136\u540e\u6211\u4eec<br \/>\n\u521b\u5efa\u4e00\u4e2a\u540d\u4e3amy_repository\u7684\u5b58\u50a8\u5e93\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XPUT 'http:\/\/localhost:9200\/_snapshot\/my_repository' -d '\r\n{\r\n    &quot;type&quot;: &quot;fs&quot;,\r\n    &quot;settings&quot;: {\r\n        &quot;location&quot;: &quot;\/tmp\/my_repository&quot;,\r\n        &quot;compress&quot;: true\r\n    }\r\n}'\r\n<\/pre>\n<p>\u521b\u5efa\u6210\u529f\u8fd4\u56de\u7ed3\u679c\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n{&quot;acknowledged&quot;:true}\r\n<\/pre>\n<p>\u5982\u679c\u4f60\u68c0\u67e5\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u7684\u8bdd\uff0c\u4f1a\u53d1\u73b0\/tmp\/my_repository\u76ee\u5f55\u5df2\u7ecf\u88ab\u521b\u5efa<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u65b9\u5f0f\u6765\u56de\u53bb\u4ed3\u5e93\u7684\u4e00\u4e9b\u4fe1\u606f\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XGET 'http:\/\/localhost:9200\/_snapshot\/my_repository'\r\n\r\n\u8fd4\u56de\u7ed3\u679c\u4e3a\uff1a\r\n\r\n&#x5B;sourcecode language=shell]\r\n{\r\n    &quot;my_repository&quot;: {\r\n        &quot;type&quot;: &quot;fs&quot;,\r\n        &quot;settings&quot;: {\r\n            &quot;compress&quot;: &quot;true&quot;,\r\n            &quot;location&quot;: &quot;\/tmp\/my_repository&quot;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\u83b7\u53d6\u6240\u6709\u4ed3\u5e93\u7684\u4fe1\u606f<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XGET 'http:\/\/localhost:9200\/_snapshot'\r\n<\/pre>\n<p>\u5982\u679c\u60f3\u5220\u9664\u8fd9\u4e2a\u4ed3\u5e93\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XDELETE 'http:\/\/localhost:9200\/_snapshot\/my_repository'\r\n<\/pre>\n<p>\u8fd4\u56de\u7ed3\u679c\u4e3a\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n{&quot;acknowledged&quot;:true}\r\n<\/pre>\n<h1>\u7ba1\u7406snapshot<\/h1>\n<p>\u5047\u8bbe\u6211\u4eec\u60f3\u4e3atest-index\u548ctest-2\u8fd9\u4e24\u4e2a\u7d22\u5f15\u521b\u5efa\u4e00\u4e2a\u5feb\u7167snap_1\uff0c\u90a3\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XPUT &quot;http:\/\/localhost:9200\/_snapshot\/my_repository\/snap_1? wait_for_completion=true&quot; -d '\r\n{\r\n    &quot;indices&quot;: &quot;test-index,test-2&quot;,\r\n    &quot;ignore_unavailable&quot;: &quot;true&quot;,\r\n    &quot;include_global_state&quot;: false\r\n}'\r\n<\/pre>\n<p>\u6267\u884c\u4ee5\u540e\uff0c\u5982\u679c\u4f60\u53bb\u68c0\u67e5\/tmp\/my_repository\u76ee\u5f55\u7684\u8bdd\uff0c\u4e0b\u9762\u4f1a\u65b0\u589e\u4e00\u4e9b\u6570\u636e\u6587\u4ef6\u3002<\/p>\n<p>\u4e3a\u4e86\u83b7\u53d6\u5feb\u7167\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XGET 'http:\/\/localhost:9200\/_snapshot\/my_repository\/snap_1?pretty'\r\n<\/pre>\n<p>\u5982\u679c\u60f3\u5220\u9664\u5feb\u7167\u7684\u8bdd\uff0c\u53ef\u4ee5\u4f7f\u7528<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XDELETE 'http:\/\/localhost:9200\/_snapshot\/my_repository\/snap_1'\r\n<\/pre>\n<p>\u5982\u679c\u60f3\u67e5\u770b\u6240\u6709\u7684\u7d22\u5f15\u5feb\u7167\u7684\u8bdd\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XGET 'http:\/\/localhost:9200\/_snapshot\/my_repository\/_all'\r\n<\/pre>\n<p>\u53e6\u5916\u5feb\u7167\u7684\u5904\u7406\u8fc7\u7a0b\u53ef\u4ee5\u88ab\u76d1\u63a7\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XGET &quot;http:\/\/localhost:9200\/_snapshot\/my_repository\/snap_1\/_status?pretty&quot;\r\n<\/pre>\n<p>\u4ece\u5feb\u7167\u8fdb\u884c\u6570\u636e\u8fd8\u539f<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XPOST &quot;http:\/\/localhost:9200\/_snapshot\/my_repository\/snap_1\/_restore? pretty&quot; -d '\r\n{\r\n    &quot;indices&quot;: &quot;test-index,test-2&quot;,\r\n    &quot;ignore_unavailable&quot;: &quot;true&quot;,\r\n    &quot;include_global_state&quot;: false,\r\n    &quot;rename_pattern&quot;: &quot;test-(.+)&quot;,\r\n    &quot;rename_replacement&quot;: &quot;copy_$1&quot;\r\n}'\r\n<\/pre>\n<h1>Reindexing from a remote cluster<\/h1>\n<p>\u5feb\u7167\u548c\u6062\u590dAPI\u6267\u884c\u7684\u975e\u5e38\u5feb\uff0c\u5e76\u4e14\u662f\u5907\u4efd\u6570\u636e\u7684\u9996\u9009\u65b9\u5f0f\uff0c\u4f46\u5b83\u4eec\u6709\u4e00\u4e9b\u9650\u5236\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u5907\u4efd\u662f\u4e00\u4e2a\u5b89\u5168\u7684Lucene\u7d22\u5f15\u526f\u672c\uff0c\u6240\u4ee5\u8fd9\u53d6\u51b3\u4e8e\u4f7f\u7528\u7684Elasticsearch\u7248\u672c\u3002 \u5982\u679c\u60a8\u4ece\u7248\u672c5.x\u4e4b\u524d\u7684Elastisearch\u7248\u672c\u5207\u6362\uff0c\u5219\u65e0\u6cd5\u6062\u590d\u65e7\u7d22\u5f15\u3002<\/li>\n<li>\u4e0d\u53ef\u80fd\u5728\u65e7\u7248\u672c\u4e2d\u6062\u590d\u66f4\u65b0\u7684Elasticsearch\u7248\u672c\u7684\u5907\u4efd\u3002 \u6062\u590d\u53ea\u80fd\u5411\u524d\u517c\u5bb9\u3002<\/li>\n<li>\u4e0d\u53ef\u80fd\u4ece\u5907\u4efd\u6062\u590d\u90e8\u5206\u6570\u636e\u3002<\/li>\n<\/ul>\n<p>\u4e3a\u4e86\u80fd\u591f\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u590d\u5236\u6570\u636e\uff0c\u89e3\u51b3\u65b9\u6848\u662f\u4f7f\u7528\u8fdc\u7a0b\u670d\u52a1\u5668\u4f7f\u7528reindex API\u3002<\/p>\n<p>\u4e3a\u4e86\u80fd\u591f\u4ece\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u590d\u5236\u6570\u636e\uff0c\u6211\u4eec\u9700\u8981\u5728config\/elasticsearch.yml\u6587\u4ef6\u4e2d\u589e\u52a0\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u5730\u5740\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nreindex.remote.whitelist: &#x5B;&quot;192.168.1.227:9200&quot;]\r\n<\/pre>\n<p>\u7136\u540e\u91cd\u542fElasticsearch\uff0c\u7136\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u6267\u884capi\u8c03\u7528\u4e86\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -XPOST &quot;http:\/\/localhost:9200\/_reindex&quot; -d '{\r\n    &quot;source&quot;: {\r\n        &quot;remote&quot;: {\r\n            &quot;host&quot;: &quot;http:\/\/192.168.1.227:9200&quot;\r\n        },\r\n        &quot;index&quot;: &quot;test-source&quot;\r\n    },\r\n    &quot;dest&quot;: {\r\n        &quot;index&quot;: &quot;test-dest&quot;\r\n    }\r\n}'\r\n<\/pre>\n<h1>\u53c2\u8003\u6587\u6863<\/h1>\n<p>https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/5.0\/modules-snapshots.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Elasticsearch\u7ecf\u5e38\u7528\u6765\u5b58\u50a8\u6570\u636e\uff0c\u5982\u679c\u4f60\u5728\u91cc\u9762\u5b58\u50a8\u4e86\u91cd\u8981\u7684\u6570\u636e\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u8fdb\u884c\u5907\u4efd\uff0c\u7136\u540e\u5728\u51fa\u73b0\u95ee\u9898\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-6379","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=6379"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6379\/revisions"}],"predecessor-version":[{"id":6380,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6379\/revisions\/6380"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=6379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=6379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=6379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}