ElasticSearch之docker集群搭建

1、搭建

  • 创建文件挂载目录并开启777权限
mkdir -p /data/es/data1 mkdir -p /data/es/data2 mkdir -p /data/es/data3 chmod -R 777 /data/es/data1 chmod -R 777 /data/es/data2 chmod -R 777 /data/es/data3

  • 创建es配置文件
mkdir -p /data/es/config

#vim /data/es/config/es1.ymlcluster.name: elasticsearch-cluster node.name: es-node1 network.bind_host: 0.0.0.0 network.publish_host: *.*.*.* http.port: 9200 transport.tcp.port: 9300 http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true discovery.zen.ping.unicast.hosts: ["*.*.*.*:9300","*.*.*.*:9301","*.*.*.*:9302"] discovery.zen.minimum_master_nodes: 2

PS:network.publish_host: *.*.*.*替换为宿主机IP
#vim /data/es/config/es2.ymlcluster.name: elasticsearch-cluster node.name: es-node2 network.bind_host: 0.0.0.0 network.publish_host: *.*.*.* http.port: 9201 transport.tcp.port: 9301 http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true discovery.zen.ping.unicast.hosts: ["*.*.*.*:9300","*.*.*.*:9301","*.*.*.*:9302"] discovery.zen.minimum_master_nodes: 2

【ElasticSearch之docker集群搭建】
#vim /data/es/config/es3.ymlcluster.name: elasticsearch-cluster node.name: es-node3 network.bind_host: 0.0.0.0 network.publish_host: *.*.*.* http.port: 9202 transport.tcp.port: 9302 http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true discovery.zen.ping.unicast.hosts: ["*.*.*.*:9300","*.*.*.*:9301","*.*.*.*:9302"] discovery.zen.minimum_master_nodes: 2


  • 启动es集群
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 -v /data/es/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /data/es/data1:/usr/share/elasticsearch/data --name ES01 elasticsearch:6.8.5 docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 -v /data/es/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /data/es/data2:/usr/share/elasticsearch/data --name ES02 elasticsearch:6.8.5 docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9202:9202 -p 9302:9302 -v /data/es/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /data/es/data3:/usr/share/elasticsearch/data --name ES03 elasticsearch:6.8.5

2、问题记录
  • bootstrap checks failed max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
vim /etc/sysctl.confvm.max_map_count=262144 sysctl -p


    推荐阅读