{"id":573,"date":"2020-04-14T18:14:42","date_gmt":"2020-04-14T10:14:42","guid":{"rendered":"https:\/\/www.aiqinqin.info\/?p=573"},"modified":"2021-12-16T16:52:22","modified_gmt":"2021-12-16T08:52:22","slug":"elasticsearch%e9%9b%86%e7%be%a4%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/www.aiqinqin.info\/?p=573","title":{"rendered":"Elasticsearch\u96c6\u7fa4\u642d\u5efa"},"content":{"rendered":"<h6>1. \u4e0b\u9762\u662f\u4e09\u53f0\u670d\u52a1\u5668\u7684\u4e00\u4e9b\u57fa\u672c\u4fe1\u606f<\/h6>\n<table>\n<thead>\n<tr>\n<th>ip<\/th>\n<th>\u76d1\u542c\u7aef\u53e3<\/th>\n<th>\u4e3b\u673a\u540d\u79f0<\/th>\n<th>\u7cfb\u7edf\u7248\u672c<\/th>\n<th>\u914d\u7f6e\u4fe1\u606f<\/th>\n<th>es\u5b9e\u4f8b\u540d\u79f0<\/th>\n<th>es\u7248\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>172.16.50.51<\/td>\n<td>9200\/9300<\/td>\n<td>es01<\/td>\n<td>centos7<\/td>\n<td>2u4g<\/td>\n<td>es01<\/td>\n<td>7.6<\/td>\n<\/tr>\n<tr>\n<td>172.16.50.52<\/td>\n<td>9200\/9300<\/td>\n<td>es02<\/td>\n<td>centos7<\/td>\n<td>2u4g<\/td>\n<td>es02<\/td>\n<td>7.6<\/td>\n<\/tr>\n<tr>\n<td>172.16.50.53<\/td>\n<td>9200\/9300<\/td>\n<td>es03<\/td>\n<td>centos7<\/td>\n<td>2u4g<\/td>\n<td>es03<\/td>\n<td>7.6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h6>2. \u5728\u4e09\u53f0\u670d\u52a1\u5668\u4e0a\u9762\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u6267\u884c\u4e00\u4e9b\u521d\u59cb\u5316\u5de5\u4f5c<\/h6>\n<pre><code class=\"\"># \u521b\u5efaes\u8fd0\u884c\u65f6\u7684\u7528\u6237\nuseradd -s \/bin\/bash -U elasticsearch\n\n#\u4fee\u6539 elasticsearch \u7cfb\u7edf\u6587\u4ef6\u6253\u5f00\u6570\ncat &lt;&lt; EOF &gt;&gt; \/etc\/security\/limits.conf\nelasticsearch soft nofile 65536\nelasticsearch hard nofile 65536\nEOF\n\n#\u4fee\u6539 max_map_count \u503c\nsysctl -w vm.max_map_count=655360\necho 'vm.max_map_count=655360' &gt;&gt; \/etc\/sysctl.conf \nsysctl -p\n<\/code><\/pre>\n<h6>3. \u5728\u4e09\u53f0\u670d\u52a1\u5668\u4e0a\u9762\u6267\u884c\u4e00\u4e0b\u547d\u4ee4\uff0c\u5b89\u88c5es\u5230opt\u76ee\u5f55\u4e0b\u9762<\/h6>\n<pre><code class=\"\">cd \/opt &amp;&amp; wget https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-7.6.1-linux-x86_64.tar.gz\ntar zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz &amp;&amp; mv elasticsearch-7.6.1 elasticsearch\nmkdir -p \/opt\/elasticsearch\/data &amp;&amp; mkdir -p \/opt\/elasticsearch\/logs &amp;&amp; mkdir -p \/opt\/elasticsearch\/config\/certs\nchown -Rf elasticsearch.elasticsearch \/opt\/elasticsearch\n<\/code><\/pre>\n<h6>4. \u5728\u4efb\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u9762\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u751f\u4ea7\u8bc1\u4e66\u7528\u4e8e\u96c6\u7fa4\u95f4\u7684\u52a0\u5bc6\u901a\u4fe1\uff0c\u5e76\u5c06\u751f\u6210\u7684elastic-certificates.p12\u6587\u4ef6\u590d\u5236\u5230\u53e6\u5916\u4e24\u53f0\u670d\u52a1\u5668\u4e0a\u9762\u7684\/opt\/elasticsearch\/config\/certs\u76ee\u5f55\u4e0b<\/h6>\n<pre><code class=\"\">\/opt\/elasticsearch\/bin\/elasticsearch-certutil cert -out \/opt\/elasticsearch\/config\/certs\/elastic-certificates.p12 -pass \"\"\n<\/code><\/pre>\n<h6>5.\u4fee\u6539172.16.50.51\u8fd9\u53f0\u670d\u52a1\u5668\/opt\/elasticsearch\/config\/elasticsearch.yml\u914d\u7f6e\u6587\u4ef6\u5982\u4e0b\u5185\u5bb9\uff1a<\/h6>\n<pre><code class=\"\">cluster.name: es-cluster\nnode.name: es01\nnode.master: true\nnode.data: true\npath.data: \/opt\/elasticsearch\/data\npath.logs: \/opt\/elasticsearch\/logs\n\nnetwork.host: 172.16.50.51\nhttp.port: 9200\nnetwork.tcp.no_delay: true\nnetwork.tcp.keep_alive: true\nnetwork.tcp.reuse_address: true\nnetwork.tcp.send_buffer_size: 128mb\nnetwork.tcp.receive_buffer_size: 128mb\n\ntransport.tcp.port: 9300\ntransport.tcp.compress: true\n\ndiscovery.zen.ping.unicast.hosts: [\"172.16.50.51\", \"172.16.50.52\",\"172.16.50.53\"]\ndiscovery.zen.minimum_master_nodes: 2\n\ncluster.initial_master_nodes: [\"172.16.50.51:9300\",\"172.16.50.52:9300\",\"172.16.50.53:9300\"]\ncluster.fault_detection.leader_check.interval: 5s\ncluster.max_shards_per_node: 100000\ncluster.join.timeout: 20s\ncluster.publish.timeout: 60s\ncluster.routing.allocation.cluster_concurrent_rebalance: 4\ncluster.routing.allocation.node_concurrent_recoveries: 8\ncluster.routing.allocation.node_initial_primaries_recoveries: 8\n\nxpack.security.enabled: true\nxpack.security.transport.ssl.enabled: true\nxpack.security.transport.ssl.verification_mode: certificate\nxpack.security.transport.ssl.keystore.path: certs\/elastic-certificates.p12\nxpack.security.transport.ssl.truststore.path: certs\/elastic-certificates.p12\n<\/code><\/pre>\n<h6>6. 172.16.50.52\u7684\u914d\u7f6e\u6587\u4ef6\u53ea\u9700\u8981\u4fee\u6539node.name\u4e3aes02\uff0cnetwork.host\u4fee\u6539\u4e3a172.16.50.52\u5373\u53ef<\/h6>\n<h6>7. 172.16.50.53\u7684\u914d\u7f6e\u6587\u4ef6\u53ea\u9700\u8981\u4fee\u6539node.name\u4e3aes03\uff0cnetwork.host\u4fee\u6539\u4e3a172.16.50.53\u5373\u53ef<\/h6>\n<h6>8. \u542f\u52a8es\uff0c\u53ef\u4ee5\u53c2\u8003 <a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.aiqinqin.info\/?p=555\" title=\"\u4f7f\u7528supervisor\u8fd0\u884celasticsearch\">\u4f7f\u7528supervisor\u8fd0\u884celasticsearch<\/a><\/h6>\n<h6>9. \u6700\u540e\u5728\u4efb\u4e00\u53f0\u670d\u52a1\u5668\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u81ea\u52a8\u751f\u4ea7es\u7684\u5404\u79cd\u8fde\u63a5\u5bc6\u7801<\/h6>\n<pre><code class=\"\">\/opt\/elasticsearch\/bin\/elasticsearch-setup-passwords auto\n<\/code><\/pre>\n<blockquote><p>\n  \u53c2\u8003\u6587\u7ae0\uff1a https:\/\/abcops.cn\/archives\/1192\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>1. \u4e0b\u9762\u662f\u4e09\u53f0\u670d\u52a1\u5668\u7684\u4e00\u4e9b\u57fa\u672c\u4fe1\u606f ip \u76d1\u542c\u7aef\u53e3 \u4e3b\u673a\u540d\u79f0 \u7cfb\u7edf\u7248\u672c \u914d\u7f6e\u4fe1\u606f es\u5b9e\u4f8b\u540d\u79f0 es\u7248\u672c 1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-573","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/posts\/573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=573"}],"version-history":[{"count":10,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/posts\/573\/revisions"}],"predecessor-version":[{"id":758,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/posts\/573\/revisions\/758"}],"wp:attachment":[{"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}