{"id":582,"date":"2020-09-08T16:50:59","date_gmt":"2020-09-08T08:50:59","guid":{"rendered":"https:\/\/blog.espnlol.com\/?p=582"},"modified":"2022-04-20T18:21:11","modified_gmt":"2022-04-20T10:21:11","slug":"elk%e9%9d%9e%e4%ba%a4%e4%ba%92%e4%bf%ae%e6%94%b9elastic%e5%af%86%e7%a0%81%ef%bc%88%e8%bd%ac%e8%bd%bd%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.espnlol.com\/?p=582","title":{"rendered":"ELK\u975e\u4ea4\u4e92\u4fee\u6539elastic\u5bc6\u7801\uff08\u8f6c\u8f7d\uff09"},"content":{"rendered":"\n<p>\u901a\u8fc7&nbsp;<strong>Restful \u63a5\u53e3<\/strong>\u6765\u7ed5\u5f00\u4ea4\u4e92\u5f0f\u7684\u547d\u4ee4\u884c\u4fee\u6539\u5bc6\u7801\uff0c\u8fbe\u5230\u6279\u91cf\u81ea\u52a8\u5316\u90e8\u7f72 ELK \u76ee\u7684\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u7b80\u4ecb\">\u7b80\u4ecb<\/h1>\n\n\n\n<p>ElasticSearch \u5728 6.1 \u7248\u672c\u540e\uff0c\u53d6\u6d88\u4e86\u901a\u8fc7 Docker-compose \u7684\u73af\u5883\u53d8\u91cf\u00a0ELASTIC_PASSWORD\u00a0\u6765\u76f4\u63a5\u8bbe\u7f6e\u5176\u5bc6\u7801\uff0c\u8f6c\u800c\u63a8\u8350\u4f7f\u7528\u547d\u4ee4\u884c\u3002<\/p>\n\n\n\n<table class=\"wp-block-table is-style-regular\"><tbody><tr><td>1<br>2<br><\/td><td>$ bin\/x-pack\/setup-passwords interactive # \u8981\u4ea4\u4e92\u5f0f\u624b\u5de5\u8f93\u5165\u8d26\u6237\u7684\u5bc6\u7801<br>$ bin\/x-pack\/setup-passwords auto # \u7a0b\u5e8f\u81ea\u52a8\u4e3a\u4f60\u751f\u6210\u8d26\u6237\u7684\u968f\u673a\u5bc6\u7801<br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>\u5982\u4e0a\u9762\u6240\u5c5e\uff0c\u8981\u4e48\u662f\u8ba9\u7a0b\u5e8f\u4e3a\u6bcf\u4e00\u4e2a ElasticSearch \u81ea\u52a8\u751f\u6210\u968f\u673a\u5bc6\u7801\uff0c\u90a3\u4e48\u5bf9\u4e8e\u6574\u4f53\u7684\u7ba1\u63a7\u6765\u8bf4\u662f\u4e0d\u5b9e\u9645\u7684\u3002<br>\u90a3\u4e48\u5982\u679c\u5b89\u88c5\u4e86 X-Pack \u4f46\u662f\u4e0d\u91cd\u7f6e\u5bc6\u7801\u884c\u4e0d\u884c\u5462\uff1f \u7b54\u6848\u662f\u4e0d\u884c\u7684\uff0c\u7f51\u4e0a\u6d41\u4f20\u7684\u00a0changeme\u00a0\u521d\u59cb\u5bc6\u7801\u5728 6.x \u7248\u672c\u4e2d\u542f\u52a8\u4e86 X-Pack \u540e\u5e76\u4e0d\u80fd\u901a\u8fc7\u5b89\u5168\u8ba4\u8bc1\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u5269\u4e0b\u7684\u65b9\u5f0f\u5c31\u662f&nbsp;<strong>\u4ea4\u4e92\u5f0f<\/strong>&nbsp;\u7684\u624b\u5de5\u8f93\u5165\u8d26\u6237\u5bc6\u7801\uff0c\u4ea4\u4e92\u5f0f\u5373\u5bfc\u81f4\u4e86\u6211\u4eec\u4e0d\u80fd\u5199 Bash \u6765\u89e3\u51b3\u8f93\u5165\u95ee\u9898\uff08\u9664\u975e\u989d\u5916\u5b89\u88c5\u63d2\u4ef6\u53bb\u5b8c\u6210\uff09\u3002\u800c\u672c\u6587\u8981\u89e3\u51b3\u7684\u95ee\u9898\u662f\uff0c\u5728\u6279\u91cf\u90e8\u7f72\u5177\u6709\u5bc6\u7801\u9a8c\u8bc1\u529f\u80fd\u7684 ELK \u4e2d\u9047\u5230\u7684\u5bc6\u7801\u4fee\u6539\u65e0\u6cd5\u901a\u8fc7\u811a\u672c\u5b9e\u73b0\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u89e3\u51b3\u65b9\u6848\">\u89e3\u51b3\u65b9\u6848<\/h1>\n\n\n\n<p>\u5728\u5b98\u65b9\u7684 Issue&nbsp;<a target=\"_blank\" rel=\"noreferrer noopener\" href=\"https:\/\/discuss.elastic.co\/t\/x-pack-authentication-issue\/121632\/7\">\u7b54\u7591\u89e3\u60d1<\/a>\u4e2d\uff0c\u53d1\u73b0\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u63a5\u53e3\u76f4\u63a5\u5bf9 ElasticSearch \u8fdb\u884c\u5bc6\u7801\u4fee\u6539\u3002<br>\u5177\u4f53\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u521b\u5efa\u4e00\u4e2a\u8d85\u7ea7\u6743\u9650\u7684\u7528\u6237<\/li><li>\u4ee5\u8d85\u7ea7\u6743\u9650\u7528\u6237\u7684\u6743\u9650\u901a\u8fc7\u63a5\u53e3\u91cd\u7f6e elastic \u7684\u5bc6\u7801<\/li><li>\u9a8c\u8bc1\u91cd\u7f6e\u5bc6\u7801\u540e\u7684\u8d26\u6237<\/li><li>\u5220\u9664\u521a\u521a\u521b\u5efa\u7684\u8d85\u7ea7\u6743\u9650\u7528\u6237\uff08\u53ef\u9009\uff09<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u64cd\u4f5c\u6b65\u9aa4\">\u64cd\u4f5c\u6b65\u9aa4<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u521b\u5efa\u8d85\u7ea7\u6743\u9650\u7528\u6237\">\u521b\u5efa\u8d85\u7ea7\u6743\u9650\u7528\u6237<\/h2>\n\n\n\n<p>\u901a\u8fc7\u547d\u4ee4\u884c,\u521b\u5efa\u4e00\u4e2a\u8d26\u6237\u540d\u4e3a\u00a0copriwolf\uff0c\u4e14\u5bc6\u7801\u4e3a\u00a0sayHi2Elastic\u00a0\u7684\u8d85\u7ea7\u6743\u9650\u7528\u6237<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>1<br><\/td><td>$ {ES\u5b89\u88c5\u76ee\u5f55}\/bin\/elasticsearch-users useradd copriwolf -p sayHi2Elastic -r superuser<br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u91cd\u7f6e-elastic-\u8d26\u6237\u7684\u5bc6\u7801\">\u91cd\u7f6e elastic \u8d26\u6237\u7684\u5bc6\u7801<\/h2>\n\n\n\n<p>\u91cd\u7f6e\u8d26\u6237\u5bc6\u7801\u7684\u63a5\u53e3 URL \u5982\u4e0b<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>1<br><\/td><td>{ES\u7684\u8bbf\u95ee\u5730\u5740}\/_xpack\/security\/user\/{\u88ab\u4fee\u6539\u7684\u8d26\u6237\u540d}\/_password?pretty<br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>\u6240\u4ee5\u6211\u6839\u636e\u9700\u6c42\uff0c\u901a\u8fc7\u00a0copriwolf\u00a0\u8d26\u6237\u91cd\u7f6e\u5728\u00a0localhost:9200\u00a0\u8fd9\u4e2a\u7aef\u53e3\u7684 ES \u670d\u52a1\u4e2d\u7684\u00a0elastic\u00a0\u8d26\u6237\u7684\u5bc6\u7801\u4e3a\u00a0123456\uff0c\u53d1\u8d77\u4e86\u4e00\u4e2a CURL \u5982\u4e0b<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>1<br>2<br>3<br>4<br><\/td><td>$ curl -u copriwolf:sayHi2Elastic \\<br>  -XPUT &#8220;http:\/\/localhost:9200\/_xpack\/security\/user\/elastic\/_password?pretty&#8221; \\<br>  -H &#8216;Content-Type: application\/json&#8217; \\<br>  -d &#8216;{&#8220;password&#8221;: &#8220;123456&#8221;}&#8217;<br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u9a8c\u8bc1\u91cd\u7f6e\u5bc6\u7801\u540e\u7684\u8d26\u6237\">\u9a8c\u8bc1\u91cd\u7f6e\u5bc6\u7801\u540e\u7684\u8d26\u6237<\/h2>\n\n\n\n<p>\u4fee\u6539\u540e\uff0c\u6211\u4eec\u9700\u8981\u9a8c\u8bc1\u662f\u5426\u771f\u6b63\u6709\u751f\u6548\uff0c\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b CURL \u8fdb\u884c\u786e\u8ba4<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>1<br><\/td><td>$ curl -u elastic &#8216;http:\/\/localhost:9200\/_xpack\/security\/_authenticate?pretty&#8217;<br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u5220\u9664\u521a\u521a\u521b\u5efa\u7684\u8d85\u7ea7\u6743\u9650\u7528\u6237\">\u5220\u9664\u521a\u521a\u521b\u5efa\u7684\u8d85\u7ea7\u6743\u9650\u7528\u6237<\/h2>\n\n\n\n<p>\u5df2\u7ecf\u5b8c\u6210\u4e86\u9700\u6c42\uff0c\u8fd9\u4e2a\u65f6\u5019\u53ef\u4ee5\u5220\u9664\u4e3a\u8fd9\u4e2a\u9700\u6c42\u800c\u7279\u610f\u521b\u5efa\u7684\u8d85\u7ea7\u6743\u9650\u7528\u6237\uff0c\u5bf9\u4e8e\u6700\u5c0f\u6743\u9650\u539f\u5219\uff0c\u8fd8\u662f\u5c3d\u91cf\u5220\u9664\u6743\u9650\u8fc7\u5927\u4f46\u662f\u7528\u5904\u4e0d\u660e\u7684\u8d26\u6237\u3002<br>\u6240\u4ee5\u901a\u8fc7\u4e00\u4e0b\u547d\u4ee4\u884c\u53ef\u4ee5\u5b8c\u6210\u7528\u6237\u00a0copriwolf\u00a0\u7684\u5220\u9664\u3002<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>1<br><\/td><td>$ {ES\u5b89\u88c5\u76ee\u5f55}\/bin\/elasticsearch-users userdel copriwolf<br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5b98\u65b9\u63d0\u5230\uff0c\u5982\u679c\u5728 elasticsearch.yml \u4e2d\u6307\u5b9a\u4e86\u9a8c\u8bc1\u57df( authentication realms )\uff0c\u9700\u8981\u6709\u7279\u6b8a\u7684\u64cd\u4f5c\uff0c\u4e0d\u59a8\u5230<a target=\"_blank\" rel=\"noreferrer noopener\" href=\"https:\/\/discuss.elastic.co\/t\/x-pack-authentication-issue\/121632\/7\">\u5b98\u65b9\u535a\u6587<\/a>\u4e2d\u4e86\u89e3\u3002<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7&nbsp;Restful \u63a5\u53e3\u6765\u7ed5\u5f00\u4ea4\u4e92\u5f0f\u7684\u547d\u4ee4\u884c\u4fee\u6539\u5bc6\u7801\uff0c\u8fbe\u5230\u6279\u91cf\u81ea\u52a8\u5316 &hellip; <a href=\"https:\/\/blog.espnlol.com\/?p=582\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-582","post","type-post","status-publish","format-standard","hentry","category-elk"],"_links":{"self":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=582"}],"version-history":[{"count":2,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/582\/revisions"}],"predecessor-version":[{"id":584,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/582\/revisions\/584"}],"wp:attachment":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}