{"id":4408,"date":"2019-07-11T16:11:22","date_gmt":"2019-07-11T08:11:22","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=4408"},"modified":"2019-07-11T16:11:22","modified_gmt":"2019-07-11T08:11:22","slug":"docker-%e5%ae%89%e8%a3%85-elasticsearch-%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4408","title":{"rendered":"Docker \u5b89\u88c5 Elasticsearch \u6559\u7a0b"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4e00\u5b9a\u8981\u6784\u5efa\u81ea\u5df1\u7684\u77e5\u8bc6\u4f53\u7cfb\uff0c\u627e\u5230\u81ea\u5df1\u7684\u5b66\u4e60\u65b9\u6cd5\u3002\u5c31\u4e00\u4e2a\u7b80\u5355\u7684\u5b89\u88c5\uff0c\u90fd\u4f1a\u6709\u4eba\u5361\u58f3\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u7bc7\u6587\u7ae0\u6211\u5728\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5982\u4f55\u5728 Docker \u4e2d\u5b89\u88c5 Elasticsearch\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u524d\u63d0\u662f\u4f60\u7684 Docker \u548c Docker-Compose \u90fd\u5df2\u7ecf\u5b89\u88c5\u6210\u529f\u4e86\uff0c\u5f53\u7136\uff0c\u8fd9\u91cc\u8fd8\u6682\u65f6\u7528\u4e0d\u5230 Docker-Compose\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u76ee\u524d\u8bb2\u5e08\u7528\u7684 Elasticsearch \u662f 7.2 \u7684\u7248\u672c\u3002\u8fd9\u4e2a\u7248\u672c\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728 Docker-hub \u4e2d\u641c\u7d22\u5230\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker search Elasticsearch<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g4vydt8yspj20km0e2dk9.jpg\" alt=\"\" \/><figcaption>docker search Elasticsearch<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u597d\u51e0\u4e2a\uff0c\u4e0d\u77e5\u9053\u548b\u9009\u62e9\u3002\u4e0d\u6015\uff0c\u6211\u6559\u4f60\uff0c\u4fdd\u6301\u548c\u8bb2\u5e08\u7684\u7248\u672c\u4e00\u81f4\u5c31\u53ef\u4ee5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker pull docker.elastic.co\/elasticsearch\/elasticsearch:7.2.0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b\u8fd9\u4e2a\u547d\u4ee4\uff0c\u5b89\u88c5 Elasticsearch 7.2 \u7684\u7248\u672c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\uff0c\u4e0d\u8981\u770b\u7f51\u4e0a\u7684\u4e00\u4e9b\u6559\u7a0b\uff0c\u4ece github \u4e0b\uff0c\u6162\u7684\u5f88\uff0c\u57fa\u672c\u4e0a\u65e0\u6cd5\u6210\u529f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u7167\u6211\u7684\u547d\u4ee4\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6267\u884c docker images\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker images<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g4vyfecf02j20ml02ndgd.jpg\" alt=\"\" \/><figcaption>docker images<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6216\u8005\u6267\u884c docker image ls \u662f\u4e00\u6837\u7684\u6548\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker image ls<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u770b\u5230\u6211\u4e0a\u9762\u6709\u4e24\u4e2a\u955c\u50cf\u6587\u4ef6\u3002\u6211\u4eec\u5148\u8fd0\u884c hello-world\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker container run hello-world<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4e86\u4fdd\u8bc1\u548c\u8001\u5e08\u7684\u6548\u679c\u4e00\u81f4\uff0c\u4f60\u53ef\u4ee5\u5148\u65b0\u5efa\u4e00\u4e2a xttblog \u6587\u4ef6\u5939\u3002\u7136\u540e\u5728\u8fd9\u4e2a\u6587\u4ef6\u5939\u4e2d\uff0c\u65b0\u5efa\u4e00\u4e2a docker-compose.yml \u6587\u4ef6\u3002\u5185\u5bb9\u548c\u8001\u5e08\u7684\u4e00\u81f4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '2.2'\nservices:\n  cerebro:\n    image: lmenezes\/cerebro:0.8.3\n    container_name: cerebro\n    ports:\n      - \"9000:9000\"\n    command:\n      - -Dhosts.0.host=http:\/\/elasticsearch:9200\n  kibana:\n    image: docker.elastic.co\/kibana\/kibana:7.1.0\n    container_name: kibana7\n    environment:\n      - I18N_LOCALE=zh-CN\n      - XPACK_GRAPH_ENABLED=true\n      - TIMELION_ENABLED=true\n      - XPACK_MONITORING_COLLECTION_ENABLED=\"true\"\n    ports:\n      - \"5601:5601\"\n  elasticsearch:\n    image: docker.elastic.co\/elasticsearch\/elasticsearch:7.1.0\n    container_name: es7_01\n    environment:\n      - cluster.name=xttblog\n      - node.name=es7_01\n      - bootstrap.memory_lock=true\n      - \"ES_JAVA_OPTS=-Xms512m -Xmx512m\"\n      - discovery.seed_hosts=es7_01\n      - cluster.initial_master_nodes=es7_01,es7_02\n    ulimits:\n      memlock:\n        soft: -1\n        hard: -1\n    volumes:\n      - es7data1:\/usr\/share\/elasticsearch\/data\n    ports:\n      - 9200:9200\n  elasticsearch2:\n    image: docker.elastic.co\/elasticsearch\/elasticsearch:7.1.0\n    container_name: es7_02\n    environment:\n      - cluster.name=xttblog\n      - node.name=es7_02\n      - bootstrap.memory_lock=true\n      - \"ES_JAVA_OPTS=-Xms512m -Xmx512m\"\n      - discovery.seed_hosts=es7_01\n      - cluster.initial_master_nodes=es7_01,es7_02\n    ulimits:\n      memlock:\n        soft: -1\n        hard: -1\n    volumes:\n      - es7data2:\/usr\/share\/elasticsearch\/data\nvolumes:\n  es7data1:\n    driver: local\n  es7data2:\n    driver: local<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8001\u5e08\u4e0a\u5728\u672c\u5730\u8fd0\u884c\u7684\u3002\u6211\u662f\u5728\u4e91\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u7684\uff0c\u56e0\u6b64\uff0c\u6211\u8fd9\u91cc\u6ca1\u6709 networks \u914d\u7f6e\u9879\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u4f60\u5c31\u53ef\u4ee5\u73a9\u8f6c\u4f60\u7684\u7b2c\u4e00\u4e2a Docker + Elasticsearch \u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u542f\u52a8\ndocker-compose up\n\n#\u505c\u6b62\u5bb9\u5668\ndocker-compose down\n\n#\u505c\u6b62\u5bb9\u5668\u5e76\u4e14\u79fb\u9664\u6570\u636e\ndocker-compose down -v\n\n#\u4e00\u4e9bdocker \u547d\u4ee4\ndocker ps\ndocker stop Name\/ContainerId\ndocker start Name\/ContainerId\n\n#\u5220\u9664\u5355\u4e2a\u5bb9\u5668\n$docker rm Name\/ID\n-f, \u2013force=false; -l, \u2013link=false Remove the specified link and not the underlying container; -v, \u2013volumes=false Remove the volumes associated to the container\n\n#\u5220\u9664\u6240\u6709\u5bb9\u5668\n$docker rm `docker ps -a -q`  \n\u505c\u6b62\u3001\u542f\u52a8\u3001\u6740\u6b7b\u3001\u91cd\u542f\u4e00\u4e2a\u5bb9\u5668\n$docker stop Name\/ID  \n$docker start Name\/ID  \n$docker kill Name\/ID  \n$docker restart name\/ID<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u4f60\u770b\u5230\u8fd9\u4e2a\u63d0\u793a\uff1a\u201cmax virtual memory areas vm.max_map_count [65530] is too low, increase to at least\u201d\u3002\u90a3\u8bf4\u660e\u4f60\u8bbe\u7f6e\u7684 max_map_count \u5c0f\u4e86\uff0c\u7f16\u8f91 \/etc\/sysctl.conf\uff0c\u8ffd\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1avm.max_map_count=262144\u4fdd\u5b58\u540e\uff0c\u6267\u884c\uff1asysctl -p\u91cd\u65b0\u542f\u52a8\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u770b\u5230\uff0cERROR: [1] bootstrap checks failed\uff0c\u5c31\u8bf4\u660e\u542f\u52a8\u5931\u8d25\u4e86\u3002\u68c0\u67e5\u4e00\u4e0b\u542f\u52a8\u65e5\u5fd7\u3002\u52a0\u5927\u5185\u5b58\uff0c\u770b\u770b\u90a3\u91cc\u51fa\u9519\u4e86\uff0c\u5b9a\u4f4d\u95ee\u9898\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\uff0c\u5e0c\u671b\u80fd\u591f\u5bf9\u6b63\u5728\u5b66\u4e60 Elasticsearch \u548c Docker \u7684\u540c\u5b66\u6709\u5e2e\u52a9\u3002\u5982\u679c\u4f60\u8fd8\u6709\u95ee\u9898\uff0c\u53ef\u4ee5\u52a0\u6211\u5fae\u4fe1\uff1axttblog\uff0c\u4e00\u8d77\u7cbe\u8fdb\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=4408\">Docker \u5b89\u88c5 Elasticsearch \u6559\u7a0b<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u4e00\u5b9a\u8981\u6784\u5efa\u81ea\u5df1\u7684\u77e5\u8bc6\u4f53\u7cfb\uff0c\u627e\u5230\u81ea\u5df1\u7684\u5b66\u4e60\u65b9\u6cd5\u3002\u5c31\u4e00\u4e2a\u7b80\u5355\u7684\u5b89\u88c5\uff0c\u90fd\u4f1a\u6709\u4eba\u5361\u58f3\u3002 \u8fd9\u7bc7\u6587\u7ae0\u6211\u5728\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5982\u4f55\u5728  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[512,1136,1137,1652,1986],"class_list":["post-4408","post","type-post","status-publish","format-standard","hentry","category-java","tag-docker","tag-docker-compose","tag-docker-swarm","tag-elasticsearch","tag-kibana"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4408"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4408\/revisions"}],"predecessor-version":[{"id":4409,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4408\/revisions\/4409"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}