基于docker搭建elasticsearch集群

1、拉取elasticsearch镜像
sudo docker pull elasticsearch:7.3.1
2、docker启动
sudo docker run -itd --name=elasticsearch1 -v /data/elasticsearch/node1/logs:/usr/share/elasticsearch/logs -v /data/elasticsearch/node1/data:/usr/share/elasticsearch/data -v /data/elasticsearch/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -p 9200:9200 -p 9300:9300 elasticsearch:7.3.1

sudo docker run -itd --name=elasticsearch2 -v /data/elasticsearch/node2/logs:/usr/share/elasticsearch/logs -v /data/elasticsearch/node2/data:/usr/share/elasticsearch/data -v /data/elasticsearch/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -p 9200:9200 -p 9300:9300 elasticsearch:7.3.1

node.name: “es_node1”
cluster.name: “docker-cluster”
network.host: 0.0.0.0
network.publish_host: 192.168.206.138 #设置其它结点和该结点交互的ip地址
http.port: 9200 #设置对外服务的http端口,默认为9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: “*”
discovery.zen.minimum_master_nodes: 2
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: [“192.168.206.138:9201”,“192.168.206.138:9300”,“192.168.206.139:9200”]
cluster.initial_master_nodes: [“es_node1”]

3、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
  修改/etc/sysctl.conf文件,增加配置vm.max_map_count=262144
vi /etc/sysctl.conf
sysctl -p
  执行命令sysctl -p生效

3、拉取elasticsearch-head镜像(集群可只配置其中一台)
sudo docker pull mobz/elasticsearch-head:5
sudo docker run -itd --restart always --name head --link elasticsearch1 -p 9100:9100 docker.io/mobz/elasticsearch-head:5
需要修改配置文件
Vi Gruntfile.js

若elasticsearch-head不能查询,则需要修改如下配置
编辑vendor.js
共有两处
 1. 6886行
/contentType: "application/x-www-form-urlencoded
改成
contentType: “application/json;charset=UTF-8”
 2. 7574行
 var inspectData = s.contentType === “application/x-www-form-urlencoded” &&
改成
 var inspectData = s.contentType === “application/json;charset=UTF-8” &&

发布了5 篇原创文章 · 获赞 0 · 访问量 134
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 游动-白 设计师: 上身试试

分享到微信朋友圈

×

扫一扫,手机浏览