{"id":518,"date":"2023-06-02T11:13:55","date_gmt":"2023-06-02T03:13:55","guid":{"rendered":"http:\/\/www.liuyd.cc\/?p=518"},"modified":"2023-06-02T11:13:55","modified_gmt":"2023-06-02T03:13:55","slug":"elasticsearch-%e5%ae%89%e5%85%a8%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"http:\/\/www.liuyd.cc\/?p=518","title":{"rendered":"ElasticSearch \u5b89\u5168\u914d\u7f6e"},"content":{"rendered":"\n<p>\u6211\u4eec\u77e5\u9053\u00a0ElasticSearch \u5b89\u5168\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u6ca1\u6709\u8fd9\u4e2a\u6211\u4eec\u7684\u6570\u636e\u53ef\u4ee5\u88ab\u4efb\u4f55\u7684\u4eba\u8fdb\u884c\u8bbf\u95ee\uff0c\u4e32\u6539\uff0c\u5220\u9664\u3002Elastic Stack \u7684\u5b89\u5168\u662f\u7531 x-pack \u6240\u63d0\u4f9b\u7684\u3002\u5728 Elastic Stack 7.0 \u7248\u672c\u4e4b\u524d\uff0c\u8fd9\u4e2a\u662f\u5546\u7528\u7684\u7248\u672c\uff0c\u9700\u8981\u8fdb\u884c\u5b89\u88c5\uff0c\u5e76\u8d2d\u4e70\u3002\u4ece Elastic Stack 7.0 \u4e4b\u540e\uff0cx-pack \u90fd\u5df2\u7ecf\u5728\u53d1\u5e03\u7248\u4e2d\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u8fdb\u884c\u5b89\u88c5\u3002\u6211\u4eec\u53ea\u9700\u8981\u8fdb\u884c\u914d\u7f6e\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e00\u3001\u90e8\u7f72 ElasticSearch \u96c6\u7fa4<\/h3>\n\n\n\n<p>\u9996\u5148\uff0c\u53c2\u8003\u300a<a href=\"http:\/\/www.liuyd.cc\/?p=435\" target=\"_blank\" rel=\"noreferrer noopener\">Docker \u90e8\u7f72 ElasticSearch<\/a>\u300b\u5c06ES\u96c6\u7fa4\u8dd1\u8d77\u6765\uff0c\u4e4b\u540e\u6211\u4eec\u5f00\u59cb\u589e\u52a0\u5b89\u5168\u914d\u7f6e<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001ElasticSearch \u96c6\u7fa4\u8282\u70b9\u95f4\u5b89\u5168\u914d\u7f6e<\/h2>\n\n\n\n<p>\u9996\u5148\u627e\u4e00\u4e2a\u5bb9\u5668\uff0c\u8fdb\u5165\u5230\u5bb9\u5668\u4e2d\uff0c\u4f8b\u5982\uff1a<code>es-node1<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec -it es-node1 \/bin\/bash<\/code><\/pre>\n\n\n\n<p>\u8fd0\u884c\u4e00\u4e0b\u547d\u4ee4\uff0c\u751f\u6210 <code>elastic-certificates.p12<\/code> \u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>### \u8fd0\u884c\u547d\u4ee4\uff0c\u751f\u6210\u6587\u4ef6 elastic-certificates.p12\nbin\/elasticsearch-certutil ca -out elastic-certificates.p12 -pass \"\"\n\n### \u67e5\u770b\u751f\u6210\u7684\u6587\u4ef6\nll | grep \"p12\"\n-rw-------.  1 root          root   2672 Jun  1 16:32 elastic-certificates.p12<\/code><\/pre>\n\n\n\n<p>\u9000\u51fa\u5bb9\u5668\uff0c\u5e76\u5c06\u5bb9\u5668\u5185\u7684\u6587\u4ef6Copy\u5230\u5bbf\u4e3b\u673a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u4ece\u5bb9\u5668\u4e2dCopy\u51fa\u6765\uff0c\u76f4\u63a5\u653e\u5728 es-node1\/config \u4e2d\ndocker cp es-node1:\/usr\/share\/elasticsearch\/elastic-certificates.p12 \/houder\/elasticsearch\/node1\/config\/\n\n# \u5c06\u6587\u4ef6\u5206\u53d1\u7ed9\u53e6\u5916\u4e24\u4e2a\u8282\u70b9\ncp elasticsearch\/node1\/config\/elastic-certificates.p12 elasticsearch\/node2\/config\/\r\ncp elasticsearch\/node1\/config\/elastic-certificates.p12 elasticsearch\/node3\/config\/\n\n## \u6267\u884c\u6388\u6743\u64cd\u4f5c\nchmod -R 777 elasticsearch\/node{1..3}\/config\/elastic-certificates.p12\n\n<\/code><\/pre>\n\n\n\n<p>\u7f16\u8f91 \u4e09\u4e2a\u8282\u70b9\u7684 elasticsearch.yml \u914d\u7f6e\uff0c\u5e76\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\u9879\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>xpack.security.transport.ssl.enabled: true\r\nxpack.security.transport.ssl.verification_mode: certificate\r\nxpack.security.transport.ssl.keystore.path: elastic-certificates.p12\r\nxpack.security.transport.ssl.truststore.path: elastic-certificates.p12\r<\/code><\/pre>\n\n\n\n<p>\u5220\u9664\u5e76\u91cd\u65b0\u521b\u5efa\u5bb9\u5668\uff0c\u5728\u6bcf\u4e2a\u5bb9\u5668\u4e2d\uff0c\u589e\u52a0 elastic-certificates.p12 \u6620\u5c04<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-v \/houder\/elasticsearch\/nodeXXX\/config\/elastic-certificates.p12:\/usr\/share\/elasticsearch\/config\/elastic-certificates.p12 \\\n\n\u6ce8\u610f\u8c03\u6574 nodeXXX \u6307\u5411\u5177\u4f53\u8282\u70b9\u76ee\u5f55 node1, node2, node3<\/code><\/pre>\n\n\n\n<p>\u9a8c\u8bc1\u5bb9\u5668\u542f\u52a8\u6210\u529f\uff1a<code>http:\/\/192.168.0.31:19200\/_cat\/nodes?pretty<\/code>\u00a0<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"541\" height=\"144\" src=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-1.png\" alt=\"\" class=\"wp-image-586\" srcset=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-1.png 541w, http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-1-300x80.png 300w\" sizes=\"auto, (max-width: 541px) 100vw, 541px\" \/><\/figure>\n\n\n\n<p>\u6ce8\u91ca\u6389 node3 \u7684 xpack \u914d\u7f6e\uff0c\u91cd\u542f\u5bb9\u5668\u540e\u65e0\u6cd5\u4e0a\u7ebf\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"554\" height=\"185\" src=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-2.png\" alt=\"\" class=\"wp-image-592\" srcset=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-2.png 554w, http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-2-300x100.png 300w\" sizes=\"auto, (max-width: 554px) 100vw, 554px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e09\u3001\u4e3a\u5185\u7f6e\u7528\u6237\u914d\u7f6e\u5bc6\u7801<\/h3>\n\n\n\n<p>\u901a\u8fc7\u4e0a\u4e00\u6b65\u914d\u7f6e\uff0c\u53ef\u4ee5\u4fdd\u8bc1\u96c6\u7fa4\u95f4\u7684\u5b89\u5168\u8ba4\u8bc1\u914d\u7f6e\uff0c\u4f46\u662f ElasticSearch \u4e2d\u7684\u7528\u6237\u8fd8\u662f\u6ca1\u6709\u5bc6\u7801\u7684\uff0c\u4f8b\u5982\uff0c\u6211\u4eec\u914d\u7f6e\u4e0a\u8282\u70b9\u94fe\u63a5\uff0c\u5219\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"309\" src=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-3.png\" alt=\"\" class=\"wp-image-598\" srcset=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-3.png 731w, http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-3-300x127.png 300w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/figure>\n\n\n\n<p>\u9996\u5148\u6211\u4eec\u8981\u5728 elasticsearch.yml \u4e2d\u4e3a\u6bcf\u4e00\u4e2a\u8282\u70b9\u589e\u52a0\u4e00\u4e2a\u914d\u7f6e\uff0c\u6765\u4fdd\u8bc1\u542f\u7528 <code>xpack.security<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>xpack.security.enabled: true<\/code><\/pre>\n\n\n\n<p>\u91cd\u542f\u96c6\u7fa4\u8282\u70b9\u540e\uff0c\u8fdb\u5165\u5230\u5176\u4e2d\u4e00\u4e2a\u5bb9\u5668\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u5bc6\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/bin\/elasticsearch-setup-passwords interactive&#91;auto]\n\n# interactive\uff1a\u4ea4\u4e92\u5f0f\u7528\u6237\u624b\u52a8\u8bbe\u5b9a\u5bc6\u7801\n# auto\uff1a\u81ea\u52a8\u521b\u5efa\u5e76\u663e\u793a\u5bc6\u7801<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\uff1a\u521b\u5efa\u5bc6\u7801\u524d\u4fdd\u8bc1\u9700\u8981\u4fdd\u8bc1\u96c6\u7fa4\u6bcf\u4e2a\u8282\u70b9\u90fd\u53ef\u7528\uff0c\u5728\u521b\u5efa\u5bc6\u7801\u65f6\u4f1a\u81ea\u52a8\u53d1\u9001\u7ed9\u5176\u4ed6\u96c6\u7fa4\u8282\u70b9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@ea4e265dcaf5:\/usr\/share\/elasticsearch# bin\/elasticsearch-setup-passwords auto \r\nInitiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.\r\nThe passwords will be randomly generated and printed to the console.\r\nPlease confirm that you would like to continue &#91;y\/N]y    # \u8fd9\u91cc\u9700\u8981\u786e\u8ba4\uff0c\u8f93\u5165y\r\n\r\n\r\nChanged password for user apm_system\r\nPASSWORD apm_system = 8fRPljcNgnnxYjLA9VZC\r\n\r\nChanged password for user kibana_system\r\nPASSWORD kibana_system = qvxy771goB9Zr7qirjzS\r\n\r\nChanged password for user kibana\r\nPASSWORD kibana = qvxy771goB9Zr7qirjzS\r\n\r\nChanged password for user logstash_system\r\nPASSWORD logstash_system = Mu07F38tDQLC8pd7i7jV\r\n\r\nChanged password for user beats_system\r\nPASSWORD beats_system = YLgWRCjspeIZAWZ36khY\r\n\r\nChanged password for user remote_monitoring_user\r\nPASSWORD remote_monitoring_user = EUZKfKL5b20AwvcRu8c6\r\n\r\nChanged password for user elastic\r\nPASSWORD elastic = 0cXv3ngDjM3DsSenVHzf\n<\/code><\/pre>\n\n\n\n<p>\u6211\u4eec\u8fd8\u662f\u901a\u8fc7\u8fd9\u4e2a\u94fe\u63a5\u6765\u9a8c\u8bc1\uff1a<code>http:\/\/192.168.0.31:19200\/_cat\/nodes?pretty<\/code>\u00a0\uff0c\u63d0\u793a\u6211\u4eec\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u6211\u4eec\u8f93\u5165\uff1a<code>elastic 0cXv3ngDjM3DsSenVHzf<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"836\" height=\"337\" src=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-5.png\" alt=\"\" class=\"wp-image-621\" srcset=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-5.png 836w, http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-5-300x121.png 300w, http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-5-768x310.png 768w\" sizes=\"auto, (max-width: 836px) 100vw, 836px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u56db\u3001\u6539\u7528https\u534f\u8bae<\/h3>\n\n\n\n<p>\u7ecf\u8fc7\u4e0a\u4e00\u6b65\u8c03\u6574\u540e\uff0c\u6211\u4eec\u9700\u8981\u914d\u7f6e\u7528\u6237\u540d\u548c\u5bc6\u7801\u624d\u53ef\u4ee5\u6b63\u786e\u8bbf\u95ee\uff0c\u4f46\u662f\u8bbf\u95ee\u65f6\u8fd8\u662f\u7528\u7684http\u534f\u8bae<\/p>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4eec\u8c03\u6574\u4e3ahttps\u534f\u8bae\uff0c\u53ea\u9700\u8981\u5728 elasticsearch.yml \u4e2d\u589e\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>xpack.security.http.ssl.enabled: true\r\nxpack.security.http.ssl.keystore.path: elastic-certificates.p12\r\nxpack.security.http.ssl.truststore.path: elastic-certificates.p12\r<\/code><\/pre>\n\n\n\n<p>\u542f\u7528\u540e\u901a\u8fc7https\u8bbf\u95ee\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"526\" height=\"147\" src=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-6.png\" alt=\"\" class=\"wp-image-628\" srcset=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-6.png 526w, http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-6-300x84.png 300w\" sizes=\"auto, (max-width: 526px) 100vw, 526px\" \/><\/figure>\n\n\n\n<p>\u901a\u8fc7http\u5c06\u65e0\u6cd5\u8bbf\u95ee\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"646\" height=\"505\" src=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-7.png\" alt=\"\" class=\"wp-image-634\" srcset=\"http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-7.png 646w, http:\/\/www.liuyd.cc\/wp-content\/uploads\/2023\/06\/78805a221a988e7-7-300x235.png 300w\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u77e5\u9053\u00a0ElasticSearch \u5b89\u5168\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u6ca1\u6709\u8fd9\u4e2a\u6211\u4eec\u7684\u6570\u636e\u53ef\u4ee5\u88ab\u4efb\u4f55\u7684\u4eba\u8fdb\u884c\u8bbf\u95ee\uff0c\u4e32\u6539\uff0c\u5220\u9664\u3002Elastic Stack \u7684\u5b89\u5168\u662f\u7531 x-pack \u6240\u63d0\u4f9b\u7684\u3002\u5728 Elastic Stack 7.0 \u7248\u672c\u4e4b\u524d\uff0c\u8fd9\u4e2a\u662f\u5546\u7528\u7684\u7248\u672c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":23,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,7],"tags":[8],"topic":[],"class_list":["post-518","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","category-elasticsearch","tag-elasticsearch"],"_links":{"self":[{"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=\/wp\/v2\/posts\/518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=518"}],"version-history":[{"count":113,"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=\/wp\/v2\/posts\/518\/revisions"}],"predecessor-version":[{"id":638,"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=\/wp\/v2\/posts\/518\/revisions\/638"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=\/wp\/v2\/media\/23"}],"wp:attachment":[{"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=518"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=518"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.liuyd.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}